apply pdfjs font patch

https://github.com/mozilla/pdf.js/issues/2594#issuecomment-247644205
This commit is contained in:
Brian Gough 2016-09-19 10:30:34 +01:00
parent dd4a509d51
commit 6f50d56ceb

View file

@ -18017,7 +18017,7 @@ var Font = (function FontClosure() {
} }
/** /**
* Helper function for |adjustMapping|. * Helper function for `adjustMapping`.
* @return {boolean} * @return {boolean}
*/ */
function isProblematicUnicodeLocation(code) { function isProblematicUnicodeLocation(code) {
@ -18060,12 +18060,18 @@ var Font = (function FontClosure() {
var fontCharCode = originalCharCode; var fontCharCode = originalCharCode;
// First try to map the value to a unicode position if a non identity map // First try to map the value to a unicode position if a non identity map
// was created. // was created.
var hasUnicodeValue = false;
if (!isIdentityUnicode && toUnicode.has(originalCharCode)) { if (!isIdentityUnicode && toUnicode.has(originalCharCode)) {
var unicode = toUnicode.get(fontCharCode); var unicode = toUnicode.get(fontCharCode);
// TODO: Try to map ligatures to the correct spot. // TODO: Try to map ligatures to the correct spot.
if (unicode.length === 1) { if (unicode.length === 1) {
fontCharCode = unicode.charCodeAt(0); fontCharCode = unicode.charCodeAt(0);
} }
// For Symbolic fonts, we trust the `unicode` value if and only if the
// font includes either `ToUnicode` or `Encoding` data, since otherwise
// `toUnicode` may not be correct.
hasUnicodeValue = properties.hasIncludedToUnicodeMap ||
properties.hasEncoding;
} }
// Try to move control characters, special characters and already mapped // Try to move control characters, special characters and already mapped
// characters to the private use area since they will not be drawn by // characters to the private use area since they will not be drawn by
@ -18075,7 +18081,7 @@ var Font = (function FontClosure() {
// with firefox and thuluthfont). // with firefox and thuluthfont).
if ((usedFontCharCodes[fontCharCode] !== undefined || if ((usedFontCharCodes[fontCharCode] !== undefined ||
isProblematicUnicodeLocation(fontCharCode) || isProblematicUnicodeLocation(fontCharCode) ||
(isSymbolic && isIdentityUnicode)) && (isSymbolic && !hasUnicodeValue)) &&
nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END) { // Room left. nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END) { // Room left.
// Loop to try and find a free spot in the private use area. // Loop to try and find a free spot in the private use area.
do { do {