public static LigCaretList CreateFrom(BinaryReader reader, long beginAt)
        {
            reader.BaseStream.Seek(beginAt, SeekOrigin.Begin);
            //----
            LigCaretList ligcaretList   = new LigCaretList();
            ushort       coverageOffset = reader.ReadUInt16();
            ushort       ligGlyphCount  = reader.ReadUInt16();

            ushort[]   ligGlyphOffsets = Utils.ReadUInt16Array(reader, ligGlyphCount);
            LigGlyph[] ligGlyphs       = new LigGlyph[ligGlyphCount];
            for (int i = 0; i < ligGlyphCount; ++i)
            {
                ligGlyphs[i] = LigGlyph.CreateFrom(reader, beginAt + ligGlyphOffsets[i]);
            }
            ligcaretList._ligGlyphs     = ligGlyphs;
            ligcaretList._coverageTable = CoverageTable.CreateFrom(reader, beginAt + coverageOffset);
            return(ligcaretList);
        }
Esempio n. 2
0
        protected override void ReadContentFrom(BinaryReader reader)
        {
            _tableStartAt = reader.BaseStream.Position;
            //-----------------------------------------
            //GDEF Header, Version 1.0
            //Type      Name                Description
            //uint16    MajorVersion        Major version of the GDEF table, = 1
            //uint16    MinorVersion        Minor version of the GDEF table, = 0
            //Offset16  GlyphClassDef       Offset to class definition table for glyph type, from beginning of GDEF header (may be NULL)
            //Offset16  AttachList          Offset to list of glyphs with attachment points, from beginning of GDEF header (may be NULL)
            //Offset16  LigCaretList        Offset to list of positioning points for ligature carets, from beginning of GDEF header (may be NULL)
            //Offset16  MarkAttachClassDef  Offset to class definition table for mark attachment type, from beginning of GDEF header (may be NULL)
            //
            //GDEF Header, Version 1.2
            //Type  Name    Description
            //uint16    MajorVersion        Major version of the GDEF table, = 1
            //uint16    MinorVersion        Minor version of the GDEF table, = 2
            //Offset16  GlyphClassDef       Offset to class definition table for glyph type, from beginning of GDEF header (may be NULL)
            //Offset16  AttachList          Offset to list of glyphs with attachment points, from beginning of GDEF header (may be NULL)
            //Offset16  LigCaretList        Offset to list of positioning points for ligature carets, from beginning of GDEF header (may be NULL)
            //Offset16  MarkAttachClassDef  Offset to class definition table for mark attachment type, from beginning of GDEF header (may be NULL)
            //Offset16  MarkGlyphSetsDef    Offset to the table of mark set definitions, from beginning of GDEF header (may be NULL)
            //
            //GDEF Header, Version 1.3
            //Type  Name    Description
            //uint16    MajorVersion        Major version of the GDEF table, = 1
            //uint16    MinorVersion        Minor version of the GDEF table, = 3
            //Offset16  GlyphClassDef       Offset to class definition table for glyph type, from beginning of GDEF header (may be NULL)
            //Offset16  AttachList          Offset to list of glyphs with attachment points, from beginning of GDEF header (may be NULL)
            //Offset16  LigCaretList        Offset to list of positioning points for ligature carets, from beginning of GDEF header (may be NULL)
            //Offset16  MarkAttachClassDef  Offset to class definition table for mark attachment type, from beginning of GDEF header (may be NULL)
            //Offset16  MarkGlyphSetsDef    Offset to the table of mark set definitions, from beginning of GDEF header (may be NULL)
            //Offset32  ItemVarStore        Offset to the Item Variation Store table, from beginning of GDEF header (may be NULL)

            //common to 1.0, 1.2, 1.3...
            this.MajorVersion = reader.ReadUInt16();
            this.MinorVersion = reader.ReadUInt16();
            //
            ushort glyphClassDefOffset      = reader.ReadUInt16();
            ushort attachListOffset         = reader.ReadUInt16();
            ushort ligCaretListOffset       = reader.ReadUInt16();
            ushort markAttachClassDefOffset = reader.ReadUInt16();
            ushort markGlyphSetsDefOffset   = 0;
            uint   itemVarStoreOffset       = 0;

            //
            switch (MinorVersion)
            {
            default:
                Utils.WarnUnimplemented("GDEF Minor Version {0}", MinorVersion);
                return;

            case 0:
                break;

            case 2:
                markGlyphSetsDefOffset = reader.ReadUInt16();
                break;

            case 3:
                markGlyphSetsDefOffset = reader.ReadUInt16();
                itemVarStoreOffset     = reader.ReadUInt32();
                break;
            }
            //---------------


            this.GlyphClassDef       = (glyphClassDefOffset == 0) ? null : ClassDefTable.CreateFrom(reader, _tableStartAt + glyphClassDefOffset);
            this.AttachmentListTable = (attachListOffset == 0) ? null : AttachmentListTable.CreateFrom(reader, _tableStartAt + attachListOffset);
            this.LigCaretList        = (ligCaretListOffset == 0) ? null : LigCaretList.CreateFrom(reader, _tableStartAt + ligCaretListOffset);

            //A Mark Attachment Class Definition Table defines the class to which a mark glyph may belong.
            //This table uses the same format as the Class Definition table (for details, see the chapter, Common Table Formats ).


#if DEBUG
            if (markAttachClassDefOffset == 2)
            {
                //temp debug invalid font
                this.MarkAttachmentClassDef = (markAttachClassDefOffset == 0) ? null : ClassDefTable.CreateFrom(reader, reader.BaseStream.Position);
            }
            else
            {
                this.MarkAttachmentClassDef = (markAttachClassDefOffset == 0) ? null : ClassDefTable.CreateFrom(reader, _tableStartAt + markAttachClassDefOffset);
            }
#else
            this.MarkAttachmentClassDef = (markAttachClassDefOffset == 0) ? null : ClassDefTable.CreateFrom(reader, _tableStartAt + markAttachClassDefOffset);
#endif

            this.MarkGlyphSetsTable = (markGlyphSetsDefOffset == 0) ? null : MarkGlyphSetsTable.CreateFrom(reader, _tableStartAt + markGlyphSetsDefOffset);

            if (itemVarStoreOffset != 0)
            {
                //not supported
                Utils.WarnUnimplemented("GDEF ItemVarStore");
                reader.BaseStream.Seek(this.Header.Offset + itemVarStoreOffset, SeekOrigin.Begin);
            }
        }