Browse Source

Merge pull request #6135 from Snuffleupagus/issue-5677-v2

Skip mapping of CIDFontType2 glyphs when the font either has a |IdentityToUnicodeMap| or a |toUnicodeMap| with 65536 elements (issue 5677)
Brendan Dahl 10 years ago
parent
commit
d8e201446d
  1. 8
      src/core/fonts.js
  2. 1
      test/pdfs/.gitignore
  3. BIN
      test/pdfs/issue5677.pdf
  4. 7
      test/test_manifest.json

8
src/core/fonts.js

@ -4130,13 +4130,17 @@ var Font = (function FontClosure() {
var charCodeToGlyphId = [], charCode; var charCodeToGlyphId = [], charCode;
var toUnicode = properties.toUnicode, widths = properties.widths; 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) { function hasGlyph(glyphId, charCode, widthCode) {
if (!missingGlyphs[glyphId]) { if (!missingGlyphs[glyphId]) {
return true; return true;
} }
if (!isIdentityUnicode && charCode >= 0 && toUnicode.has(charCode)) { if (!skipToUnicode && charCode >= 0 && toUnicode.has(charCode)) {
return true; return true;
} }
if (widths && widthCode >= 0 && isNum(widths[widthCode])) { if (widths && widthCode >= 0 && isNum(widths[widthCode])) {

1
test/pdfs/.gitignore vendored

@ -26,6 +26,7 @@
!issue4909.pdf !issue4909.pdf
!issue5202.pdf !issue5202.pdf
!issue5280.pdf !issue5280.pdf
!issue5677.pdf
!issue5954.pdf !issue5954.pdf
!alphatrans.pdf !alphatrans.pdf
!devicen.pdf !devicen.pdf

BIN
test/pdfs/issue5677.pdf

Binary file not shown.

7
test/test_manifest.json

@ -565,6 +565,13 @@
"link": false, "link": false,
"type": "load" "type": "load"
}, },
{ "id": "issue5677",
"file": "pdfs/issue5677.pdf",
"md5": "c9101578fcb806269145132724d24ac1",
"rounds": 1,
"link": false,
"type": "eq"
},
{ "id": "issue5954", { "id": "issue5954",
"file": "pdfs/issue5954.pdf", "file": "pdfs/issue5954.pdf",
"md5": "4f60ec0d9bbeec845b681242b8982361", "md5": "4f60ec0d9bbeec845b681242b8982361",

Loading…
Cancel
Save