Exemplo n.º 1
0
        public static byte[] ReadProgram(BinaryReader reader, TableRecord[] tables, FourCC tag)
        {
            var index = FindTable(tables, tag);

            if (index == -1)
            {
                return(null);
            }

            reader.Seek(tables[index].Offset);
            return(reader.ReadBytes((int)tables[index].Length));
        }
Exemplo n.º 2
0
        public static int FindTable(TableRecord[] tables, FourCC tag)
        {
            var index = -1;

            for (int i = 0; i < tables.Length; i++)
            {
                if (tables[i].Tag == tag)
                {
                    index = i;
                    break;
                }
            }

            return(index);
        }
Exemplo n.º 3
0
        public static bool SeekToTable(BinaryReader reader, TableRecord[] tables, FourCC tag, bool required = false)
        {
            // check if we have the desired table and that it's not empty
            var index = FindTable(tables, tag);

            if (index == -1 || tables[index].Length == 0)
            {
                if (required)
                {
                    throw new InvalidFontException($"Missing or empty '{tag}' table.");
                }
                return(false);
            }

            // seek to the appropriate offset
            reader.Seek(tables[index].Offset);
            return(true);
        }