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

Author Topic: How do I disable font smoothing?  (Read 1843 times)

0 Members and 1 Guest are viewing this topic.

Twenty

  • Newbie
  • *
  • Posts: 1
    • View Profile
How do I disable font smoothing?
« on: May 02, 2024, 10:31:17 pm »
Hi, I know that there's been one hundred thousand posts about this issue before, but I couldn't find anything helpful, so I'm writting my post.

The issue is well known: if you try to use small (pixel) fonts, SFML tries to smooth characters. Which looks ugly when it comes to pixel games. How do I disable font smoothing?

I tried to find the solution myself, but nothing worked.

The first way was modifying Font.cpp and changing FT_RENDER_MODE_NORMAL to FT_RENDER_MODE_MONO. It didn't work because I couldn't find Font.cpp. I mean, I know it's kind of weird, Font.cpp must be somewhere in the SFML folder, but I can't find it whatsoever! cpp's are usually stored in the folder called src, but I didn't find even that. I thought something happened to my folder and I downloaded the archive from this site, but even it didn't contained Font.cpp

The second option was using sf::Font::setSmooth(bool).
But my compliler said it wasn't an option:

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: How do I disable font smoothing?
« Reply #1 on: May 02, 2024, 11:09:21 pm »
If you downloaded SFML from the Download page of SFML's website, you are downloading pre-built binaries. That is, all the CPP files have been compiled already so the source CPP files are no longer necessary.

If you want to modify the code, you'll need to build that code yourself after your modification.
The source code for version 2.6 (the "latest stable version") is here:
https://github.com/SFML/SFML/tree/2.6.x
(note that it contains Font.cpp)

If, however, you'd like to try using the most recent version that is currently in development (version 3), you can get the code here:
https://github.com/SFML/SFML/tree/master

If you use GitHub, you can also fork the repository and modify it in your own version.

sf::Font's setSmooth should be available in both v3 and also v2.6.1. Are you using an older version as it appears it might not have been available in v2.6.0. (see here)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: How do I disable font smoothing?
« Reply #2 on: May 03, 2024, 07:19:09 am »
Also make sure you're rendering text only on integer position and choose the fitting font size, i.e. never scaling the text.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything