iPhone / iPad: Font issue for non-Latin languages - iphone

I have a problem about the font in iphone/ipad
Everyone knows UILabel can't do rich text.
So I choose FrontLabel http://github.com/zynga/FontLabel/blob/master/README
I guess what FrontLabel is doing is something like NSAttributedString and core text framework, and also, it is quite low level. But anyway, I have a problem.
If I want to display a mixed language text, let's say English + Chinese, and give the whole string a font of "ArialMT", then all Chinese characters are displayed like small squares.
I have tried, if I assign "STHeitiTC-Light" font to the text, no problem, both Chinese and English can be displayed, because STHeitiTC-Light is a Chinese font in iphone/ipad.
I think FrontLabel can't automatically select best font for non-latin text if the given font does not apply.
If I use UILabel and assign it as "ArialMT", and let it display text of Chinese or Japanese, NO problem, right? I guess apple is detecting font for different language?
Please give me some clues how can I solve this problem if I want to use FrontLabel?
Thanks

author of FontLabel here.
You're right, FontLabel does not do automatic font fallback if the glyph cannot be found in the selected font. Implementing such a behavior was outside the scope of the project, as it can be quite complex. UILabel does perform this, as it uses WebKit to do the actual text rendering and WebKit supports font fallback. I am unsure if CoreText provides this or if it behaves like FontLabel. In any case, if you need multiple fonts in FontLabel, you can specify different fonts for different ranges of your ZAttributedString. Unfortunately there's no easy way to determine which ranges are necessary without inspecting your string directly. If you know you're only working with English and Chinese, you could iterate over the characters in your string to determine if they're likely to be english or chinese characters, and use that to determine which ranges to assign fonts to. The alternative would be to teach FontLabel how to perform font fallback, but as I said before, that's quite complicated.
Alternatively, if you're comfortable require 4.0 or above on iPhone, you can try using CoreText. As I said before, I'm unsure if it does font fallback, but it's worth investigating.

Related

Multi Language Textbox in unity

I've been trying to make a project that creates Flash Cards , and i wanted to make the user be able to input any text on either sides of the card , the problem I'm facing now is that since the textbox(from TextMeshPro or regular one) has certain font whenever I try to input another languages like Japanese or Arabic it simply shows as squares, I tried the suggestion to use the textmesh pro dynamic font feature but still with no luck.
my question is , is there any way to do what I'm asking for without using fallback assets for every single language?
are there any unity plugins that do the job?
Like I said the aim is to make a textbox that displays whatever language is put in it.
any tips would be appreciated
NOTE: the solution doesn't need to use textmeshpro , it can use standard text component or any other custom ones.
I think the problem is the font. You will need a font that supports all the characters.
Perhaps you could use different fonts for different languages.
TextMeshPro creates a texture from the fonts characters. This texture will get very large if you have a lot of characters (e.g. for chinese). Because of that, the standard Text-component should be easier to work with.
(But I don't exactly know how the dynamic font feature of TextMeshPro works.)
So Since this is the first time I've worked with Fonts it appears that I didn't quite understand how fonts work and now I found the right way to approach the problem so I will give here the steps that I used to solve the multi-language issue:
1)you need a Font that supports as many languages as possible i found out that "Ariel Unicode" fits this need quite well with support to most common used languages support
2)you need to create a TextMeshPro Dynamic font asset that uses the font chosen in step one. (I tried using TextMeshPro Dynamic font before but i was mistakenly under the impression that the dynamic feature "search" for a font that has a certain character rather than we need to supply the font and it searches within the font for a character, that was a bit of a stupid assumption at my part created from the fact that I didn't understand how fonts work) .Here is a link how to use Dynamic SDF textmeshPro
I hope this helps someone with this process.

Unity: How to use TextMesh to display Emojis

I am making a 3D environment in Unity which is designed to retrieve Tweets and display them using Unity's TextMesh. The problem arises when a tweet includes an emoji (emoticons such as 😀 and 😉, which should appear as smiley faces in your browser).
When a tweet includes one of these characters, unity renders them as either a "?" symbol, or the following symbol in the editor:
...and like this when using a TextMesh:
What Do I Want?
All I need is to represent any smiley/emoticon as character in the TextMesh, using a TTF font. I don't need to show a full colour image (like your browser/phone does) of the emoji. I realise that there are some extensions in the Unity store which allow you to do that - TextMesh Pro for example. If there's an easy way of doing this though, it would be better than plain characters.
I am specifically looking to do this using TextMesh, not in any of the new GUI system components.
Things I've Tried
You'd have thought that by downloading a font which contains characters for all of the emoticons you can imagine with their correct encoding, and using this as the font for the TextMesh would solve the problem. This was unfortunately not the case when I tried using Symbola (http://users.teilar.gr/~g1951d/). This, along with some other fonts rendered the "?" symbol despite having characters for the emoticons being used.

Displaying the ASCII Artwork in the UITextView

I want to add the ascii artwork functionality into my existing Emoji App. I have seen some applications on the appstore, which displayed the ASCII Artwork. I donot have any idea from where i should start. Please help me in adding this functionality.
You need to pick a monospaced font so that the ascii art is displayed properly. You can check iOSFonts.com for which fonts are supported on the devices you are targeting. To display the ascii art you could use a multiline UILabel (set numberOfLines to 0). A UITextView will work as well but remember that they are editable by default unless you set editable to NO.

UITextView displaying spaces after newline/wordwrap

I am using a UITextView to display arbitrary NSStrings, with various font sizes (depending on the length of the string, and the screen resolution of the device). My problem is that the UITextView seems to display these little "underscore like" characters, instead of spaces, if the space character is the first character on a newline (after the text has been wrapped). Anyone know a way to turn this off?
OK, I think this was a problem with the font I was using. Also possibly the text size of the font was important. Perhaps the fact that I was displaying in italic was the thing. Anyhow, now that I have a different font, different size, not italic, I haven't noticed this problem.

iPad/iphone font leading and kerning

I've searched on the Internet but can't find definite details.
Is there anyway to specify leading and keening for uilabels, textfields or textviews?
I could create custom fonts for each leading and keening pairing but this seems a bit overkill.
There does not appear to be. CoreText offers solutions tho.