Flash, CSS and Embedded Fonts
Seems like every time I get a new project that involves styling dynamically generated text in Flash, using custom fonts and with no access to Flex’s @embed trickery, I run into problems. I’m writing this blog entry not just to share a solution with you but also to have a single writeup for my own reference moving forward.
So, here’s the assignment: you’re working with Flash (let’s say CS4) and you have some dynamic textfields that are going to hold text. This text needs to be styled, dynamically at runtime. Font size is going to vary between 10 and 20. You know that some text is going to be set in one font (let’s say Avenir Heavy Oblique) and some will be set in another (let’s say Myriad Semibold Condensed Italic). The client even wants you to manually tweak the letter spacing on certain words. Setting properties on the textfields themselves, then, won’t work. You need to be able to handle custom styling of substrings within the larger set of content. How do you do it?
Tagged CSS, embedded fonts, embedding fonts, flash, flash.text.StyleSheet, fonts