All fonts used by web, desktop and native apps are located inside assets/fonts/
folder. The native app will use fonts with .otf
or .ttf
formats, where the web app will use fonts with .otf
, .ttf
, .woff
or .woff2
formats.
The font files used by the native apps are stored inside assets/fonts/native/
folder. We use the @react-native-community/cli-link-assets tool to link the fonts to each platform (Android and iOS).
To add or remove a font used in the native app:
- Add or remove the desired font files inside
assets/fonts/native/
folder. - Run
npx @react-native-community/cli-link-assets
to link the assets with the native files.- On Android, native files like
MainApplication.kt
and font files will be synced with the updated fonts. - On iOS, native files like
project.pbxproj
andInfo.plist
will be synced with the updated fonts.
- On Android, native files like
- If you are adding a new font family into the project:
- Add all the new font family variants to the FontFamilyKey type.
type FontFamilyKey = | 'SYSTEM' | 'MONOSPACE' | 'MONOSPACE_BOLD' | 'EXP_NEUE' | 'EXP_NEUE_BOLD' | 'EXP_NEUE_ITALIC' | 'EXP_NEUE_BOLD_ITALIC' | 'EXP_NEW_KANSAS_MEDIUM' | 'EXP_NEW_KANSAS_MEDIUM_ITALIC' | 'NEW_FONT_FAMILY' // Add it here. | 'NEW_FONT_FAMILY_BOLD' // Add it here (it it exists). | 'NEW_FONT_FAMILY_ITALIC' // Add it here (it it exists). | 'NEW_FONT_FAMILY_BOLD_ITALIC'; // Add it here (it it exists).
- Add all the font variants to the singleFontFamily file, replacing
<new_font_family>
with the font family name (you can find the name insideMainApplication.kt
file).const fontFamily: FontFamilyStyles = { ... NEW_FONT_FAMILY: { fontFamily: '<new_font_family>', fontStyle: 'normal', fontWeight: fontWeight.normal, }, // Add the other variants too. };
- Add all the new font family variants to the FontFamilyKey type.
- If you are removing a font family from the project:
- Remove all the font family variants from the FontFamilyKey type.
- Remove all the font family variants from the singleFontFamily file.
The font files used by the web / desktop apps are stored inside assets/fonts/web/
folder.
To add or remove a font used in the web / desktop app:
- Add or remove the desired font files inside
assets/fonts/web/
folder. - If you are adding a new font family into the project:
- Add all the new font family variants to the FontFamilyKey type.
- Add all the font variants to the multiFontFamily file, replacing
<new_font_family>
with the font family name.const fontFamily: FontFamilyStyles = { ... NEW_FONT_FAMILY: { fontFamily: '<new_font_family>, Segoe UI Emoji, Noto Color Emoji', fontStyle: 'normal', fontWeight: fontWeight.normal, }, // Add the other variants too. };
- Add all the new font family variants to the fonts.css file, replacing
<new_font_family>
with the font family name and<font-family-file>
with the file name.@font-face { font-family: <new_font_family>; font-weight: 500; font-style: normal; src: url('/fonts/<font-family-file>.woff2') format('woff2'), url('/fonts/<font-family-file>.woff') format('woff'); } /* Add the other variants too. */
- If you are removing a font family from the project:
- Remove all the font family variants from the FontFamilyKey type.
- Remove all the font family variants from the multiFontFamily file.
- Remove all the font family variants from the fonts.css file.
The font files used by the Storybook web app are stored inside assets/fonts/web/
folder.
To add or remove a font used in the storybook web app:
- Add or remove the desired font files inside
assets/fonts/web/
folder. - If you are adding a new font family into the project:
- Add all the new font family variants to the fonts.css storybook file, replacing
<new_font_family>
with the font family name and<font-family-file>
with the file name.@font-face { font-family: <new_font_family>; font-weight: 500; font-style: normal; src: url('../assets/fonts/web/<font-family-file>.woff2') format('woff2'), url('../assets/fonts/web/<font-family-file>.woff') format('woff'); } /* Add the other variants too. */
- Add all the new font family variants to the fonts.css storybook file, replacing
- If you are removing a font family from the project:
- Remove all the font family variants from the fonts.css storybook file.
The fonts files used by the Expensify Help web app are located inside docs/assets/fonts/
folder.
To add or remove a font used in the Expensify Help web app:
- Add or remove the desired font files inside
docs/assets/fonts/
folder. - If you are adding a new font family into the project:
- Add all the new font family variants to the _fonts.scss file, replacing
<new_font_family>
with the font family name and<font-family-file>
with the file name.@font-face { font-family: <new_font_family>; font-weight: 500; font-style: normal; src: url('/assets/fonts/<font-family-file>.woff2') format('woff2'), url('/assets/fonts/<font-family-file>.woff') format('woff'); } /* Add the other variants too. */
- Add all the new font family variants to the _fonts.scss file, replacing
- If you are removing a font family from the project:
- Remove all the font family variants from the _fonts.scss file.
To use your fonts in the app, just import the desired font from FontUtils and use in your style objects.
You should use FontUtils.fontFamily.platform.<font-family-key>
for most use cases in the app because it will use the correspondent set of font families (with fallback fonts or not) according to the platform. FontUtils.fontFamily.single.
and FontUtils.fontFamily.multi.
should only be used when we want a specific set of font families independently of the platform.
import FontUtils from '@styles/utils/FontUtils';
const style = {
h4: {
...FontUtils.fontFamily.platform.NEW_FONT_FAMILY,
fontSize: variables.fontSizeLabel,
},
};
To use your fonts in Storybook and Expensify Help, simply apply and use them as you would with regular web files.