[Pkg-javascript-commits] [pdf.js] 99/116: Try to skip mapping of missing TrueType glyphs
David Prévot
taffit at moszumanska.debian.org
Fri Mar 6 16:20:05 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 01e6565dd4c5c3e162cc4d44194b549bebd7324d
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date: Sat Feb 7 00:13:41 2015 +0100
Try to skip mapping of missing TrueType glyphs
Also don't skip mapping of glyphs which are empty, if the corresponding charCode is included in toUnicode.
---
src/core/fonts.js | 21 ++++++++++++++++-----
test/pdfs/.gitignore | 2 ++
test/pdfs/bug893730.pdf | Bin 0 -> 30845 bytes
test/pdfs/issue5704.pdf | Bin 0 -> 17915 bytes
test/test_manifest.json | 14 ++++++++++++++
5 files changed, 32 insertions(+), 5 deletions(-)
diff --git a/src/core/fonts.js b/src/core/fonts.js
index 8a191e1..93a5160 100644
--- a/src/core/fonts.js
+++ b/src/core/fonts.js
@@ -4070,11 +4070,21 @@ var Font = (function FontClosure() {
}
}
- var charCodeToGlyphId = [], charCode;
+ var charCodeToGlyphId = [], charCode, toUnicode = properties.toUnicode;
+
+ function hasGlyph(glyphId, charCode) {
+ if (!missingGlyphs[glyphId]) {
+ return true;
+ }
+ if (charCode >= 0 && toUnicode.has(charCode)) {
+ return true;
+ }
+ return false;
+ }
+
if (properties.type === 'CIDFontType2') {
var cidToGidMap = properties.cidToGidMap || [];
var isCidToGidMapEmpty = cidToGidMap.length === 0;
- var toUnicode = properties.toUnicode;
properties.cMap.forEach(function(charCode, cid) {
assert(cid <= 0xffff, 'Max size of CID is 65,535');
@@ -4086,7 +4096,7 @@ var Font = (function FontClosure() {
}
if (glyphId >= 0 && glyphId < numGlyphs &&
- (!missingGlyphs[glyphId] || toUnicode.has(charCode))) {
+ hasGlyph(glyphId, charCode)) {
charCodeToGlyphId[charCode] = glyphId;
}
});
@@ -4146,7 +4156,8 @@ var Font = (function FontClosure() {
var found = false;
for (i = 0; i < cmapMappingsLength; ++i) {
- if (cmapMappings[i].charCode === unicodeOrCharCode) {
+ if (cmapMappings[i].charCode === unicodeOrCharCode &&
+ hasGlyph(cmapMappings[i].glyphId, unicodeOrCharCode)) {
charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
found = true;
break;
@@ -4156,7 +4167,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) {
+ if (glyphId > 0 && hasGlyph(glyphId, -1)) {
charCodeToGlyphId[charCode] = glyphId;
}
}
diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore
index 8108d7c..d05e4f4 100644
--- a/test/pdfs/.gitignore
+++ b/test/pdfs/.gitignore
@@ -59,6 +59,8 @@
!zerowidthline.pdf
!bug868745.pdf
!mmtype1.pdf
+!issue5704.pdf
+!bug893730.pdf
!bug864847.pdf
!issue1002.pdf
!issue925.pdf
diff --git a/test/pdfs/bug893730.pdf b/test/pdfs/bug893730.pdf
new file mode 100644
index 0000000..8c6f818
Binary files /dev/null and b/test/pdfs/bug893730.pdf differ
diff --git a/test/pdfs/issue5704.pdf b/test/pdfs/issue5704.pdf
new file mode 100644
index 0000000..585a7d1
Binary files /dev/null and b/test/pdfs/issue5704.pdf differ
diff --git a/test/test_manifest.json b/test/test_manifest.json
index 797ddd8..cb799c8 100644
--- a/test/test_manifest.json
+++ b/test/test_manifest.json
@@ -1022,6 +1022,20 @@
"link": true,
"type": "eq"
},
+ { "id": "issue5704",
+ "file": "pdfs/issue5704.pdf",
+ "md5": "6e0b62585feef24dff2d7e7687cd8128",
+ "rounds": 1,
+ "link": false,
+ "type": "eq"
+ },
+ { "id": "bug893730",
+ "file": "pdfs/bug893730.pdf",
+ "md5": "2587379fb1b3bbff89c14f0863e78383",
+ "rounds": 1,
+ "link": false,
+ "type": "eq"
+ },
{ "id": "pdfkit_compressed",
"file": "pdfs/pdfkit_compressed.pdf",
"md5": "ffe9c571d0a1572e234253e6c7cdee6c",
--
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