예제 #1
0
        public static byte[] ReadProgram(DataReader 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));
        }
예제 #2
0
        public static int FindTable(TableRecord[] tables, FourCC tag)
        {
            var index = -1;

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

            return(index);
        }
예제 #3
0
        public static bool SeekToTable(DataReader 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);
        }