Question

UPDATE: I've completely changed the question because in reality, I'm having a really hard time properly using device-fonts for multiple languages displayed in the same app (at the same time).

I must use device-fonts (cannot use the .embedFonts = true property) and I won't be masking, scaling or rotating or animating the text anyways. I'm not worried about the disappearing issues side-effects. I'm noticing that English characters are showing up correctly, BUT other characters aren't...

Like the following encoded characters for example:

सकत

Instead, the above characters show up as hollow squares.

Is there something I need to use / be aware of? I've looked into these:

  • System.useCodePage;
  • TextField.defaultTextFormat;
  • TextField.setTextFormat(...);
  • TextFormat object;
  • StyleSheet object;
  • Font.enumerateFonts(true);

What I'm trying to do is display single words (or short sentences) from various sources and various languages. In other words.... many TextFields will be scattered near eachother, but each TextField will use one language independant from the other Textfields. One may be in Mandarin, another in Spanish, another in French, in English... etc.

What do I need to do to get the Font "_sans" (or any supported device fonts) to show up correctly in various languages?

Was it helpful?

Solution

I think I may have finally resolved my device-font issue.

In Flex, it looks like modifying the style letter-spacing other than zero (0) will break the font-support for Asian characters. Perhaps only the Latin characters are meant to be customized with those extra styles.

But anyhow, for those of you who encounter hollow squares instead of the actual asian character, verify that you are not using style-properties that may be unsupported by the character set.

My approach to setting the label with the correct style was to override the label setter accessor:

override public function set label(value:String):void {
    super.label = value;

    //If English characters / numerals (space letters by 1-pixel):
    if(/[a-z0-9]/i.test(value)) {
        this.setStyle("letterSpacing", 1);
    } else {
        this.setStyle("letterSpacing", 0);
    }
}

OTHER TIPS

If you will look to the documentation they have different purposes.

defaultTextFormat () "specifies the format applied to newly inserted text"

So it means that when you will be entering a text into the TF it will take this format which were specified.

and setTextFormat () Applies the text formatting that the format parameter specifies to the specified text in a text field.

if after the defaultTextFormat() you calling the setTextFormat() then the allready inserted text will be affected. But if you will add new text then it will be using the defaultTextFormat() format.

more on that:

setTextFormat ()

defaultTextFormat()

Question: If the characters are not beeing displayed are you using the embedeFont as true? if yes then you need to embed the font with the characters you want to be displayed.

More about the fonts on my previous answers:

alternative-to-embedding-a-font-in-as3

alternative-to-embedding-a-font-in-as3

text-goes-invisible-on-embeddedfont-true

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top