Merge pull request #16199 from Snuffleupagus/commonobj-FontInspector

Slightly reduce the size of the `FontInspector`-integration in the API
This commit is contained in:
Tim van der Meij 2023-03-25 15:27:01 +01:00 committed by GitHub
commit a1685fd0d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 13 deletions

View File

@ -2762,19 +2762,15 @@ class WorkerTransport {
break; break;
} }
let fontRegistry = null; const inspectFont =
if (params.pdfBug && globalThis.FontInspector?.enabled) { params.pdfBug && globalThis.FontInspector?.enabled
fontRegistry = { ? (font, url) => globalThis.FontInspector.fontAdded(font, url)
registerFont(font, url) { : null;
globalThis.FontInspector.fontAdded(font, url);
},
};
}
const font = new FontFaceObject(exportedData, { const font = new FontFaceObject(exportedData, {
isEvalSupported: params.isEvalSupported, isEvalSupported: params.isEvalSupported,
disableFontFace: params.disableFontFace, disableFontFace: params.disableFontFace,
ignoreErrors: params.ignoreErrors, ignoreErrors: params.ignoreErrors,
fontRegistry, inspectFont,
}); });
this.fontLoader this.fontLoader

View File

@ -322,7 +322,7 @@ class FontFaceObject {
isEvalSupported = true, isEvalSupported = true,
disableFontFace = false, disableFontFace = false,
ignoreErrors = false, ignoreErrors = false,
fontRegistry = null, inspectFont = null,
} }
) { ) {
this.compiledGlyphs = Object.create(null); this.compiledGlyphs = Object.create(null);
@ -333,7 +333,7 @@ class FontFaceObject {
this.isEvalSupported = isEvalSupported !== false; this.isEvalSupported = isEvalSupported !== false;
this.disableFontFace = disableFontFace === true; this.disableFontFace = disableFontFace === true;
this.ignoreErrors = ignoreErrors === true; this.ignoreErrors = ignoreErrors === true;
this.fontRegistry = fontRegistry; this._inspectFont = inspectFont;
} }
createNativeFontFace() { createNativeFontFace() {
@ -357,7 +357,7 @@ class FontFaceObject {
); );
} }
this.fontRegistry?.registerFont(this); this._inspectFont?.(this);
return nativeFontFace; return nativeFontFace;
} }
@ -379,7 +379,7 @@ class FontFaceObject {
rule = `@font-face {font-family:"${this.cssFontInfo.fontFamily}";${css}src:${url}}`; rule = `@font-face {font-family:"${this.cssFontInfo.fontFamily}";${css}src:${url}}`;
} }
this.fontRegistry?.registerFont(this, url); this._inspectFont?.(this, url);
return rule; return rule;
} }