Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Letter spacing on React Native - Android

I'm using React Native 0.29 with Android emulator (API Level 23). I am trying to achieve letterSpacing on Text component. But it seems not working on Android. Official documentation says that it only works in iOS. Is there any workaround of this problem?

like image 607
Provash Shoumma Avatar asked Jul 19 '16 06:07

Provash Shoumma


People also ask

How do you add letter spacing in React Native?

The lack of letter spacing on Android can be "solved" by adding one or more spaces between each character. I have found the unicode HAIR_SPACE U+200A to give the best results, but you might have to experiment to find what suits best for your font. For example 2 hair spaces or one U+2009 THIN SPACE .

What is the font spacing for a letter?

The most common layout of a business letter is known as block format. Using this format, the entire letter is left justified and single spaced except for a double space between paragraphs.

What is adjusting space between letters?

While tracking adjusts the space between characters evenly, regardless of the characters, kerning adjusts the space based on character pairs.


1 Answers

The lack of letter spacing on Android can be "solved" by adding one or more spaces between each character. I have found the unicode HAIR_SPACE U+200A to give the best results, but you might have to experiment to find what suits best for your font. For example 2 hair spaces or one U+2009 THIN SPACE.

function applyLetterSpacing(string, count = 1) { return string.split('').join('\u200A'.repeat(count)); }

It probably works best for headers and menu labels.

Unicode spaces: https://www.cs.tut.fi/~jkorpela/chars/spaces.html

like image 185
hanse Avatar answered Sep 17 '22 17:09

hanse