May 12, 2003
Flash Font Encoding

I recently enjoyed the pleasures and pains of making a multilingual Flash site work. Not really unknown territory for me - I've been through this before, but that was in good old Flash 5 times. Back then it was an almost hopless venture to have a site not only in english or german, but also in greek, russian, polish, czech or hebrew. So I knew it would be a rough road.

But that's the past - now we are living in MX times where only the sky's the limit isn't it? And since we are now driving with a U-N-I-C-O-D-E engine there's nothing that can stop us - ha! Flash from ΑΛΠΗΑ to ΩΜΕΓΑ!

But little did I know about the perils and hardships that lay before me.

Read the small print.

Make this test: Take Arial Unicode MS which contains almost every available Unicode char and therefore has a size of ~23MB and embed it into an swf. The published SWF has a size of 16K. Wow - is this some amazing font-compression algorithm? No it's only the answer why you don't see Greek or Cyrillic chars in your headline: they are simply not there. The reason is that even though Flash uses Unicode, it still thinks in codepages. The ugly consequence of that is: There is currently no way to embed every char of a font into a SWF file. It took a while until I realized that: Macromedia offers quite a lot of infos about the use of multiple languages in Flash. Unfortunately it's so much that you do not find it. And after some hard searching I finally came across this technote.


Don't trust the small print.

Okay - so I cannot do all languages in one file, but at least I can simply exchange the fonts and make one basic file for each language. All I have to do is to follow the instructions to change my system's codepage (in my case for Windows XP). Problem 1 - the step by step list somehow does not match with what I see on my screen, but I think that I've got the general idea. Annoying: you have to reboot in order to make the changes happen. So I change my system into thinking it's Greek, reboot, embed the font, publish, load the xml-content and ... see a lot of ÜÄöäü. Which is definitely not Greek. The interesting fact is that this is something completely wrong: either ther should be no chars at all or Greek ones, but not some other letters.
Analysis of the swf shows that indeed there are some chars at the unicode positions that are reserved for Greece, but it's the characters from the latin-1 codepage. Now that's what I would call a bug.


Back to the roots.

So what happens here? Flash thinks that the system uses the Greek codepage. Unfortunately the system doesn't. It uses Unicode. So we have to tell the system to use codepages. Codeword: Font Substitutes. Now we are not in good old Windows 98 anymore where you added a few lines to win.ini. No, we have to dive deep into the registry, right here: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes

Here you can make special codepage versions of your fonts (given that they contain the needed characters). If you need a Greek Version of Arial, you add a key named "Arial Greek" - the name is not important, you can also call it "Arial Hellas" or "Arial Greek, 161". What's important is the value. Which in our case is "Arial,161" . The value consists of a name and a number. The name must match exactly the name of the Font that you create the virtual font from. The number is the the codepage ID number. As these numbers were originally meant for Microsoft internal usage only they are based on a weird system - in the begining the codes were chosen based on the visual associations of the hexadecimal notation:



DECHEXMeaningCodepage
238EEEastern Europe1250
204CC CyrilliC 1251
161 A1 Greek 1253
162 A2 Turkish 1254
177 B1 Hebrew 1255
162 B2 Arabic 1256
186 BA BAltic 1257
163 B3 Vietnamese 1258

After you have added your fonts in this way you will have to reboot. If you restart Flash then you will see new fonts in your font list. Now instead of embedding Arial, embed your new "Arial Greek" - and voilá it works!

I've just discovered a shareware tool that can help you with the font substitutes: WGL Assistant. I didn't test it yet, but it looks promising.

Posted at May 12, 2003 09:11 PM | Further reading
Comments

Nice job explaining the problem regarding embedding fonts in Flash. This is why when I built the multilanguage product configurator Flash MX demo app, I created two SWFs, one with a very large embedded Korean font. I guess the Flash engineers' idea is for one to use device fonts, and switch unicode based on the System.capabilities.language property. Not a bad solution.

