From e72171d7eb21b444156b59eb99054e142405400b Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Thu, 17 Oct 2024 13:55:58 -0500 Subject: [PATCH] Split out fake fonts hook for platforms --- src/alf/fonts.ts | 27 +++----------------------- src/alf/util/unusedUseFonts.android.ts | 19 ++++++++++++++++++ src/alf/util/unusedUseFonts.ts | 15 ++++++++++++++ 3 files changed, 37 insertions(+), 24 deletions(-) create mode 100644 src/alf/util/unusedUseFonts.android.ts create mode 100644 src/alf/util/unusedUseFonts.ts diff --git a/src/alf/fonts.ts b/src/alf/fonts.ts index 97fe338e94..7869167212 100644 --- a/src/alf/fonts.ts +++ b/src/alf/fonts.ts @@ -1,5 +1,4 @@ import {TextStyle} from 'react-native' -import {useFonts} from 'expo-font' import {isAndroid, isWeb} from '#/platform/detection' import {Device, device} from '#/storage' @@ -96,27 +95,7 @@ export function applyFonts(style: TextStyle, fontFamily: 'system' | 'theme') { } } -/* - * IMPORTANT: This is unused. Expo statically extracts these fonts. - * - * All used fonts MUST be configured here. Unused fonts can be commented out. - * - * This is used for both web fonts and native fonts. +/** + * Here only for bundling purposes, not actually used. */ -export function DO_NOT_USE() { - return useFonts( - isAndroid - ? { - 'Inter-Regular': require('../../assets/fonts/inter/Inter-Regular.otf'), - 'Inter-Italic': require('../../assets/fonts/inter/Inter-Italic.otf'), - 'Inter-Bold': require('../../assets/fonts/inter/Inter-SemiBold.otf'), - 'Inter-BoldItalic': require('../../assets/fonts/inter/Inter-SemiBoldItalic.otf'), - 'Inter-Black': require('../../assets/fonts/inter/Inter-ExtraBold.otf'), - 'Inter-BlackItalic': require('../../assets/fonts/inter/Inter-ExtraBoldItalic.otf'), - } - : { - InterVariable: require('../../assets/fonts/inter/InterVariable.ttf'), - 'InterVariable-Italic': require('../../assets/fonts/inter/InterVariable-Italic.ttf'), - }, - ) -} +export {DO_NOT_USE} from '#/alf/util/unusedUseFonts' diff --git a/src/alf/util/unusedUseFonts.android.ts b/src/alf/util/unusedUseFonts.android.ts new file mode 100644 index 0000000000..083c9d4d65 --- /dev/null +++ b/src/alf/util/unusedUseFonts.android.ts @@ -0,0 +1,19 @@ +import {useFonts} from 'expo-font' + +/* + * IMPORTANT: This is unused. Expo statically extracts these fonts. + * + * All used fonts MUST be configured here. Unused fonts can be commented out. + * + * This is used for both web fonts and native fonts. + */ +export function DO_NOT_USE() { + return useFonts({ + 'Inter-Regular': require('../../../assets/fonts/inter/Inter-Regular.otf'), + 'Inter-Italic': require('../../../assets/fonts/inter/Inter-Italic.otf'), + 'Inter-Bold': require('../../../assets/fonts/inter/Inter-SemiBold.otf'), + 'Inter-BoldItalic': require('../../../assets/fonts/inter/Inter-SemiBoldItalic.otf'), + 'Inter-Black': require('../../../assets/fonts/inter/Inter-ExtraBold.otf'), + 'Inter-BlackItalic': require('../../../assets/fonts/inter/Inter-ExtraBoldItalic.otf'), + }) +} diff --git a/src/alf/util/unusedUseFonts.ts b/src/alf/util/unusedUseFonts.ts new file mode 100644 index 0000000000..70bdc285b5 --- /dev/null +++ b/src/alf/util/unusedUseFonts.ts @@ -0,0 +1,15 @@ +import {useFonts} from 'expo-font' + +/* + * IMPORTANT: This is unused. Expo statically extracts these fonts. + * + * All used fonts MUST be configured here. Unused fonts can be commented out. + * + * This is used for both web fonts and native fonts. + */ +export function DO_NOT_USE() { + return useFonts({ + InterVariable: require('../../../assets/fonts/inter/InterVariable.ttf'), + 'InterVariable-Italic': require('../../../assets/fonts/inter/InterVariable-Italic.ttf'), + }) +}