[AS3]as3使用中文字体黑体,隶书,楷体等的源码
[AS3]as3使用中文字体黑体,隶书,楷体等的源码
[AS3]as3使用中文字体黑体,隶书,楷体等的源码
- package
- {
- import flash.display.Bitmap;
- import flash.display.BitmapData;
- import flash.display.Sprite;
- import flash.events.Event;
- import flash.geom.Matrix;
- import flash.geom.Point;
- import flash.geom.Rectangle;
- import flash.text.TextField;
- import flash.text.TextFormat;
- /**
- * ...
- * @author flashk
- */
- public class TextTextAntiAliasingDemo extends Sprite
- {
- public var a_txt:TextField;
- private var bp:Bitmap;
- private var bd:BitmapData;
- private var quality:Number = 4;
- public function TextTextAntiAliasingDemo() {
- a_txt.addEventListener(Event.CHANGE, update);
- bp = new Bitmap();
- bp.y = a_txt.y + a_txt.height + 10;
- this.addChild(bp);
- bd = new BitmapData(a_txt.width*quality, 400*quality);
- bp.bitmapData = bd;
- bpbp.scaleX = bp.scaleY = 1 / quality;
- bp.smoothing = true;
- bp.x = a_txt.x;
- update();
- }
- private function update(event:Event=null):void {
- var tmpBD:BitmapData = new BitmapData(a_txt.width * quality, a_txt.height * quality, true, 0x00FFFFFF);
- var mat:Matrix = new Matrix();
- mat.scale(quality, quality);
- tmpBD.draw(a_txt, mat);
- bd.fillRect(new Rectangle(0, 0, bd.width, bd.height), 0x00FFFFFF);
- bd.draw(tmpBD);
- var tf:TextFormat = new TextFormat();
- tf.font = "SimHei";
- a_txt.setTextFormat(tf);
- tmpBD.fillRect(new Rectangle(0, 0, tmpBD.width, tmpBD.height), 0x00FFFFFF);
- tmpBD.draw(a_txt, mat);
- bd.copyPixels(tmpBD, new Rectangle(0, 0, tmpBD.width, tmpBD.height), new Point(0, 1 * a_txt.height * quality));
- tf.font = "YouYuan";
- a_txt.setTextFormat(tf);
- tmpBD.fillRect(new Rectangle(0, 0, tmpBD.width, tmpBD.height), 0x00FFFFFF);
- tmpBD.draw(a_txt, mat);
- bd.copyPixels(tmpBD, new Rectangle(0, 0, tmpBD.width, tmpBD.height), new Point(0, 2 * a_txt.height * quality));
- tf.font = "STKaiti";
- a_txt.setTextFormat(tf);
- tmpBD.fillRect(new Rectangle(0, 0, tmpBD.width, tmpBD.height), 0x00FFFFFF);
- tmpBD.draw(a_txt, mat);
- bd.copyPixels(tmpBD, new Rectangle(0, 0, tmpBD.width, tmpBD.height), new Point(0, 3 * a_txt.height * quality));
- tf.font = "LiSu";
- a_txt.setTextFormat(tf);
- tmpBD.fillRect(new Rectangle(0, 0, tmpBD.width, tmpBD.height), 0x00FFFFFF);
- tmpBD.draw(a_txt, mat);
- bd.copyPixels(tmpBD, new Rectangle(0, 0, tmpBD.width, tmpBD.height), new Point(0, 4 * a_txt.height * quality));
- tf.font = "FZYaoTi";
- a_txt.setTextFormat(tf);
- tmpBD.fillRect(new Rectangle(0, 0, tmpBD.width, tmpBD.height), 0x00FFFFFF);
- tmpBD.draw(a_txt, mat);
- bd.copyPixels(tmpBD, new Rectangle(0, 0, tmpBD.width, tmpBD.height), new Point(0, 5 * a_txt.height * quality));
- tf.font = "Microsoft YaHei";
- a_txt.setTextFormat(tf);
- tmpBD.fillRect(new Rectangle(0, 0, tmpBD.width, tmpBD.height), 0x00FFFFFF);
- tmpBD.draw(a_txt, mat);
- bd.copyPixels(tmpBD, new Rectangle(0, 0, tmpBD.width, tmpBD.height), new Point(0, 6 * a_txt.height * quality));
- tf.font = "SimSun";
- a_txt.setTextFormat(tf);
- }
- }
- }
热门文章推荐
- [HLS]做自己的m3u8点播系统使用HTTP Live Streaming(HLS技术)
- [FMS]FMS流媒体服务器配置与使用相关的介绍
- [AS3]什么是M3U8,与HTML5的区别是什么
- AS2.0 让flash自适应全屏,并且不自动缩放
- [AS3]as3.0的sound类常用技巧整理
- [AS3]as3与ByteArray详解、ByteArray介绍、ByteArray用法
- 关于RTMP,RTMPT,RTMPS,RTMPE,RTMPTE协议的介绍
- [JS]分享浏览器弹出窗口不被拦截JS示例
请稍候...