Skip to content

Commit 71d257c

Browse files
committed
Merge pull request mozilla#2652 from yurydelendik/issue-215-1
Fixes cmap sanitizer for mozilla#215
2 parents f88c0e9 + e5a6246 commit 71d257c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/fonts.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2484,6 +2484,10 @@ var Font = (function FontClosure() {
24842484
// Repair the TrueType file. It is can be damaged in the point of
24852485
// view of the sanitizer
24862486
data = this.checkAndRepair(name, file, properties);
2487+
if (!data) {
2488+
// TrueType data is not found, e.g. when the font is an OpenType font
2489+
warn('Font is not a TrueType font');
2490+
}
24872491
break;
24882492

24892493
default:
@@ -3830,6 +3834,8 @@ var Font = (function FontClosure() {
38303834
prep = table;
38313835
else if (table.tag == 'cvt ')
38323836
cvt = table;
3837+
else if (table.tag == 'CFF ')
3838+
return null; // XXX: OpenType font is found, stopping
38333839
else // skipping table if it's not a required or optional table
38343840
continue;
38353841
}
@@ -5463,13 +5469,18 @@ Type1Font.prototype = {
54635469
getOrderedCharStrings: function Type1Font_getOrderedCharStrings(glyphs,
54645470
properties) {
54655471
var charstrings = [];
5472+
var usedUnicodes = [];
54665473
var i, length, glyphName;
54675474
var unusedUnicode = CMAP_GLYPH_OFFSET;
54685475
for (i = 0, length = glyphs.length; i < length; i++) {
54695476
var item = glyphs[i];
54705477
var glyphName = item.glyph;
54715478
var unicode = glyphName in GlyphsUnicode ?
54725479
GlyphsUnicode[glyphName] : unusedUnicode++;
5480+
while (usedUnicodes[unicode]) {
5481+
unicode = unusedUnicode++;
5482+
}
5483+
usedUnicodes[unicode] = true;
54735484
charstrings.push({
54745485
glyph: glyphName,
54755486
unicode: unicode,

0 commit comments

Comments
 (0)