Generate TTFAutohint control files for better glyph display for variant glyphs (#1963).

This commit is contained in:
be5invis 2023-08-27 21:48:13 -07:00
parent 6fed1572c1
commit 25ee0bcc50
9 changed files with 932 additions and 31 deletions

View file

@ -114,5 +114,27 @@ export const ArrayUtil = {
},
insertSliceAt(a, i, b) {
a.splice(i, 0, ...b);
},
// Convert character array to array of ranges. Input may be unsorted.
// The output ranges has both ends inclusive.
toRanges(chars) {
chars.sort((a, b) => a - b);
const ranges = [];
let range = null;
for (const ch of chars) {
if (!range) {
range = [ch, ch];
ranges.push(range);
} else if (ch === range[1] + 1) {
range[1] = ch;
} else {
range = [ch, ch];
ranges.push(range);
}
}
return ranges;
}
};