Fallback to font name matching, when checking for serif fonts (issue 13845)
In order to handle fonts that specify completely bogus /Flags-entries, fallback to font name matching to determine if the font is a serif one.
This commit is contained in:
parent
8dc22f40c7
commit
9acfe486d4
@ -3855,6 +3855,7 @@ class PartialEvaluator {
|
|||||||
loadedName: baseDict.loadedName,
|
loadedName: baseDict.loadedName,
|
||||||
widths: metrics.widths,
|
widths: metrics.widths,
|
||||||
defaultWidth: metrics.defaultWidth,
|
defaultWidth: metrics.defaultWidth,
|
||||||
|
isSimulatedFlags: true,
|
||||||
flags,
|
flags,
|
||||||
firstChar,
|
firstChar,
|
||||||
lastChar,
|
lastChar,
|
||||||
|
@ -45,6 +45,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
getGlyphMapForStandardFonts,
|
getGlyphMapForStandardFonts,
|
||||||
getNonStdFontMap,
|
getNonStdFontMap,
|
||||||
|
getSerifFonts,
|
||||||
getStdFontMap,
|
getStdFontMap,
|
||||||
getSupplementalGlyphMapForArialBlack,
|
getSupplementalGlyphMapForArialBlack,
|
||||||
getSupplementalGlyphMapForCalibri,
|
getSupplementalGlyphMapForCalibri,
|
||||||
@ -872,7 +873,21 @@ class Font {
|
|||||||
this._charsCache = Object.create(null);
|
this._charsCache = Object.create(null);
|
||||||
this._glyphCache = 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.isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
|
||||||
this.isMonospace = !!(properties.flags & FontFlags.FixedPitch);
|
this.isMonospace = !!(properties.flags & FontFlags.FixedPitch);
|
||||||
|
|
||||||
|
@ -243,6 +243,7 @@ const getSerifFonts = getLookupTableFactory(function (t) {
|
|||||||
t.Joanna = true;
|
t.Joanna = true;
|
||||||
t.Korinna = true;
|
t.Korinna = true;
|
||||||
t.Lexicon = true;
|
t.Lexicon = true;
|
||||||
|
t.LiberationSerif = true;
|
||||||
t["Liberation Serif"] = true;
|
t["Liberation Serif"] = true;
|
||||||
t["Linux Libertine"] = true;
|
t["Linux Libertine"] = true;
|
||||||
t.Literaturnaya = true;
|
t.Literaturnaya = true;
|
||||||
|
1
test/pdfs/issue13845.pdf.link
Normal file
1
test/pdfs/issue13845.pdf.link
Normal file
@ -0,0 +1 @@
|
|||||||
|
https://github.com/mozilla/pdf.js/files/6916129/example.pdf
|
@ -1084,6 +1084,14 @@
|
|||||||
"type": "eq",
|
"type": "eq",
|
||||||
"forms": true
|
"forms": true
|
||||||
},
|
},
|
||||||
|
{ "id": "issue13845",
|
||||||
|
"file": "pdfs/issue13845.pdf",
|
||||||
|
"md5": "7c6b675f61ae68a2e416f4aa26da567c",
|
||||||
|
"link": true,
|
||||||
|
"rounds": 1,
|
||||||
|
"lastPage": 1,
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
{ "id": "xfa_bug1718521_1",
|
{ "id": "xfa_bug1718521_1",
|
||||||
"file": "pdfs/xfa_bug1718521_1.pdf",
|
"file": "pdfs/xfa_bug1718521_1.pdf",
|
||||||
"md5": "9b89dd9e6a4c6c3258ca24debd806863",
|
"md5": "9b89dd9e6a4c6c3258ca24debd806863",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user