Home‎ > ‎My Notebook‎ > ‎Dev Notes‎ > ‎


Flash & Unicode

Translating our Flash files.

"SetVariable()" test

We have Flash embedded as an ActiveX control in a Delphi application. We want to translate fields in the flash layer from the Delphi layer. We don't want to use XML files or the like.

To do this we call the Flash COM method "SetVariable()" which takes Delphi WideStrings as params.

  • Test Machine: Windows XP SP1
  • Flash Version Installed: Flash MX 2004 (Version 7)
  • SWF files: Flash 5/6/7 test files
  • SWF file content: Some with Embedded Japense fonts + some files with no embedding at all.
  • SWF files fonts: Test fields a) Font=Tomaha b) Font=Arial Unicode MS
  • We send 4 types of strings - ANSI (DB and UTF8) and Unicode (!LittleEndian & Mac !BigEndian) !WideString.


OK this time I was more methodical with testing SetVariable() with Japanese text. All worked OK.

  • Font Embedding did not seem to help on any level with the !SetVariable() command.
  • Unicode Japanese strings displayed fine on Jap WinXP and Eng WinXP PCs (no embedding; standard XP fonts).
  • Ansi Japanese strings displayed fine on Jap !WinXP & Eng WinXP (if CP = Japanese lang).
  • All tests = SWF 6/7 test files.
  • SWF 5 test file = forget it — only fields using Font: "Arial Unicode MS" displayed OK.

Comment: Not surprising. Japanese PC should show Japanese ANSI DB strings OK as well as Unicode. To enable English PC to display Japanese Ansi chars you need to enable #2 and #3 Control Panel item (see below). Eng PC had not problems with Japanese Unicode — I disabled Japanese support (see #3 below) and it still displayed ok.

Note: English XP with Japanese Enabled means:

  1. Go to "Control Panel > Regional Settings"
  2. Select Japanese from the drop down (advanced page tab).
  3. Check the box "Install Files for East Asian languages" (Languages page tab).

More Results

  • If no fonts are embedded in a control - The device font is used and you lose the smooth antalias font. Looks harsh.
  • If you embed a font but no Japanes font embedded - then Japanese will no show even on a Japanese machine. In fact you will see blank field.
  • So.. Embed to get smooth chars but need to embed all languages you may use (otherwise lang wont work).

Our Project

Embedding all fonts sounds like the answer — however a 40K file quickly becomes 2MB with all Japanese fonts embedded. We don't want the software to be wearing that cost.

  • Embed Japanese Kana - Addes 25K
  • Embed Japanese Kanji - Addes 580K << — seems to cover us
  • Embed All Japanese Chars - Addes 1,500K

Solution #1: Have one swf which has most languages. filename.swf (Eng + Latin — filename.swf). And have some special cases where we don't even try to translate. ie. filename_jap.swf, filename_chi.swf. We can just past in the few strings from a Unicode text file sent from the translator and then convert text to BMP (ie, Break apart the font). Either that or have a separate Chinese and Japanese file and they can be big (embed fonts).

  • The other thing I need to do ... add INI switch to not translate SWF.
  • Note#1: You only embed the JP_Kanji into one dynamic field and all fields benifit. ie they will show Japanes correctly on a JP machine.
  • Note#2: I'm using the common Windows font Tomaha. If I use an uncommon font like Rotis again the Japanese text shows blank (even though we embedded the Japanese Glyphs).


New development...

With Flash MX 2004 we embed
  • Uppercase, Lowercase A..Z + Numeral + Puntuation + Basic Latin + Latin I

If you look at the character properties of the 2nd field (between the heading and version fields) you will see all these fonts selected. This brings the file up from 25K to around 50K. No problem.

Note: All fields are Tohama Font and will receive the benifit of embedded in this field. We don't need to embed in all fields. To display Japanese chars we would need to embed the Japanese fonts (Kanji & Kana). However this would see the filesize swell from 25K to 650K.

Because our Japanese strings are fixed we can embed each Japanese word into each associated field. This saves us around 600KB and must be done on a Japanese PC OR an English PC with...
  • Control Panel > Regional Settings > Advanced page : Langage = Japanese

The above settings are required to safely paste the Japanese text into the Unicode entry field "Include these Characters" of the "Character Options" dialog of Flash MX 2004.

This works for us since our Japanese strings are static (we know the runtime strings and users do not enter other characters).