I've been struggling with this for a whole day now and I decided to ask it again, seeing as this is (used to be?) a common problem.
My sf::Font is always blurred unless they are really big (Bigger then 20px or 32px for some).
DialogueFont = new sf::Font;
if (!DialogueFont->loadFromFile(Folders::ROOT_FOLDER + Folders::DIALOGUE_FOLDER + "Ace-Attorney.ttf"))
{
std::cout << "Failed to load Dialogue font!" << std::endl;
}
TextRenderer = new sf::Text();
TextRenderer->setFont(*DialogueFont);
TextRenderer->setColor(sf::Color::White);
----more code here----
TextRenderer->setString(pCurrentUnit->getCHAR()->getNAME());
TextRenderer->setCharacterSize(16);
TextSanitizer::CenterOrigin(TextRenderer);
TextRenderer->setPosition(108, 34);
pWindow->draw(*TextRenderer);
TextRenderer->setString(pCurrentUnit->getCLASS()->GetNAME());
TextSanitizer::CenterOrigin(TextRenderer);
TextRenderer->setPosition(242, 34);
pWindow->draw(*TextRenderer);
It's always random, some texts come out crisp and other ones unreadable. I've read about Issue #228 but that's 4 years ago, wich said it got fixed in SFML 2, wich I use. The rest all say that the position should be rounded to ints, but mine already are ints.
I tried about 15 fonts and none will show normal consistently at 16px. Not even Arial works.
void TextSanitizer::CenterOrigin(sf::Text* _pText)
{
sf::FloatRect textRect = _pText->getLocalBounds();
_pText->setOrigin(textRect.left + textRect.width / 2.0f, textRect.top + textRect.height / 2.0f);
}
If you wanna see the centering code.