Egret之位图字体

1 , 关于位图字体的制作
Egret之位图字体

2 , egret官方提供的资源
Egret之位图字体

看看cartoon-font.fnt的内容

{"file":"cartoon-font.png","frames":{
"A":{"x":1,"y":54,"w":21,"h":24,"offX":2,"offY":11,"sourceW":23,"sourceH":35},
"B":{"x":195,"y":29,"w":22,"h":26,"offX":2,"offY":10,"sourceW":24,"sourceH":36},
"C":{"x":31,"y":33,"w":20,"h":26,"offX":2,"offY":10,"sourceW":22,"sourceH":36},
"D":{"x":171,"y":1,"w":24,"h":26,"offX":2,"offY":10,"sourceW":26,"sourceH":36},
"E":{"x":108,"y":55,"w":19,"h":24,"offX":2,"offY":11,"sourceW":21,"sourceH":35},
"F":{"x":167,"y":80,"w":18,"h":24,"offX":2,"offY":11,"sourceW":20,"sourceH":35},
"G":{"x":197,"y":1,"w":23,"h":26,"offX":2,"offY":10,"sourceW":25,"sourceH":36},
"H":{"x":143,"y":1,"w":26,"h":24,"offX":2,"offY":11,"sourceW":28,"sourceH":35},
"I":{"x":235,"y":141,"w":13,"h":24,"offX":2,"offY":11,"sourceW":15,"sourceH":35},
"J":{"x":205,"y":107,"w":15,"h":25,"offX":2,"offY":11,"sourceW":17,"sourceH":36},
"K":{"x":117,"y":1,"w":24,"h":26,"offX":2,"offY":10,"sourceW":26,"sourceH":36},
"L":{"x":147,"y":55,"w":18,"h":24,"offX":2,"offY":11,"sourceW":20,"sourceH":35},
"M":{"x":1,"y":27,"w":28,"h":25,"offX":2,"offY":11,"sourceW":30,"sourceH":36},
"N":{"x":193,"y":57,"w":22,"h":24,"offX":2,"offY":11,"sourceW":24,"sourceH":35},
"O":{"x":91,"y":1,"w":24,"h":26,"offX":2,"offY":10,"sourceW":26,"sourceH":36},
"P":{"x":219,"y":54,"w":22,"h":25,"offX":2,"offY":10,"sourceW":24,"sourceH":35},
"Q":{"x":37,"y":1,"w":24,"h":30,"offX":2,"offY":10,"sourceW":26,"sourceH":40},
"R":{"x":143,"y":27,"w":23,"h":26,"offX":2,"offY":10,"sourceW":25,"sourceH":36},
"S":{"x":128,"y":107,"w":16,"h":26,"offX":3,"offY":10,"sourceW":19,"sourceH":36},
"T":{"x":86,"y":29,"w":21,"h":24,"offX":2,"offY":11,"sourceW":23,"sourceH":35},
"U":{"x":222,"y":27,"w":23,"h":25,"offX":2,"offY":11,"sourceW":25,"sourceH":36},
"V":{"x":217,"y":81,"w":22,"h":24,"offX":2,"offY":11,"sourceW":24,"sourceH":35},
"W":{"x":1,"y":1,"w":34,"h":24,"offX":2,"offY":11,"sourceW":36,"sourceH":35},
"X":{"x":222,"y":1,"w":24,"h":24,"offX":2,"offY":11,"sourceW":26,"sourceH":35},
"Y":{"x":168,"y":54,"w":23,"h":24,"offX":2,"offY":11,"sourceW":25,"sourceH":35},
"Z":{"x":109,"y":29,"w":21,"h":24,"offX":2,"offY":11,"sourceW":23,"sourceH":35},
"0":{"x":86,"y":55,"w":20,"h":25,"offX":2,"offY":10,"sourceW":22,"sourceH":35},
"1":{"x":235,"y":114,"w":13,"h":25,"offX":2,"offY":10,"sourceW":15,"sourceH":35},
"2":{"x":146,"y":140,"w":16,"h":24,"offX":2,"offY":11,"sourceW":18,"sourceH":35},
"3":{"x":146,"y":113,"w":16,"h":25,"offX":3,"offY":10,"sourceW":19,"sourceH":35},
"4":{"x":1,"y":80,"w":19,"h":24,"offX":2,"offY":11,"sourceW":21,"sourceH":35},
"5":{"x":164,"y":132,"w":17,"h":24,"offX":2,"offY":11,"sourceW":19,"sourceH":35},
"6":{"x":108,"y":81,"w":18,"h":25,"offX":2,"offY":10,"sourceW":20,"sourceH":35},
"7":{"x":164,"y":106,"w":17,"h":24,"offX":3,"offY":11,"sourceW":20,"sourceH":35},
"8":{"x":24,"y":61,"w":19,"h":25,"offX":2,"offY":10,"sourceW":21,"sourceH":35},
"9":{"x":53,"y":56,"w":19,"h":26,"offX":2,"offY":10,"sourceW":21,"sourceH":36},
"a":{"x":1,"y":54,"w":21,"h":24,"offX":2,"offY":11,"sourceW":23,"sourceH":35},
"b":{"x":195,"y":29,"w":22,"h":26,"offX":2,"offY":10,"sourceW":24,"sourceH":36},
"c":{"x":31,"y":33,"w":20,"h":26,"offX":2,"offY":10,"sourceW":22,"sourceH":36},
"d":{"x":171,"y":1,"w":24,"h":26,"offX":2,"offY":10,"sourceW":26,"sourceH":36},
"e":{"x":108,"y":55,"w":19,"h":24,"offX":2,"offY":11,"sourceW":21,"sourceH":35},
"f":{"x":167,"y":80,"w":18,"h":24,"offX":2,"offY":11,"sourceW":20,"sourceH":35},
"g":{"x":197,"y":1,"w":23,"h":26,"offX":2,"offY":10,"sourceW":25,"sourceH":36},
"h":{"x":143,"y":1,"w":26,"h":24,"offX":2,"offY":11,"sourceW":28,"sourceH":35},
"i":{"x":235,"y":141,"w":13,"h":24,"offX":2,"offY":11,"sourceW":15,"sourceH":35},
"j":{"x":205,"y":107,"w":15,"h":25,"offX":2,"offY":11,"sourceW":17,"sourceH":36},
"k":{"x":117,"y":1,"w":24,"h":26,"offX":2,"offY":10,"sourceW":26,"sourceH":36},
"l":{"x":147,"y":55,"w":18,"h":24,"offX":2,"offY":11,"sourceW":20,"sourceH":35},
"m":{"x":1,"y":27,"w":28,"h":25,"offX":2,"offY":11,"sourceW":30,"sourceH":36},
"n":{"x":193,"y":57,"w":22,"h":24,"offX":2,"offY":11,"sourceW":24,"sourceH":35},
"o":{"x":91,"y":1,"w":24,"h":26,"offX":2,"offY":10,"sourceW":26,"sourceH":36},
"p":{"x":219,"y":54,"w":22,"h":25,"offX":2,"offY":10,"sourceW":24,"sourceH":35},
"q":{"x":37,"y":1,"w":24,"h":30,"offX":2,"offY":10,"sourceW":26,"sourceH":40},
"r":{"x":143,"y":27,"w":23,"h":26,"offX":2,"offY":10,"sourceW":25,"sourceH":36},
"s":{"x":128,"y":107,"w":16,"h":26,"offX":3,"offY":10,"sourceW":19,"sourceH":36},
"t":{"x":86,"y":29,"w":21,"h":24,"offX":2,"offY":11,"sourceW":23,"sourceH":35},
"u":{"x":222,"y":27,"w":23,"h":25,"offX":2,"offY":11,"sourceW":25,"sourceH":36},
"v":{"x":217,"y":81,"w":22,"h":24,"offX":2,"offY":11,"sourceW":24,"sourceH":35},
"w":{"x":1,"y":1,"w":34,"h":24,"offX":2,"offY":11,"sourceW":36,"sourceH":35},
"x":{"x":222,"y":1,"w":24,"h":24,"offX":2,"offY":11,"sourceW":26,"sourceH":35},
"y":{"x":168,"y":54,"w":23,"h":24,"offX":2,"offY":11,"sourceW":25,"sourceH":35},
"z":{"x":109,"y":29,"w":21,"h":24,"offX":2,"offY":11,"sourceW":23,"sourceH":35},
",":{"x":247,"y":34,"w":8,"h":11,"offX":3,"offY":29,"sourceW":11,"sourceH":40},
".":{"x":213,"y":157,"w":9,"h":6,"offX":3,"offY":30,"sourceW":12,"sourceH":36},
"~":{"x":213,"y":151,"w":18,"h":4,"offX":4,"offY":21,"sourceW":22,"sourceH":25},
"\"":{"x":183,"y":155,"w":10,"h":11,"offX":4,"offY":11,"sourceW":14,"sourceH":22},
"!":{"x":243,"y":54,"w":11,"h":25,"offX":4,"offY":11,"sourceW":15,"sourceH":36},
"|":{"x":248,"y":1,"w":7,"h":31,"offX":3,"offY":8,"sourceW":10,"sourceH":39},
"\\":{"x":147,"y":83,"w":15,"h":28,"offX":2,"offY":9,"sourceW":17,"sourceH":37},
";":{"x":132,"y":29,"w":9,"h":21,"offX":4,"offY":19,"sourceW":13,"sourceH":40},
":":{"x":205,"y":83,"w":9,"h":17,"offX":4,"offY":19,"sourceW":13,"sourceH":36},
"<":{"x":200,"y":134,"w":12,"h":12,"offX":3,"offY":17,"sourceW":15,"sourceH":29},
">":{"x":183,"y":141,"w":12,"h":12,"offX":3,"offY":17,"sourceW":15,"sourceH":29},
"?":{"x":187,"y":83,"w":16,"h":26,"offX":3,"offY":10,"sourceW":19,"sourceH":36},
"+":{"x":183,"y":127,"w":15,"h":12,"offX":4,"offY":18,"sourceW":19,"sourceH":30},
"_":{"x":164,"y":158,"w":17,"h":3,"offX":2,"offY":37,"sourceW":19,"sourceH":40},
"=":{"x":197,"y":148,"w":14,"h":9,"offX":4,"offY":19,"sourceW":18,"sourceH":28},
"-":{"x":164,"y":163,"w":11,"h":5,"offX":4,"offY":25,"sourceW":15,"sourceH":30},
")":{"x":222,"y":107,"w":11,"h":31,"offX":4,"offY":7,"sourceW":15,"sourceH":38},
"#":{"x":128,"y":85,"w":17,"h":20,"offX":3,"offY":13,"sourceW":20,"sourceH":33},
"$":{"x":129,"y":55,"w":16,"h":28,"offX":2,"offY":9,"sourceW":18,"sourceH":37},
"%":{"x":63,"y":1,"w":26,"h":26,"offX":2,"offY":10,"sourceW":28,"sourceH":36},
"^":{"x":214,"y":140,"w":15,"h":9,"offX":5,"offY":18,"sourceW":20,"sourceH":27},
"&":{"x":63,"y":29,"w":21,"h":25,"offX":2,"offY":11,"sourceW":23,"sourceH":36},
"*":{"x":183,"y":111,"w":14,"h":14,"offX":3,"offY":11,"sourceW":17,"sourceH":25},
"(":{"x":241,"y":81,"w":12,"h":31,"offX":3,"offY":7,"sourceW":15,"sourceH":38},
"@":{"x":168,"y":29,"w":25,"h":23,"offX":2,"offY":12,"sourceW":27,"sourceH":35},
"'":{"x":53,"y":33,"w":5,"h":11,"offX":4,"offY":11,"sourceW":9,"sourceH":22}}}

