In a mixed Flash IDE/Flex project, I have a TextField and I want to retrieve the Font class object that's associated with that TextField. The TextField lives in a SWF that was created in the CS4 IDE and is loaded into a Flex SWF.
Currently, I have code that works if the following criteria are met:
- The font is exported in the child SWF's library.
- The TextField is linked to the exported font.
- The name of the exported font is hard-coded in the parent SWF.
Code as follows:
fontClass = childSwf.loaderInfo.applicationDomain.getDefinition("CustomFont") as Class;
What I really want to do is not have to know the name of the exported font. Instead, I want to grab either the font's Class or the Class name dynamically from the TextField.
Even better would be the ability to get the Class for built-in fonts without requiring the export.
FWIW, the end goal is to grab any arbitrary TextField and check if it contains characters that its embedded font can't show using Font::hasGlyphs(). However, fonts in child SWFs aren't registered to show up in Font::enumerateFonts().