Posted by: Daniel Wabyick on May 12, 2003 06:31 PM

hi,
i am working on a windows xp machine as well... tried following the specs outlined within the macromedia page concerning the copdepage changes... after i did restart my machine only partial parts of the copy did show up properly within flash. could you maybe outline how you were able of getting it to work under xp?
thanks,
chris

Posted by: chris on May 27, 2003 12:03 AM

I have a problem sending cyr texts entered in a dynamic text field with font Verdana. When the use enters cyr chars they apear right, but sending the data to external PHP page it is not quite OK. It's some strange symbols but not cyrillic. Tell me what can I do about this ??

Posted by: Martin Donchev on May 30, 2003 02:14 PM

Liked the info + it worked.

Thing is i have made my own font (which includes some charactrers from central europe) but i dont know how i can tell the font that it support latin-2 codepage...(cause it should)...

Ideas?

Posted by: SomeCoolName on June 6, 2003 04:00 PM

In this case I would put the chars inside the font simply at the positions where they should be in the Latin 2 codepage http://czyborra.com/charsets/iso8859.html#ISO-8859-2, but leave the system in standard western encoding when you embed the fonts. Then the OS thinks that the chars are at the correct positions and doesn't overwrite them.

I think whenever you can type the chars in a textfield in editing mode and you can see them they will be also embedded.

Posted by: coma2mario on June 6, 2003 04:08 PM

Huh? but flash only embeds the first 255 characters, so i NEED to use codepages.

Posted by: SomeCoolName on June 7, 2003 10:38 AM

I've discovered a program named "Fontlab" is able to do what I wanted.

Posted by: SomeCoolName on June 7, 2003 11:17 AM

Hi SomeCoolName.

What you wanted to do?

I want to display greek font characters like "Garamong" e.g. but whereas in MS Word it is displayed normally, in Flash it doesn't.

Can FontLab help on this?

Posted by: Panos on June 30, 2003 01:51 AM

Hi,
I'm Egyptian ,in my registry Arabic uses 178 not 162 as you mentioned

Posted by: Ahmed on July 3, 2003 10:29 AM

I'm having a similar problem with a dynamic text field that I want curly quotes in. I DO NOT want to load the text from an external file however. (otherwise I could mime encode the curly quotes). Here's a test to show the problem
1) make a dynamic field with say, Arial
2) set it to embed ALL characters and publish a size report
3) view the size report to see all the characters supposedly embedded
4) copy and paste those characters into the dynamic text field. You can see them all fine in the flash authoring environment.
5) publish and many of those characters fail to show in the SWF!!!

What you're doing sounds like a bit of a different problem. Anyone have ideas? please email me! Thanks!

Posted by: george on August 9, 2003 07:19 PM

Traditional Chinese:

Seems impossible..... Embed a font? I need the characters to show up where I paste em into. Any suggestions?