实际上是Json文件 , 文本对应的是Json的Key

3 , 资源加载
Egret之位图字体

4 , 核心代码

module demo{/*** 测试位图字体* @author Husz*/export class BitMapTextView extends egret.DisplayObjectContainer{private _bitmapText : egret.BitmapText = null;private _bitmapFont : egret.BitmapFont = null;public constructor(){super();this._bitmapText = new egret.BitmapText();this._bitmapFont = RES.getRes("cartoon-font_fnt");this._bitmapText.font = this._bitmapFont;this._bitmapText.x = this._bitmapText.y = 150;this.addChild( this._bitmapText ); }/*** 显示文本*/public showText( $str : string ) : void{this._bitmapText.text = $str;}}
}

调用:

            let $demo : BitMapTextView = new BitMapTextView();this.addChild($demo);$demo.showText("I am Aonaufly!");

结果:
Egret之位图字体

官方:

/*** 以下示例演示了使用 BitmapText 显示特殊字体。*/
class BitmapFontExample extends egret.DisplayObjectContainer {public constructor() {super();RES.getResByUrl("resource/assets/font.fnt", this.onLoadComplete, this,RES.ResourceItem.TYPE_FONT);}private onLoadComplete(font:egret.BitmapFont):void {var bitmapText:egret.BitmapText = new egret.BitmapText();bitmapText.font = font;this.addChild(bitmapText);bitmapText.text = "Hello Egret";}
}

