]> git.parisson.com Git - pdf.js.git/commitdiff
Do not rasterize below 14px
authorVivien Nicolas <21@vingtetun.org>
Tue, 19 Jul 2011 12:22:51 +0000 (14:22 +0200)
committerVivien Nicolas <21@vingtetun.org>
Tue, 19 Jul 2011 12:22:51 +0000 (14:22 +0200)
fonts.js
pdf.js

index a54168a1ea6b7c51bb160a43d525cde9973d7b6c..edd54b0a114ace160340366eaad40e4b3411f21f 100755 (executable)
--- a/fonts.js
+++ b/fonts.js
@@ -22,7 +22,7 @@ var kMaxWaitForFontFace = 1000;
  */
 
 var Fonts = (function Fonts() {
-  var kScalePrecision = 40;
+  var kScalePrecision = 50;
   var fonts = [];
 
   if (!isWorker) {
@@ -404,6 +404,7 @@ var Font = (function Font() {
         // Repair the TrueType file if it is can be damaged in the point of
         // view of the sanitizer
         data = this.checkAndRepair(name, file, properties);
+                               writeToFile(data, "/tmp/file." + this.name + ".ttf");
         break;
 
       default:
diff --git a/pdf.js b/pdf.js
index f164dbd682ec450bcf94d9e82c5a9b0f93a9df8d..03cb16126fc2af7dc8635c87666238d69b2dc288 100644 (file)
--- a/pdf.js
+++ b/pdf.js
@@ -3898,6 +3898,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();
@@ -4113,8 +4116,10 @@ var CanvasGraphics = (function() {
       if (this.ctx.$setFont) {
         this.ctx.$setFont(fontName, size);
       } else {
-        this.ctx.font = size + 'px "' + fontName + '"';
         Fonts.setActive(fontName, fontObj, size);
+
+        size = (size <= kRasterizerMin) ? size * kScalePrecision : size;
+        this.ctx.font = size + 'px "' + fontName + '"';
       }
     },
     setTextRenderingMode: function(mode) {
@@ -4162,6 +4167,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);
         }