Skip to content

Commit

Permalink
fix cmap table selection (#650)
Browse files Browse the repository at this point in the history
  • Loading branch information
Connum authored Nov 30, 2023
1 parent 7f1480f commit fb886bb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/tables/cmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ function parseCmapTable(data, start) {
(platformId === 0 && platform0Encodings.includes(encodingId)) ||
(platformId === 1 && encodingId === 0) // MacOS <= 9
) {
// only use the first supported table
if (offset > 0) continue;
offset = parse.getULong(data, start + 4 + (i * 8) + 4);
// allow for early break
if (format14Parser) {
Expand All @@ -193,6 +195,9 @@ function parseCmapTable(data, start) {
if (format14Parser.parseUShort() !== 14) {
format14offset = -1;
format14Parser = null;
} else if (offset > 0) {
// we already got the regular table, early break
break;
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions test/opentypeSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ describe('opentype.js', function() {
assert.equal(aGlyph.name, 'gid2');
assert.equal(aGlyph.unicode, 1);
assert.equal(aGlyph.path.commands.length, 24);
assert.deepEqual(font.stringToGlyphIndexes('🌺'), [59]);
});

it('can load a WOFF/CFF font', function() {
Expand Down Expand Up @@ -158,6 +159,7 @@ describe('opentype.js on low memory mode', function() {
assert.equal(aGlyph.name, 'gid2');
assert.equal(aGlyph.unicode, 1);
assert.equal(aGlyph.path.commands.length, 24);
assert.deepEqual(font.stringToGlyphIndexes('🌺'), [59]);
});

it('can load a WOFF/CFF font', function() {
Expand Down

0 comments on commit fb886bb

Please sign in to comment.