Merge pull request #20224 from james-atticus/improve-serif-fallback-font-name-matching

Improve serif fallback font name matching
This commit is contained in:
calixteman 2025-10-01 19:58:13 +02:00 committed by GitHub
commit 3234912c86
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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;
}