Sanniv Khare 6 min read

Variable fonts in React Native 0.88: fontVariationSettings tested

Variable fonts in React Native 0.88: fontVariationSettings tested

React Native 0.88 adds a fontVariationSettings style to Text and TextInput. With it, one variable font file can stand in for the four to six static weights most apps bundle: you register the file once and pick any weight with fontVariationSettings: "'wght' 650" or {wght: 650}. In our test build every value from 100 to 900 rendered, an empty string reset an inherited value, and a malformed string was dropped as a whole.

We built this with React Native 0.88.1 and React 19.3.0, as a Release build for the iOS 26.3 Simulator (iPhone 17 Pro) with Xcode 26.2 on our M1 lab Mac, using the Inter variable font (SIL Open Font License, one wght axis from 100 to 900, a 120 KB Latin subset). For Android we read the 0.88.1 native sources; Android runtime screenshots and TV devices are outside this post. fontVariationSettings does not exist anywhere in the react-native 0.87.1 package, so this needs 0.88.

Why we did this: our banking and TV apps each ship several static font weights, and designs often call for weights in between. One file with a weight axis is smaller to ship and easier to keep in sync between the phone and TV builds.

Simulator screenshot: one variable font at weights 100 to 900, the object form, a malformed value, a nested reset and a TextInput

Release build on the iOS 26.3 Simulator, React Native 0.88.1. One screen, split in two columns.

Step 1: add the font file

Variable fonts are registered exactly like static ones. Put the .ttf in your project and let the linking tool add it to both apps:

// react-native.config.js
module.exports = {
  assets: ['./assets/fonts'],
};
npx react-native-asset

With react-native-asset 2.3.0 this took 21 seconds and did two things we checked afterwards: it added the file to UIAppFonts in ios/<App>/Info.plist and to the Xcode target’s resources, and it copied it to android/app/src/main/assets/fonts/. The Release .app contained the font at its full size.

<key>UIAppFonts</key>
<array>
  <string>InterVariable.ttf</string>
</array>

Name the file after the family

On iOS, fontFamily is the family name stored inside the font (Inter here), not the file name. On Android, React Native’s ReactFontManager looks for assets/fonts/<fontFamily>.ttf (or .otf), so the file name is what counts. If you want one fontFamily value for both platforms, rename the file to match the family before linking: Inter.ttf. Our test app kept the original file name because it ran on iOS only.

Step 2: set the axes

The style takes the CSS syntax as a string, or an object keyed by four-character axis tags:

fontVariationSettings in a React Native 0.88 StyleSheet, string and object form

Both forms end up as the same string on the native side.

<Text style={{fontFamily: 'Inter', fontVariationSettings: "'wght' 300"}}>
  Light
</Text>
<Text style={{fontFamily: 'Inter', fontVariationSettings: {wght: 650}}}>
  Between semibold and bold
</Text>
<TextInput style={{fontFamily: 'Inter', fontVariationSettings: "'wght' 600"}} />

The object form is converted in JavaScript by processFontVariationSettings.js: keys are sorted, quoted and joined into 'wght' 650. That conversion throws if an axis tag is not exactly four printable ASCII characters or a value is not a finite number, so a typo in the object form is a red screen in development, not a silent fallback. Variable fonts with more axes work the same way: {wght: 500, wdth: 90}.

What the native code does

We read the 0.88.1 sources that ship in the npm package.

iOS (RCTFontUtils.mm in ReactCommon/react/renderer/textlayoutmanager). RCTParseFontVariationSettings parses the string with a regular expression into a dictionary of axis tag (as a 32-bit number) to value. After React Native has resolved the font by family, weight and style, it adds that dictionary to the font descriptor as kCTFontVariationAttribute and creates the final UIFont. "normal" or an empty string produce an empty dictionary. If any part of the string does not match, including a trailing comma, the function logs Invalid fontVariationSettings value and returns an empty dictionary, so none of the axes are applied.

Android (ReactTypefaceUtils.kt in ReactAndroid). The string is validated with FontVariationAxis.fromFontVariationSettings and then passed to Paint.setFontVariationSettings for Text (through CustomStyleSpan) and to setFontVariationSettings on the EditText behind TextInput. Both calls exist from API 26. Below that, parseFontVariationSettings returns null and the font renders at its default instance. The 0.88 template’s minSdkVersion is 24, so on API 24 and 25 devices fontVariationSettings has no effect at all. An invalid string is logged and ignored. React Native clears the previous settings before applying new ones, because Android reuses Paint objects between layouts.

The parsing code for fontVariationSettings in React Native 0.88.1 on iOS and Android

Shortened from RCTFontUtils.mm and ReactTypefaceUtils.kt, React Native 0.88.1.

What we saw on iOS

The screenshot above shows each case from our test screen, all with fontFamily: 'Inter' at 30 points:

Style Result on the iOS 26.3 Simulator
no setting the font’s default instance, weight 400
"'wght' 100" to "'wght' 900" each weight rendered, thin to black
{wght: 650} a weight between 600 and 700
fontWeight: '700' only bold, without any variation setting
"'wght' 700," (trailing comma) default weight 400: the whole value was dropped
parent "'wght' 800", child '' parent at 800, child back to 400
TextInput with "'wght' 600" the input text at 600

Two results are worth knowing before you change a codebase:

  • fontWeight still works with a variable font on iOS. In our build, fontWeight: '700' alone gave a bold rendering of the same file. If you only use the standard steps (400, 600, 700), you can keep your fontWeight styles and just swap the files. fontVariationSettings is for values in between and for other axes.
  • A malformed string falls back silently in Release. The warning goes through React Native’s logger, which you will see in development; in our Release build nothing appeared in the system log. Prefer the object form in shared styles, because its mistakes fail loudly while you develop.

A migration checklist

  1. Pick the variable version of your font and check its axes and default instance (the name and fvar tables; fonttools ttx -t fvar prints them).
  2. Name the file after the family, put it in assets/fonts, run npx react-native-asset, and remove the static weight files you replace (from UIAppFonts, the Xcode target and android/app/src/main/assets/fonts).
  3. Keep fontWeight where a standard weight is enough; add fontVariationSettings only where you need a value in between or another axis.
  4. Use '' on a nested Text to reset an inherited setting.
  5. If your minSdkVersion is below 26, check on an API 24 or 25 emulator how your weights look without fontVariationSettings, and decide whether that is acceptable.
  6. Check text measurement on screens with tight layouts: a weight change also changes glyph widths, as the 900 row in our screenshot shows.

For the rest of an 0.88 upgrade on iOS, see our notes on stripping the 0.88.1 prebuilt frameworks; for the TV side of the next release, the react-native-tvos 0.89 native diff.

Made by the team behind this post

Apps from our studio

  • Goes with this post

    Cardigami

    Pop-up greeting cards that rise out of the fold on iPhone Duo.

    iPhone · App Store

    Get
  • Goes with this post

    BMDB.fun

    Your Bollywood world at a glance, with links straight to the OTT app that streams each film.

    Android TV · Web · Mobile

    Get
  • Nix

    The Mac uninstaller that finds what the Trash leaves behind: caches, logs, derived data and saved states.

    macOS

    Get
  • OneClick QuitAll

    Quit every running app in one click. See memory and CPU first.

    macOS · Mac App Store

    Get

Need this built? Let’s talk.

We build and run apps for Mac, TV, mobile and the web, and write about what we learn.