Example #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));
        }
Example #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);
        }
Example #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);
        }
Example #4
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.");
                    throw new InvalidFontException(string.Format(
                        "Missing or empty '{0}' table.", tag));
                return false;
            }

            // seek to the appropriate offset
            reader.Seek(tables[index].Offset);
            return true;
        }
Example #5
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;
        }
Example #6
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);
        }