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

Author Topic: sf::string draws in bad quality  (Read 3656 times)

0 Members and 1 Guest are viewing this topic.

Blublop

  • Newbie
  • *
  • Posts: 13
    • View Profile
sf::string draws in bad quality
« on: June 27, 2011, 08:07:00 am »
Hello.
So I want to display strings with an text and small sizes.
I tried to copy the font in codeblocks.
There you have a Courier font (by default) only 8 pixels big.
Now I go other to sfml, load the font and set the strings size also to 8 pixels, but the quality is completely different than in codeblocks.

I also tried to change the second parameter in the LoadfromFile function from the font object.

Is there any way to reproduce the font-quality from codeblocks or is there just no way to draw that small?

Thank's in advance.

aquaglow

  • Newbie
  • *
  • Posts: 15
    • View Profile
sf::string draws in bad quality
« Reply #1 on: July 02, 2011, 06:00:45 am »
Do you have a screenshot and the example code you're using?

For me anyway, the font sizes I specify in SFML don't seem equivalent to those in GUI programs, i.e. a font size 8 in SFML appears much smaller than it would in a GUI.

I presume you're following the tutorial advice of loading the font at a larger size than you display it?

Code: [Select]
// Load at size 30
sf::Font scoreFont;
if (!scoreFont.LoadFromFile("Fonts/Courier_New.ttf", 30)) {
    return EXIT_FAILURE;
}

// Display at size 20
sf::String scoreLabel("Score", scoreFont, 20);

Blublop

  • Newbie
  • *
  • Posts: 13
    • View Profile
sf::string draws in bad quality
« Reply #2 on: July 21, 2011, 04:56:11 pm »
Thanks for your reply !

Yea, I load fonts with greater sizes than displaying them with smaller ones.
The code is easy :
Code: [Select]

    sf::Font myCourier;
    myCourier.LoadFromFile("cour.ttf",100); // Note : cour.ttf is actually Courier New , exactly what c::b is using
    sf::String tst("Text", myCourier, 8);
    tst.SetPosition(20,20);

   // sfml routines ...



And here's a screen shot :
Note : Left pictures come from sfml, the text under each picture is drawn in MS Paint. (Arial, 8 Pixels)
Right picture shows the text written in c::b.


You will notice that sfml will give up when you try to display a string under 10pixels.

Is there any function or possibility to display the orginal font, as GUI's do or a similar thing like SetSmooth (sf::Image).
Then is there a chance to integrate glutBitmapCharacter() from OpenGl with right positions ?

PS : It seems decreasing the quality param down to 10 makes the string look better, but not as perfect as in c::b : (
PPS : I saw this question twice I think on this forum and you're the first to reply on this topic, so I'm really glad : D

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
sf::string draws in bad quality
« Reply #3 on: July 21, 2011, 05:12:20 pm »
It's not the "quality", it's the characters size. So for a perfect result it must match the string size (here it's 8 ), so that no rescaling happens.
Laurent Gomila - SFML developer

Blublop

  • Newbie
  • *
  • Posts: 13
    • View Profile
sf::string draws in bad quality
« Reply #4 on: July 21, 2011, 05:27:07 pm »
Quote from: "Laurent"
It's not the "quality", it's the characters size. So for a perfect result it must match the string size (here it's 8 ), so that no rescaling happens.


Thanks, I can't believe I've never tried this out, thats really simple.
I'm ashamed : S

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
sf::string draws in bad quality
« Reply #5 on: July 21, 2011, 06:30:05 pm »
Quote
I can't believe I've never tried this out

Tried... or read the doc ;)
Laurent Gomila - SFML developer