Merge pull request #12419 from Snuffleupagus/fallbackToSystemFont-cidToGidMap
Use the `cidToGidMap`, if it exists, when building the glyph mapping for non-embedded composite fonts (issue 12418)
This commit is contained in:
commit
8e7a6e010d
@ -622,7 +622,7 @@ var Font = (function FontClosure() {
|
||||
// attempting to recover by assuming that no file exists.
|
||||
warn('Font file is empty in "' + name + '" (' + this.loadedName + ")");
|
||||
}
|
||||
this.fallbackToSystemFont();
|
||||
this.fallbackToSystemFont(properties);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -679,7 +679,7 @@ var Font = (function FontClosure() {
|
||||
}
|
||||
} catch (e) {
|
||||
warn(e);
|
||||
this.fallbackToSystemFont();
|
||||
this.fallbackToSystemFont(properties);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1308,7 +1308,7 @@ var Font = (function FontClosure() {
|
||||
return data;
|
||||
},
|
||||
|
||||
fallbackToSystemFont: function Font_fallbackToSystemFont() {
|
||||
fallbackToSystemFont(properties) {
|
||||
this.missingFile = true;
|
||||
// The file data is not specified. Trying to fix the font name
|
||||
// to be used with the canvas.font.
|
||||
@ -1339,7 +1339,8 @@ var Font = (function FontClosure() {
|
||||
type === "CIDFontType2" &&
|
||||
this.cidEncoding.startsWith("Identity-")
|
||||
) {
|
||||
const GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
|
||||
const GlyphMapForStandardFonts = getGlyphMapForStandardFonts(),
|
||||
cidToGidMap = properties.cidToGidMap;
|
||||
// Standard fonts might be embedded as CID font without glyph mapping.
|
||||
// Building one based on GlyphMapForStandardFonts.
|
||||
const map = [];
|
||||
@ -1357,6 +1358,16 @@ var Font = (function FontClosure() {
|
||||
map[+charCode] = SupplementalGlyphMapForCalibri[charCode];
|
||||
}
|
||||
}
|
||||
// Always update the glyph mapping with the `cidToGidMap` when it exists
|
||||
// (fixes issue12418_reduced.pdf).
|
||||
if (cidToGidMap) {
|
||||
for (const charCode in map) {
|
||||
const cid = map[charCode];
|
||||
if (cidToGidMap[cid] !== undefined) {
|
||||
map[+charCode] = cidToGidMap[cid];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
|
||||
if (!isIdentityUnicode) {
|
||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -370,6 +370,7 @@
|
||||
!annotation-squiggly-without-appearance.pdf
|
||||
!annotation-highlight.pdf
|
||||
!annotation-highlight-without-appearance.pdf
|
||||
!issue12418_reduced.pdf
|
||||
!annotation-freetext.pdf
|
||||
!annotation-line.pdf
|
||||
!annotation-square-circle.pdf
|
||||
|
135
test/pdfs/issue12418_reduced.pdf
Normal file
135
test/pdfs/issue12418_reduced.pdf
Normal file
File diff suppressed because one or more lines are too long
@ -1440,6 +1440,12 @@
|
||||
"rounds": 1,
|
||||
"type": "eq"
|
||||
},
|
||||
{ "id": "issue12418",
|
||||
"file": "pdfs/issue12418_reduced.pdf",
|
||||
"md5": "596b70f00a5f88ff58f4f4d06fcf75f1",
|
||||
"rounds": 1,
|
||||
"type": "eq"
|
||||
},
|
||||
{ "id": "issue6692",
|
||||
"file": "pdfs/issue6692.pdf",
|
||||
"md5": "ba078e0ddd59cda4b6c51ea10599f49a",
|
||||
|
Loading…
x
Reference in New Issue
Block a user