| 1381 | return "Testing rendering Title of Button on DistanceField"; |
| 1382 | } |
| 1383 | LabelTTFSDF::LabelTTFSDF() |
| 1384 | { |
| 1385 | auto size = Director::getInstance()->getWinSize(); |
| 1386 | |
| 1387 | FontFreeType::setGlobalSDFEnabled(false); |
| 1388 | Label* title = Label::createWithTTF("Normal", "fonts/Marker Felt.ttf", 20); |
| 1389 | this->addChild(title); |
| 1390 | title->setPosition(Vec2(size.width * 3 / 4, size.height * 0.75)); |
| 1391 | _labelNormal = Label::createWithTTF("Should be the same", "fonts/Marker Felt.ttf", 20); |
| 1392 | this->addChild(_labelNormal); |
| 1393 | _labelNormal->setPosition(Vec2(size.width * 3 / 4, size.height * 0.65)); |
| 1394 | |
| 1395 | FontFreeType::setGlobalSDFEnabled(true); |
| 1396 | title = Label::createWithTTF("SDF", "fonts/Marker Felt.ttf", 20); |
| 1397 | this->addChild(title); |
| 1398 | title->setPosition(Vec2(size.width / 4, size.height * 0.75)); |
| 1399 | _labelSDF = Label::createWithTTF("Should be the same", "fonts/Marker Felt.ttf", 20); |
| 1400 | this->addChild(_labelSDF); |
| 1401 | _labelSDF->setPosition(Vec2(size.width / 4, size.height * 0.65)); |
| 1402 | auto config = _labelSDF->getTTFConfig(); |
| 1403 | config.distanceFieldEnabled = true; |
| 1404 | _labelSDF->setTTFConfig(config); |
| 1405 | |
| 1406 | initToggleLabel("enableItalics", Vec2(size.width * 0.15, size.height * 0.25), |
| 1407 | [=, this](Object* obj, ax::ui::CheckBox::EventType type) { |
| 1408 | if (type == ax::ui::CheckBox::EventType::SELECTED) |
| 1409 | { |
| 1410 | _labelSDF->enableItalics(); |
| 1411 | _labelNormal->enableItalics(); |
| 1412 | } |
| 1413 | else |
| 1414 | { |
| 1415 | _labelSDF->disableEffect(ax::LabelEffect::ITALICS); |
| 1416 | _labelNormal->disableEffect(ax::LabelEffect::ITALICS); |
| 1417 | } |
| 1418 | }); |
| 1419 | initToggleLabel("enableShadow", Vec2(size.width * 0.15, size.height * 0.35), |
| 1420 | [=, this](Object* obj, ax::ui::CheckBox::EventType type) { |
| 1421 | if (type == ax::ui::CheckBox::EventType::SELECTED) |
| 1422 | { |
| 1423 | _labelSDF->enableShadow(Color4B::YELLOW, Vec2(-1, -1)); |
| 1424 | _labelNormal->enableShadow(Color4B::YELLOW, Vec2(-1, -1)); |
| 1425 | } |
| 1426 | else |
| 1427 | { |
| 1428 | _labelSDF->disableEffect(ax::LabelEffect::SHADOW); |
| 1429 | _labelNormal->disableEffect(ax::LabelEffect::SHADOW); |
| 1430 | } |
| 1431 | }); |
| 1432 | initToggleLabel("enableBold", Vec2(size.width * 0.15, size.height * 0.45), |
| 1433 | [=, this](Object* obj, ax::ui::CheckBox::EventType type) { |
| 1434 | if (type == ax::ui::CheckBox::EventType::SELECTED) |
| 1435 | { |
| 1436 | _labelSDF->enableBold(); |
| 1437 | _labelNormal->enableBold(); |
| 1438 | } |
| 1439 | else |
| 1440 | { |
nothing calls this directly
no test coverage detected