@react-native-gpui /字体
在桌面应用程序运行时加载自定义字体。
的一部分 react-native-gpui, macOS, Windows和Linux的React Native。
安装
npm install @react-native-gpui/fonts
使用
import { loadAsync } from '@react-native-gpui/fonts';
await loadAsync({
Inter: require('./assets/fonts/Inter.ttf'),
'Inter-Bold': require('./assets/fonts/Inter-Bold.ttf'),
});
<Text style={{ fontFamily: 'Inter-Bold' }}>Hello</Text>;
| 函数 | 描述 |
|---|---|
loadAsync(fonts) | 加载几种字体。解析何时全部注册。 |
loadFont(family, source) | 加载一种字体。 source 是一个 require 结果或路径字符串。 |
字体在应用程序的 desktop/assets/fonts 文件夹自动捆绑,不需要代码。
文档
许可证
麻省理工学院。看到 许可证.