转载于:https://blog.51cto.com/aonaufly/2067382

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/255549.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【机器视觉】——平面测量实际尺寸(像素尺寸转物理尺寸)

目录 方法一:比例尺法 方法:二:三角法 方法三:相机标定 以下方法均在平面的前提下进行 方法一:比例尺法 在一张纸上绘制一个带刻度的直线,将纸张放在摄像头下,抓取任意两点的像素坐标,计算像素距离pd,再根据刻度读取实际距离ad,根据两者可以求出缩放比例,即地图上…

图像处理基本算法-滤波

线性滤波器的向量表示&#xff1a; W是一个大小为m*n的滤波器的系数&#xff0c;Z为由滤波器覆盖的相应图像的灰度值。 线性滤波器所能是实现的就是乘积求和操作。 几种常见的滤波器&#xff1a; 平滑空间滤波器如均值滤波 统计排序滤波器如中值滤波 锐化空间滤波器如锐化…

20145122《Java面向对象程序设计》实验二实验报告

实验名称&#xff1a; Java面向对象程序设计 实验内容&#xff1a; 初步掌握单元测试和TDD理解并掌握面向对象三要素&#xff1a;封装、继承、多态初步掌握UML建模熟悉S.O.L.I.D原则了解设计模式 PSP时间 步骤耗时百分比需求分析1h12.5%设计1h12.5%代码实现3h37.5%测试1h12.5%分…

