A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Embed font example for CS3

Hybrid View

  1. #1
    Junior Member
    Join Date
    May 2008
    Posts
    19

    Question Embed font example for CS3

    I'm trying to use the following script to embed a font in a CS3 flash file. When I publish and preview it, all I get is a blank screen :S Can someone tell me if this script is valid for AS3/CS3?

    Thanks.

    Code:
    package {
    
    //import flash.util.describeType;
    import flash.display.MovieClip;
    import flash.text.TextField;
    import flash.text.TextFormat;
    import flash.text.AntiAliasType;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFormatAlign;
    
    public class Test extends MovieClip {
    
    // be sure this is pointing to a ttf font in your hardrive
    [Embed(source="Arial.ttf", fontFamily="foo", mimeType="application/x-font-truetype")]
    public var bar:String;
    
    public function Test() {
    
    var format:TextFormat = new TextFormat();
    format.font = "foo";
    format.color = 0xFFFFFF;
    format.size = 130;
    
    var label:TextField = new TextField();
    label.embedFonts = true;
    label.autoSize = TextFieldAutoSize.LEFT;
    label.antiAliasType = AntiAliasType.ADVANCED;
    label.defaultTextFormat = format;
    label.text = "Hello World!";
    addChild(label);
    trace(label.text);
    }
    }
    }

  2. #2
    Member
    Join Date
    May 2009
    Posts
    57

    All it needs is Flex SDK

    I also recently came with this problem but when I used this same code in Flash CS4 and compiled it using Flex SDK,the result was seen.
    But I tried with Flash CS3 but didn't get any result.
    Further,I looked up into several tutorials and all they have given examples similar like you and said to have worked in Flash CS3,but I even downloaded those examples but it didn't run.
    But since so many tutorials about this issue says that it works on CS3,then it may be.
    Good Luck

  3. #3
    Junior Member
    Join Date
    May 2008
    Posts
    19
    Thanks for the reply.

    I have downloaded a trial version of CS4 and it works in there! But I still have a problem in that italic and bold formatting does not work

    I think this maybe a limitation where bold and italic do not work with embedFonts = true;

  4. #4
    Member
    Join Date
    May 2009
    Posts
    57

    Is this the case?

    Are you using option in Actionscript like
    Code:
    format.bold = true;
    to the font Arial.ttf.Then it won't work as this is not supported in embedding fonts technique
    In order to get bold font then you must embed Arial Bold.ttf instead of Arial.ttf.
    But there may be other possibilities also.
    Good Luck
    Last edited by laaptu; 06-23-2009 at 12:45 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center