Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Blurred fonts in newest SFML2  (Read 3880 times)

0 Members and 1 Guest are viewing this topic.

l0ud

  • Newbie
  • *
  • Posts: 23
    • View Profile
Blurred fonts in newest SFML2
« on: May 28, 2011, 06:24:41 pm »
Hello. I just updated ~5-month old SFML2 to the lastest revision in my project.

Unfortunately, something changed in sf::Text appearance.
Just look at the screen:


(verdana, size: 12)

Is there any way to restore the previous rendering? Everything is blurry now :(

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Blurred fonts in newest SFML2
« Reply #1 on: May 28, 2011, 10:20:24 pm »
Oh... that's bad :P

Would you be able to find the revision where it started to be like this?

And can you show me a minimal and complete code that reproduces the problem (so that I can make sure that you do everything right, and then test it myself)?
Laurent Gomila - SFML developer

l0ud

  • Newbie
  • *
  • Posts: 23
    • View Profile
Blurred fonts in newest SFML2
« Reply #2 on: May 29, 2011, 12:33:14 am »
Well... It's caused by FreeType update in this commit:

https://github.com/SFML/SFML/commit/5e73228b5e10b0ebbde1d667b30097df95578be8

And minimal example:
Code: [Select]

////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Window.hpp>
#include <SFML/Graphics/Font.hpp>
#include <SFML/Graphics/Text.hpp>
#include <SFML/Graphics/RenderWindow.hpp>

////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////
int main()
{
    // Create the main window
    sf::RenderWindow window(sf::VideoMode(200, 100, 32), "SFML Window", sf::Style::Default, sf::ContextSettings(32));

sf::Font font;

font.LoadFromFile("verdana.ttf");
sf::Text text("Test abcdefghijkl\nABCDEFGHIJKL\n1234567890",font,12);

    // Start the game loop
    while (window.IsOpened())
    {
        // Process events
        sf::Event event;
        while (window.GetEvent(event))
        {
            // Close window : exit
            if (event.Type == sf::Event::Closed)
                window.Close();

            // Escape key : exit
            if ((event.Type == sf::Event::KeyPressed) && (event.Key.Code == sf::Key::Escape))
                window.Close();

       }


        window.Clear();
window.Draw(text);


        // Finally, display the rendered frame on screen
        window.Display();
    }

    return EXIT_SUCCESS;
}


Just extract verdana.ttf from windows folder and compare the results ;)

I know that newest version should be better, but there we have noticeable regression in text quality...

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Blurred fonts in newest SFML2
« Reply #3 on: May 29, 2011, 10:52:04 am »
Quote
Well... It's caused by FreeType update in this commit:

Thanks for finding it :)

This is surprising, I expected the problem to come from an SFML update. I may be harder to solve.
Laurent Gomila - SFML developer

l0ud

  • Newbie
  • *
  • Posts: 23
    • View Profile
Blurred fonts in newest SFML2
« Reply #4 on: May 29, 2011, 01:35:52 pm »
I Just changed 319 line in Graphics/Font.cpp to
Code: [Select]
if (FT_Load_Char(face, codePoint, FT_LOAD_FORCE_AUTOHINT) != 0)
 what fixed the problem for me. Now rendering is almost the same to the previous one. :)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Blurred fonts in newest SFML2
« Reply #5 on: May 29, 2011, 03:04:25 pm »
You're very efficient :shock:

I'll try this, thanks. There are a lot of problems related to hinting, especially regarding patents, so I need to examine this carefully.
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Blurred fonts in newest SFML2
« Reply #6 on: June 05, 2011, 02:04:43 pm »
The default behaviour is supposed to be better than using this flag.
Quote
By default, hinting is enabled and the font's native hinter (see FT_FACE_FLAG_HINTER) is preferred over the auto-hinter. You can [...] change the precedence by setting FT_LOAD_FORCE_AUTOHINT


Is the quality worse with any font that you try?
Laurent Gomila - SFML developer

l0ud

  • Newbie
  • *
  • Posts: 23
    • View Profile
Blurred fonts in newest SFML2
« Reply #7 on: June 06, 2011, 12:12:45 am »
I have done several tests and decided that sometimes forced autohinting is better, sometimes worse.

Verdana 12px: forced autohinting is much clearer
Times 12px: default settings looks better
Comic Sans MS: forced ah 'wins'...

(default settings on the left, forced autohinting on the right)


I think you should add some kind of flag to allow us to select hinting method without modifying SFML source.

Until then, I stay with my mod :)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Blurred fonts in newest SFML2
« Reply #8 on: June 06, 2011, 07:52:07 am »
Thanks for your tests :)

Quote
I think you should add some kind of flag to allow us to select hinting method without modifying SFML source.

I'd like to avoid this, but if it's really necessary I guess I have no choice...
Laurent Gomila - SFML developer

 

anything