Wednesday, July 13, 2011
Let me start this little technical treat by first saying I hate the Flash IDE. If you are reading this article and you use the Flash IDE one very quick solution to all of your problems is to simply stop using it. Go and buy Flash Builder or for an even cheaper price get FDT. Both of those applications are built on Eclipse and are a much better more intuitive development environment.
That said I do realize that you are already too deep down the rabbit hole on your current project, or perhaps you work on a team that uses the Flash IDE or are picking up the broken pieces of another developers project.
Ok enough trash talk. In general adding a text field in Flash and clicking the embed fonts button associated with that text field is by far a great tried and true method of confidently embedding fonts. But that is not really all the powerful for developing anything more then a simple add banner or splash screen. The real power of Actionscript and text is dynamically generated content i.e. private var tf:TextField = new TextField();. For these types of text fields embedding fonts becomes a bit more involved.
The methods that Flash has historical used to embed fonts has changed a bit over the last several versions. With CS5 once again they have made additional “advancements”, which I assume are to help unleash the power of Flash’s text engine. I have sat at work for hours reading over users “best practices for embedding fonts with CS5”. Everyone seems to have a little something different they do. And even within those examples the end goal is very scattered. One might be for css, or textFormat, or to support html tags in xml. Either way its a big fact searching expedition with very mixed information. Well yesterday I went on this mission again for a team project I am working on where out of the blue several fonts for some magical reason stopped embedding. I stumbled across this blog post (http://www.dotstrosity.net/2010/05/10/flash-cs5-font-embedding-its-totally-different/) on the subject I and spotted a very interesting comment. One person noted that depending on what font management application you are using the font name that appears in the Font Embedding window may be completely wrong. At work I am on a Macbook Pro and use Suitcase Fusion 3 to manage my fonts. (I assume this little bit of misdirection is much more common on the mac.) This possibility had never occurred to me and got me thinking, “why don’t I just ask Flash what font it would like me to use”. So using traditional Flash “add text field” methods I used the ole tool bar, grabbed a text box and set that text field up with all the font features I wanted in my embed. Hold onto your seat because this is where the wonderment comes in. I added this code:
var objFormat:TextFormat = myTextField.getTextFormat();
This trace will return the exact “real” name of the font that is being used regardless of whatever made up version your font management software is communicating to the IDE. Now all you have to do is copy that name and use it in your, xml, html, css, or textFormat.