Skip to content

AI-native design editor. Open-source Figma alternative.

fix(text): bundle Inter ExtraBold font

Danila Poyarkov1ffc61cf5008
diff --git a/packages/core/assets/Inter-ExtraBold.ttf b/packages/core/assets/Inter-ExtraBold.ttf
new file mode 100644
index 000000000..8a9a1bcb9
Binary files /dev/null and b/packages/core/assets/Inter-ExtraBold.ttf differ
diff --git a/packages/core/src/text/fonts.ts b/packages/core/src/text/fonts.ts
index 9ba767c5a..0f83e8547 100644
--- a/packages/core/src/text/fonts.ts
+++ b/packages/core/src/text/fonts.ts
@@ -61,6 +61,7 @@ const BUNDLED_FONTS: Record<string, string> = {
'Inter|Medium': '/Inter-Medium.ttf',
'Inter|SemiBold': '/Inter-SemiBold.ttf',
'Inter|Bold': '/Inter-Bold.ttf',
+ 'Inter|ExtraBold': '/Inter-ExtraBold.ttf',
'Noto Naskh Arabic|Regular': '/NotoNaskhArabic-Regular.ttf'
}
@@ -236,6 +237,16 @@ export class FontManager {
const localBuffer = await this.findLocalFont(family, style)
if (localBuffer) return this.registerAndCache(family, style, localBuffer)
+ const bundledUrl = BUNDLED_FONTS[cacheKey]
+ if (bundledUrl) {
+ try {
+ const buffer = await this.fetchBundledFont(bundledUrl)
+ if (buffer && !isVariableFont(buffer)) return this.registerAndCache(family, style, buffer)
+ } catch (e) {
+ console.warn(`Bundled font load failed for "${family}" ${style}:`, e)
+ }
+ }
+
if (typeof fetch !== 'undefined') {
try {
const buffer = await this.fetchGoogleFont(family, style)
@@ -248,16 +259,6 @@ export class FontManager {
}
}
- const bundledUrl = BUNDLED_FONTS[cacheKey]
- if (bundledUrl) {
- try {
- const buffer = await this.fetchBundledFont(bundledUrl)
- if (buffer && !isVariableFont(buffer)) return this.registerAndCache(family, style, buffer)
- } catch (e) {
- console.warn(`Bundled font load failed for "${family}" ${style}:`, e)
- }
- }
-
return null
}
diff --git a/public/Inter-ExtraBold.ttf b/public/Inter-ExtraBold.ttf
new file mode 100644
index 000000000..8a9a1bcb9
Binary files /dev/null and b/public/Inter-ExtraBold.ttf differ
diff --git a/tests/engine/text/fonts/loading.test.ts b/tests/engine/text/fonts/loading.test.ts
index 65c359d6a..7d8cf6137 100644
--- a/tests/engine/text/fonts/loading.test.ts
+++ b/tests/engine/text/fonts/loading.test.ts
@@ -184,6 +184,25 @@ describe('FontManager loaded font cache', () => {
expect(recording.registrations).toEqual([{ family: 'DownloadedCache', byteLength: 16 }])
expect(writes).toBe(0)
})
+
+ test('loads bundled Inter ExtraBold without network access', async () => {
+ const manager = new FontManager()
+ const recording = createRecordingProvider()
+ const originalFetch = globalThis.fetch
+ globalThis.fetch = (() => {
+ throw new Error('network disabled')
+ }) as typeof fetch
+
+ try {
+ manager.attachProvider({} as CanvasKit, recording.provider)
+ const data = await manager.loadFont('Inter', 'ExtraBold')
+
+ expect(data?.byteLength).toBeGreaterThan(0)
+ expect(recording.registrations).toEqual([{ family: 'Inter', byteLength: data?.byteLength }])
+ } finally {
+ globalThis.fetch = originalFetch
+ }
+ })
})
describe('collectFontKeys', () => {