[Pkg-javascript-commits] [pdf.js] 81/109: Only choose a (3, 1) cmap table for TrueType fonts that have an encoding specified (issue 6410)
David Prévot
taffit at moszumanska.debian.org
Fri Sep 25 03:04:21 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 29a1cdb6a6f5807fdad952166496a3c49901da59
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date: Sun Sep 6 17:16:31 2015 +0200
Only choose a (3, 1) cmap table for TrueType fonts that have an encoding specified (issue 6410)
For (1, 0) cmaps, we have two different codepaths depending on whether the font has/hasn't got an encoding. But with (3, 1) cmaps we don't have a good fallback when the encoding is missing, hence this patch changes `readCmapTable` to only choose a (3, 1) cmap table if the font is non-symbolic *and* an encoding exists. Without this, we'll not be able to successfully create a working glyph map for some TrueType fonts with (3, 1) cmap tables.
Fixes 6410.
---
src/core/fonts.js | 11 ++++++-----
test/pdfs/.gitignore | 1 +
test/pdfs/issue6410.pdf | Bin 0 -> 211633 bytes
test/test_manifest.json | 7 +++++++
4 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/src/core/fonts.js b/src/core/fonts.js
index 0f457bc..ece7121 100644
--- a/src/core/fonts.js
+++ b/src/core/fonts.js
@@ -3222,7 +3222,7 @@ var Font = (function FontClosure() {
* Read the appropriate subtable from the cmap according to 9.6.6.4 from
* PDF spec
*/
- function readCmapTable(cmap, font, isSymbolicFont) {
+ function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
var segment;
var start = (font.start ? font.start : 0) + cmap.offset;
font.pos = start;
@@ -3253,7 +3253,7 @@ var Font = (function FontClosure() {
// Continue the loop since there still may be a higher priority
// table.
} else if (platformId === 3 && encodingId === 1 &&
- (!isSymbolicFont || !potentialTable)) {
+ ((!isSymbolicFont && hasEncoding) || !potentialTable)) {
useTable = true;
if (!isSymbolicFont) {
canBreak = true;
@@ -4202,13 +4202,14 @@ var Font = (function FontClosure() {
} else {
// Most of the following logic in this code branch is based on the
// 9.6.6.4 of the PDF spec.
- var cmapTable = readCmapTable(tables.cmap, font, this.isSymbolicFont);
+ var hasEncoding =
+ properties.differences.length > 0 || !!properties.baseEncodingName;
+ var cmapTable =
+ readCmapTable(tables.cmap, font, this.isSymbolicFont, hasEncoding);
var cmapPlatformId = cmapTable.platformId;
var cmapEncodingId = cmapTable.encodingId;
var cmapMappings = cmapTable.mappings;
var cmapMappingsLength = cmapMappings.length;
- var hasEncoding = properties.differences.length ||
- !!properties.baseEncodingName;
// The spec seems to imply that if the font is symbolic the encoding
// should be ignored, this doesn't appear to work for 'preistabelle.pdf'
diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore
index da70782..ab225f1 100644
--- a/test/pdfs/.gitignore
+++ b/test/pdfs/.gitignore
@@ -98,6 +98,7 @@
!issue5747.pdf
!issue6099.pdf
!issue6336.pdf
+!issue6410.pdf
!gradientfill.pdf
!bug903856.pdf
!bug850854.pdf
diff --git a/test/pdfs/issue6410.pdf b/test/pdfs/issue6410.pdf
new file mode 100644
index 0000000..c0b5ad9
Binary files /dev/null and b/test/pdfs/issue6410.pdf differ
diff --git a/test/test_manifest.json b/test/test_manifest.json
index c430951..42c9861 100644
--- a/test/test_manifest.json
+++ b/test/test_manifest.json
@@ -1086,6 +1086,13 @@
"link": true,
"type": "eq"
},
+ { "id": "issue6410",
+ "file": "pdfs/issue6410.pdf",
+ "md5": "fd5c5898d5b9754bb546724b7d31bf59",
+ "rounds": 1,
+ "link": false,
+ "type": "eq"
+ },
{ "id": "issue6413",
"file": "pdfs/issue6413.pdf",
"md5": "08926ac7a46e27a4abbb31256b3a7b29",
--
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