Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renderer - Draw text if a font can't be loaded #12711

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/display/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -1592,10 +1592,10 @@ const CanvasGraphics = (function CanvasGraphicsClosure() {

let addToPath;
if (font.disableFontFace || isAddToPathSet || patternFill) {
addToPath = font.getPathGenerator(this.commonObjs, character);
addToPath = font.tryGetPathGenerator(this.commonObjs, character);
}

if (font.disableFontFace || patternFill) {
if (addToPath && (font.disableFontFace || patternFill)) {
ctx.save();
ctx.translate(x, y);
ctx.beginPath();
Expand Down
8 changes: 3 additions & 5 deletions src/display/font_loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ class FontFaceObject {
return rule;
}

getPathGenerator(objs, character) {
tryGetPathGenerator(objs, character) {
if (this.compiledGlyphs[character] !== undefined) {
return this.compiledGlyphs[character];
}
Expand All @@ -410,11 +410,9 @@ class FontFaceObject {
featureId: UNSUPPORTED_FEATURES.errorFontGetPath,
});
}
warn(`getPathGenerator - ignoring character: "${ex}".`);
warn(`tryGetPathGenerator - ignoring character: "${ex}".`);

return (this.compiledGlyphs[character] = function (c, size) {
// No-op function, to allow rendering to continue.
});
return (this.compiledGlyphs[character] = null);
}

// If we can, compile cmds into JS for MAXIMUM SPEED...
Expand Down