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

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

0 Members and 1 Guest are viewing this topic.

Hapax

  • Hero Member
  • *****
  • Posts: 3351
  • 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.
e.g.
position += advance (both floats representing xs)
position += advance (both representing Vector2fs)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything