1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-24 17:18:07 +02:00

speedup unicode/glyph conversion and cache translated strings in the font

This commit is contained in:
Andreas Gal 2011-06-17 21:22:37 -07:00
parent 2588eb054b
commit 5517602df0
2 changed files with 32 additions and 13 deletions

8
pdf.js
View file

@ -2245,13 +2245,7 @@ var CanvasGraphics = (function() {
this.ctx.translate(0, 2 * this.current.y);
this.ctx.scale(1, -1);
this.ctx.transform.apply(this.ctx, this.current.textMatrix);
// Replace characters code by glyphs code
var glyphs = [];
for (var i = 0; i < text.length; i++)
glyphs[i] = String.fromCharCode(Fonts.unicodeFromCode(text[i].charCodeAt(0)));
this.ctx.fillText(glyphs.join(""), this.current.x, this.current.y);
this.ctx.fillText(Fonts.chars2Unicode(text), this.current.x, this.current.y);
this.current.x += this.ctx.measureText(text).width;
this.ctx.restore();