New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
missing ligature characters #187
Comments
Remember that the substitution table's coverage gives you the first glyph, and then the ligaturesets are for "everything after that". To quote the spec:
It does this by not "double-encoding" that first letter, so that first code point is left out of the actual substitution rules. |
thanks! posting my fixed snippet here const fontkit = require('fontkit');
let font = fontkit.openSync('./MaterialIcons-Regular.ttf');
let lookupList = font.GSUB.lookupList.toArray();
let lookupListIndexes = font.GSUB.featureList[0].feature.lookupListIndexes;
lookupListIndexes.forEach(index => {
let subTable = lookupList[index].subTables[0];
let leadingCharacters = [];
subTable.coverage.rangeRecords.forEach((coverage) => {
for (let i = coverage.start; i <= coverage.end; i++) {
let character = font.stringsForGlyph(i)[0];
leadingCharacters.push(character);
}
});
let ligatureSets = subTable.ligatureSets.toArray();
ligatureSets.forEach((ligatureSet, ligatureSetIndex) => {
let leadingCharacter = leadingCharacters[ligatureSetIndex];
ligatureSet.forEach(ligature => {
let character = font.stringsForGlyph(ligature.glyph)[0];
let characterCode = character.charCodeAt(0).toString(16).toUpperCase();
let ligatureText = ligature
.components
.map(x => font.stringsForGlyph(x)[0])
.join('');
ligatureText = leadingCharacter + ligatureText;
console.log(`${ligatureText} -> ${characterCode}`);
});
});
}); |
I have an existing ttf font where I wish to extract all Ligature mappings into this form:
I'm using this snippet:
However, I'm not getting the full Ligature name. output:
Am I doing something wrong? Judging by the analysis with FontForge, the font's Ligature names are not missing any characters.
The text was updated successfully, but these errors were encountered: