mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 17:48:07 +02:00
Merge pull request #11515 from Snuffleupagus/cache-fallback-font
Cache the fallback font dictionary on the `PartialEvaluator` (PR 11218 follow-up)
This commit is contained in:
commit
cbbda9d883
3 changed files with 34 additions and 10 deletions
|
@ -935,11 +935,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||
|
||||
// Falling back to a default font to avoid completely broken rendering,
|
||||
// but note that there're no guarantees that things will look "correct".
|
||||
fontRef = new Dict();
|
||||
fontRef.set("BaseFont", Name.get("PDFJS-FallbackFont"));
|
||||
fontRef.set("Type", Name.get("FallbackType"));
|
||||
fontRef.set("Subtype", Name.get("FallbackType"));
|
||||
fontRef.set("Encoding", Name.get("WinAnsiEncoding"));
|
||||
fontRef = PartialEvaluator.getFallbackFontDict();
|
||||
}
|
||||
|
||||
if (this.fontCache.has(fontRef)) {
|
||||
|
@ -3132,6 +3128,21 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||
}
|
||||
};
|
||||
|
||||
// TODO: Change this to a `static` getter, using shadowing, once
|
||||
// `PartialEvaluator` is converted to a proper class.
|
||||
PartialEvaluator.getFallbackFontDict = function() {
|
||||
if (this._fallbackFontDict) {
|
||||
return this._fallbackFontDict;
|
||||
}
|
||||
const dict = new Dict();
|
||||
dict.set("BaseFont", Name.get("PDFJS-FallbackFont"));
|
||||
dict.set("Type", Name.get("FallbackType"));
|
||||
dict.set("Subtype", Name.get("FallbackType"));
|
||||
dict.set("Encoding", Name.get("WinAnsiEncoding"));
|
||||
|
||||
return (this._fallbackFontDict = dict);
|
||||
};
|
||||
|
||||
return PartialEvaluator;
|
||||
})();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue