Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native Custom Font Extra Padding

I am using a custom font (Cairo) for both Android & IOS. The font rendered with an extra padding for both platforms like the following

sample one

When I tried to set lineHeight=[fontSize] I got the following

sample two

I tried to set lineGap=0 following this article: Consistent font line height rendering but I find that it's already ZERO

Also tried the paddingTop solution but it's not working at all just shift the text down with the bottom space like the above images

Hope anyone can help :)

like image 629
Ahmed Yehia Avatar asked Oct 20 '25 01:10

Ahmed Yehia


2 Answers

I ended up doing something like that:

fontSize: 15,
lineHeight: 15 * 1.4,
height: 15

Unconvinced with a solution like that but it's the only thing that makes it work o_O

If I get a better solution I will update the question :)

like image 130
Ahmed Yehia Avatar answered Oct 21 '25 14:10

Ahmed Yehia


For me it worked to set includeFontPadding: false in styles:

https://reactnative.dev/docs/text-style-props#includefontpadding-android

like image 27
Maxym Hyba Avatar answered Oct 21 '25 15:10

Maxym Hyba



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!