diff --git a/src/tables/cmap.js b/src/tables/cmap.js index 3130b051..1b434b98 100644 --- a/src/tables/cmap.js +++ b/src/tables/cmap.js @@ -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) { @@ -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; } } } diff --git a/test/opentypeSpec.js b/test/opentypeSpec.js index 193cd72e..ad0426b5 100644 --- a/test/opentypeSpec.js +++ b/test/opentypeSpec.js @@ -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() { @@ -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() {