]> git.parisson.com Git - pdf.js.git/commitdiff
fix small fonts
authorsbarman <sbarman@L3CWZ5T.(none)>
Thu, 21 Jul 2011 16:20:19 +0000 (09:20 -0700)
committersbarman <sbarman@L3CWZ5T.(none)>
Thu, 21 Jul 2011 16:20:19 +0000 (09:20 -0700)
pdf.js

diff --git a/pdf.js b/pdf.js
index 1f02d7d6d87c6866526bbfff707d20397c35e21d..5c29edd0c98c25cd3cdb8d673c91f9de338837dc 100644 (file)
--- a/pdf.js
+++ b/pdf.js
@@ -3879,6 +3879,9 @@ function ScratchCanvas(width, height) {
 }
 
 var CanvasGraphics = (function() {
+  var kScalePrecision = 50;
+  var kRasterizerMin = 14;
+
   function constructor(canvasCtx, imageCanvas) {
     this.ctx = canvasCtx;
     this.current = new CanvasExtraState();
@@ -4094,8 +4097,10 @@ var CanvasGraphics = (function() {
       if (this.ctx.$setFont) {
         this.ctx.$setFont(fontName, size);
       } else {
-        this.ctx.font = size + 'px "' + fontName + '"';
         FontMeasure.setActive(fontObj, size);
+
+        size = (size <= kRasterizerMin) ? size * kScalePrecision : size;
+        this.ctx.font = size + 'px"' + fontName + '"';
       }
     },
     setTextRenderingMode: function(mode) {
@@ -4143,6 +4148,8 @@ var CanvasGraphics = (function() {
         ctx.translate(current.x, -1 * current.y);
         var font = this.current.font;
         if (font) {
+          if (this.current.fontSize < kRasterizerMin)
+            ctx.transform(1 / kScalePrecision, 0, 0, 1 / kScalePrecision, 0, 0);
           ctx.transform.apply(ctx, font.textMatrix);
           text = font.charsToUnicode(text);
         }