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

Author Topic: Render sf::Text in HD quality using sf::View  (Read 251 times)

0 Members and 1 Guest are viewing this topic.


  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
Render sf::Text in HD quality using sf::View
« on: May 14, 2022, 04:32:00 pm »
I'm developing a co-op game and i need to draw nicknames with good quality of sf::Text. It's could be easier if the sf::View size was 1920x1080, but in my game it is 300x300.
I made a test project (https://github.com/JusticeShurup/ViewAndTextTest)

(click to show/hide)

(click to show/hide)

As you can see the quality leaves much to be desired.

We can resize current sf::View to 1920x1080 and after resize to 300x300.
(click to show/hide)
(click to show/hide)

Everything would be fine if not for one problem. This nickname moves, when you move camera and i don't know why.
(click to show/hide)
This happens without assigning a position to a nick. I can assign a position to a nickname, but that won't solve the other problem, which is that I won't be able to add other players' nicknames, as they will be in the wrong places.

Is it possible to display text in HD quality and still have it's actual size?


  • SFML Team
  • Hero Member
  • *****
  • Posts: 10234
    • View Profile
    • development blog
    • Email
Re: Render sf::Text in HD quality using sf::View
« Reply #1 on: August 04, 2022, 12:11:53 am »
Sorry for the late reply :-\
Unfortunately, I can't see the images (anymore).

For text rendering there are a few important things to consider.
  • You should never scale the text object itself (i.e. zooming in or out with a view), because text should be rendered at the "native" resolution, so you get crisp text and not wrongly rasterized text
  • Use a separate view to render fix objects such as text or HUD elements, that way they won't be affected when moving the camera
  • Render text on integer positions and if you move the view, move it only integer positions. When text is put between pixel positions, the rasterizer has to decide how to render it and it might drop the "wrong" pixel, leaving your font looking crooked.
Official FAQ: https://www.sfml-dev.org/faq.php
Nightly Builds: https://www.nightlybuilds.ch/
Dev Blog: https://dev.my-gate.net/
Thor: http://www.bromeon.ch/libraries/thor/