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
13 changes: 5 additions & 8 deletions src/core/text-rendering/SdfFontHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,14 +302,11 @@ export const loadFont = async (
const nwff: CoreTextNode[] = (nodesWaitingForFont[fontFamily] = []);
// Create loading promise
const loadPromise = (async (): Promise<void> => {
// Load font JSON data
const response = await fetch(atlasDataUrl);
if (!response.ok) {
throw new Error(`Failed to load font data: ${response.statusText}`);
}

const fontData = (await response.json()) as SdfFontData;
if (!fontData || !fontData.chars) {
// Load font JSON data via the platform's fetch abstraction so behaviour
// can be overridden per platform (XHR, Fetch API, custom loaders, etc.).
const blob = (await stage.platform.fetch(atlasDataUrl)) as Blob;
const fontData = JSON.parse(await blob.text()) as SdfFontData;
if (fontData === null || fontData.chars === undefined) {
throw new Error('Invalid SDF font data format');
}

Expand Down
Loading