From ae8f8e4d34a73535eb3b2f7be03907e1eb1f16b1 Mon Sep 17 00:00:00 2001 From: James Fitzsimmons Date: Tue, 2 Sep 2025 13:12:50 +1000 Subject: [PATCH] Improve serif fallback font name matching --- src/core/fonts.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/core/fonts.js b/src/core/fonts.js index bfb9943c6..29797c5ea 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -989,10 +989,14 @@ class Font { // Fallback to checking the font name, in order to improve text-selection, // since the /Flags-entry is often wrong (fixes issue13845.pdf). if (!isSerifFont && !properties.isSimulatedFlags) { - const baseName = name.replaceAll(/[,_]/g, "-").split("-", 1)[0], + const stdFontMap = getStdFontMap(), + nonStdFontMap = getNonStdFontMap(), serifFonts = getSerifFonts(); - for (const namePart of baseName.split("+")) { - if (serifFonts[namePart]) { + for (const namePart of name.split("+")) { + let fontName = namePart.replaceAll(/[,_]/g, "-"); + fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName; + fontName = fontName.split("-", 1)[0]; + if (serifFonts[fontName]) { isSerifFont = true; break; }