iOS中AutoLayer自动布局流程及相关方法

关于UIView的Layer&#xff0c;IOS提供了三个方法&#xff1a; 1、layoutSubviews 系统重写布局:在iOS5.1和之前的版本&#xff0c;此方法的缺省实现不会做任何事情(实现为空)&#xff0c;iOS5.1之后(iOS6开始)的版本&#xff0c;此方法的缺省实现是使用你设置在此view上面的co…

移动开发web第一天

一、适配问题解决方案&#xff1a;流式布局 viewport1、流式布局百分比布局&#xff0c;通过设置盒子的宽度为百分比来根据屏幕的大小进行伸缩&#xff0c;特点是不受固定像素的限制&#xff0c;内容向两侧填充2、viewport在移动端用来承载网页的这个区域&#xff0c;就是我们…

均值滤波 中值滤波 高斯平滑滤波

均值滤波是典型的线性滤波算法&#xff0c;它是指在图像上对目标像素给一个模板&#xff0c;该模板包括了其周围的临近像素&#xff08;以目标象素为中心的周围8个像素&#xff0c;构成一个滤波模板&#xff0c;即去掉目标像素本身&#xff09;&#xff0c;再用模板中的全体像素…

javaWeb开发总结 ---- 前端数据插入到后台

一&#xff0c;概述&#xff1a; 本文主要描述如何将数据通过表单提交到后台并插入到数据库&#xff0e;其中后台使用spring框架&#xff0e; 二&#xff0c;开发流程&#xff1a; 明确需求&#xff0c;即将什么数据插入到数据库平台搭建&#xff0c;配置spring, 数据库&#…

对clear float 的理解

