26#include "../testResource.h"
27#include "2d/CCFontAtlasCache.h"
28#include "2d/CCFontFreeType.h"
46 "fonts/A Damn Mess.ttf",
47 "fonts/Abberancy.ttf",
48 "fonts/Abduction.ttf",
49 "fonts/Paint Boy.ttf",
50 "fonts/Schwarzwald.ttf",
51 "fonts/Scissor Cuts.ttf",
58 TextVAlignment::CENTER,
59 TextVAlignment::BOTTOM,
85 auto s = Director::getInstance()->getWinSize();
87 auto blockSize = Size(s.width/3, 200);
98 auto top = Label::createWithSystemFont(fontFile, fontFile, 24);
99 auto left = Label::createWithSystemFont(
"alignment left", fontFile, fontSize,
101 auto center = Label::createWithSystemFont(
"alignment center", fontFile, fontSize,
103 auto right = Label::createWithSystemFont(
"alignment right", fontFile, fontSize,
106 auto leftColor = LayerColor::create(Color4B(100, 100, 100, 255), blockSize.width, blockSize.height);
107 auto centerColor = LayerColor::create(Color4B(200, 100, 100, 255), blockSize.width, blockSize.height);
108 auto rightColor = LayerColor::create(Color4B(100, 100, 200, 255), blockSize.width, blockSize.height);
110 leftColor->setIgnoreAnchorPointForPosition(
false);
111 centerColor->setIgnoreAnchorPointForPosition(
false);
112 rightColor->setIgnoreAnchorPointForPosition(
false);
115 top->setAnchorPoint(Vec2(0.5, 1));
116 left->setAnchorPoint(Vec2(0,0.5));
117 leftColor->setAnchorPoint(Vec2(0,0.5));
118 center->setAnchorPoint(Vec2(0,0.5));
119 centerColor->setAnchorPoint(Vec2(0,0.5));
120 right->setAnchorPoint(Vec2(0,0.5));
121 rightColor->setAnchorPoint(Vec2(0,0.5));
123 top->setPosition(s.width/2,s.height-20);
124 left->setPosition(0,s.height/2);
125 leftColor->setPosition(left->getPosition());
126 center->setPosition(blockSize.width, s.height/2);
127 centerColor->setPosition(center->getPosition());
128 right->setPosition(blockSize.width*2, s.height/2);
129 rightColor->setPosition(right->getPosition());
148 if (ret && ret->init())
169 FontAtlasCache::unloadFontAtlasTTF(
"fonts/A Damn Mess.ttf");
170 FontFreeType::releaseFont(
"fonts/A Damn Mess.ttf");
171 FontAtlasCache::unloadFontAtlasTTF(
"fonts/Abberancy.ttf");
172 FontFreeType::releaseFont(
"fonts/Abberancy.ttf");
173 FontAtlasCache::unloadFontAtlasTTF(
"fonts/Abduction.ttf");
174 FontFreeType::releaseFont(
"fonts/Abduction.ttf");
175 FontAtlasCache::unloadFontAtlasTTF(
"fonts/Schwarzwald.ttf");
176 FontFreeType::releaseFont(
"fonts/Schwarzwald.ttf");
177 FileUtils::getInstance()->setFilenameLookupDictionary(ValueMap());
188 {
"fonts/A Damn Mess.ttf", Value(
"fonts/arial.ttf") },
189 {
"fonts/Abberancy.ttf", Value(
"fonts/arial.ttf") },
190 {
"fonts/Abduction.ttf", Value(
"fonts/arial.ttf") },
191 {
"fonts/Schwarzwald.ttf", Value(
"fonts/arial.ttf") }
194 FileUtils::getInstance()->setFilenameLookupDictionary(dict);
195 suffix =
" replaced by arial.ttf";
198 auto s = Director::getInstance()->getWinSize();
200 auto blockSize = Size(s.width / 3, 200);
211 auto top = Label::createWithTTF(
"fonts/A Damn Mess.ttf" + suffix,
"fonts/A Damn Mess.ttf", 24);
212 auto left = Label::createWithTTF(
"fonts/Abberancy.ttf" + suffix,
"fonts/Abberancy.ttf", fontSize,
214 auto center = Label::createWithTTF(
"fonts/Abduction.ttf" + suffix,
"fonts/Abduction.ttf", fontSize,
216 auto right = Label::createWithTTF(
"fonts/Schwarzwald.ttf" + suffix,
"fonts/Schwarzwald.ttf", fontSize,
219 auto leftColor = LayerColor::create(Color4B(100, 100, 100, 255), blockSize.width, blockSize.height);
220 auto centerColor = LayerColor::create(Color4B(200, 100, 100, 255), blockSize.width, blockSize.height);
221 auto rightColor = LayerColor::create(Color4B(100, 100, 200, 255), blockSize.width, blockSize.height);
223 leftColor->setIgnoreAnchorPointForPosition(
false);
224 centerColor->setIgnoreAnchorPointForPosition(
false);
225 rightColor->setIgnoreAnchorPointForPosition(
false);
227 top->setAnchorPoint(Vec2(0.5, 1));
228 left->setAnchorPoint(Vec2(0, 0.5));
229 leftColor->setAnchorPoint(Vec2(0, 0.5));
230 center->setAnchorPoint(Vec2(0, 0.5));
231 centerColor->setAnchorPoint(Vec2(0, 0.5));
232 right->setAnchorPoint(Vec2(0, 0.5));
233 rightColor->setAnchorPoint(Vec2(0, 0.5));
235 top->setPosition(s.width / 2, s.height - 20);
236 left->setPosition(0, s.height / 2);
237 leftColor->setPosition(left->getPosition());
238 center->setPosition(blockSize.width, s.height / 2);
239 centerColor->setPosition(center->getPosition());
240 right->setPosition(blockSize.width * 2, s.height / 2);
241 rightColor->setPosition(right->getPosition());
254 return "Font no replacement test";
260 if (ret && ret->init())
280 return "Font replacement test";
#define ADD_TEST_CASE(__className__)
static TextVAlignment verticalAlignment[]
static std::string fontList[]
virtual std::string title() const override
virtual void onEnter() override
static FontNoReplacementTest * create()
static FontReplacementTest * create()
virtual std::string title() const override
static FontTest * create(const std::string &fontFile)
void showFont(const std::string &fontFile)
virtual std::string title() const override
virtual void onEnter() override