system, ttf(true type font)
enum class LabelType {
TTF, // createWithTTF
BMFONT,
CHARMAP,
STRING_TEXTURE,// default
};
enum class LabelEffect {
NORMAL,
OUTLINE,
SHADOW,
GLOW,
ITALICS,
BOLD,
UNDERLINE,
STRIKETHROUGH, // 删除线
ALL
};
STRING_TEXTURE
使用系统将整个文字绘制成一张纹理,然后贴到sprite上渲染。
Sprite* _textSprite;
Sprite* _shadowNode;
TTF
-
fontSize, outlineSize, fontName
作为FontAtlas的key - fontAtlas将使用到的字符分别渲染到一个512512的texture上,如果这个texture满了,就再开辟一个512512的texture。
- 根据fontAtlas的纹理数量,创建对等数量的SpriteBatchNode
- 处理文本换行
- 更新四边形顶点,将每个字符的信息更新到SpriteBatchNode
- 渲染的时候先绑定纹理,然后将quads数据一次提交,完成最终的渲染
CHARMAP
按照anscii码的顺序依次罗列字母和对应的纹理,渲染时也借助了fontAtlas
fontAtlas.texture的key就是plist文件名

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>version</key>
<integer>1</integer>
<key>textureFilename</key>
<string>tuffy_bold_italic-charmap-hd.png</string>
<key>itemHeight</key>
<integer>128</integer>
<key>itemWidth</key>
<integer>96</integer>
<key>firstChar</key>
<integer>32</integer>
</dict>
</plist>
BMFont
和charmap同理,只是配置文件数据格式不太一样而已
creator处理
- render/utils/label/bmfont.js
-
render/utils/label/letter-font.js

网友评论