(this info was nice, but altering the registry isn't something i feel comfortable doing.)

Posted by: Gunny_SNipes on November 27, 2003 01:39 PM

this doesn't work with arabic or hebrew text, flash doesn't understand right-to left text direction

Posted by: inka on January 21, 2004 03:54 PM

Hi I have a related problem. I am working with flash 6, integrated with VC++ code. I need to populate a dynamic field with a Japanese Kanji character(㊙) having hexcode 0x3299 from VC++. I am using SetVariable() function of VC++, but it shows only Questionmark(???) in flash. I understand that I need to use unicode here.
I did the following in VC++, then could see the character in VC++ debugger, but in flash, it shows it as a squarish dot. Need a help very badly.

Posted by: Piyali Aravindan on April 5, 2004 07:25 AM

Sorry, forgot to attach the code snippet.

WCHAR wszValue[2] = {0x3299};
myFlash.SetVariable("MyVar", (LPCTSTR)wszValue);

"MyVar" is teh name of flsh dynamic field.

Posted by: Piyali Aravindan on April 5, 2004 07:27 AM

I've tried this with Arial Cyrillic on XP and it doesn't seem to work, all I get is blank characters where the cyrillic letters should be.

The Arial,204 font is available for embedding in flash, but I still get blank text

Posted by: Ed on April 14, 2004 04:29 PM

I have a problem with flash and greeks. I have create a flash movie wich playing perfect with flash 5 player but with flash 7 player i am seeing boxes in place of greek fonts!What happening?
I must say that the input boxes are dynamics.The values come from db.

Posted by: flasho on May 10, 2004 02:28 PM

Hi. I'm trying to get Freehand 10 and Photoshop 7 to work with Hebrew. Where shall I start? I'm quite good at VB. Is there any Com object available? Or, is it just a matter of chaing settings? I use Win98 and XP

Posted by: Raizel on August 31, 2004 02:33 PM

Hello,
I have done the described actions but still get blank characters when exporting a movie.
If someone can provide help I will highly appreciate a response back with some guidelines.
Thank you.

Posted by: Ivan on October 24, 2004 09:46 PM

I'm attempting something a bit different here. I've got a simple XML file with 10 Pieces of Text. I've had 4 of my friends translate the lines into their respective languages, and now, I'm trying to get my flash movie to be able to switch between them during the playing of the movie. I am using dynamic text fields with corresponding instance names with the XML fields. I have already figured out how to use the "strings" panel to import the languages, and I can manually switch it using the "Stage Language" pulldown menu, but I want to be able to do it from a button bar I have created. Any pointers? It seems that there should be a _root.stageLanguage variable or similar that I could change... any ideas?

Posted by: RyanK on January 20, 2005 11:27 PM

I have made a content right click menu, - would love to put in some russian in it... is that possible??

Posted by: KalleBalle on January 27, 2005 09:23 AM

@KalleBalle: I haven't tried yet - did you? But I see no reason why it should not work. Well, on the other hand, there might be some cross-OS issues, but it would be great if you post your findings here.

Posted by: Mario Klingemann on January 27, 2005 11:36 AM

I have problem with Arabic font. Who I can corected?

Posted by: emad on February 14, 2005 12:58 PM

Hi,

I haven't got the problem of Arabic characters not displaying, the problem I have is that I can't get them to display in fonts other than the default system Arabic font.

I'm running it through a teletyping chat field which renders the characters in HTML formatting.

Any Ideas? Anyone?

Posted by: Danny O'Brian on August 26, 2005 05:25 PM

i like flash, but if i make my site in flash how do i allow search engines to index the content contained inside the swf files?

whats the most efficient method in terms of load on users cpu and bandwidth?

one idea i have is xml served via php, into some form of internal xml service native to flash....does sound good or is there a faster way coz php is pretty versitile....

hanng on one momento,, just saw this MING package for php servers...mmmm creates flash files on the fly!@ wtf...

well answer questioned i guess...adios

Posted by: airtonix on December 29, 2005 08:10 AM
Post a comment
Name:


Email Address:


URL:


Comments:


Remember info?



Thank you!

Most Visited Entries
Sketches, Works & Source Code
Lectures
Contact
Backlog
In Love with
Powered by
Movable Type 2.661

© Copyright Mario Klingemann

Syndicate this site:
RSS 1.0 - RSS 2.0

Quasimondo @ flickr
Quasimondo @ LinkedIn
Quasimondo @ Twitter
Quasimondo @ Facebook
Quasimondo @ MySpace
Quasimondo is a Bright
Citizen of the TRansnational Republic
My other blog in german
Impressum


My family name is written Klingemann,
not Klingelmann, Klingeman, Klingaman, Kingemann,
Kindermann, Killingaman, Klingman, Klingmann, Klingonman
Klingemman, Cleangerman, Klingerman or Kleangerman

profile for Quasimondo at Stack Overflow, Q&A for professional and enthusiast programmers