Pages

Wednesday, 11 January 2012

Embedding Fonts In Actionscript 3

I hardly use the Flash IDE at all any more. Pretty much all of my coding is done in FlashDevelop. One thing that the IDE does very well is the embedding of fonts but there are certainly ways of doing it using purely code. People seem to have found many ways of embedding fonts but this one has always worked for me:

This class is my font library - I embed all fonts that I use in here. The two things to note are the embed code for the fonts and public constants to allow me to access them using FontLibrary.FONT...


This is the main class of my application. Here I create a sample text field and set the text format to one of my embedded fonts.

Easy! You can download all of the source files for this and my other projects from: http://experimentalized.com/blog/sourcezip/Blog.zip.

4 comments:

  1. Thanks,

    For the Flash CS5 Use this
    [Embed(source="samplefont.ttf",fontName = "Mia's Scriblings ~", mimeType = "application/x-font-truetype",embedAsCFF="false")]

    ReplyDelete
  2. Thanks vijay, good point, I also turn off embedAsCFF when using the 4.5 or later SDKs.

    ReplyDelete
  3. Thanks for sharing this quality information with us and i like this.
    ----
    i like play game click jogos online free and play game juegos pou

    ReplyDelete