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 1 commit
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
12 changes: 5 additions & 7 deletions src/display/font_loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ class FontFaceObject {
fontRegistry = null,
}
) {
this.compiledGlyphs = Object.create(null);
timvandermeij marked this conversation as resolved.
Show resolved Hide resolved
this.compiledGlyphs = {};
// importing translated data
for (const i in translatedData) {
this[i] = translatedData[i];
Expand Down Expand Up @@ -393,8 +393,8 @@ class FontFaceObject {
return rule;
}

getPathGenerator(objs, character) {
if (this.compiledGlyphs[character] !== undefined) {
tryGetPathGenerator(objs, character) {
if (this.compiledGlyphs.hasOwnProperty(character)) {
timvandermeij marked this conversation as resolved.
Show resolved Hide resolved
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] = undefined);
}

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