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

Author Topic: Disable Font Antialiasing / Smoothing  (Read 3807 times)

0 Members and 1 Guest are viewing this topic.

Kuliu

  • Newbie
  • *
  • Posts: 6
    • View Profile
Disable Font Antialiasing / Smoothing
« on: October 26, 2020, 10:05:36 pm »
Let me preface this post with the fact that, yes I have seen the 100 other posts on this exact topic but I cant find a solid solution in any of that material to achieve what I want.

I want to use a Bitmap font with the SFML font but no settings allow me to disable the smoothing or baked in antialiasing.
I have seen the multitude of posts saying to
Quote
const_cast<sf::Texture&>(font->getTexture(13)).setSmooth(false);
This does disable the smoothing / filtering of the actual texture but the font its self has some sort of baked in antialising applied to it that I want to disable.

This is what the result of the the line of code above provides but you can see how its trying super hard to make this pixel font smooth.


This is the actual desired result I would like to achieve

Sharp clean pixels without any type of antialising or smoothing applied.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Disable Font Antialiasing / Smoothing
« Reply #1 on: October 27, 2020, 08:19:06 am »
You're right that there's no solution to your problem.

he usual advice is to modify SFML:
https://github.com/SFML/SFML/blob/master/src/SFML/Graphics/Font.cpp#L609
... changing FT_RENDER_MODE_NORMAL to FT_RENDER_MODE_MONO should do the job.
Laurent Gomila - SFML developer

Kuliu

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Disable Font Antialiasing / Smoothing
« Reply #2 on: October 29, 2020, 08:46:45 pm »
You're right that there's no solution to your problem.

he usual advice is to modify SFML:
https://github.com/SFML/SFML/blob/master/src/SFML/Graphics/Font.cpp#L609
... changing FT_RENDER_MODE_NORMAL to FT_RENDER_MODE_MONO should do the job.

Is there any specific reason this is baked into SFML? It seems like over the years the community has been doing this work around for a while. If the "fix" is so easy why isn't this just a feature some sort of flag you can change when loading up a font. Sorry if it's deeper than that I'm not familiar with the FreeType library, but having to bring around my own build of SFML for each of my platforms just isn't something I want to maintain  ;D

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Disable Font Antialiasing / Smoothing
« Reply #3 on: October 30, 2020, 08:10:37 am »
One step at a time. First, can you try it and let me know if that solves your problem? ;)
Laurent Gomila - SFML developer

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Disable Font Antialiasing / Smoothing
« Reply #4 on: October 30, 2020, 03:15:19 pm »
I have seen the multitude of posts saying to
Quote
const_cast<sf::Texture&>(font->getTexture(13)).setSmooth(false);
This does disable the smoothing / filtering of the actual texture but the font its self has some sort of baked in antialising applied to it that I want to disable.
With PR #1690 you can and should this now also do via sf::Font::setSmooth(bool) directly.

Also don't forget to render the text at integer positions and to not zoom the view, both of which can lead to pixel interpolations.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Kuliu

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Disable Font Antialiasing / Smoothing
« Reply #5 on: October 31, 2020, 02:59:46 am »
With PR #1690 you can and should this now also do via sf::Font::setSmooth(bool) directly.

This is a very convenient change thank you. 

 

anything