1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Merge pull request #14064 from Snuffleupagus/issue-13845

Fallback to font name matching, when checking for serif fonts (issue 13845)
This commit is contained in:
Tim van der Meij 2021-09-25 12:41:57 +02:00 committed by GitHub
commit cc110b8542
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 1 deletions

View file

@ -3855,6 +3855,7 @@ class PartialEvaluator {
loadedName: baseDict.loadedName,
widths: metrics.widths,
defaultWidth: metrics.defaultWidth,
isSimulatedFlags: true,
flags,
firstChar,
lastChar,

View file

@ -45,6 +45,7 @@ import {
import {
getGlyphMapForStandardFonts,
getNonStdFontMap,
getSerifFonts,
getStdFontMap,
getSupplementalGlyphMapForArialBlack,
getSupplementalGlyphMapForCalibri,
@ -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);

View file

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