Extract some of the glyphMap handling, for non-embedded composite standard fonts, into a helper function
This reduces some unnecessary duplication, since we currently have essentially the same code in a handful of places in the `Font.fallbackToSystemFont`-method.
This commit is contained in:
parent
ed73cf6d50
commit
e3223b68fc
@ -376,6 +376,12 @@ function getFontFileType(file, { type, subtype, composite }) {
|
|||||||
return [fileType, fileSubtype];
|
return [fileType, fileSubtype];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function applyStandardFontGlyphMap(map, glyphMap) {
|
||||||
|
for (const charCode in glyphMap) {
|
||||||
|
map[+charCode] = glyphMap[charCode];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function buildToFontChar(encoding, glyphsUnicodeMap, differences) {
|
function buildToFontChar(encoding, glyphsUnicodeMap, differences) {
|
||||||
const toFontChar = [];
|
const toFontChar = [];
|
||||||
let unicode;
|
let unicode;
|
||||||
@ -1052,26 +1058,16 @@ class Font {
|
|||||||
type === "CIDFontType2" &&
|
type === "CIDFontType2" &&
|
||||||
this.cidEncoding.startsWith("Identity-")
|
this.cidEncoding.startsWith("Identity-")
|
||||||
) {
|
) {
|
||||||
const GlyphMapForStandardFonts = getGlyphMapForStandardFonts(),
|
const cidToGidMap = properties.cidToGidMap;
|
||||||
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 = [];
|
||||||
for (const charCode in GlyphMapForStandardFonts) {
|
applyStandardFontGlyphMap(map, getGlyphMapForStandardFonts());
|
||||||
map[+charCode] = GlyphMapForStandardFonts[charCode];
|
|
||||||
}
|
|
||||||
if (/Arial-?Black/i.test(name)) {
|
if (/Arial-?Black/i.test(name)) {
|
||||||
const SupplementalGlyphMapForArialBlack =
|
applyStandardFontGlyphMap(map, getSupplementalGlyphMapForArialBlack());
|
||||||
getSupplementalGlyphMapForArialBlack();
|
|
||||||
for (const charCode in SupplementalGlyphMapForArialBlack) {
|
|
||||||
map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
|
|
||||||
}
|
|
||||||
} else if (/Calibri/i.test(name)) {
|
} else if (/Calibri/i.test(name)) {
|
||||||
const SupplementalGlyphMapForCalibri =
|
applyStandardFontGlyphMap(map, getSupplementalGlyphMapForCalibri());
|
||||||
getSupplementalGlyphMapForCalibri();
|
|
||||||
for (const charCode in SupplementalGlyphMapForCalibri) {
|
|
||||||
map[+charCode] = SupplementalGlyphMapForCalibri[charCode];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always update the glyph mapping with the `cidToGidMap` when it exists
|
// Always update the glyph mapping with the `cidToGidMap` when it exists
|
||||||
@ -1158,10 +1154,7 @@ class Font {
|
|||||||
if (this.composite && this.toUnicode instanceof IdentityToUnicodeMap) {
|
if (this.composite && this.toUnicode instanceof IdentityToUnicodeMap) {
|
||||||
if (/Verdana/i.test(name)) {
|
if (/Verdana/i.test(name)) {
|
||||||
// Fixes issue11242_reduced.pdf
|
// Fixes issue11242_reduced.pdf
|
||||||
const GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
|
applyStandardFontGlyphMap(map, getGlyphMapForStandardFonts());
|
||||||
for (const charCode in GlyphMapForStandardFonts) {
|
|
||||||
map[+charCode] = GlyphMapForStandardFonts[charCode];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.toFontChar = map;
|
this.toFontChar = map;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user