getGlyphClass method
dynamic
getGlyphClass(
- dynamic classDefTable,
- dynamic glyphIndex
Find a glyph in a class definition table https://docs.microsoft.com/en-us/typography/opentype/spec/chapter2#class-definition-table @param {object} classDefTable - an OpenType Layout class definition table @param {number} glyphIndex - the index of the glyph to find @returns {number} -1 if not found
Implementation
getGlyphClass(classDefTable, glyphIndex) {
switch (classDefTable.format) {
case 1:
if (classDefTable.startGlyph <= glyphIndex && glyphIndex < classDefTable.startGlyph + classDefTable.classes.length) {
return classDefTable.classes[glyphIndex - classDefTable.startGlyph];
}
return 0;
case 2:
var range = searchRange(classDefTable.ranges, glyphIndex);
return range ? range.classId : 0;
}
}