Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
expo-font
Advanced tools
Load fonts at runtime and use them in React Native components.
The expo-font package is a part of the Expo ecosystem and provides utilities for loading and using custom fonts in React Native applications. It simplifies the process of integrating custom fonts, ensuring they are loaded before the app renders.
Loading Custom Fonts
This feature allows you to load custom fonts asynchronously before the app renders. The AppLoading component is used to display a loading screen until the fonts are fully loaded.
import * as Font from 'expo-font';
import { AppLoading } from 'expo';
import React, { useState } from 'react';
import { Text, View } from 'react-native';
const loadFonts = () => {
return Font.loadAsync({
'custom-font': require('./assets/fonts/CustomFont.ttf'),
});
};
export default function App() {
const [fontsLoaded, setFontsLoaded] = useState(false);
if (!fontsLoaded) {
return (
<AppLoading
startAsync={loadFonts}
onFinish={() => setFontsLoaded(true)}
onError={console.warn}
/>
);
}
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text style={{ fontFamily: 'custom-font', fontSize: 20 }}>Hello, world!</Text>
</View>
);
}
Using Loaded Fonts
Once the fonts are loaded, you can use them in your components by specifying the fontFamily style property.
import React from 'react';
import { Text, View } from 'react-native';
export default function App() {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text style={{ fontFamily: 'custom-font', fontSize: 20 }}>Hello, world!</Text>
</View>
);
}
react-native-fonts is a package that provides similar functionality for loading and using custom fonts in React Native applications. It offers a straightforward API for font management but lacks the tight integration with the Expo ecosystem that expo-font provides.
react-native-custom-fonts is another package for managing custom fonts in React Native. It offers a more manual approach compared to expo-font, requiring additional setup steps and configuration.
Load fonts at runtime and use them in React Native components.
For managed Expo projects, please follow the installation instructions in the API documentation for the latest stable release.
For bare React Native projects, you must ensure that you have installed and configured the expo
package before continuing.
npx expo install expo-font
No additional set up necessary.
Run npx pod-install
after installing the npm package.
Contributions are very welcome! Please refer to guidelines described in the contributing guide.
FAQs
Load fonts at runtime and use them in React Native components.
The npm package expo-font receives a total of 531,384 weekly downloads. As such, expo-font popularity was classified as popular.
We found that expo-font demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 32 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.