Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #861 from notmasteryet/issue-840

(#840) fix font stretching and overlapping characters encoding
  • Loading branch information...
commit c0291e9fa3dbfd0a710729d34a06aaf18bd00158 2 parents b958fd4 + 05c1f68
vingtetun vingtetun authored
4 src/canvas.js
@@ -575,7 +575,7 @@ var CanvasGraphics = (function canvasGraphics() {
575 575 ctx.scale(1, -1);
576 576 ctx.translate(current.x, -1 * current.y);
577 577 ctx.transform.apply(ctx, fontMatrix);
578   - ctx.scale(1 / textHScale, 1);
  578 + ctx.scale(textHScale, 1);
579 579 },
580 580 getTextGeometry: function canvasGetTextGeometry() {
581 581 var geometry = {};
@@ -651,7 +651,7 @@ var CanvasGraphics = (function canvasGraphics() {
651 651 ctx.transform.apply(ctx, current.textMatrix);
652 652 ctx.translate(current.x, current.y);
653 653
654   - ctx.scale(1 / textHScale, 1);
  654 + ctx.scale(textHScale, 1);
655 655 for (var i = 0; i < glyphsLength; ++i) {
656 656
657 657 var glyph = glyphs[i];
16 src/fonts.js
@@ -1705,10 +1705,18 @@ var Font = (function Font() {
1705 1705
1706 1706 var cidToGidMap = properties.cidToGidMap || [];
1707 1707 var gidToCidMap = [0];
1708   - for (var j = cidToGidMap.length - 1; j >= 0; j--) {
1709   - var gid = cidToGidMap[j];
1710   - if (gid)
1711   - gidToCidMap[gid] = j;
  1708 + if (cidToGidMap.length > 0) {
  1709 + for (var j = cidToGidMap.length - 1; j >= 0; j--) {
  1710 + var gid = cidToGidMap[j];
  1711 + if (gid)
  1712 + gidToCidMap[gid] = j;
  1713 + }
  1714 + // filling the gaps using CID above the CIDs currently used in font
  1715 + var nextCid = cidToGidMap.length;
  1716 + for (var i = 1; i < numGlyphs; i++) {
  1717 + if (!gidToCidMap[i])
  1718 + gidToCidMap[i] = nextCid++;
  1719 + }
1712 1720 }
1713 1721
1714 1722 var glyphs = [], ids = [];
1  test/pdfs/.gitignore
@@ -16,3 +16,4 @@
16 16 !alphatrans.pdf
17 17 !devicen.pdf
18 18 !cmykjpeg.pdf
  19 +!issue840.pdf
BIN  test/pdfs/issue840.pdf
Binary file not shown
6 test/test_manifest.json
@@ -290,5 +290,11 @@
290 290 "link": true,
291 291 "rounds": 1,
292 292 "type": "eq"
  293 + },
  294 + { "id": "issue840",
  295 + "file": "pdfs/issue840.pdf",
  296 + "md5": "20d88011dd7e3c4fb5274979094dab93",
  297 + "rounds": 1,
  298 + "type": "eq"
293 299 }
294 300 ]

0 comments on commit c0291e9

Please sign in to comment.
Something went wrong with that request. Please try again.