public static AttachmentListTable CreateFrom(BinaryReader reader, long beginAt)
        {
            AttachmentListTable attachmentListTable = new AttachmentListTable();

            reader.BaseStream.Seek(beginAt, SeekOrigin.Begin);
            //
            ushort coverageOffset = reader.ReadUInt16();
            ushort glyphCount     = reader.ReadUInt16();

            ushort[] attachPointOffsets = Utils.ReadUInt16Array(reader, glyphCount);
            //-----------------------
            attachmentListTable.CoverageTable = CoverageTable.CreateFrom(reader, beginAt + coverageOffset);
            attachmentListTable._attachPoints = new AttachPoint[glyphCount];
            for (int i = 0; i < glyphCount; ++i)
            {
                reader.BaseStream.Seek(beginAt + attachPointOffsets[i], SeekOrigin.Begin);
                ushort pointCount = reader.ReadUInt16();
                attachmentListTable._attachPoints[i] = new AttachPoint()
                {
                    pointIndices = Utils.ReadUInt16Array(reader, pointCount)
                };
            }

            return(attachmentListTable);
        }
Exemplo n.º 2
0
        void FillAttachPoints(Glyph[] inputGlyphs)
        {
            AttachmentListTable attachmentListTable = this.AttachmentListTable;

            if (attachmentListTable == null)
            {
                return;
            }
            //-----------------------------------------

            Utils.WarnUnimplemented("please implement GDEF.FillAttachPoints()");
        }
Exemplo n.º 3
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);
            }
        }