]> git.parisson.com Git - pdf.js.git/commitdiff
Add more precision for positionning fonts by scaling the canvas
authorVivien Nicolas <21@vingtetun.org>
Tue, 28 Jun 2011 15:26:52 +0000 (17:26 +0200)
committerVivien Nicolas <21@vingtetun.org>
Tue, 28 Jun 2011 15:26:52 +0000 (17:26 +0200)
pdf.js

diff --git a/pdf.js b/pdf.js
index 48fc8f1ae2be90793815a97b895012fb01b13a4d..2d25cf707943b95dab742348068f9f442e06e426 100644 (file)
--- a/pdf.js
+++ b/pdf.js
@@ -2807,6 +2807,7 @@ var CanvasGraphics = (function() {
                 return;
             }
 
+            this.current.fontName = fontName;
             this.current.fontSize = size;
             this.ctx.font = this.current.fontSize +'px "' + fontName + '", Symbol';
         },
@@ -2850,7 +2851,11 @@ var CanvasGraphics = (function() {
                 text = Fonts.charsToUnicode(text);
                 this.ctx.translate(this.current.x, -1 * this.current.y);
                 this.ctx.fillText(text, 0, 0);
-                this.current.x += this.ctx.measureText(text).width;
+
+                this.ctx.scale(0.05, 1);
+                this.ctx.font = (this.current.fontSize * 20) + 'px "' + this.current.fontName + '", Symbol';
+                this.current.x += this.ctx.measureText(text).width / 20;
+                this.ctx.scale(1, 1);
             }
 
             this.ctx.restore();