diff --git a/fonts.js b/fonts.js index 02aa52601..6488c073b 100755 --- a/fonts.js +++ b/fonts.js @@ -2207,25 +2207,29 @@ var Type2CFF = (function() { var nominalWidth = privDict['nominalWidthX']; var charstrings = []; + var kCmapGlyphOffset = 0xE000; var differences = properties.differences; var index = 0; - var kCmapGlyphOffset = 0xE000; for (var i = 1; i < charsets.length; i++) { + var code = -1; var glyph = charsets[i]; for (var j = index; j < differences.length; j++) { if (differences[j]) { index = j; + code = differences.indexOf(glyph); break; } } - var code = differences.indexOf(glyph); if (code == -1) - code = properties.glyphs[glyph] || index; + index = code = properties.glyphs[glyph] || index; var width = widths[code] || defaultWidth; properties.encoding[index] = index + kCmapGlyphOffset; - charstrings.push({unicode: code + kCmapGlyphOffset, width: width, gid: i}); + charstrings.push({ + unicode: code + kCmapGlyphOffset, + width: width, gid: i + }); index++; } diff --git a/pdf.js b/pdf.js index 46f946c40..df8871e7f 100644 --- a/pdf.js +++ b/pdf.js @@ -55,11 +55,17 @@ function backtrace() { } function shadow(obj, prop, value) { - Object.defineProperty(obj, prop, { value: value, - enumerable: true, - configurable: true, - writable: false }); - return value; + try { + Object.defineProperty(obj, prop, { value: value, + enumerable: true, + configurable: true, + writable: false }); + } catch(e) { + obj.__defineGetter__(prop, function() { + return value; + }); + } + return value; } function bytesToString(bytes) {