@keel-ai/font
v0.1.0
Published
Custom font registration at runtime for Keel.
Readme
@keel-ai/font
Register custom fonts at runtime — load a
.ttf/.otffrom a file path or download from a URL and make it usable in<Text style={{ fontFamily: ... }}>. Counterpart ofexpo-font.
Install
keel install @keel-ai/font @keel-ai/asset@keel-ai/asset is used to download remote font files before registration.
Usage
import { loadAsync } from '@keel-ai/font';
import { downloadAsync } from '@keel-ai/asset';
// Local file (e.g. bundled with the app).
await loadAsync({
'NotoSansSC-Bold': '/absolute/path/to/NotoSansSC-Bold.ttf',
});
// Remote — download first, then register.
const cached = await downloadAsync('https://cdn.example.com/font.ttf');
await loadAsync({ 'CustomFont': cached.localUri });
// Use in <Text>:
<Text style={{ fontFamily: 'NotoSansSC-Bold' }}>你好</Text>Platform mapping
| API | iOS | Android |
|---|---|---|
| loadAsync() | CTFontManagerRegisterFontsForURL (system-level registration) | ReactFontManager.setTypeface() (RN's font registry) |
