Should I use different fonts for iOS & Android devices?

I use native.getFontNames() to list all the fonts in a iOS & an Android device,

and I found that they have different fonts…

Does it mean I have to use different font names in

display.newText() ?

I have to check if the device is Android, then use XXXX font, and if my device is iOS, then use YYYY font?

Yes and no. It’s obvious that different os will have different fonts. However you can include tff file in your corona project and you will have any (free) font you want on both. Remember that even if some fonts are basic for your os it doesn’t mean they are free (ios’ s Helvetica for example)

Hi Joe,

Please refer to this tutorial, which should answer several of your questions:

http://www.coronalabs.com/blog/2013/01/16/faq-wednesday-custom-fonts/

Take care,

Brent

@Brent 

Do you know why some fonts do not work on iOS while they works on Android? I mean fonts with subfamilies - like semibold, bold, italic. On Android they seems to work fine but on iOS only main font works but semibold, italic, bold variant not… :frowning:

Hi @piotrz55,

In the linked tutorial, did you read the platform-specific notes? If so, can you give me a code example of what you describe and what the behavior is?

Thanks,

Brent

Yes, I have read. It works because standard one works. The issue is that some fonts are defined as subtypes of family. For Example I have Open Sans font (open sans regular) and Open Sans Semibold which works fine. The problem are bold and italic. This files have properties like: family - open sans, subtype = bold. Is there possibility in Corona to get this bold and italic, or I have to create somehow font file which is: family - open sans bold? Such fonts on Windows installs as one font (regular, bold, italic) so even in simulator I cannot test it.

To joe528’s question.  Corona supports native.systemFont and native.systemFontBold which should use the default font for the operating system.  On iOS 6 and earlier, it will be Helvetica and Helvetica Bold.  iOS 7 it changes to Helvetica Neue Light and Helvetica Neue.  On Google based Android’s it will be Droid Sans and Droid Sans Bold.  The Kindle Fire and Nook I think use Arial.

Since they are all similar, many apps can get away with just using these fonts, but it will make fitting tight text tough to do since they all render a little bit differently.

Are there any articles about using fonts for other languages (other than English)?

It looks like Corona uses only one type of font for other languages?

On simulator you just use any font installed on your computer supporting non-english characters. On Android or on iPhone you just put font file inside folder with main.lua

http://www.coronalabs.com/blog/2013/01/16/faq-wednesday-custom-fonts/

If I have a string, str, mixed with English & non-English words,

and when I call

display.newText(str, …, “Helvetica”, 16)

the English characters will be in “Helvetica”? and how about the non-English characters?

Helvetica should support a considerable range of UTF-8 glyphs covering many languages.   I ran into an issue with Hindi and had to find a font that had Hindi support.

I am using Chinese so I think most fonts don’t support it because of the huge number of characters.

Therefore, when I call

display.newText(str, …, “Helvetica”, 16)  or display.newText(str, … ,“Arial”, 16)

both shows the Chinese characters, but I am wondering which font is actually used?

And my second question is, does native.systemFont() support all kinds of language? (for both iPhone & Android)

When I call native.systemFont() for iPhone & Android, the font is decided & rendered by the device, not Corona, right?

If you say “Helvetica”, it’s going to use Helvetica.  If you say “Arial”, it’s going to use Arial.  If that font doesn’t exist, it falls back to native.systemFont.

On iOS 6 and earlier, native.systemFont is Helvetica.  On Android, its Droid Sans.  On the Kindle Fire and maybe the Nook, it’s Arial.  Corona won’t switch font’s mid-string.  If it doesn’t know a glyph, it just won’t display it or display a block.

Yes and no. It’s obvious that different os will have different fonts. However you can include tff file in your corona project and you will have any (free) font you want on both. Remember that even if some fonts are basic for your os it doesn’t mean they are free (ios’ s Helvetica for example)

Hi Joe,

Please refer to this tutorial, which should answer several of your questions:

http://www.coronalabs.com/blog/2013/01/16/faq-wednesday-custom-fonts/

Take care,

Brent

@Brent 

Do you know why some fonts do not work on iOS while they works on Android? I mean fonts with subfamilies - like semibold, bold, italic. On Android they seems to work fine but on iOS only main font works but semibold, italic, bold variant not… :frowning:

Hi @piotrz55,

In the linked tutorial, did you read the platform-specific notes? If so, can you give me a code example of what you describe and what the behavior is?

Thanks,

Brent

Yes, I have read. It works because standard one works. The issue is that some fonts are defined as subtypes of family. For Example I have Open Sans font (open sans regular) and Open Sans Semibold which works fine. The problem are bold and italic. This files have properties like: family - open sans, subtype = bold. Is there possibility in Corona to get this bold and italic, or I have to create somehow font file which is: family - open sans bold? Such fonts on Windows installs as one font (regular, bold, italic) so even in simulator I cannot test it.

To joe528’s question.  Corona supports native.systemFont and native.systemFontBold which should use the default font for the operating system.  On iOS 6 and earlier, it will be Helvetica and Helvetica Bold.  iOS 7 it changes to Helvetica Neue Light and Helvetica Neue.  On Google based Android’s it will be Droid Sans and Droid Sans Bold.  The Kindle Fire and Nook I think use Arial.

Since they are all similar, many apps can get away with just using these fonts, but it will make fitting tight text tough to do since they all render a little bit differently.

Are there any articles about using fonts for other languages (other than English)?

It looks like Corona uses only one type of font for other languages?