AS3: Using embedded fonts with components in Flash CS3

Firstly, if you are not using SSL for all your sites, you should step it up! NameCheap's SSL certificates start at only $9. There's no excuse!
Firstly, if you have not tried Digital Ocean's SSD Virtual Servers for only $5/mo, I highly recommend them!

(I don’t recommend using the Adobe components, but sometimes shit hits the fan)

First, create a new font in the library (e.g. with id MyFont).
IMPORTANT: This is the one thing that prevented it from working at first. When you embed a font in the library, “Bitmap Text” is checked by default. When this was checked, TextFields behaved like device fonts – I couldn’t set an alpha on them. Uncheck it!

This will set the global style for all components:

StyleManager.setStyle( "textFormat", new TextFormat("MyFont") );
StyleManager.setStyle( "embedFonts", true );

There are a lot of real slick examples out there that use the Embed metadata to embed the font directly from the font file. This doesn’t work in CS3 – only Flex…

About this entry

Good Reads