Skip to content

Commit ae8f8e4

Browse files
committed
Improve serif fallback font name matching
1 parent c386d9b commit ae8f8e4

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/core/fonts.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -989,10 +989,14 @@ class Font {
989989
// Fallback to checking the font name, in order to improve text-selection,
990990
// since the /Flags-entry is often wrong (fixes issue13845.pdf).
991991
if (!isSerifFont && !properties.isSimulatedFlags) {
992-
const baseName = name.replaceAll(/[,_]/g, "-").split("-", 1)[0],
992+
const stdFontMap = getStdFontMap(),
993+
nonStdFontMap = getNonStdFontMap(),
993994
serifFonts = getSerifFonts();
994-
for (const namePart of baseName.split("+")) {
995-
if (serifFonts[namePart]) {
995+
for (const namePart of name.split("+")) {
996+
let fontName = namePart.replaceAll(/[,_]/g, "-");
997+
fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
998+
fontName = fontName.split("-", 1)[0];
999+
if (serifFonts[fontName]) {
9961000
isSerifFont = true;
9971001
break;
9981002
}

0 commit comments

Comments
 (0)