//===============================flash IDE中============================//
1.打开ide, 先择-- > 文本工具框
2.在属性面板-- > 样式-- > 嵌入
3.选择字体名称(任意)-- > 在下方的-- > 字符范围-- > 先择你要使用的字符
4.在代码中将TextFiled实例的embedFonts 属性设为true即可;
//===============================flash builder中============================//
package{
import flash.display.Sprite;
import flash.text.Font;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
public class TestFont extends Sprite{
//需要字体MStiffHei HKS.TTF,,,设置参数embedAsCFF="false",;
[Embed(source = "assets/MStiffHei HKS.TTF", fontName = "font", embedAsCFF = "false", advancedAntiAliasing = "true", mimeType = "application/x-font-truetype")]
public var FF : Class;
private var txt : TextField = new TextField();
private var format : TextFormat;
private var font : Font;
public function TestFont() {
font = new FF()as Font;
trace("font....", font.fontName, font.fontStyle, font.fontType); //输出 font regular embeddedCFF
txt = new TextField();
txt.autoSize = TextFieldAutoSize.LEFT;
txt.embedFonts = true;
txt.text = "word...text.....";
format = new TextFormat(font.fontName, 50, 0xff0000);
txt.setTextFormat(format);
addChild(txt);
}
}
}