Skip to content

Commit

Permalink
check and load font face for each text line
Browse files Browse the repository at this point in the history
  • Loading branch information
SeregPie committed Oct 12, 2020
1 parent 077696c commit e475e6f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ let Class = class extends AbstractDynamicTexture {

checkFontFace() {
try {
return document.fonts.check(this.font);
let {
font,
lines,
} = this;
return lines.every(text => document.fonts.check(font, text));
} catch {
// pass
}
Expand All @@ -70,7 +74,11 @@ let Class = class extends AbstractDynamicTexture {

async loadFontFace() {
try {
return await document.fonts.load(this.font);
let {
font,
lines,
} = this;
return await Promise.all(lines.map(text => document.fonts.load(font, text)));
} catch {
// pass
}
Expand Down

0 comments on commit e475e6f

Please sign in to comment.