2013-04-09 116 views
0

我有一個繪製文本字段的位圖數據。縮放之後,文本會變形。 我使用下面的代碼:textField中的扭曲

// tf is text Field and bm is bitmap. 
var tf:TextField = new TextField(); 
tf.text = "Hello world"; 
var bd:BitmapData = new BitmapData(200, 200, true, 0x00ff00); 
bd.draw(tf); 
var bm:Bitmap = new Bitmap(bd); 
addChild(bm); 
bm.scaleX = 2; 
bm.scaleY = 2; 

請指導我。

回答

0

首先,增加字體大小,然後轉化和規模作爲位像這樣,

//---- Text format ---- 
var textFormat:TextFormat = new TextFormat(); 
textFormat.font = "Arial"; 
//textFormat.bold = true; 
textFormat.size = 40; 
//--------------------------------------------- 

// 
var tf:TextField = new TextField(); 
tf.text = "Hello world"; 
/*tf.antiAliasType = AntiAliasType.ADVANCED; 
tf.gridFitType = GridFitType.PIXEL; 
tf.thickness = 0; 
tf.sharpness = 0;*/ 
tf.setTextFormat(textFormat); 
// 

// 
var bd:BitmapData = new BitmapData(200,200,true,0x00ff00); 
bd.draw(tf); 
var bm:Bitmap = new Bitmap(bd); 
bm.smoothing = true; 
addChild(bm); 

bm.scaleX = 2; 
bm.scaleY = 2; 

祝您好運。

+0

使用此代碼文本獲取失真。 – 2013-04-09 10:49:23

+0

使用Vesper的技巧。 – 2013-04-09 10:54:05

1

您應該使用變換矩陣將放大的文本字段(或任何其他矢量圖形對象)繪製到BitmapData上。

var mat:Matrix=new Matrix(); 
mat.scale(2.0,2.0); 
bd.draw(tf,mat); 
+0

好戲。感謝分享。 – 2013-04-09 10:52:35