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

Author Topic: Blurred font  (Read 3526 times)

0 Members and 1 Guest are viewing this topic.

Manux

  • Newbie
  • *
  • Posts: 23
    • View Profile
Blurred font
« on: April 05, 2010, 05:02:27 am »
Hello,

I've had a problem with fonts since I started using SFML: they are somehow blurred.
I've looked into the sf::String code, and briefly into the FontLoader code.
One thing I've noticed, with this minimal code, is that the rendered font image is kind of blurry:
Code: [Select]

font13.LoadFromFile("data/times.ttf",13);
sf::Sprite s;
const sf::Image* img = font13.GetImage();
((sf::Image*)img)->SetSmooth(false);//without that its worse...
s.SetImage(*img);
s.SetPosition(100,100);
App.Draw(s);


I'm using 1.5, should I consider going to 1.6 or 2.0? Or is it something I can fix?

Thanks, and here's an image:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Blurred font
« Reply #1 on: April 05, 2010, 11:43:28 am »
Font rendering has been improved in SFML 2, maybe you can try it.
Laurent Gomila - SFML developer

Manux

  • Newbie
  • *
  • Posts: 23
    • View Profile
Blurred font
« Reply #2 on: April 05, 2010, 05:32:31 pm »
I successfully compiled the latest revision of sfml2, and I wondered, are all centers gone? They were extremely useful to me in my code since I used the center of the image as the point where all of my sprites touched the isometric floor...

So, I commented out everything about centers, changed to sf::Text instead of sf::String, SetString instead of SetText, and yet...  text is still blurry.

 :cry:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Blurred font
« Reply #3 on: April 05, 2010, 05:40:35 pm »
Center is now named Origin.

Quote
text is still blurry.

Can you give me a complete and minimal code that clearly shows this blurriness?
Laurent Gomila - SFML developer

Manux

  • Newbie
  • *
  • Posts: 23
    • View Profile
Blurred font
« Reply #4 on: April 05, 2010, 05:52:46 pm »
Ay, Origins :lol: , I guess I need to read the doc with more attention next time...

Here:
Code: [Select]

#include <SFML/Graphics.hpp>
#include <iostream>
using namespace std;

int main(int argc,char** argv)
{

    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "Client");

sf::Font font;
font.LoadFromFile("data/font.ttf",13);

sf::Sprite s;
const sf::Image* img = &font.GetImage();
((sf::Image*)img)->SetSmooth(false);
s.SetImage(*img);
s.SetPosition(100,100);

sf::String str("Hello World!",font,13);
    while (App.IsOpened())
    {
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            if (Event.Type == sf::Event::Closed)
                App.Close();
            if (Event.Type == sf::Event::KeyPressed){
                if (Event.Key.Code == sf::Key::Escape){
                    App.Close();
                }
            }
        }

        App.Clear(sf::Color(0,0,0));
        App.Draw(str);
App.Draw(s);

        App.Display();
    }
    return EXIT_SUCCESS;
}

I also tried the same code but with 2.0 fixes to classes and names, same result.
font.ttf is Windows/Fonts/times.ttf by the way.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Blurred font
« Reply #5 on: April 05, 2010, 06:16:02 pm »
Here is what I get with SFML 2:


It looks good enough for me.
Laurent Gomila - SFML developer