Ejemplo n.º 1
0
        public static void ReadMaxp(DataReader reader, TableRecord[] tables, ref FaceHeader header)
        {
            SeekToTable(reader, tables, FourCC.Maxp, required: true);

            if (reader.ReadInt32BE() != 0x00010000)
            {
                throw new InvalidFontException("Font contains an old style maxp table.");
            }

            header.GlyphCount = reader.ReadUInt16BE();
            if (header.GlyphCount > MaxGlyphs)
            {
                throw new InvalidFontException("Font contains too many glyphs.");
            }

            // skip maxPoints, maxContours, maxCompositePoints, maxCompositeContours, maxZones
            reader.Skip(sizeof(short) * 5);

            header.MaxTwilightPoints   = reader.ReadUInt16BE();
            header.MaxStorageLocations = reader.ReadUInt16BE();
            header.MaxFunctionDefs     = reader.ReadUInt16BE();
            header.MaxInstructionDefs  = reader.ReadUInt16BE();
            header.MaxStackSize        = reader.ReadUInt16BE();

            // sanity checking
            if (header.MaxTwilightPoints > MaxTwilightPoints || header.MaxStorageLocations > MaxStorageLocations ||
                header.MaxFunctionDefs > MaxFunctionDefs || header.MaxInstructionDefs > MaxFunctionDefs ||
                header.MaxStackSize > MaxStackSize)
            {
                throw new InvalidFontException("Font programs have limits that are larger than built-in sanity checks.");
            }
        }
Ejemplo n.º 2
0
        public static void ReadMaxp(DataReader reader, TableRecord[] tables, ref FaceHeader header)
        {
            SeekToTable(reader, tables, FourCC.Maxp, required: true);

            if (reader.ReadInt32BE() != 0x00010000)
                throw new InvalidFontException("Font contains an old style maxp table.");

            header.GlyphCount = reader.ReadUInt16BE();
            if (header.GlyphCount > MaxGlyphs)
                throw new InvalidFontException("Font contains too many glyphs.");

            // skip maxPoints, maxContours, maxCompositePoints, maxCompositeContours, maxZones
            reader.Skip(sizeof(short) * 5);

            header.MaxTwilightPoints = reader.ReadUInt16BE();
            header.MaxStorageLocations = reader.ReadUInt16BE();
            header.MaxFunctionDefs = reader.ReadUInt16BE();
            header.MaxInstructionDefs = reader.ReadUInt16BE();
            header.MaxStackSize = reader.ReadUInt16BE();

            // sanity checking
            if (header.MaxTwilightPoints > MaxTwilightPoints || header.MaxStorageLocations > MaxStorageLocations ||
                header.MaxFunctionDefs > MaxFunctionDefs || header.MaxInstructionDefs > MaxFunctionDefs ||
                header.MaxStackSize > MaxStackSize)
                throw new InvalidFontException("Font programs have limits that are larger than built-in sanity checks.");
        }
Ejemplo n.º 3
0
        public static void ReadPost(DataReader reader, TableRecord[] tables, ref FaceHeader header)
        {
            if (!SeekToTable(reader, tables, FourCC.Post))
            {
                return;
            }

            // skip over version and italicAngle
            reader.Skip(sizeof(int) * 2);

            header.UnderlinePosition  = reader.ReadInt16BE();
            header.UnderlineThickness = reader.ReadInt16BE();
            header.IsFixedPitch       = reader.ReadUInt32BE() != 0;
        }
Ejemplo n.º 4
0
        public static void ReadHead(DataReader reader, TableRecord[] tables, out FaceHeader header)
        {
            SeekToTable(reader, tables, FourCC.Head, required: true);

            // 'head' table contains global information for the font face
            // we only care about a few fields in it
            reader.Skip(sizeof(int) * 4);   // version, revision, checksum, magic number

            header = new FaceHeader
            {
                Flags = (HeadFlags)reader.ReadUInt16BE(),
                UnitsPerEm = reader.ReadUInt16BE()
            };
            if (header.UnitsPerEm == 0)
                throw new InvalidFontException("Invalid 'head' table.");

            // skip over created and modified times, bounding box,
            // deprecated style bits, direction hints, and size hints
            reader.Skip(sizeof(long) * 2 + sizeof(short) * 7);

            header.IndexFormat = (IndexFormat)reader.ReadInt16BE();
        }
Ejemplo n.º 5
0
        public static void ReadHead(DataReader reader, TableRecord[] tables, out FaceHeader header)
        {
            SeekToTable(reader, tables, FourCC.Head, required: true);

            // 'head' table contains global information for the font face
            // we only care about a few fields in it
            reader.Skip(sizeof(int) * 4);   // version, revision, checksum, magic number

            header = new FaceHeader {
                Flags      = (HeadFlags)reader.ReadUInt16BE(),
                UnitsPerEm = reader.ReadUInt16BE()
            };
            if (header.UnitsPerEm == 0)
            {
                throw new InvalidFontException("Invalid 'head' table.");
            }

            // skip over created and modified times, bounding box,
            // deprecated style bits, direction hints, and size hints
            reader.Skip(sizeof(long) * 2 + sizeof(short) * 7);

            header.IndexFormat = (IndexFormat)reader.ReadInt16BE();
        }
Ejemplo n.º 6
0
        public static void ReadPost(DataReader reader, TableRecord[] tables, ref FaceHeader header)
        {
            if (!SeekToTable(reader, tables, FourCC.Post))
                return;

            // skip over version and italicAngle
            reader.Skip(sizeof(int) * 2);

            header.UnderlinePosition = reader.ReadInt16BE();
            header.UnderlineThickness = reader.ReadInt16BE();
            header.IsFixedPitch = reader.ReadUInt32BE() != 0;
        }