React Native · APIs and utilities
Fonts
The Inter font family, with only the weights added to the app.
Import
interFont
functionThe Inter font family, with only the weights added to the app. Details and setup: inter.
Examples
weightNumber
functionConverts a weight to a 100–900 number.
pickFontFile
functionPicks the file nearest to the requested weight (CSS rule: for 400 try 500 first, for 500 try 400 first; when bolder is requested try bolder first, when lighter try lighter first).
resolveFont
functionProduces a style from family, weight and slant. With an object family the right file's name becomes fontFamily and fontWeight is not set (Android would pick the wrong file or fake the bold).
INTER_WEIGHTS
constantInter weights shipped with the library.
INTER_ITALIC_WEIGHTS
constantInter italic weights.
inter
constantThe library's bundled font: Inter (SIL Open Font License 1.1). Designed for screens, with weights 100–900 and Latin, Turkish, Greek and Cyrillic characters. Since the same files are used on iOS and Android, text is drawn exactly the same on both platforms (the system fonts San Francisco and Roboto differ).
It goes into the app only when requested: add fonts: ["inter"] to ui.config.ts and run npx yasinsensoy-native sync (Android assets/fonts, the iOS Fonts folder and UIAppFonts). The default weights are 400, 500, 600 and 700; for other weights see interFont.
Examples
FontWeightName
typeWeight name (CSS 100–900 scale).
FontWeightInput
typeWeight: a name, a number (600) or the React Native form ("600", "bold").
FontFiles
typeA file per weight (the font's PostScript name = the file name).
Extends: Partial<Record<FontWeightName, string>>
| Name | Type | Description |
|---|---|---|
regular | string | File of the regular (400) weight; required. |
FontFamily
typeFont family.
- String (
"Inter"): a single name; the weight is picked withfontWeight. Works correctly only for fonts where the platform can find the weights in the family (the system font, files registered to one family on iOS). - Object: a separate file per weight. This is the way that gives exactly the same result on both platforms (Android cannot pick the weight from the family). A missing weight falls back to the nearest one. The library's bundled font:
inter.
Examples
FontStyle
interfaceResult of resolveFont: values to add to a Text style.
| Name | Type | Description |
|---|---|---|
fontFamily? | string | Font family name. |
fontWeight? | TextStyle["fontWeight"] | Font weight. |
fontStyle? | TextStyle["fontStyle"] | "italic" for italic. |
InterOptions
interfaceOptions of interFont; must match the ui.config fonts setting.
| Name | Type | Default | Description |
|---|---|---|---|
weights? | readonly number[] | [400, 500, 600, 700] | Weights added to the app. |
italic? | boolean | false | Whether italics were added (400–700). |