[Pkg-javascript-commits] [pdf.js] 28/106: Skip mapping of CIDFontType2 glyphs in fonts with a |IdentityToUnicodeMap|, unless |properties.widths| is defined for the glyph

David Prévot taffit at moszumanska.debian.org
Sat Jun 20 21:33:46 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit 6fbc5428bd3fd72106cc49205be6cf43ec7f3c9e
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date:   Thu Apr 30 12:40:54 2015 +0200

    Skip mapping of CIDFontType2 glyphs in fonts with a |IdentityToUnicodeMap|, unless |properties.widths| is defined for the glyph
    
    Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1142033.
    Also fixes issue 5874.
---
 src/core/fonts.js             |  17 +++++++++++------
 test/pdfs/.gitignore          |   1 +
 test/pdfs/bug1142033.pdf.link |   1 +
 test/pdfs/issue5874.pdf       | Bin 0 -> 214331 bytes
 test/test_manifest.json       |  15 +++++++++++++++
 5 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/src/core/fonts.js b/src/core/fonts.js
index 751183a..313f771 100644
--- a/src/core/fonts.js
+++ b/src/core/fonts.js
@@ -4121,13 +4121,18 @@ var Font = (function FontClosure() {
         }
       }
 
-      var charCodeToGlyphId = [], charCode, toUnicode = properties.toUnicode;
+      var charCodeToGlyphId = [], charCode;
+      var toUnicode = properties.toUnicode, widths = properties.widths;
+      var isIdentityUnicode = toUnicode instanceof IdentityToUnicodeMap;
 
-      function hasGlyph(glyphId, charCode) {
+      function hasGlyph(glyphId, charCode, widthCode) {
         if (!missingGlyphs[glyphId]) {
           return true;
         }
-        if (charCode >= 0 && toUnicode.has(charCode)) {
+        if (!isIdentityUnicode && charCode >= 0 && toUnicode.has(charCode)) {
+          return true;
+        }
+        if (widths && widthCode >= 0 && isNum(widths[widthCode])) {
           return true;
         }
         return false;
@@ -4147,7 +4152,7 @@ var Font = (function FontClosure() {
           }
 
           if (glyphId >= 0 && glyphId < numGlyphs &&
-              hasGlyph(glyphId, charCode)) {
+              hasGlyph(glyphId, charCode, cid)) {
             charCodeToGlyphId[charCode] = glyphId;
           }
         });
@@ -4208,7 +4213,7 @@ var Font = (function FontClosure() {
             var found = false;
             for (i = 0; i < cmapMappingsLength; ++i) {
               if (cmapMappings[i].charCode === unicodeOrCharCode &&
-                  hasGlyph(cmapMappings[i].glyphId, unicodeOrCharCode)) {
+                  hasGlyph(cmapMappings[i].glyphId, unicodeOrCharCode, -1)) {
                 charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
                 found = true;
                 break;
@@ -4218,7 +4223,7 @@ var Font = (function FontClosure() {
               // Try to map using the post table. There are currently no known
               // pdfs that this fixes.
               var glyphId = properties.glyphNames.indexOf(glyphName);
-              if (glyphId > 0 && hasGlyph(glyphId, -1)) {
+              if (glyphId > 0 && hasGlyph(glyphId, -1, -1)) {
                 charCodeToGlyphId[charCode] = glyphId;
               }
             }
diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore
index 7946c42..04d0cf2 100644
--- a/test/pdfs/.gitignore
+++ b/test/pdfs/.gitignore
@@ -7,6 +7,7 @@
 !issue2391-2.pdf
 !issue5801.pdf
 !issue5972.pdf
+!issue5874.pdf
 !filled-background.pdf
 !ArabicCIDTrueType.pdf
 !ThuluthFeatures.pdf
diff --git a/test/pdfs/bug1142033.pdf.link b/test/pdfs/bug1142033.pdf.link
new file mode 100644
index 0000000..51cba85
--- /dev/null
+++ b/test/pdfs/bug1142033.pdf.link
@@ -0,0 +1 @@
+https://bug1142033.bugzilla.mozilla.org/attachment.cgi?id=8597714
diff --git a/test/pdfs/issue5874.pdf b/test/pdfs/issue5874.pdf
new file mode 100644
index 0000000..496c45f
Binary files /dev/null and b/test/pdfs/issue5874.pdf differ
diff --git a/test/test_manifest.json b/test/test_manifest.json
index f20b986..684d74b 100644
--- a/test/test_manifest.json
+++ b/test/test_manifest.json
@@ -947,6 +947,21 @@
       "link": true,
       "type": "load"
     },
+    {  "id": "bug1142033",
+       "file": "pdfs/bug1142033.pdf",
+       "md5": "1d9afd397e89a0f52c056f449ec93daa",
+       "rounds": 1,
+       "lastPage": 1,
+       "link": true,
+       "type": "eq"
+    },
+    {  "id": "issue5874",
+       "file": "pdfs/issue5874.pdf",
+       "md5": "25922edf223aa91bc259663d0a34a6ab",
+       "rounds": 1,
+       "link": false,
+       "type": "eq"
+    },
     {  "id": "S2-eq",
        "file": "pdfs/S2.pdf",
        "md5": "d0b6137846df6e0fe058f234a87fb588",

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list