Hi Kerry,

I think this is one that gave me headaches a while ago...

My solution was to apply the textFormat AFTER the text has been applied
to the textField.

C:

-----Original Message-----
From: flashcoders-boun...@chattyfig.figleaf.com
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Kerry
Thompson
Sent: Thursday, 23 September 2010 11:05 AM
To: Flash Coders List
Subject: [Flashcoders] Using an embedded font

I've been banging my head up against this for 4 hours, and the client
has to ship tonight.

FlashBuilder 4, Windows 7.

I am just trying to make a little demo of how to embed a font, but
when I pull together code that has worked before into one simple
class, it doesn't show the text. It draws the outline of the text
field, but there is no text. When I comment out one line,
textField.embedFonts = true, it works, but not with the embedded font.

I've tried different fonts, and can't get any of them to work. Can
somebody spot what I'm doing wrong?

Cordially,
Kerry Thompson

        public class FontEmbedding extends Sprite
        {
                public function FontEmbedding()
                {
                        showText();
                }
                
                /**
                 * Embeds the  Garamond 3 font
                 */                     
                [Embed(
                                source='../fonts/GaramThrSC.ttf',
                                fontName='Garamond3'
                )]
                
                private static var Garamond3Embedded: Class;
                
                private function showText():void
                {
                        var textFormat:TextFormat;
                        var textField:TextField;
                        registerFonts();

                        textFormat = new TextFormat();
                        textFormat.color = 0x000000;
                        textFormat.font = "Garamond3Embedded";
                        textFormat.align = "left";
                        
                        textField = new TextField();
                        textField.defaultTextFormat = textFormat;
                        textField.border = (true);
                        
                        textField.embedFonts = true;

                        textField.text = "Hello Autovod!";

                        textField.width = 100;
                        textField.height = 30;
                        
                        addChild(textField);
                        textField.x = 100;
                        textField.y = 60;
                }
                        
                public static function registerFonts(): void
                {
                        Font.registerFont(Garamond3Embedded);
                }
        }
}
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
This e-mail, including any attached files, may contain confidential and 
privileged information for the sole use of the intended recipient.  Any review, 
use, distribution, or disclosure by others is strictly prohibited.  If you are 
not the intended recipient (or authorized to receive information for the 
intended recipient), please contact the sender by reply e-mail and delete all 
copies of this message.

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to