1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Merge pull request #5990 from Snuffleupagus/missing-glyphs-identityUnicode

Skip mapping of CIDFontType2 glyphs in fonts with a |IdentityToUnicodeMap|, unless |properties.widths| is defined for the glyph
This commit is contained in:
Brendan Dahl 2015-06-05 14:50:02 -07:00
commit 749a60a0b7
5 changed files with 28 additions and 6 deletions

View file

@ -4126,13 +4126,18 @@ var Font = (function FontClosure() {
}
}
var charCodeToGlyphId = [], charCode, toUnicode = properties.toUnicode;
var charCodeToGlyphId = [], charCode;
var toUnicode = properties.toUnicode, widths = properties.widths;
var isIdentityUnicode = toUnicode instanceof IdentityToUnicodeMap;
function hasGlyph(glyphId, charCode) {
function hasGlyph(glyphId, charCode, widthCode) {
if (!missingGlyphs[glyphId]) {
return true;
}
if (charCode >= 0 && toUnicode.has(charCode)) {
if (!isIdentityUnicode && charCode >= 0 && toUnicode.has(charCode)) {
return true;
}
if (widths && widthCode >= 0 && isNum(widths[widthCode])) {
return true;
}
return false;
@ -4152,7 +4157,7 @@ var Font = (function FontClosure() {
}
if (glyphId >= 0 && glyphId < numGlyphs &&
hasGlyph(glyphId, charCode)) {
hasGlyph(glyphId, charCode, cid)) {
charCodeToGlyphId[charCode] = glyphId;
}
});
@ -4213,7 +4218,7 @@ var Font = (function FontClosure() {
var found = false;
for (i = 0; i < cmapMappingsLength; ++i) {
if (cmapMappings[i].charCode === unicodeOrCharCode &&
hasGlyph(cmapMappings[i].glyphId, unicodeOrCharCode)) {
hasGlyph(cmapMappings[i].glyphId, unicodeOrCharCode, -1)) {
charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
found = true;
break;
@ -4223,7 +4228,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 && hasGlyph(glyphId, -1)) {
if (glyphId > 0 && hasGlyph(glyphId, -1, -1)) {
charCodeToGlyphId[charCode] = glyphId;
}
}