开发者

Flash CS5, dynamic font embeding problem

I'm trying to create dynamic textfield with font embedding. Embeding is dynamic like this:

public class TextFormats extends TextFormat {

    private var TF:TextFormat = new TextFormat();
    [Embed(source = "/fonts/tahoma.ttf", fontWeight = "normal", fontFamily = "tahomaNormal")]
    var fontTahoma:Cla开发者_JAVA百科ss;               

    private var fTahoma:Font;

    public function TextFormats():void {
        fTahoma = new fontTahoma();
    }

    public function format(fmb:String):TextFormat {
        TF.letterSpacing = -1;
        TF.font = fTahoma.fontName;     
        switch(fmb) {
            case "combolist_label":                 
                TF.color = 0x383838;
                TF.size = 13;
                TF.letterSpacing = 0;
                break;                  
        }
        return TF;
    }
}   

When I compile it in flash CS4, embeded text appears on stage fine! But, when I tried to compile it with flash CS5, the text do not appear and no error warnings.

What is the reason? Should I use another methods for font embeding?!


There are a few articles published about the big difference in font embedding that is new in CS5. I think this one is quite good:

Having trouble with embedded fonts and HTML text in Flash CS5?

The manner in which fonts are embedded is an improvement in CS5 -- but it means that all your CS5 dynamic text fields break when you open the FLA for editing in CS5! Which sucks! (Everything still works fine as deployed in SWFs.)

If you open the CS4 FLA in CS5, you basically need to rebuild the dynamic text fields and reapply the embedding.

There is code here:

import flash.text.*;
var font:Font1=new Font1();
var txt_fmt:TextFormat=new TextFormat();
txt_fmt.font=font.fontName;
txt_fmt.size=24
var txt:TextField=new TextField();
txt.autoSize=TextFieldAutoSize.LEFT;
txt.defaultTextFormat=txt_fmt;
txt.embedFonts=true
txt.text="Designscripting.com"
txt.selectable=false
addChild(txt);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