react-native-design-utility icon indicating copy to clipboard operation
react-native-design-utility copied to clipboard

Custom font doesn't work with Text component

Open andydev404 opened this issue 5 years ago • 10 comments

As a User when I implement a custom font (Lato, Roboto, Poppins, etc.), the font is no taking effect on the Text component

andydev404 avatar Feb 08 '20 21:02 andydev404

It's should, did you link the font into your app ? If you change the name now the text is like the one you use before

EQuimper avatar Feb 09 '20 01:02 EQuimper

The font is already linked when I use import { Text } from 'react-native' works fine

andydev404 avatar Feb 09 '20 02:02 andydev404

If possible may I see your code for this? I use this lib for like 7+ projects with custom fonts and work. Just to make sure.

EQuimper avatar Feb 09 '20 19:02 EQuimper

 import { Text } from 'react-native-design-utility';

// I tested with this 2 ways
<Text font="Lato-Black">Some text</Text>
// and
<Text style={{fontFamily: "Lato-Black"}}>Some text</Text>

andydev404 avatar Feb 09 '20 20:02 andydev404

Ha ok the issue is the font here need to match the theme. So you can example add this font to the base or example Lato. And now you can do font=“Lato”

EQuimper avatar Feb 09 '20 21:02 EQuimper

so your theme should have

{
	font: {
		lato: 'Lato-Black',
		base: 'Roboto'
	}
}

<Text font="lato">Hello world</Text>

EQuimper avatar Feb 09 '20 23:02 EQuimper

The same, It does not work

andydev404 avatar Feb 10 '20 18:02 andydev404

I am having the same issues with @andydev404 , The custom font isn't working properly on Android, but works well on iOS. Following the example you displayed above, if I add the bold or normal props to the text component, the text returns back to the default Android font

tolustar avatar Jul 31 '20 18:07 tolustar

I got it fixed. After you initialize a theme via npx react-native-design-utility init, remove the weight object on line 56, and everything would work properly

tolustar avatar Jul 31 '20 21:07 tolustar

@EQuimper it doesn't work for me, I have everything right and inspecting the text, I can see that there is no fontFamily set in the text component

This is my theme config:

fonts: {
  base: "Sora",
  sora: "Sora",
},

And I'm using like this:

<Text font="sora">Test</Text>

I've tried not passing the font prop, tried passing fontFamily as prop, none works, the only thing that works is if I pass a style object that has the fontFamily: 'Sora', so I am sure the bug is in this lib

ghmendonca avatar Feb 15 '23 05:02 ghmendonca