mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 10:08:06 +02:00
Use the cidToGidMap
, if it exists, when building the glyph mapping for non-embedded composite fonts (issue 12418)
This commit is contained in:
parent
6728c8fa61
commit
bd3b15b897
4 changed files with 157 additions and 4 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue