10
11
12
13
14
15
16
17
18
19
20
21
typedef
struct
_ttfConfig
{
std::stringfontFilePath;
int
fontSize;
GlyphCollectionglyphs;
const
char
*customGlyphs;
bool
distanceFieldEnabled;
outlineSize;
_ttfConfig(
*filePath=
""
size=12,
GlyphCollection&glyphCollection=GlyphCollection::DYNAMIC,
*customGlyphCollection=nullptr,
useDistanceField=
false
outline=0
);
}TTFConfig;
|
TTFConfig&ttfConfig,0)!important; background:none!important">//TTFConfig配置
TextHAlignmentalignment=TextHAlignment::LEFT,monospace!important; font-size:1em!important; min-height:inherit!important; background:none!important">maxLineWidth=0
);
|
TTFConfigttfConfig;
ttfConfig.fontFilePath=
"fonts/MarkerFelt.ttf"
;
ttfConfig.fontSize=12;
ttfConfig.distanceFieldEnabled=
;
ttfConfig.outlineSize=0;
ttfConfig.glyphs=GlyphCollection::DYNAMIC;
ttfConfig.customGlyphs=nullptr;
//使用TTFConfig配置,来创建TTF
Label*lb3=Label::createWithTTF(ttfConfig,monospace!important; font-size:1em!important; min-height:inherit!important; background:none!important">);
|
//charMapFile:字符资源图片png
//itemWidth:每个字符的宽
//itemHeight:每个字符的高
//startCharMap:图片第一个是什么字符
Label*createWithCharMap(
std::string&charMapFile,
itemWidth,monospace!important; font-size:1em!important; min-height:inherit!important; background:none!important">itemHeight,monospace!important; font-size:1em!important; min-height:inherit!important; background:none!important">startCharMap);
Label*createWithCharMap(Texture2D*texture,monospace!important; font-size:1em!important; min-height:inherit!important; background:none!important">startCharMap);
std::string&plistFile);
|
//create字符图片.png,每个字符宽,高,起始字符
Label*lb4=Label::createWithCharMap(
"fonts/digit.png"
'0'
);
lb4->setString(
"123456"
);
|
//创建图片纹理Texture2D
Texture2D*texture=TextureCache::getInstance()->addImage(
Label*lb5=Label::createWithCharMap(texture,monospace!important; font-size:1em!important; min-height:inherit!important; background:none!important">);
lb5->setString(
//设置字符串内容
|
//
<?
xml
version
=
"1.0"
encoding
"UTF-8"
?>
<!DOCTYPEplistPUBLIC"-//Apple//DTDPLIST1.0//EN""http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<
plist
"1.0"
>
dict
>
key
>version</
>
integer
>1</
>
>textureFilename</
<!--字符图片资源:digit.png-->
string
>digit.png</
>
>itemWidth</
<!--每个字符的宽:20-->
>20</
>
>itemHeight</
<!--每个字符的高:20-->
>
>firstChar</
<!--起始字符:'0'-->
>48</
>
</
>
plist
>
//
|