Custom fontFamily does not work with Text Heading (h1, h2, h3, h4)
See original GitHub issueI’m loading a custom font using Expo as described here.
Setting the new font as fontFamily style works in regular Text components.
However, as soon as one of the heading props are set on the Text component, the fontFamily is no longer applied.
Example:
import { Text } from 'react-native-elements'
<Text
h1
h1Style={{ color: 'red', fontFamily: 'dosis-regular' }}
style={{ color: 'blue', fontFamily: 'dosis-regular' }}
>This is my text</Text>
This text is large, red and uses the default font.
After removing the h1 prop, the text is small, blue and using the Dosis font.
Keeping h1 but removing h1Style, the text is large, blue and using the default font.
Keeping h1 but removing style does nothing.
Environment:
| software | version |
|---|---|
| react-native-elements | 1.2.7 |
| react-native | 0.59.10 |
| expo | 35.0.0 |
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Adjust Heading Styles with Custom Design (h1, h2, h3, etc)
I'm having problems getting different fonts to work for the H3/H4 headers, though. I'm trying to use some of the other fonts that...
Read more >How to Add and Apply Custom Fonts to Squarespace 7.1
Scroll down and find the button that says Manage Custom Files. Click Add Images or Fonts, and select your font file from the...
Read more >How To Style Text Elements with Font, Size, and Color in CSS
You will work with different heading levels ( h1 - h6 ) and content types ( p , strong , and em )...
Read more >Page Title and Heading different font from rest of site
Hello. I just added the CSS code below to change the font to my entire website (I am using the Storefront theme). After...
Read more >Can I customise the header tags(h1,h2,h3...) in redactor editor?
You can format the text by adding CSS! By adding classes to the elements, you could style them like you want to. See...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Setting
fontWeight: 'normal'seems to fix the issue. Loading and setting the Bold variant of the font however doesn’t seem to make any difference, unless the fontWeight is also changed (the custom font ONLY shows up with normal fontWeight).Maybe the information about which “weight” the font has is getting lost when loaded by
expo-font, and all fonts are handled as regular.For now, I’ll change the default fontWeight of all h-elements in the ThemeProvider, thanks!
@bearbytes I’m not sure about exactly REGULAR fonts for using with
h*props… https://github.com/react-native-elements/react-native-elements/blob/0f06b924fc7536f7599aca268864a75f33e13b1e/src/text/Text.js#L29-L32 Please try to use BOLD font… Or setfontWeightasnormalinsideh1Style