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
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to