[Pkg-javascript-commits] [pdf.js] 95/207: Don't blindly trust toUnicode when building toFontChar for non-standard fonts without a font file (issue 4934)

David Prévot taffit at moszumanska.debian.org
Mon Jul 28 15:36:35 UTC 2014


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

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

commit 158790981c5337ed2960b1dec2c0366e75882fac
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date:   Sat Jun 14 22:51:13 2014 +0200

    Don't blindly trust toUnicode when building toFontChar for non-standard fonts without a font file (issue 4934)
---
 src/core/fonts.js       |  15 +++++++++++----
 test/pdfs/.gitignore    |   1 +
 test/pdfs/issue4934.pdf | Bin 0 -> 1822 bytes
 test/test_manifest.json |   9 +++++++++
 4 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/src/core/fonts.js b/src/core/fonts.js
index 1e18e23..d9e0eba 100644
--- a/src/core/fonts.js
+++ b/src/core/fonts.js
@@ -2150,7 +2150,7 @@ var Glyph = (function GlyphClosure() {
  */
 var Font = (function FontClosure() {
   function Font(name, file, properties) {
-    var charCode;
+    var charCode, glyphName;
 
     this.name = name;
     this.loadedName = properties.loadedName;
@@ -2249,13 +2249,20 @@ var Font = (function FontClosure() {
       } else if (isStandardFont) {
         this.toFontChar = [];
         for (charCode in properties.defaultEncoding) {
-          var glyphName = properties.differences[charCode] ||
-                          properties.defaultEncoding[charCode];
+          glyphName = (properties.differences[charCode] ||
+                       properties.defaultEncoding[charCode]);
           this.toFontChar[charCode] = GlyphsUnicode[glyphName];
         }
       } else {
+        var unicodeCharCode, notCidFont = (type.indexOf('CIDFontType') === -1);
         for (charCode in this.toUnicode) {
-          this.toFontChar[charCode] = this.toUnicode[charCode].charCodeAt(0);
+          unicodeCharCode = this.toUnicode[charCode].charCodeAt(0);
+          if (notCidFont) {
+            glyphName = (properties.differences[charCode] ||
+                         properties.defaultEncoding[charCode]);
+            unicodeCharCode = (GlyphsUnicode[glyphName] || unicodeCharCode);
+          }
+          this.toFontChar[charCode] = unicodeCharCode;
         }
       }
       this.loadedName = fontName.split('-')[0];
diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore
index 726a852..debc332 100644
--- a/test/pdfs/.gitignore
+++ b/test/pdfs/.gitignore
@@ -66,6 +66,7 @@
 !noembed-sjis.pdf
 !vertical.pdf
 !bug878026.pdf
+!issue4934.pdf
 !issue4650.pdf
 !issue3025.pdf
 !issue2099-1.pdf
diff --git a/test/pdfs/issue4934.pdf b/test/pdfs/issue4934.pdf
new file mode 100644
index 0000000..6924fcc
Binary files /dev/null and b/test/pdfs/issue4934.pdf differ
diff --git a/test/test_manifest.json b/test/test_manifest.json
index 77306d0..57eb4c9 100644
--- a/test/test_manifest.json
+++ b/test/test_manifest.json
@@ -436,6 +436,15 @@
        "lastPage": 1,
        "type": "eq"
     },
+    {  "id": "issue4934",
+       "file": "pdfs/issue4934.pdf",
+       "md5": "6099da44f677702ae65a648b51a2226d",
+       "rounds": 1,
+       "link": false,
+       "firstPage": 1,
+       "lastPage": 1,
+       "type": "eq"
+    },
     {  "id": "txt2pdf",
        "file": "pdfs/txt2pdf.pdf",
        "md5": "02cefa0f5e8d96313bb05163b2f88c8c",

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