SFML community forums
Help => Graphics => Topic started by: Blublop 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.
-
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?
// 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);
-
Thanks for your reply !
Yea, I load fonts with greater sizes than displaying them with smaller ones.
The code is easy :
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.
(http://img94.imageshack.us/img94/2366/testxu.png)
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
-
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.
-
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
-
I can't believe I've never tried this out
Tried... or read the doc ;)