[Pkg-javascript-commits] [pdf.js] 10/157: Skip mapping of CIDFontType2 glyphs when the font either has a |IdentityToUnicodeMap| or a |toUnicodeMap| with 65536 elements (issue 5677)

David Prévot taffit at moszumanska.debian.org
Tue Aug 11 06:46:25 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 aa3a64e97502b2045f07168210b7a45b9497f5ef
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date:   Thu Jun 18 21:53:15 2015 +0200

    Skip mapping of CIDFontType2 glyphs when the font either has a |IdentityToUnicodeMap| or a |toUnicodeMap| with 65536 elements (issue 5677)
    
    This patch slightly extends the heuristics used when trying to skip mapping of missing glyphs.
    
    Fixes 5677.
---
 src/core/fonts.js       |   8 ++++++--
 test/pdfs/.gitignore    |   1 +
 test/pdfs/issue5677.pdf | Bin 0 -> 194851 bytes
 test/test_manifest.json |   7 +++++++
 4 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/core/fonts.js b/src/core/fonts.js
index 93c8826..996dbf9 100644
--- a/src/core/fonts.js
+++ b/src/core/fonts.js
@@ -4130,13 +4130,17 @@ var Font = (function FontClosure() {
 
       var charCodeToGlyphId = [], charCode;
       var toUnicode = properties.toUnicode, widths = properties.widths;
-      var isIdentityUnicode = toUnicode instanceof IdentityToUnicodeMap;
+      var skipToUnicode = (toUnicode instanceof IdentityToUnicodeMap ||
+                           toUnicode.length === 0x10000);
 
+      // Helper function to try to skip mapping of empty glyphs.
+      // Note: In some cases, just relying on the glyph data doesn't work,
+      //       hence we also use a few heuristics to fix various PDF files.
       function hasGlyph(glyphId, charCode, widthCode) {
         if (!missingGlyphs[glyphId]) {
           return true;
         }
-        if (!isIdentityUnicode && charCode >= 0 && toUnicode.has(charCode)) {
+        if (!skipToUnicode && charCode >= 0 && toUnicode.has(charCode)) {
           return true;
         }
         if (widths && widthCode >= 0 && isNum(widths[widthCode])) {
diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore
index 65961a4..b972504 100644
--- a/test/pdfs/.gitignore
+++ b/test/pdfs/.gitignore
@@ -25,6 +25,7 @@
 !issue4630.pdf
 !issue5202.pdf
 !issue5280.pdf
+!issue5677.pdf
 !issue5954.pdf
 !alphatrans.pdf
 !devicen.pdf
diff --git a/test/pdfs/issue5677.pdf b/test/pdfs/issue5677.pdf
new file mode 100644
index 0000000..064c954
Binary files /dev/null and b/test/pdfs/issue5677.pdf differ
diff --git a/test/test_manifest.json b/test/test_manifest.json
index aa8b77d..3cb595b 100644
--- a/test/test_manifest.json
+++ b/test/test_manifest.json
@@ -558,6 +558,13 @@
        "link": false,
        "type": "load"
     },
+    {  "id": "issue5677",
+       "file": "pdfs/issue5677.pdf",
+       "md5": "c9101578fcb806269145132724d24ac1",
+       "rounds": 1,
+       "link": false,
+       "type": "eq"
+    },
     {  "id": "issue5954",
        "file": "pdfs/issue5954.pdf",
        "md5": "4f60ec0d9bbeec845b681242b8982361",

-- 
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