OT: CS4, AS3 and dynamically embedding fonts
This is a classic example of the kind of frustrations yer average amateur punter can face when using Flash CS4.
You’re trying to use an embedded font which ( you think ) you have added to your library, and set to export for use with Actionscript. However, when you try use that font dynamically with either TextFormat() or a StyleSheet() or whatever, the font will not display. It usually happens with fonts like Helvetica, Frutiger etc. You end up jumping through hoops and using ‘alternative methods’ to get your font to display correctly – and it’s a enough to make you want to jump out of the nearest window.
Well I finally figured out what is going on…
It’s to do with the difference between ‘fonts’, and ‘font families’. Actionscript, whilst using TextFormat() or StyleSheet(), will recognise a ‘Font Family’, and a ‘Font Style’ which ( for Actionscript ) can only be either ‘Bold’ or ‘Regular’. Many fonts, and lets stick with Helvetica, consist of a whole family of fonts under one umbrella ‘name’ – which Flash reads in a weird way. It will take the family name ‘Helvetica Neue’, and then put the family member name ( ’67 Condensed’ for example) in the ‘Font Style’ field where you would normally find ‘Bold’, ‘Regular’, ‘Italic’ etc. So you end up with ‘Helvetica Neue’, and ’67 Condensed’, neither of which are the actual system name of the font you want. Then when you create a ‘New Font’ in the Library, and try to link to it from Actionscript trying any which way you can – and it is not recognised. It’s infuriating.
This is because Flash is not displaying the correct system name for the actual member of the ‘font family’, rather, it’s displaying the name it thinks you will understand. The way to find out the correct name of the font family member to use in Actionscript is thusly:
Create a normal dynamic TextField somewhere on your stage, set it to the font you are trying to use ( ‘Helvetica Neue’, and ’67 Condensed’ ), and manually set ‘Character embedding’ ( from within the IDE itself ) to something like ‘Uppercase’ ( doesn’t matter which ). Then in ‘Publish Settings’, ‘Flash’, select ‘Generate Size Report’, and then test your movie. In the Size Report that traces out, you will find the ‘correct’ name of your desired font ( in this example it’s actually something like ‘HelveticaNeue-BoldCond’ ). This is the name you need to use in Actionscript to refer the to Font you have created in your library.
You can delete your test TextField now, and take a deep breath as you finally, after hours of messing about, figure out how to use the font your client wants you to use!
I haven’t checked, but this is probably the same problem that on some machines causes ‘Arial’ not to display, forcing you to use ‘Arial CE’, or ‘Arial MT’ or similar.