mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +02:00
Reduce code-duplication when caching data in CompiledFont.getPathJs
This commit is contained in:
parent
234067e745
commit
85ff8f34e2
1 changed files with 10 additions and 13 deletions
|
@ -780,25 +780,22 @@ class CompiledFont {
|
||||||
|
|
||||||
getPathJs(unicode) {
|
getPathJs(unicode) {
|
||||||
const { charCode, glyphId } = lookupCmap(this.cmap, unicode);
|
const { charCode, glyphId } = lookupCmap(this.cmap, unicode);
|
||||||
let fn = this.compiledGlyphs[glyphId];
|
let fn = this.compiledGlyphs[glyphId],
|
||||||
|
compileEx;
|
||||||
if (!fn) {
|
if (!fn) {
|
||||||
try {
|
try {
|
||||||
fn = this.compiledGlyphs[glyphId] = this.compileGlyph(
|
fn = this.compileGlyph(this.glyphs[glyphId], glyphId);
|
||||||
this.glyphs[glyphId],
|
|
||||||
glyphId
|
|
||||||
);
|
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
// Avoid attempting to re-compile a corrupt glyph.
|
fn = NOOP; // Avoid attempting to re-compile a corrupt glyph.
|
||||||
this.compiledGlyphs[glyphId] = NOOP;
|
|
||||||
|
|
||||||
if (this.compiledCharCodeToGlyphId[charCode] === undefined) {
|
compileEx = ex;
|
||||||
this.compiledCharCodeToGlyphId[charCode] = glyphId;
|
|
||||||
}
|
}
|
||||||
throw ex;
|
this.compiledGlyphs[glyphId] = fn;
|
||||||
}
|
}
|
||||||
}
|
this.compiledCharCodeToGlyphId[charCode] ??= glyphId;
|
||||||
if (this.compiledCharCodeToGlyphId[charCode] === undefined) {
|
|
||||||
this.compiledCharCodeToGlyphId[charCode] = glyphId;
|
if (compileEx) {
|
||||||
|
throw compileEx;
|
||||||
}
|
}
|
||||||
return fn;
|
return fn;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue