package {
import flash.display.*;
import flash.text.*;
//埋め込みフォントの利用
[SWF(width=240, height=240, backgroundColor=0xFFFFFF)]
public class EmbedFontEx extends Sprite {
//埋め込みフォント
[Embed(source='comic.ttf', fontName='comic', mimeType='application/x-font')]
private var embedFont:Class;
//コンストラクタ
public function EmbedFontEx(){
//ラベルの生成
var label:TextField = new TextField();
label.text = "This is Embed Font!";
label.x = 10;
label.y = 10;
label.autoSize = TextFieldAutoSize.LEFT;
label.selectable = false;
label.embedFonts = true;//埋め込みフォント有効
//書式の指定
var format:TextFormat = new TextFormat();
format.color = 0xFF0000;
format.font = "comic";//埋め込みフォント指定
format.size = 24;
label.setTextFormat(format);
//ラベルの追加
addChild(label);
}
}
} |