Merge pull request #18018 from Snuffleupagus/CompiledFont-tweak-caching
Reduce code-duplication when caching data in `CompiledFont.getPathJs`
This commit is contained in:
commit
2b2ade7883
@ -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;
|
||||||
}
|
}
|
||||||
if (this.compiledCharCodeToGlyphId[charCode] === undefined) {
|
this.compiledCharCodeToGlyphId[charCode] ??= glyphId;
|
||||||
this.compiledCharCodeToGlyphId[charCode] = glyphId;
|
|
||||||
|
if (compileEx) {
|
||||||
|
throw compileEx;
|
||||||
}
|
}
|
||||||
return fn;
|
return fn;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user