The following example shows how you can use an embedded font with the Flash ActionScript 3.0 TextInput control by setting the embedFonts and textFormat styles.
Full code after the jump.
// ActionScript 3.0 /* Requires: * - TextInput component in Flash library * - Embedded font with class name "MyEmbeddedFont" in Flash library */ import fl.controls.TextInput; var embeddedFont:Font = new MyEmbeddedFont(); var textFmt:TextFormat = new TextFormat(); textFmt.color = 0xFF0000; textFmt.font = embeddedFont.fontName; textFmt.size = 18; var textInput:TextInput = new TextInput(); textInput.text = new Date().toString(); textInput.setStyle("embedFonts", true); textInput.setStyle("textFormat", textFmt); textInput.width = 300; textInput.move(10, 10); addChild(textInput);

{ 2 comments… read them below or add one }
Excellent, I was attempting to set embedFonts and textFormat through the TextInput.textField property for the longest time…
Hi. I’ve read this post as well as your article on http://www.adobe.com/devnet/flash/quickstart/embedding_fonts/ and I found that using the described instructions I can’t get the text fields to display unicode characters - only Latin1 characters can be embedded.
Do you know of a way to work around that limitation, as I really need to be able to embed fonts for unicode text.
Thanks.