Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/core/text-rendering/font-face-types/WebTrFontFace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class WebTrFontFace extends TrFontFace {
const determinedDescriptors = this.descriptors;

// Convert TrFontFaceDescriptors to CSS FontFaceDescriptors
const cssDescriptors: FontFaceDescriptors = {
let cssDescriptors: FontFaceDescriptors = {
style: determinedDescriptors.style,
weight:
typeof determinedDescriptors.weight === 'number'
Expand All @@ -61,6 +61,13 @@ export class WebTrFontFace extends TrFontFace {
display: determinedDescriptors.display,
};

for (const k in cssDescriptors) {
const key = k as keyof FontFaceDescriptors;
if (cssDescriptors[key] === undefined) {
delete cssDescriptors[key];
}
}

const fontFace = new FontFace(
fontFamily,
`url(${fontUrlWithoutParentheses})`,
Expand All @@ -71,14 +78,12 @@ export class WebTrFontFace extends TrFontFace {
fontFace
.load()
.then(() => {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
(this.loaded as boolean) = true;
this.emit('loaded');
})
.catch(console.error);
} else {
// Default font
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
(this.loaded as boolean) = true;
this.emit('loaded');
}
Expand Down
Loading