[Pkg-javascript-commits] [pdf.js] 107/246: Adjust the heuristics to recognize more cases of unknown glyphs for |toUnicode| (issue 5070)
David Prévot
taffit at moszumanska.debian.org
Sun Sep 7 15:36:31 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 8ecbb4da05272519572b96b6ebe818ae4f80ad42
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date: Mon Jul 28 18:41:47 2014 +0200
Adjust the heuristics to recognize more cases of unknown glyphs for |toUnicode| (issue 5070)
---
src/core/fonts.js | 14 ++++++++++++++
test/pdfs/.gitignore | 1 +
test/pdfs/issue5070.pdf | Bin 0 -> 34369 bytes
test/test_manifest.json | 7 +++++++
4 files changed, 22 insertions(+)
diff --git a/src/core/fonts.js b/src/core/fonts.js
index b4ab818..76b4eac 100644
--- a/src/core/fonts.js
+++ b/src/core/fonts.js
@@ -4300,6 +4300,7 @@ var Font = (function FontClosure() {
if (!properties.composite /* is simple font */) {
toUnicode = [];
var encoding = properties.defaultEncoding.slice();
+ var baseEncodingName = properties.baseEncodingName;
// Merge in the differences array.
var differences = properties.differences;
for (charcode in differences) {
@@ -4328,12 +4329,25 @@ var Font = (function FontClosure() {
}
break;
case 'C': // Cddd glyph
+ case 'c': // cddd glyph
if (glyphName.length >= 3) {
code = +glyphName.substr(1);
}
break;
}
if (code) {
+ // If |baseEncodingName| is one the predefined encodings,
+ // and |code| equals |charcode|, using the glyph defined in the
+ // baseEncoding seems to yield a better |toUnicode| mapping
+ // (fixes issue 5070).
+ if (baseEncodingName && code === +charcode) {
+ var baseEncoding = Encodings[baseEncodingName];
+ if (baseEncoding && (glyphName = baseEncoding[charcode])) {
+ toUnicode[charcode] =
+ String.fromCharCode(GlyphsUnicode[glyphName]);
+ continue;
+ }
+ }
toUnicode[charcode] = String.fromCharCode(code);
}
continue;
diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore
index 77da225..f468102 100644
--- a/test/pdfs/.gitignore
+++ b/test/pdfs/.gitignore
@@ -56,6 +56,7 @@
!issue925.pdf
!issue4668.pdf
!issue5039.pdf
+!issue5070.pdf
!gradientfill.pdf
!bug903856.pdf
!bug850854.pdf
diff --git a/test/pdfs/issue5070.pdf b/test/pdfs/issue5070.pdf
new file mode 100644
index 0000000..fe77923
Binary files /dev/null and b/test/pdfs/issue5070.pdf differ
diff --git a/test/test_manifest.json b/test/test_manifest.json
index b3af44c..15f1ea8 100644
--- a/test/test_manifest.json
+++ b/test/test_manifest.json
@@ -1067,6 +1067,13 @@
"rounds": 1,
"type": "eq"
},
+ { "id": "issue5070",
+ "file": "pdfs/issue5070.pdf",
+ "md5": "ec2ca0b4954c8390a5b3b0ffd79a8e92",
+ "link": false,
+ "rounds": 1,
+ "type": "eq"
+ },
{ "id": "issue1257",
"file": "pdfs/issue1257.pdf",
"md5": "9111533826bc21ed774e8e01603a2f54",
--
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