diff --git a/src/core/fonts.js b/src/core/fonts.js index a2efa65d4..ba025edc3 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -2655,6 +2655,38 @@ var Font = (function FontClosure() { return readUint32(header, 0) === 0x00010000; } + /** + * Helper function for |adjustMapping|. + * @return {boolean} + */ + function isProblematicUnicodeLocation(code) { + if (code <= 0x1F) { // Control chars + return true; + } + if (code >= 0x80 && code <= 0x9F) { // Control chars + return true; + } + if ((code >= 0x2000 && code <= 0x200F) || // General punctuation chars + (code >= 0x2028 && code <= 0x202F) || + (code >= 0x2060 && code <= 0x206F)) { + return true; + } + if (code >= 0xFFF0 && code <= 0xFFFF) { // Specials Unicode block + return true; + } + switch (code) { + case 0x7F: // Control char + case 0xA0: // Non breaking space + case 0xAD: // Soft hyphen + case 0x0E33: // Thai character SARA AM + case 0x2011: // Non breaking hyphen + case 0x205F: // Medium mathematical space + case 0x25CC: // Dotted circle (combining mark) + return true; + } + return false; + } + /** * Rebuilds the char code to glyph ID map by trying to replace the char codes * with their unicode value. It also moves char codes that are in known @@ -2694,15 +2726,7 @@ var Font = (function FontClosure() { // characters probably aren't in the correct position (fixes an issue // with firefox and thuluthfont). if ((usedFontCharCodes[fontCharCode] !== undefined || - fontCharCode <= 0x1f || // Control chars - fontCharCode === 0x7F || // Control char - fontCharCode === 0xAD || // Soft hyphen - fontCharCode === 0xA0 || // Non breaking space - fontCharCode === 0x0E33 || // Thai character SARA AM - fontCharCode === 0x25CC || // Dotted circle (combining mark) - (fontCharCode >= 0x80 && fontCharCode <= 0x9F) || // Control chars - // Prevent drawing characters in the specials unicode block. - (fontCharCode >= 0xFFF0 && fontCharCode <= 0xFFFF) || + isProblematicUnicodeLocation(fontCharCode) || (isSymbolic && isIdentityUnicode)) && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END) { // Room left. // Loop to try and find a free spot in the private use area. diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index a744db6ca..d65b22c82 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -30,6 +30,7 @@ !bug847420.pdf !bug860632.pdf !bug894572.pdf +!bug911034.pdf !bug1108301.pdf !pdfjsbad1586.pdf !freeculture.pdf diff --git a/test/pdfs/bug911034.pdf b/test/pdfs/bug911034.pdf new file mode 100644 index 000000000..344161cff Binary files /dev/null and b/test/pdfs/bug911034.pdf differ diff --git a/test/test_manifest.json b/test/test_manifest.json index 4ddf669af..5a511510f 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -52,6 +52,13 @@ "type": "eq", "about": "Fonts referenced only by name and not by an object identifier." }, + { "id": "bug911034", + "file": "pdfs/bug911034.pdf", + "md5": "54ee432a4e16b26b242fbf549cdad177", + "rounds": 1, + "link": false, + "type": "eq" + }, { "id": "bug921760", "file": "pdfs/bug921760.pdf", "md5": "1aa136d786a65b0d7cce7bdb3c58c6c3",