开发者

How to display Traditional Chinese text in a SWF with the text populated from XML

I know this is similar to an already asked question, but I would love to get some more detailed help on how the outcome was achieved.

I have a website with SWF animations of automotive systems. Each animation has labels naming the parts, action buttons to show failures, and links to other animations. The text for each label is dynamic, with the label being pulled from an XML file. We allow the user the option of changing the language, and currently have successfully used English/French/Spanish (all left to right) and Hebrew (right to left).

We are trying to add Traditional Chinese for a user in Taiwan, and are having difficulty getting the characters to display. We can make it work if we embed the font file into the SWF, but the file size increases to a point that it is not practical to do. I want to use the "Device Font" option, so that we can enter the Chinese text into our XML file, and then the SWF will use the font file from the end users computer to display the characters, but if I change the text property to "Device Font" it makes all the label text in the boxes disappear, no matter what language I select. If I leave the box set to "Anti-alias", the other languages display correctly开发者_运维问答.

The XML file contains this for the Chinese language label: and this for the English Language label:

The encoding of the XML file is UTF-8.

Is there something I am forgetting to do? Any help will be greatly appreciated.


UTF-8 encoding will only work properly with unicode fonts. If you use device fonts, you will have to use the local code page and character encoding. I would advise against this, because you can never ever be sure it will work for everyone. UTF-8 is a much better choice.

So, you should use UTF-8 and embedded fonts, but do some of the following:

  1. Load all fonts from external files, decide which ones to load according to the language displayed
  2. or create a special chinese version to load only when accessing the program from China and Taiwan. Either 1. or 2. will take all other languages out of the equation, which will make things a lot less complicated, and even if you can't find a solution that fixes all your problems, only the Chinese version will be affected, while all the other ones can still be streamlined.
  3. Embed only the characters actually used in the text. Traditional Chinese fonts have about 20000 characters, which you will never use. In my experience, around 200 characters will be enough for even larger websites. You can find out which ones are needed by pasting the entire XML file into a TextField on the stage in the Flash IDE and using the properties inspector.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