diff --git a/fonts.js b/fonts.js index 3beac011a..ce4215663 100644 --- a/fonts.js +++ b/fonts.js @@ -1373,7 +1373,10 @@ var Font = (function Font() { var glyph = encoding[charcode]; if ('undefined' == typeof(glyph)) { warn('Unencoded charcode ' + charcode); - glyph = { unicode: charcode }; + glyph = { + unicode: charcode, + width: this.defaultWidth + }; } glyphs.push(glyph); // placing null after each word break charcode (ASCII SPACE) @@ -1387,7 +1390,10 @@ var Font = (function Font() { var glyph = encoding[charcode]; if ('undefined' == typeof(glyph)) { warn('Unencoded charcode ' + charcode); - glyph = { unicode: charcode }; + glyph = { + unicode: charcode, + width: this.defaultWidth + }; } glyphs.push(glyph); if (charcode == 0x20) diff --git a/pdf.js b/pdf.js index 975792141..5c3102b85 100644 --- a/pdf.js +++ b/pdf.js @@ -4989,7 +4989,6 @@ var CanvasGraphics = (function() { ctx.transform.apply(ctx, font.textMatrix || IDENTITY_MATRIX); var glyphs = font.charsToGlyphs(text); - var defaultCharWidth = font.defaultWidth; var fontSize = current.fontSize; var charSpacing = current.charSpacing; var wordSpacing = current.wordSpacing; @@ -5010,7 +5009,7 @@ var CanvasGraphics = (function() { String.fromCharCode(0xD800 | ((unicode - 0x10000) >> 10), 0xDC00 | (unicode & 0x3FF)) : String.fromCharCode(unicode); - var charWidth = (glyph.width || defaultCharWidth) * fontSize * 0.001; + var charWidth = glyph.width * fontSize * 0.001; charWidth += charSpacing; ctx.fillText(char, width, 0);