Skip to content

Commit 44acabb

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

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-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 (let 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
}

test/pdfs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,7 @@
737737
!bug1708041.pdf
738738
!bug1978317.pdf
739739
!dates.pdf
740+
!issue13845_TimesNewRomanPSMT.pdf
740741
!dates_save.pdf
741742
!print_protection.pdf
742743
!tracemonkey_with_annotations.pdf
33.8 KB
Binary file not shown.

test/test_manifest.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8560,6 +8560,12 @@
85608560
"108R": {
85618561
"value": true
85628562
},
8563+
{ "id": "issue13845_TimesNewRomanPSMT",
8564+
"file": "pdfs/issue13845_TimesNewRomanPSMT.pdf",
8565+
"md5": "be3648879c0dfce8ce070f714e2cb075",
8566+
"rounds": 1,
8567+
"type": "eq"
8568+
},
85638569
"109R": {
85648570
"value": false
85658571
},

0 commit comments

Comments
 (0)