Merge pull request #11243 from Snuffleupagus/issue-11242

Add a fallback for non-embedded *composite* Verdana fonts (issue 11242)
This commit is contained in:
Tim van der Meij 2019-10-18 23:56:46 +02:00 committed by GitHub
commit 11f3851a97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 4 deletions

View File

@ -1203,10 +1203,10 @@ var Font = (function FontClosure() {
this.remeasure = Object.keys(this.widths).length > 0;
if (isStandardFont && type === 'CIDFontType2' &&
this.cidEncoding.startsWith('Identity-')) {
var GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
const GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
// Standard fonts might be embedded as CID font without glyph mapping.
// Building one based on GlyphMapForStandardFonts.
var map = [];
const map = [];
for (charCode in GlyphMapForStandardFonts) {
map[+charCode] = GlyphMapForStandardFonts[charCode];
}
@ -1247,7 +1247,8 @@ var Font = (function FontClosure() {
getGlyphsUnicode(),
this.differences);
} else {
var glyphsUnicodeMap = getGlyphsUnicode();
const glyphsUnicodeMap = getGlyphsUnicode();
const map = [];
this.toUnicode.forEach((charCode, unicodeCharCode) => {
if (!this.composite) {
var glyphName = (this.differences[charCode] ||
@ -1257,8 +1258,20 @@ var Font = (function FontClosure() {
unicodeCharCode = unicode;
}
}
this.toFontChar[charCode] = unicodeCharCode;
map[+charCode] = unicodeCharCode;
});
// Attempt to improve the glyph mapping for (some) composite fonts that
// appear to lack meaningful ToUnicode data.
if (this.composite && this.toUnicode instanceof IdentityToUnicodeMap) {
if (/Verdana/i.test(name)) { // Fixes issue11242_reduced.pdf
const GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
for (charCode in GlyphMapForStandardFonts) {
map[+charCode] = GlyphMapForStandardFonts[charCode];
}
}
}
this.toFontChar = map;
}
this.loadedName = fontName.split('-')[0];
this.fontType = getFontType(type, subtype);

View File

@ -84,6 +84,7 @@
!issue11016_reduced.pdf
!issue11045.pdf
!issue11150_reduced.pdf
!issue11242_reduced.pdf
!bad-PageLabels.pdf
!decodeACSuccessive.pdf
!filled-background.pdf

Binary file not shown.

View File

@ -2208,6 +2208,13 @@
"rounds": 1,
"type": "eq"
},
{ "id": "issue11242",
"file": "pdfs/issue11242_reduced.pdf",
"md5": "ba50b6ee537f3e815ccfe0c99e598e05",
"link": false,
"rounds": 1,
"type": "eq"
},
{ "id": "issue3323",
"file": "pdfs/issue3323.pdf",
"md5": "1a14ff574013caeafa9d598269988764",