Use the cidToGidMap, if it exists, when building the glyph mapping for non-embedded composite fonts (issue 12418)

This commit is contained in:
Jonas Jenwald 2020-09-28 14:39:48 +02:00
parent 6728c8fa61
commit bd3b15b897
4 changed files with 157 additions and 4 deletions

View File

@ -622,7 +622,7 @@ var Font = (function FontClosure() {
// attempting to recover by assuming that no file exists. // attempting to recover by assuming that no file exists.
warn('Font file is empty in "' + name + '" (' + this.loadedName + ")"); warn('Font file is empty in "' + name + '" (' + this.loadedName + ")");
} }
this.fallbackToSystemFont(); this.fallbackToSystemFont(properties);
return; return;
} }
@ -679,7 +679,7 @@ var Font = (function FontClosure() {
} }
} catch (e) { } catch (e) {
warn(e); warn(e);
this.fallbackToSystemFont(); this.fallbackToSystemFont(properties);
return; return;
} }
@ -1308,7 +1308,7 @@ var Font = (function FontClosure() {
return data; return data;
}, },
fallbackToSystemFont: function Font_fallbackToSystemFont() { fallbackToSystemFont(properties) {
this.missingFile = true; this.missingFile = true;
// The file data is not specified. Trying to fix the font name // The file data is not specified. Trying to fix the font name
// to be used with the canvas.font. // to be used with the canvas.font.
@ -1339,7 +1339,8 @@ var Font = (function FontClosure() {
type === "CIDFontType2" && type === "CIDFontType2" &&
this.cidEncoding.startsWith("Identity-") this.cidEncoding.startsWith("Identity-")
) { ) {
const GlyphMapForStandardFonts = getGlyphMapForStandardFonts(); const GlyphMapForStandardFonts = getGlyphMapForStandardFonts(),
cidToGidMap = properties.cidToGidMap;
// 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.
const map = []; const map = [];
@ -1357,6 +1358,16 @@ var Font = (function FontClosure() {
map[+charCode] = SupplementalGlyphMapForCalibri[charCode]; 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; var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
if (!isIdentityUnicode) { if (!isIdentityUnicode) {

View File

@ -370,6 +370,7 @@
!annotation-squiggly-without-appearance.pdf !annotation-squiggly-without-appearance.pdf
!annotation-highlight.pdf !annotation-highlight.pdf
!annotation-highlight-without-appearance.pdf !annotation-highlight-without-appearance.pdf
!issue12418_reduced.pdf
!annotation-freetext.pdf !annotation-freetext.pdf
!annotation-line.pdf !annotation-line.pdf
!annotation-square-circle.pdf !annotation-square-circle.pdf

File diff suppressed because one or more lines are too long

View File

@ -1440,6 +1440,12 @@
"rounds": 1, "rounds": 1,
"type": "eq" "type": "eq"
}, },
{ "id": "issue12418",
"file": "pdfs/issue12418_reduced.pdf",
"md5": "596b70f00a5f88ff58f4f4d06fcf75f1",
"rounds": 1,
"type": "eq"
},
{ "id": "issue6692", { "id": "issue6692",
"file": "pdfs/issue6692.pdf", "file": "pdfs/issue6692.pdf",
"md5": "ba078e0ddd59cda4b6c51ea10599f49a", "md5": "ba078e0ddd59cda4b6c51ea10599f49a",