tamagui: Adding fontWeight: 600 with system-fonts doesn't make texts appear bold on Android
Current Behavior
I have a custom Tamagui theme that uses the system font on each platform. In my theme settings I set 600 as the value for weight number 3. When using this value in my custom components either inline or with the styled function as fontWeight="$3" it works on iOS, but on Android the fonts are rendered as regular weight.
I’m only developing for Android and iOS right now, so web doesn’t concern me. However I do use @storybook/addon-react-native-web for presentation and QA and in the browser based Storybook environment the font-weight works properly.
I think this might be related to an earlier issue reported here, but I see you’ve closed that for lack of reproducible example.
Expected Behavior
The value 600 for the fontWeight property should render a bolded text on both Android and iOS.
If I add the basic Text component imported from react-native, that works on both platform.
<Text style={{ fontWeight: "600" }}>
Native Text component that's bold
</Text>
Tamagui Version
1.91.3
Platform (Web, iOS, Android)
Tested on:
- Android (Emulator): Pixel 7 Pro API level 34
- Android physical device: Google Pixel 4, Android Version 13, Expo Go v2.30.11
- iOS (Simulator): iPhone 15, iOS 17.2
Reproduction
- Clone the example repository
- Install dependencies (
npm run install) - Run
npm run iosandnpm run androidin two separate terminal windows and open the app in two emulators (or physical devices using Expo Go). - Tap on the “Toggle emphasis” button and observe that the text becomes bold on iOS, while it stays the same on Android.
- Also observe the text “Native Text component that’s bold” below the button, this is a native
Textcomponent withfontWeightset to600and it gets bolded on both platforms.
System Info
System:
OS: macOS 14.2.1
CPU: (8) arm64 Apple M1
Memory: 59.23 MB / 16.00 GB
Shell: 3.7.0 - /opt/homebrew/bin/fish
Binaries:
Node: 20.11.0 - /usr/local/bin/node
npm: 10.2.4 - /usr/local/bin/npm
Browsers:
Brave Browser: 123.1.64.122
Chrome: 124.0.6367.60
Safari: 17.2.1
npmPackages:
@babel/core: ^7.20.0 => 7.24.4
@tamagui/config: 1.91.3 => 1.91.3
@tamagui/core: 1.91.3 => 1.91.3
@types/react: ~18.2.45 => 18.2.79
expo: ~50.0.14 => 50.0.17
expo-status-bar: ~1.11.1 => 1.11.1
react: 18.2.0 => 18.2.0
react-native: 0.73.6 => 0.73.6
tamagui: 1.91.3 => 1.91.3
typescript: ^5.1.3 => 5.4.5
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 16 (6 by maintainers)
You need to specify your
fontFamilyname when usingTextcomponent, otherwise it will pickdefaultFontvalue from your tamagui config which isbody('Inter').you can change
defaultFonttosystemFontin your tamagui config as well.just tested and it’s working fine what those changes, I’ll close this issue. let me know if there’s a need to re-open
in that github repo. just put this line to your tamagui.config file and it should work
const config = createTamagui({ defaultFont: “systemFont” })
@ShivamJoker like this
systemFontis a custom name that you assigned to your font.