Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/core/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -3855,6 +3855,7 @@ class PartialEvaluator {
loadedName: baseDict.loadedName,
widths: metrics.widths,
defaultWidth: metrics.defaultWidth,
isSimulatedFlags: true,
flags,
firstChar,
lastChar,
Expand Down
17 changes: 16 additions & 1 deletion src/core/fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
import {
getGlyphMapForStandardFonts,
getNonStdFontMap,
getSerifFonts,
getStdFontMap,
getSupplementalGlyphMapForArialBlack,
getSupplementalGlyphMapForCalibri,
Expand Down Expand Up @@ -872,7 +873,21 @@ class Font {
this._charsCache = Object.create(null);
this._glyphCache = Object.create(null);

this.isSerifFont = !!(properties.flags & FontFlags.Serif);
let isSerifFont = !!(properties.flags & FontFlags.Serif);
// 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.replace(/[,_]/g, "-").split("-")[0],
serifFonts = getSerifFonts();
for (const namePart of baseName.split("+")) {
if (serifFonts[namePart]) {
isSerifFont = true;
break;
}
}
}
this.isSerifFont = isSerifFont;

this.isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
this.isMonospace = !!(properties.flags & FontFlags.FixedPitch);

Expand Down
1 change: 1 addition & 0 deletions src/core/standard_fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ const getSerifFonts = getLookupTableFactory(function (t) {
t.Joanna = true;
t.Korinna = true;
t.Lexicon = true;
t.LiberationSerif = true;
t["Liberation Serif"] = true;
t["Linux Libertine"] = true;
t.Literaturnaya = true;
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/issue13845.pdf.link
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/mozilla/pdf.js/files/6916129/example.pdf
8 changes: 8 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,14 @@
"type": "eq",
"forms": true
},
{ "id": "issue13845",
"file": "pdfs/issue13845.pdf",
"md5": "7c6b675f61ae68a2e416f4aa26da567c",
"link": true,
"rounds": 1,
"lastPage": 1,
"type": "text"
},
{ "id": "xfa_bug1718521_1",
"file": "pdfs/xfa_bug1718521_1.pdf",
"md5": "9b89dd9e6a4c6c3258ca24debd806863",
Expand Down