コード例 #1
0
        private TrueTypeFontTable ReadPostscriptTable(uint length, TrueTypeTableEntryList list, BigEndianReader reader)
        {
            PostscriptTable post = new PostscriptTable(reader.Position);

            post.TableVersion       = reader.ReadFixedVersion();
            post.ItalicAngle        = reader.ReadFixed1616();
            post.UnderlinePosition  = reader.ReadInt16();
            post.UnderlineThickness = reader.ReadInt16();
            post.FixedPitch         = reader.ReadUInt32();
            post.MinMemoryOpenType  = reader.ReadUInt32();
            post.MaxMemoryOpenType  = reader.ReadUInt32();
            post.MinMemoryType1     = reader.ReadUInt32();
            post.MaxMemoryType1     = reader.ReadUInt32();


            //TODO: Read the names if correct version.
            if (post.TableVersion == new Version(2, 0))
            {
                List <GlyphName>            glyphnammes = new List <GlyphName>();
                Dictionary <int, GlyphName> offsets     = new Dictionary <int, GlyphName>();

                ushort count = reader.ReadUInt16();
                for (int i = 0; i < count; i++)
                {
                    GlyphName gname = new GlyphName();
                    gname.Index = reader.ReadUInt16();
                    if (gname.Index > 257)
                    {
                        offsets.Add(gname.Index - 258, gname);
                    }
                    glyphnammes.Add(gname);
                }
                post.Names = glyphnammes;

                if (offsets.Count > 0)
                {
                    count = (ushort)offsets.Count;
                    for (int i = 0; i < count; i++)
                    {
                        string    s = reader.ReadPascalString();
                        GlyphName g;
                        if (offsets.TryGetValue(i, out g))
                        {
                            g.Name = s;
                        }
                    }
                }
            }
            else if (post.TableVersion == new Version(2, 5))
            {
            }
            return(post);
        }
コード例 #2
0
        private TrueTypeFontTable ReadFontHeader(uint length, TrueTypeTableEntryList list, BigEndianReader reader)
        {
            FontHeader fh = new FontHeader(reader.Position);

            fh.TableVersion       = reader.ReadFixedVersion();
            fh.FontRevision       = reader.ReadFixedVersion();
            fh.ChecksumAdjustment = reader.ReadUInt32();
            fh.MagicNumber        = reader.ReadUInt32();
            fh.FontFlags          = (FontHeaderFlags)reader.ReadUInt16();
            fh.UnitsPerEm         = reader.ReadUInt16();
            fh.Created            = reader.ReadDateTime();
            fh.Modified           = reader.ReadDateTime();
            fh.XMin                  = reader.ReadInt16();
            fh.YMin                  = reader.ReadInt16();
            fh.XMax                  = reader.ReadInt16();
            fh.YMax                  = reader.ReadInt16();
            fh.MacStyle              = (FontStyleFlags)reader.ReadUInt16();
            fh.SmallestScreenFont    = reader.ReadUInt16();
            fh.DirectionHints        = (FontDirectionFlags)reader.ReadInt16();
            fh.IndexToLocationFormat = (FontIndexLocationFormat)reader.ReadInt16();
            fh.GlyphDataFormat       = (GlyphDataFormat)reader.ReadInt16();
            return(fh);
        }
コード例 #3
0
        private TrueTypeFontTable ReadMaxProfile(uint length, TrueTypeTableEntryList list, BigEndianReader reader)
        {
            long    pos  = reader.Position;
            Version vers = reader.ReadFixedVersion();

            if (vers == new Version(1, 0)) //0x00010000
            {
                MaxTTProfile ttp = new MaxTTProfile(pos);
                ttp.TableVersion              = vers;
                ttp.NumberOfGlyphs            = reader.ReadUInt16();
                ttp.MaxPoints                 = reader.ReadUInt16();
                ttp.MaxContours               = reader.ReadUInt16();
                ttp.MaxCompositePoints        = reader.ReadUInt16();
                ttp.MaxCompositeContours      = reader.ReadUInt16();
                ttp.MaxZones                  = reader.ReadUInt16();
                ttp.MaxTwilightPoints         = reader.ReadUInt16();
                ttp.MaxStorage                = reader.ReadUInt16();
                ttp.MaxFunctionDefinitions    = reader.ReadUInt16();
                ttp.MaxInstructionDefinitions = reader.ReadUInt16();
                ttp.MaxStackComponents        = reader.ReadUInt16();
                ttp.MaxSizeOfInstructions     = reader.ReadUInt16();
                ttp.MaxComponentComponents    = reader.ReadUInt16();
                ttp.MaxComponentDepth         = reader.ReadUInt16();

                return(ttp);
            }
            else if (vers.Major == 0 && vers.Minor == 20480) //0x00005000
            {
                MaxProfile prof = new MaxProfile(pos);
                prof.TableVersion   = MaxPv05;
                prof.NumberOfGlyphs = reader.ReadUInt16();

                return(prof);
            }
            else
            {
                throw new NotSupportedException("The MaxProfile version " + vers.ToString() + " is not supported");
            }
        }
コード例 #4
0
        private TrueTypeFontTable ReadHorizontalHeader(uint length, TrueTypeTableEntryList list, BigEndianReader reader)
        {
            HorizontalHeader hhead = new HorizontalHeader(reader.Position);

            hhead.TableVersion            = reader.ReadFixedVersion();
            hhead.Ascender                = reader.ReadInt16();
            hhead.Descender               = reader.ReadInt16();
            hhead.LineGap                 = reader.ReadInt16();
            hhead.AdvanceWidthMax         = reader.ReadUInt16();
            hhead.MinimumLeftSideBearing  = reader.ReadInt16();
            hhead.MinimumRightSideBearing = reader.ReadInt16();
            hhead.XMaxExtent              = reader.ReadInt16();
            hhead.CaretSlopeRise          = reader.ReadInt16();
            hhead.CaretSlopeRun           = reader.ReadInt16();
            hhead.CaretOffset             = reader.ReadInt16();
            hhead.Reserved1               = reader.ReadInt16();
            hhead.Reserved2               = reader.ReadInt16();
            hhead.Reserved3               = reader.ReadInt16();
            hhead.Reserved4               = reader.ReadInt16();
            hhead.MetricDataFormat        = reader.ReadInt16();
            hhead.NumberOfHMetrics        = reader.ReadUInt16();

            return(hhead);
        }