Inserting ActionScript 3 and fonts

I have a problem inserting fonts correctly into an ActionScript 3 project (flash CS4, not flex).

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

the manual says to set the Textfield.embedFonts property to true. if I do this and try to display text with a different font in that textbox, then nothing is displayed - that's fine, I expect so.

But now I have this specific problem:

i paste the font Arial in Regular style and create two input text boxes on stage. one I set the embedFonts property to true (as described in the manual) the other, which I leave as is. Now I am posting the thing as swf and trying to enter the following (turkish) line in the textbox

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

now the problem is that the untouched textbox renders the string correctly, but the embedFonts set to true is missing some letters (e.g. ş is not displayed). But the Arial font has this letter as it renders correctly in static - so why is it not rendered correctly when I set this property (as the manual says)?

my final application should have one text screen, but several embedded fonts and a way to switch between them (for example, the user should be able to select a different font to enter Chinese text).

can someone tell me how to do this correctly?

thank!

+2


source to share


3 answers


Embedding fonts in Flash is not as straightforward as it should be, and there are many special cases ... One way to ensure that you embed the correct font characters is to enable the "Generate Size Report" in Publish Publishing Options ... there you will see everything symbols of all built-in fonts. The only exception is that fonts embedded using the [EMBED] tag are not displayed there.

Adding a font to a library does not embed the entire character set of that font (e.g. Arial is about 8MB) ... it only includes a subset of them ... I'm not sure if its always the standard Western Latin set, or if it depends on the computer language ... You can extend this set manually using any text field in your movie (with the Embed Symbols ... dialog) as long as you use the actual library font name (it appears in the font list with an asterisk at the end ... in your in case it will be "Arial *").



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

+2


source


I use system fonts and avoid built-in 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 to be returned will have all letters.

(Wouldn't it be nice if ActionScript had an easier way to create inline diff?)

+2


source


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

0


source







All Articles