SFML community forums

Help => General => Topic started by: N_K on March 16, 2012, 11:19:01 pm

Title: Disabling font smoothing/anti-aliasing
Post by: N_K on March 16, 2012, 11:19:01 pm
Hello all.

I would like to disable font smoothing in my app, since the font I'm using looks extremely ugly (and completely unreadeble below size 12) right now.

I did a search, and the only useful thread I found was this (http://www.sfml-dev.org/forum/viewtopic.php?p=35073).

This code snippet was posted in there:
Code: [Select]
Font* f = MyCustomLoadFontMethod();
((Image&)f->GetImage(30U)).SetSmooth(false);


However, it looks like only a reference code to me, and since I'm not that experienced, I simply have no idea what to do with it.

Could somebody post a sample implementation, please?
Thank you.
Title: Disabling font smoothing/anti-aliasing
Post by: Laurent on March 17, 2012, 11:32:58 am
SFML 1.6 or 2?
Title: Disabling font smoothing/anti-aliasing
Post by: N_K on March 17, 2012, 02:27:13 pm
1.6

(Does SFML 2 have a built-in option to disable this?)
Title: Disabling font smoothing/anti-aliasing
Post by: Laurent on March 17, 2012, 03:09:00 pm
Quote
1.6

So the correct code is
Code: [Select]
// font is your sf::Font instance
((sf::Image&)font.GetImage()).SetSmooth(false);


Quote
Does SFML 2 have a built-in option to disable this?

No.
Title: Disabling font smoothing/anti-aliasing
Post by: Nexus on March 17, 2012, 03:14:33 pm
Not extremely important, but I would use const_cast to make the intention more expressive. When looking at the code, one directly knows that only const is removed and no other conversion is performed.