feat: multiple fonts fallbacks (#8286)

This commit is contained in:
Marcel Mraz 2024-07-30 10:34:40 +02:00 committed by GitHub
parent d0a380758e
commit 230d0edc44
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 293 additions and 127 deletions

View file

@ -72,12 +72,14 @@ vi.mock(
...mod,
ExcalidrawFont: class extends ExcalidrawFontImpl {
public async getContent(): Promise<string> {
if (this.url.protocol !== "file:") {
const url = this.urls[0];
if (url.protocol !== "file:") {
return super.getContent();
}
// read local assets directly, without running a server
const content = await fs.promises.readFile(this.url);
const content = await fs.promises.readFile(url);
return `data:font/woff2;base64,${content.toString("base64")}`;
}
},