之前自己对于清除浮动的用法比较模糊 &#xff0c;如果用到的话&#xff0c;一般都是采用简单粗暴的方式解决&#xff0c;就是直接用overflow&#xff1a;hidden&#xff0c;但是越用久就会发现其实有BUG&#xff0c;这个BUG正是overflow&#xff1a;hidden带来的&#xff0c;因…

【机器视觉】——相机标定降低重投影误差方法

目录 一、标定结果分析 二、影响标定误差的原因 1、平面标定板黑白棋盘格的精度

linux 安装RedisLive

为什么80%的码农都做不了架构师&#xff1f;>>> RedisLive 用来监控Redis&#xff0c;便于redis性能分析 安装步骤&#xff1a; 1.安装pip&#xff08;代码参考&#xff1a;https://github.com/pypa/pip&#xff09; 官方网站&#xff1a;https://pypi.python.org/…

高斯滤波和双向滤波的区别与联系

1. 简介 图像平滑是一个重要的操作&#xff0c;而且有多种成熟的算法。这里主要简单介绍一下Bilateral方法&#xff08;双边滤波&#xff09;&#xff0c;这主要是由于前段时间做了SSAO&#xff0c;需要用bilateral blur 算法进行降噪。Bilateral blur相对于传统的高斯blur来说…

Eclipse变量名自动补全问题 自定义上屏按键为TAB

Eclipse空格等号等都可以上屏&#xff0c;这样有时候输入变量名再按空格就会自动补全&#xff0c;非常讨厌。那么怎么办呢&#xff1f; 1.首先你的Eclipse需要装有 Eclipse plug-in development environment 和 Eclipse JDT Plug-in Developer Resources 或者直接去下载一个和…

Dreamweaver CS6 Mac破解版

介于之前小子分享的Mac版的Adobe的PS CS6和Illustrator CS6&#xff0c;有用户要求小子分享下Dreamweaver&#xff0c;小子当然乐意效劳。 Dreamweaver CS6 是世界顶级软件厂商Adobe推出的一套拥有可视化编辑界面&#xff0c;用于制作并编辑网站和移动应用程序的网页设计软件。…

【pyqt5学习】——graphicView显示matplotlib图像

目录 一、导入模块 二、自定义一个matplotlib窗口类Figure 三、利用QT_designer绘制窗口 四、写逻辑代码 五、结果展示 一、导入模块 import matplotlibmatplotlib.use("Qt5Agg") from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg from matplo…

happens-before规则

1&#xff09;程序顺序规则&#xff1a;一个线程中的每个操作&#xff0c;happens-before于该线程中的任意后续操作。2&#xff09;监视器锁规则&#xff1a;对一个锁的解锁&#xff0c;happens-before于随后对这个锁的加锁。3&#xff09;volatile变量规则&#xff1a;对一个v…

what is ssao

说到ssao 就要从ao说起&#xff0c;ao&#xff0c;即间接环境光遮蔽技术。我们知道现实中的光线&#xff0c;除了来自太阳和电灯的直射光线以外&#xff0c;光线碰到物体以后&#xff0c;还会再次反射&#xff0c;折射&#xff0c;而再次反射折射的过程中&#xff0c;又会被其他…

【pyqt5学习】——groupBox显示matplotlib图像

目录 一、导入模块 二、创建matplotlib窗口类 三、qt_designer设计窗口 四、逻辑代码 五、结果展示 一、导入模块 import matplotlibmatplotlib.use("Qt5Agg") from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg from matplotlib.figure impor…

[BZOJ3545][ONTAK2010]Peaks

[BZOJ3545][ONTAK2010]Peaks 试题描述 在Bytemountains有N座山峰&#xff0c;每座山峰有他的高度h_i。有些山峰之间有双向道路相连&#xff0c;共M条路径&#xff0c;每条路径有一个困难值&#xff0c;这个值越大表示越难走&#xff0c;现在有Q组询问&#xff0c;每组询问询问从…

杭电1027Ignatius and the Princess II模拟

地址&#xff1a;http://acm.hdu.edu.cn/showproblem.php?pid1027 题目&#xff1a; Problem DescriptionNow our hero finds the door to the BEelzebub feng5166. He opens the door and finds feng5166 is about to kill our pretty Princess. But now the BEelzebub has t…