mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Use a limit, in more places, when splitting strings
This should be a *tiny* bit more efficient, since it avoids parsing substrings that we don't care about. *Please note:* I cannot find an ESLint rule to enforce this automatically.
This commit is contained in:
parent
af4d2fa53c
commit
363dce6744
6 changed files with 8 additions and 8 deletions
|
@ -3955,7 +3955,7 @@ class PartialEvaluator {
|
|||
|
||||
isSerifFont(baseFontName) {
|
||||
// Simulating descriptor flags attribute
|
||||
const fontNameWoStyle = baseFontName.split("-")[0];
|
||||
const fontNameWoStyle = baseFontName.split("-", 1)[0];
|
||||
return (
|
||||
fontNameWoStyle in getSerifFonts() || /serif/gi.test(fontNameWoStyle)
|
||||
);
|
||||
|
@ -4185,7 +4185,7 @@ class PartialEvaluator {
|
|||
const metrics = this.getBaseFontMetrics(baseFontName);
|
||||
|
||||
// Simulating descriptor flags attribute
|
||||
const fontNameWoStyle = baseFontName.split("-")[0];
|
||||
const fontNameWoStyle = baseFontName.split("-", 1)[0];
|
||||
const flags =
|
||||
(this.isSerifFont(fontNameWoStyle) ? FontFlags.Serif : 0) |
|
||||
(metrics.monospace ? FontFlags.FixedPitch : 0) |
|
||||
|
|
|
@ -968,7 +968,7 @@ 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("-")[0],
|
||||
const baseName = name.replaceAll(/[,_]/g, "-").split("-", 1)[0],
|
||||
serifFonts = getSerifFonts();
|
||||
for (const namePart of baseName.split("+")) {
|
||||
if (serifFonts[namePart]) {
|
||||
|
@ -1286,7 +1286,7 @@ class Font {
|
|||
}
|
||||
|
||||
amendFallbackToUnicode(properties);
|
||||
this.loadedName = fontName.split("-")[0];
|
||||
this.loadedName = fontName.split("-", 1)[0];
|
||||
}
|
||||
|
||||
checkAndRepair(name, font, properties) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue