Skip to content

Commit 2ce2453

Browse files
committed
Improve missing font fallback families
1 parent f1db713 commit 2ce2453

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/core/fonts.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,15 +1125,18 @@ class Font {
11251125

11261126
let isSerifFont = !!(properties.flags & FontFlags.Serif);
11271127
// Fallback to checking the font name, in order to improve text-selection,
1128-
// since the /Flags-entry is often wrong (fixes issue13845.pdf).
1129-
if (!isSerifFont && !properties.isSimulatedFlags) {
1128+
// since the /Flags-entry is often wrong (fixes issue13845.pdf). When the
1129+
// font file is missing, the family also affects canvas fallback rendering.
1130+
if (!isSerifFont && (!properties.isSimulatedFlags || !file)) {
11301131
const stdFontMap = getStdFontMap(),
11311132
nonStdFontMap = getNonStdFontMap(),
11321133
serifFonts = getSerifFonts();
11331134
for (const namePart of name.split("+")) {
11341135
let fontName = normalizeFontName(namePart);
11351136
fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
11361137
fontName = fontName.split("-", 1)[0];
1138+
// TeX fonts commonly append the design size, e.g. CMR8.
1139+
fontName = fontName.replace(/\d+$/, "");
11371140
if (serifFonts[fontName]) {
11381141
isSerifFont = true;
11391142
break;

src/core/standard_fonts.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,11 @@ const getSerifFonts = getLookupTableFactory(function (t) {
218218
t.Clearface = true;
219219
t.Cochin = true;
220220
t.Colonna = true;
221+
t.CMBX = true;
222+
t.CMMI = true;
223+
t.CMR = true;
224+
t.CMSL = true;
225+
t.CMTI = true;
221226
t["Computer Modern"] = true;
222227
t["Concrete Roman"] = true;
223228
t.Constantia = true;
@@ -271,6 +276,7 @@ const getSerifFonts = getLookupTableFactory(function (t) {
271276
t["Museo Slab"] = true;
272277
t["New York"] = true;
273278
t["Nimbus Roman"] = true;
279+
t.NimbusRomNo9L = true;
274280
t["NPS Rawlinson Roadway"] = true;
275281
t.NuptialScript = true;
276282
t.Palatino = true;

0 commit comments

Comments
 (0)