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

Author Topic: Font/Text Direction  (Read 1440 times)

0 Members and 1 Guest are viewing this topic.


  • Hero Member
  • *****
  • Posts: 3360
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Font/Text Direction
« on: December 30, 2023, 05:59:46 pm »
Spending a bit of time around the SFML text rendering recently, I have noticed that it's locked in to a horizontal direction.
After checking, it looks like FreeType does provide a 2-dimensional (vector) advance but SFML only uses the x component - even in Font/Glyph i.e. it's not just Text ignoring it, it's not available from Font so even a custom text renderer would not be able to use it. This makes Font useless for any non-horizontal direction text renderer.

My suggestion is - at least at first - expose the 2D advance in Font/Glyph allowing separate renderers to use all of the font.
(by simply changing advance to Vector2f instead of float)

Following that, Text could be expanded to also be able to handle it properly. This isn't required but is an option. However, exposing the 2D advance is required before that can even be considered. Of course, exposing it means that Text would need to adjusted to focus on just the one component but it's (obviously) as simple as making a reference, for example. Later, the 2D vector could be used, likely without much disruption to the legibility of the code.
position += advance (both floats representing xs)
position += advance (both representing Vector2fs)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
 *Hapaxia Links*


  • Hero Member
  • *****
  • Posts: 1847
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Font/Text Direction
« Reply #1 on: May 20, 2024, 05:00:37 am »
I wonder if that advance is ever used in normal LTR text too or just for column writing systems. FT docs don't say. sf::Text and sf::Font are also a bit iffy for RTL text (technically you can reverse your string before inputting it but that's a bit of a hack to make RTL be just LTR backwards), and has 0 shaping needed for cursive scripts (like HarfBuzz has).
Back to C++ gamedev with SFML in May 2023