2
votes

I have a problem with doing proper font embedding in a actionscript 3 project (flash CS4, not flex).

I followed this Adobe guide to do font embedding: http://www.adobe.com/devnet/flash/quickstart/embedding_fonts/

the guide tells to set the Textfield.embedFonts property to true. if I do so and try to display a text with another font in this textfield, then nothing is displayed - that's fine, i expect it like this.

But now I have this particular problem:

i embed the font "Arial" in Regular style and create two input Textfields on the stage. one of them i set the embedFonts property to true (as described in the guide) the other i leave as is. Now I publish the thing as swf and try to enter the following (Turkish) string into the textfield

Yeni Yılın Barış ve Mutluluk Getirmesini Dileriz.

now the problem is, that the untouched textfield displays the string correctly - but the one with embedFonts set to true is missing some of the letters (for example ş is not displayed). But the Arial font does have this letter since it is displayed correctly in static - so why does it not render correctly when i set this property (as told in the guide)?

in my final app there shall be a single textField, but multiple embedded fonts and a way to switch between them (for example the user must be able to choose another font for entering chinese text).

can someone tell me how to do it properly?

thanks!

3
here is a simple fla explaining the problem: neo.cycovery.com/fontembeddingtest.zipgenesys
It seems not all glyphs are embedded by default. check this kirupa.com/forum/showthread.php?t=289266Amarghosh
I'm also running in to this... I am not embedding any fonts, but letting the user select their favorite font. When they select Arial, (a few others do too) half of their letters are missing. I somehow have to exclude embedded fonts from the list that I let them choose from... it's a pain!Jim Carroll

3 Answers

2
votes

Embedding fonts in Flash is not as straight forward as it should be, and there are a bunch of special cases... One way to ensure that you are embedding the correct characters of your font is enabling "Generate size report" in the Flash Publish Settings.... there you will see all characters of all fonts that are being embedded. The only exception is that fonts embedded using the [EMBED tag do not show there.

Adding the font to the library doesn't embed the whole set of characters of that font (Arial for instance is about 8mb)... it only embeds a subset of them... I'm not sure if its always the standard occidental Latin set, or if it depends on the computer language. You can extend this set manually using any textfield in your movie (with the "Character embedding..." dialog) as long as you use the actual Library Font name (it shows in the font list with an asterisc at the end... in your case it would be "Arial*").

You can also use the [EMBED tag with the unicodeRange to declare de character set, but bare in mind that the fonts you declare there wont be available in the Flash IDE during editing time... you need to set them at runtime with ActionScript (TextFormat, StyleSheet, etc...), which is not very practical when working with Flash.

2
votes

I use the system fonts, and avoid the embedded ones like Arial.

  public function get availableFonts(): Array
  {
     var font: Font = null;
     var allFonts: Array = Font.enumerateFonts(true).sortOn("fontName", Array.CASEINSENSITIVE);
     var embeddedFonts: Array = Font.enumerateFonts(false);

     var excludeList: Object = {}
     for each(font in embeddedFonts)
     {
        excludeList[font.fontName] = '';
     }

     var ourFonts: Array = [];
     for each(font in allFonts)
     {
        if (!excludeList.hasOwnProperty(font.fontName))
        {
           ourFonts.push(font);
        }
     }

     return ourFonts;
  }

The list of fonts that this returns are going to have all their letters.

(wouldn't it be nice if ActionScript had some easier way of doing set difference built in?)

0
votes

If you're looking for a more robust font loading solution that can load the different fonts at runtime, I've posted some code here (http://labs.tomasino.org/2009/07/16/flash-as3-runtime-font-manager/) and explanations of how to use it.