diff --git a/fonts.js b/fonts.js index 44f81442c..8770c8d06 100755 --- a/fonts.js +++ b/fonts.js @@ -532,18 +532,6 @@ var Font = (function Font() { ranges.push([start, end]); } - // Removes duplicate ranges -/* - for (var i = ranges.length - 1; i > 0; i--) { - var range = ranges[i]; - var prevRange = ranges[i - 1]; - if (range[0] <= prevRange[1]) { - range[0] = prevRange[0] - 2; - ranges.splice(i - 1, 1); - } - } -*/ - return ranges; }; @@ -840,6 +828,21 @@ var Font = (function Font() { glyphs.push({ unicode : j }); } } + + var rewrite = false; + for (var code in encoding) { + if (code < 0x20 && encoding[code]) + rewrite = true; + + if (rewrite) + encoding[code] = parseInt(code) + 0x1F; + } + + if (rewrite) { + for (var j = 0; j < glyphs.length; j++) { + glyphs[j].unicode += 0x1F; + } + } cmap.data = createCMapTable(glyphs, deltas); } else if (format == 6 && numRecords == 1 && !encoding.empty) { // Format 0 alone is not allowed by the sanitizer so let's rewrite diff --git a/pdf.js b/pdf.js index 62e9dac4f..32779f5d1 100644 --- a/pdf.js +++ b/pdf.js @@ -3733,7 +3733,11 @@ var PartialEvaluator = (function() { var index = 0; for (var j = 0; j < differences.length; j++) { var data = differences[j]; - IsNum(data) ? index = data : encodingMap[index++] = data; + if (subType.name == 'TrueType') { + IsNum(data) ? index = data : encodingMap[index++] = j; + } else { + IsNum(data) ? index = data : encodingMap[index++] = GlyphsUnicode[data.name]; + } } // Get the font charset if any