]> git.parisson.com Git - pdf.js.git/commitdiff
(#840) fix font stretching and overlapping characters encoding
authornotmasteryet <async.processingjs@yahoo.com>
Fri, 2 Dec 2011 02:56:26 +0000 (20:56 -0600)
committernotmasteryet <async.processingjs@yahoo.com>
Fri, 2 Dec 2011 02:56:26 +0000 (20:56 -0600)
src/canvas.js
src/fonts.js

index b457eb4ff59e095fc0ee0d6e82d9c17362dd769f..0913b582aa020828de635f4014a5284b0a89bc01 100644 (file)
@@ -575,7 +575,7 @@ var CanvasGraphics = (function canvasGraphics() {
       ctx.scale(1, -1);
       ctx.translate(current.x, -1 * current.y);
       ctx.transform.apply(ctx, fontMatrix);
-      ctx.scale(1 / textHScale, 1);
+      ctx.scale(textHScale, 1);
     },
     getTextGeometry: function canvasGetTextGeometry() {
       var geometry = {};
@@ -651,7 +651,7 @@ var CanvasGraphics = (function canvasGraphics() {
         ctx.transform.apply(ctx, current.textMatrix);
         ctx.translate(current.x, current.y);
 
-        ctx.scale(1 / textHScale, 1);
+        ctx.scale(textHScale, 1);
         for (var i = 0; i < glyphsLength; ++i) {
 
           var glyph = glyphs[i];
index 2e95a7c9465ebb0c59ba8f0da7ad525125aebf93..672739ea49e36eaae33f7202a1c0e2c92c272c30 100644 (file)
@@ -1705,10 +1705,18 @@ var Font = (function Font() {
 
         var cidToGidMap = properties.cidToGidMap || [];
         var gidToCidMap = [0];
-        for (var j = cidToGidMap.length - 1; j >= 0; j--) {
-          var gid = cidToGidMap[j];
-          if (gid)
-            gidToCidMap[gid] = j;
+        if (cidToGidMap.length > 0) {
+          for (var j = cidToGidMap.length - 1; j >= 0; j--) {
+            var gid = cidToGidMap[j];
+            if (gid)
+              gidToCidMap[gid] = j;
+          }
+          // filling the gaps using CID above the CIDs currently used in font
+          var nextCid = cidToGidMap.length;
+          for (var i = 1; i < numGlyphs; i++) {
+            if (!gidToCidMap[i])
+              gidToCidMap[i] = nextCid++;
+          }
         }
 
         var glyphs = [], ids = [];