コード例 #1
0
        void FillClassDefs(Glyph[] inputGlyphs)
        {
            //1. glyph def
            ClassDefTable classDef = GlyphClassDef;

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

            switch (classDef.Format)
            {
            default:
                Utils.WarnUnimplemented("GDEF GlyphClassDef Format {0}", classDef.Format);
                break;

            case 1:
            {
                ushort   startGlyph  = classDef.startGlyph;
                ushort[] classValues = classDef.classValueArray;
                int      gIndex      = startGlyph;
                for (int i = 0; i < classValues.Length; ++i)
                {
#if DEBUG
                    ushort classV = classValues[i];
                    if (classV > (ushort)GlyphClassKind.Component)
                    {
                    }
#endif

                    inputGlyphs[gIndex].GlyphClass = (GlyphClassKind)classValues[i];
                    gIndex++;
                }
            }
            break;

            case 2:
            {
                ClassDefTable.ClassRangeRecord[] records = classDef.records;
                for (int n = 0; n < records.Length; ++n)
                {
                    ClassDefTable.ClassRangeRecord rec = records[n];

#if DEBUG
                    if (rec.classNo > (ushort)GlyphClassKind.Component)
                    {
                    }
#endif

                    GlyphClassKind glyphKind = (GlyphClassKind)rec.classNo;
                    for (int i = rec.startGlyphId; i <= rec.endGlyphId; ++i)
                    {
                        inputGlyphs[i].GlyphClass = glyphKind;
                    }
                }
            }
            break;
            }
        }
コード例 #2
0
        void FillMarkAttachmentClassDefs(Glyph[] inputGlyphs)
        {
            //Mark Attachment Class Definition Table
            //A Mark Class Definition Table is used to assign mark glyphs into different classes
            //that can be used in lookup tables within the GSUB or GPOS table to control how mark glyphs within a glyph sequence are treated by lookups.
            //For more information on the use of mark attachment classes,
            //see the description of lookup flags in the “Lookup Table” section of the chapter, OpenType Layout Common Table Formats.
            ClassDefTable markAttachmentClassDef = this.MarkAttachmentClassDef;

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

            switch (markAttachmentClassDef.Format)
            {
            default:
                Utils.WarnUnimplemented("GDEF MarkAttachmentClassDef Table Format {0}", markAttachmentClassDef.Format);
                break;

            case 1:
            {
                ushort   startGlyph  = markAttachmentClassDef.startGlyph;
                ushort[] classValues = markAttachmentClassDef.classValueArray;

                int len    = classValues.Length;
                int gIndex = startGlyph;
                for (int i = 0; i < len; ++i)
                {
#if DEBUG
                    Glyph dbugTestGlyph = inputGlyphs[gIndex];
#endif
                    inputGlyphs[gIndex].MarkClassDef = classValues[i];
                    gIndex++;
                }
            }
            break;

            case 2:
            {
                ClassDefTable.ClassRangeRecord[] records = markAttachmentClassDef.records;
                int len = records.Length;
                for (int n = 0; n < len; ++n)
                {
                    ClassDefTable.ClassRangeRecord rec = records[n];
                    for (int i = rec.startGlyphId; i <= rec.endGlyphId; ++i)
                    {
#if DEBUG
                        Glyph dbugTestGlyph = inputGlyphs[i];
#endif
                        inputGlyphs[i].MarkClassDef = rec.classNo;
                    }
                }
            }
            break;
            }
        }