Add a fallback for non-embedded *composite* Verdana fonts (issue 11242)
Obviously this won't look exactly right, but considering that the PDF file doesn't bother embedding non-standard fonts this is the best that we can do here.
This commit is contained in:
parent
af61d48899
commit
2fcb5afc7b
@ -1203,10 +1203,10 @@ var Font = (function FontClosure() {
|
|||||||
this.remeasure = Object.keys(this.widths).length > 0;
|
this.remeasure = Object.keys(this.widths).length > 0;
|
||||||
if (isStandardFont && type === 'CIDFontType2' &&
|
if (isStandardFont && type === 'CIDFontType2' &&
|
||||||
this.cidEncoding.startsWith('Identity-')) {
|
this.cidEncoding.startsWith('Identity-')) {
|
||||||
var GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
|
const GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
|
||||||
// Standard fonts might be embedded as CID font without glyph mapping.
|
// Standard fonts might be embedded as CID font without glyph mapping.
|
||||||
// Building one based on GlyphMapForStandardFonts.
|
// Building one based on GlyphMapForStandardFonts.
|
||||||
var map = [];
|
const map = [];
|
||||||
for (charCode in GlyphMapForStandardFonts) {
|
for (charCode in GlyphMapForStandardFonts) {
|
||||||
map[+charCode] = GlyphMapForStandardFonts[charCode];
|
map[+charCode] = GlyphMapForStandardFonts[charCode];
|
||||||
}
|
}
|
||||||
@ -1247,7 +1247,8 @@ var Font = (function FontClosure() {
|
|||||||
getGlyphsUnicode(),
|
getGlyphsUnicode(),
|
||||||
this.differences);
|
this.differences);
|
||||||
} else {
|
} else {
|
||||||
var glyphsUnicodeMap = getGlyphsUnicode();
|
const glyphsUnicodeMap = getGlyphsUnicode();
|
||||||
|
const map = [];
|
||||||
this.toUnicode.forEach((charCode, unicodeCharCode) => {
|
this.toUnicode.forEach((charCode, unicodeCharCode) => {
|
||||||
if (!this.composite) {
|
if (!this.composite) {
|
||||||
var glyphName = (this.differences[charCode] ||
|
var glyphName = (this.differences[charCode] ||
|
||||||
@ -1257,8 +1258,20 @@ var Font = (function FontClosure() {
|
|||||||
unicodeCharCode = unicode;
|
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.loadedName = fontName.split('-')[0];
|
||||||
this.fontType = getFontType(type, subtype);
|
this.fontType = getFontType(type, subtype);
|
||||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -84,6 +84,7 @@
|
|||||||
!issue11016_reduced.pdf
|
!issue11016_reduced.pdf
|
||||||
!issue11045.pdf
|
!issue11045.pdf
|
||||||
!issue11150_reduced.pdf
|
!issue11150_reduced.pdf
|
||||||
|
!issue11242_reduced.pdf
|
||||||
!bad-PageLabels.pdf
|
!bad-PageLabels.pdf
|
||||||
!decodeACSuccessive.pdf
|
!decodeACSuccessive.pdf
|
||||||
!filled-background.pdf
|
!filled-background.pdf
|
||||||
|
BIN
test/pdfs/issue11242_reduced.pdf
Normal file
BIN
test/pdfs/issue11242_reduced.pdf
Normal file
Binary file not shown.
@ -2167,6 +2167,13 @@
|
|||||||
"rounds": 1,
|
"rounds": 1,
|
||||||
"type": "eq"
|
"type": "eq"
|
||||||
},
|
},
|
||||||
|
{ "id": "issue11242",
|
||||||
|
"file": "pdfs/issue11242_reduced.pdf",
|
||||||
|
"md5": "ba50b6ee537f3e815ccfe0c99e598e05",
|
||||||
|
"link": false,
|
||||||
|
"rounds": 1,
|
||||||
|
"type": "eq"
|
||||||
|
},
|
||||||
{ "id": "issue3323",
|
{ "id": "issue3323",
|
||||||
"file": "pdfs/issue3323.pdf",
|
"file": "pdfs/issue3323.pdf",
|
||||||
"md5": "1a14ff574013caeafa9d598269988764",
|
"md5": "1a14ff574013caeafa9d598269988764",
|
||||||
|
Loading…
Reference in New Issue
Block a user