diff --git a/src/core/text-rendering/SdfFontHandler.ts b/src/core/text-rendering/SdfFontHandler.ts index 0d9103e3..70709d26 100644 --- a/src/core/text-rendering/SdfFontHandler.ts +++ b/src/core/text-rendering/SdfFontHandler.ts @@ -302,14 +302,11 @@ export const loadFont = async ( const nwff: CoreTextNode[] = (nodesWaitingForFont[fontFamily] = []); // Create loading promise const loadPromise = (async (): Promise => { - // 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'); }