Supporting languages with unicode characters

Flash provides great support for rendering text with a great set of API. Flash also allows developers to render text in various languages so that developers can build localized applications. Flash allows developers to render text in languages like Japanese or Chinese whose character set contains unicode characters. There is a small subtlety that developers need to be aware of when targeting localized versions of their applications on iOS.

Let’s say that my aim is just to display the string “Adobe 、Adobe”. The unicode character being shown here is a Japanese punctuation. Let us write the code to show the string and look at the output.

Everything looks reasonable. Let us look at the output after having run this on an iOS device.

Folks who are aware of both Japanese and Chinese languages would know that the character being shown here instead is a Chinese punctuation. We can definitely confirm that the text is not what we had originally intended.

The issue here is that no font name has been mentioned. Runtime looks for the glyph (corresponding to unicode character) in the font family set by the application. If runtime could not find the required glyph in the default font family, it looks for glyph in the next font family listed in runtime database. If next font-family turns out to be Chinese font, glyph for the unicode character is picked from the Chinese font. And in case next font-family turns out to be Japanese font, glyph for the unicode character is picked from the Japanese font family.

Developer should make sure that they mention the correct name of the font for the language that is being targeted. One can look up for the names of correct iOS fonts. For example, for Japanese language, the name of the font is “Hiragino Kaku Gothic ProN”.

Just include the following line and let’s look at the output:

format.font="Hiragino Kaku Gothic ProN";

This is exactly the text that we were intending to display. So, the key takeaway here is that one needs to explicitly mention the font name to ensure that right glyphs show up when rendering text.