MCPcopy Create free account
hub / github.com/axmolengine/axmol / LabelTTFCJKWrappingTest

Method LabelTTFCJKWrappingTest

tests/cpp-tests/Source/LabelTest/LabelTest.cpp:1133–1177  ·  view source on GitHub ↗

NewLabelTTF Chinese/Japanese/Korean wrapping test

Source from the content-addressed store, hash-verified

1131// NewLabelTTF Chinese/Japanese/Korean wrapping test
1132//
1133LabelTTFCJKWrappingTest::LabelTTFCJKWrappingTest()
1134{
1135 auto size = Director::getInstance()->getWinSize();
1136
1137 auto drawNode = DrawNode::create();
1138 drawNode->setAnchorPoint(Vec2(0, 0));
1139 this->addChild(drawNode);
1140 drawNode->drawSegment(Vec2(size.width * 0.1f, size.height * 0.8f), Vec2(size.width * 0.1, 0.0f), 1,
1141 Color4F(1.0f, 0.0f, 0.0f, 1.0f));
1142 drawNode->drawSegment(Vec2(size.width * 0.85f, size.height * 0.8f), Vec2(size.width * 0.85f, 0.0f), 1,
1143 Color4F(1.0f, 0.0f, 0.0f, 1.0f));
1144
1145 TTFConfig ttfConfig("fonts/HKYuanMini.ttf", 25, GlyphCollection::DYNAMIC);
1146 auto label1 = Label::createWithTTF(ttfConfig, "你好,Axmol Label.", TextHAlignment::LEFT, size.width * 0.75f);
1147 if (label1)
1148 {
1149 label1->setTextColor(Color4B(128, 255, 255, 255));
1150 label1->setPosition(Vec2(size.width * 0.1f, size.height * 0.6f));
1151 label1->setAnchorPoint(Vec2(0.0f, 0.5f));
1152 this->addChild(label1);
1153 // Demo for unloadFontAtlasTTF function, after it been called, all UI widget
1154 // use the special font must reset font, because the old one is invalid.
1155 FontAtlasCache::unloadFontAtlasTTF("fonts/HKYuanMini.ttf");
1156 label1->setTTFConfig(ttfConfig);
1157 }
1158
1159 auto label2 = Label::createWithTTF(ttfConfig, "早上好,Axmol Label.", TextHAlignment::LEFT, size.width * 0.75f);
1160 if (label2)
1161 {
1162 label2->setTextColor(Color4B(255, 128, 255, 255));
1163 label2->setPosition(Vec2(size.width * 0.1f, size.height * 0.4f));
1164 label2->setAnchorPoint(Vec2(0.0f, 0.5f));
1165 this->addChild(label2);
1166 }
1167
1168 auto label3 = Label::createWithTTF(ttfConfig, "美好的一天啊美好的一天啊美好的一天啊", TextHAlignment::LEFT,
1169 size.width * 0.75f);
1170 if (label3)
1171 {
1172 label3->setTextColor(Color4B(255, 255, 128, 255));
1173 label3->setPosition(Vec2(size.width * 0.1f, size.height * 0.2f));
1174 label3->setAnchorPoint(Vec2(0.0f, 0.5f));
1175 this->addChild(label3);
1176 }
1177}
1178
1179std::string LabelTTFCJKWrappingTest::title() const
1180{

Callers

nothing calls this directly

Calls 11

getInstanceFunction · 0.85
createFunction · 0.85
Color4BFunction · 0.85
drawSegmentMethod · 0.80
setTTFConfigMethod · 0.80
Vec2Function · 0.50
Color4FFunction · 0.50
setAnchorPointMethod · 0.45
addChildMethod · 0.45
setTextColorMethod · 0.45
setPositionMethod · 0.45

Tested by

no test coverage detected