expo-font
@amazon-devices/expo-font
provides an interface to load fonts at runtime and use them in React Native components.
Installation
- Add the JavaScript library dependency in the
package.json
file.dependencies: { ... "@amazon-devices/keplerscript-turbomodule-api": "~1.0.0", "@amazon-devices/expo-asset": "~2.0.0", "@amazon-devices/expo-constants": "~2.0.0", "@amazon-devices/expo-font": "~2.0.0", "expo": "~50.0.0", ... }
- Reinstall dependencies using
npm install
command.
Examples
The example below demonstrates how to load fonts with the useFonts
hook. You need to download the .otf file and replace the content inside the useFonts
call.
import {useFonts} from '@amazon-devices/expo-font';
import React from 'react';
import {StyleSheet, Text, View} from 'react-native';
export const App = () => {
const [fontsLoaded] = useFonts({
'Inter-Black': require('./assets/fonts/Inter-Black.otf'),
});
if (!fontsLoaded) {
return null;
}
return (
<View style={styles.container}>
<Text style={[styles.text, {fontFamily: 'Inter-Black'}]}>
Inter Black
</Text>
<Text style={styles.text}>Platform Default</Text>
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
padding: 20,
backgroundColor: 'white',
},
text: {
fontSize: 30,
color: 'black',
},
});
API reference
Check out the dedicated documentation page for info about this library, API reference and more: Official Expo documentation for expo-font.
Hooks
Hook | Description |
---|---|
useFonts |
Load a map of fonts with loadAsync . This returns a boolean if the fonts are loaded and ready to use |
Methods
Method | Description |
---|---|
isLoaded |
Synchronously detect if the font for fontFamily has finished loading |
isLoading |
Synchronously detect if the font for fontFamily is still being loaded |
loadAsync |
Highly efficient method for loading fonts from static or remote resources which can then be used with the platform's native text elements |
processFontFamily |
Used to transform font family names to the scoped name. This does not need to be called in standalone or bare apps but it will return unscoped font family names if it is called in those contexts |
unloadAllAsync |
Unloads all the custom fonts. This is used for testing |
unloadAsync |
Unload custom fonts matching the fontFamilys and display values provided |
Add custom fonts
In addition to modifying the standard Vega fonts in your app, you can load your own custom fonts.
To load custom fonts, place your font file in the assets/fonts/ directory.
Your font file name must match the font family name. For example, if the font family name is Open Sans, your font file name should be Open Sans.ttf.
Supported versions
Package Version | Based On | @amazon-devices/react-native-kepler version |
---|---|---|
2.0.x | 11.8.0 | 2.0.x |
Additional resources
For information on additional libraries, see Supported Third-Party Libraries and Services.
Last updated: Sep 30, 2025