public static GlyphShapingClass GetGlyphShapingClass(FontMetrics fontMetrics, ushort glyphId, GlyphShapingData shapingData) { bool isMark; bool isBase; bool isLigature; ushort markAttachmentType = 0; if (fontMetrics.TryGetGlyphClass(glyphId, out GlyphClassDef? glyphClass)) { isMark = glyphClass == GlyphClassDef.MarkGlyph; isBase = glyphClass == GlyphClassDef.BaseGlyph; isLigature = glyphClass == GlyphClassDef.LigatureGlyph; if (fontMetrics.TryGetMarkAttachmentClass(glyphId, out GlyphClassDef? markAttachmentClass)) { markAttachmentType = (ushort)markAttachmentClass; } } else { // TODO: We may have to store each codepoint. FontKit checks all. isMark = CodePoint.IsMark(shapingData.CodePoint); isBase = !isMark; isLigature = shapingData.CodePointCount > 1; } return(new GlyphShapingClass(isMark, isBase, isLigature, markAttachmentType)); }
public static bool IsMarkGlyph(FontMetrics fontMetrics, ushort glyphId, GlyphShapingData shapingData) { if (!fontMetrics.TryGetGlyphClass(glyphId, out GlyphClassDef? glyphClass) && !CodePoint.IsMark(shapingData.CodePoint)) { return(false); } if (glyphClass != GlyphClassDef.MarkGlyph) { return(false); } return(true); }