宜昌本地软件开发与弱电工程服务商
项目咨询 · 快速响应
您当前的位置: > 博客2 > AS2与AS3技术

[AS3]as3使用中文字体黑体,隶书,楷体等的源码

2016-10-13 00:16:48 点击量:9 标签: 收藏本文

[AS3]as3使用中文字体黑体,隶书,楷体等的源码

  1. package  
  2.         import flash.display.Bitmap; 
  3.         import flash.display.BitmapData; 
  4.         import flash.display.Sprite; 
  5.         import flash.events.Event; 
  6.         import flash.geom.Matrix; 
  7.         import flash.geom.Point; 
  8.         import flash.geom.Rectangle; 
  9.         import flash.text.TextField; 
  10.         import flash.text.TextFormat; 
  11.          
  12.         /** 
  13.          * ... 
  14.          * @author flashk 
  15.          */ 
  16.         public class TextTextAntiAliasingDemo extends Sprite  
  17.         { 
  18.                 public var a_txt:TextField; 
  19.                 private var bp:Bitmap; 
  20.                 private var bd:BitmapData; 
  21.                 private var quality:Number = 4
  22.                  
  23.                  
  24.                 public function TextTextAntiAliasingDemo() { 
  25.                         a_txt.addEventListener(Event.CHANGE, update); 
  26.                         bp = new Bitmap(); 
  27.                         bp.y = a_txt.y + a_txt.height + 10; 
  28.                         this.addChild(bp); 
  29.                         bd = new BitmapData(a_txt.width*quality, 400*quality); 
  30.                         bp.bitmapData = bd
  31.                         bpbp.scaleX = bp.scaleY = 1 / quality; 
  32.                         bp.smoothing = true
  33.                         bp.x = a_txt.x; 
  34.                         update(); 
  35.                 } 
  36.                 private function update(event:Event=null):void { 
  37.                         var tmpBD:BitmapData = new BitmapData(a_txt.width * quality, a_txt.height * quality, true, 0x00FFFFFF); 
  38.                         var mat:Matrix = new Matrix(); 
  39.                         mat.scale(quality, quality); 
  40.                         tmpBD.draw(a_txt, mat); 
  41.                         bd.fillRect(new Rectangle(0, 0, bd.width, bd.height), 0x00FFFFFF); 
  42.                         bd.draw(tmpBD); 
  43.                          
  44.                         var tf:TextFormat = new TextFormat(); 
  45.                         tf.font = "SimHei"
  46.                         a_txt.setTextFormat(tf); 
  47.                         tmpBD.fillRect(new Rectangle(0, 0, tmpBD.width, tmpBD.height), 0x00FFFFFF); 
  48.                         tmpBD.draw(a_txt, mat); 
  49.                         bd.copyPixels(tmpBD, new Rectangle(0, 0, tmpBD.width, tmpBD.height), new Point(0, 1 * a_txt.height * quality)); 
  50.                          
  51.                          
  52.                         tf.font = "YouYuan"
  53.                         a_txt.setTextFormat(tf); 
  54.                         tmpBD.fillRect(new Rectangle(0, 0, tmpBD.width, tmpBD.height), 0x00FFFFFF); 
  55.                         tmpBD.draw(a_txt, mat); 
  56.                         bd.copyPixels(tmpBD, new Rectangle(0, 0, tmpBD.width, tmpBD.height), new Point(0, 2 * a_txt.height * quality)); 
  57.                          
  58.                         tf.font = "STKaiti"
  59.                         a_txt.setTextFormat(tf); 
  60.                         tmpBD.fillRect(new Rectangle(0, 0, tmpBD.width, tmpBD.height), 0x00FFFFFF); 
  61.                         tmpBD.draw(a_txt, mat); 
  62.                         bd.copyPixels(tmpBD, new Rectangle(0, 0, tmpBD.width, tmpBD.height), new Point(0, 3 * a_txt.height * quality)); 
  63.                          
  64.                         tf.font = "LiSu"
  65.                         a_txt.setTextFormat(tf); 
  66.                         tmpBD.fillRect(new Rectangle(0, 0, tmpBD.width, tmpBD.height), 0x00FFFFFF); 
  67.                         tmpBD.draw(a_txt, mat); 
  68.                         bd.copyPixels(tmpBD, new Rectangle(0, 0, tmpBD.width, tmpBD.height), new Point(0, 4 * a_txt.height * quality)); 
  69.                          
  70.                          
  71.                         tf.font = "FZYaoTi"
  72.                         a_txt.setTextFormat(tf); 
  73.                         tmpBD.fillRect(new Rectangle(0, 0, tmpBD.width, tmpBD.height), 0x00FFFFFF); 
  74.                         tmpBD.draw(a_txt, mat); 
  75.                         bd.copyPixels(tmpBD, new Rectangle(0, 0, tmpBD.width, tmpBD.height), new Point(0, 5 * a_txt.height * quality)); 
  76.                          
  77.                         tf.font = "Microsoft YaHei"
  78.                         a_txt.setTextFormat(tf); 
  79.                         tmpBD.fillRect(new Rectangle(0, 0, tmpBD.width, tmpBD.height), 0x00FFFFFF); 
  80.                         tmpBD.draw(a_txt, mat); 
  81.                         bd.copyPixels(tmpBD, new Rectangle(0, 0, tmpBD.width, tmpBD.height), new Point(0, 6 * a_txt.height * quality)); 
  82.                          
  83.                          
  84.                          
  85.                         tf.font = "SimSun"
  86.                         a_txt.setTextFormat(tf); 
  87.                 } 
  88.         } 
  89.          

 

ABOUT US
宜昌农人网络科技有限公司

我们是一家提供综合软件外包与弱电工程服务的技术公司。

业务涵盖定制软件、管理系统、网站、小程序、APP、系统集成、网络布线、监控安防、门禁、机房建设及长期技术维护。

公司地址:湖北省宜昌市伍家岗区东站二路6号三峡(宜昌)大数据产业园海洋馆二楼A203室