I am using cocos2d-x 3.8.1 c++ version. I use few custom fonts (OpenSans family and DINNextRoundedLTPro-Bold) for my game. Most of things are fine but one thing is really annoying with createWithTTF and those fonts.
The thing is that the number 1 is not centered correctly. Using custom fonts, number 1 went right side and it's not center aligned. Arial font has same problem.
Here is code for reproduce.
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
Label* arial = Label::createWithTTF("arial", "fonts/arial.ttf", 20, Size::ZERO, TextHAlignment::CENTER);
Label* openSans = Label::createWithTTF("openSans", "fonts/OpenSans-Bold.ttf",20, Size::ZERO, TextHAlignment::CENTER);
Label* system = Label::createWithSystemFont("system", "", 20, Size::ZERO, TextHAlignment::CENTER);
arial->setPosition(Vec2(visibleSize.width/2 - 100, visibleSize.height/2 + 50));
openSans->setPosition(Vec2(visibleSize.width/2-100, visibleSize.height/2 ));
system->setPosition(Vec2(visibleSize.width/2-100, visibleSize.height/2 - 50));
this->addChild(arial);
this->addChild(openSans);
this->addChild(system);
Label* arialLabel = Label::createWithTTF("1", "fonts/arial.ttf", 40, Size::ZERO, TextHAlignment::CENTER);
LayerColor* arialBG = LayerColor::create(Color4B::GREEN);
arialBG->setContentSize(arialLabel->getContentSize());
arialLabel->addChild(arialBG,-1);
Label* openSansLabel = Label::createWithTTF("1", "fonts/OpenSans-Bold.ttf",40, Size::ZERO, TextHAlignment::CENTER);
LayerColor* openSansBG = LayerColor::create(Color4B::GREEN);
openSansBG->setContentSize(arialLabel->getContentSize());
openSansLabel->addChild(openSansBG,-1);
Label* systemLabel = Label::createWithSystemFont("1", "", 40, Size::ZERO, TextHAlignment::CENTER);
LayerColor* systemBG = LayerColor::create(Color4B::GREEN);
systemBG->setContentSize(arialLabel->getContentSize());
systemLabel->addChild(systemBG,-1);
arialLabel->setPosition(Vec2(visibleSize.width/2, visibleSize.height/2 + 50));
openSansLabel->setPosition(Vec2(visibleSize.width/2, visibleSize.height/2 ));
systemLabel->setPosition(Vec2(visibleSize.width/2, visibleSize.height/2 - 50));
this->addChild(arialLabel);
this->addChild(openSansLabel);
this->addChild(systemLabel);
And here is screenshot.
Other numbers such as 2 are fine.
I could check the label string and adjust position for 1 but that's last thing I want to do.
Is there any solution for this?
Any advice would be appreciated.