Skip to content

Commit e5a6246

Browse files
committed
Fixes cmap sanitizer fro mozilla#215
1 parent 1a78fa1 commit e5a6246

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
@@ -2409,6 +2409,10 @@ var Font = (function FontClosure() {
24092409
// Repair the TrueType file. It is can be damaged in the point of
24102410
// view of the sanitizer
24112411
data = this.checkAndRepair(name, file, properties);
2412+
if (!data) {
2413+
// TrueType data is not found, e.g. when the font is an OpenType font
2414+
warn('Font is not a TrueType font');
2415+
}
24122416
break;
24132417

24142418
default:
@@ -3696,6 +3700,8 @@ var Font = (function FontClosure() {
36963700
prep = table;
36973701
else if (table.tag == 'cvt ')
36983702
cvt = table;
3703+
else if (table.tag == 'CFF ')
3704+
return null; // XXX: OpenType font is found, stopping
36993705
else // skipping table if it's not a required or optional table
37003706
continue;
37013707
}
@@ -5257,13 +5263,18 @@ Type1Font.prototype = {
52575263
getOrderedCharStrings: function Type1Font_getOrderedCharStrings(glyphs,
52585264
properties) {
52595265
var charstrings = [];
5266+
var usedUnicodes = [];
52605267
var i, length, glyphName;
52615268
var unusedUnicode = CMAP_GLYPH_OFFSET;
52625269
for (i = 0, length = glyphs.length; i < length; i++) {
52635270
var item = glyphs[i];
52645271
var glyphName = item.glyph;
52655272
var unicode = glyphName in GlyphsUnicode ?
52665273
GlyphsUnicode[glyphName] : unusedUnicode++;
5274+
while (usedUnicodes[unicode]) {
5275+
unicode = unusedUnicode++;
5276+
}
5277+
usedUnicodes[unicode] = true;
52675278
charstrings.push({
52685279
glyph: glyphName,
52695280
unicode: unicode,

0 commit comments

Comments
 (0)