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.

    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFormat;
    public class JapanesePunctuation extends Sprite
        public function JapanesePunctuation()
            stage.align = StageAlign.TOP_LEFT;
            stage.scaleMode = StageScaleMode.NO_SCALE;

            var text : String = "Adobe 、Adobe"

            var textfield : TextField = new TextField();

            var format : TextFormat = new TextFormat();
            format.size = 36;
            textfield.defaultTextFormat = format;
            textfield.text = text;
            textfield.autoSize = TextFieldAutoSize.LEFT;
            textfield.x = 0;
            textfield.y = 0;


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.

2 Responses to Supporting languages with unicode characters

  1. radyo dinle says:

    i use Supporting languages thanks fort his information.

  2. many many thanks i’ll share my friends, always use.