From e5a6246f707575f22b6e6afb7f4b498c3b08207c Mon Sep 17 00:00:00 2001 From: Yury Delendik Date: Thu, 31 Jan 2013 16:13:36 -0500 Subject: [PATCH] Fixes cmap sanitizer fro #215 --- src/fonts.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/fonts.js b/src/fonts.js index 7285cb879..8c644cd28 100644 --- a/src/fonts.js +++ b/src/fonts.js @@ -2409,6 +2409,10 @@ var Font = (function FontClosure() { // Repair the TrueType file. It is can be damaged in the point of // view of the sanitizer data = this.checkAndRepair(name, file, properties); + if (!data) { + // TrueType data is not found, e.g. when the font is an OpenType font + warn('Font is not a TrueType font'); + } break; default: @@ -3696,6 +3700,8 @@ var Font = (function FontClosure() { prep = table; else if (table.tag == 'cvt ') cvt = table; + else if (table.tag == 'CFF ') + return null; // XXX: OpenType font is found, stopping else // skipping table if it's not a required or optional table continue; } @@ -5257,6 +5263,7 @@ Type1Font.prototype = { getOrderedCharStrings: function Type1Font_getOrderedCharStrings(glyphs, properties) { var charstrings = []; + var usedUnicodes = []; var i, length, glyphName; var unusedUnicode = CMAP_GLYPH_OFFSET; for (i = 0, length = glyphs.length; i < length; i++) { @@ -5264,6 +5271,10 @@ Type1Font.prototype = { var glyphName = item.glyph; var unicode = glyphName in GlyphsUnicode ? GlyphsUnicode[glyphName] : unusedUnicode++; + while (usedUnicodes[unicode]) { + unicode = unusedUnicode++; + } + usedUnicodes[unicode] = true; charstrings.push({ glyph: glyphName, unicode: unicode,