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

Author Topic: Disabling font smoothing/anti-aliasing  (Read 2518 times)

0 Members and 1 Guest are viewing this topic.

N_K

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Disabling font smoothing/anti-aliasing
« 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.

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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Disabling font smoothing/anti-aliasing
« Reply #1 on: March 17, 2012, 11:32:58 am »
SFML 1.6 or 2?
Laurent Gomila - SFML developer

N_K

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Disabling font smoothing/anti-aliasing
« Reply #2 on: March 17, 2012, 02:27:13 pm »
1.6

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

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Disabling font smoothing/anti-aliasing
« Reply #3 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.
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Disabling font smoothing/anti-aliasing
« Reply #4 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.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: