The Colon Case - Wrapping Text in SFML
In my previous post, I presented a simple FontFamily class. This was just the first step in being able to render large blocks of text for my upcoming detective game, The Colon Case.
When SFML renders text on the screen, it will only wrap that text to a new line if the string actually contains newline characters. I wanted to be able to define a position and maximum width per line, and have the text wrap naturally. I want this to be done dynamically, as I plan to have a menu option available for font size.
In my SFML utilities Git repository, I'm working on a new feature to handle this. So far, it handles horizontal alignment (left, center, and right justification). I'm working on vertical alignment and rotation as well, just for the sake of completion. Below is a screenshot from a simple example program making use of the feature.
One small issue I came across involved rounding issues when dealing with floating point values. When SFML renders text at a fractional pixel position, it can sometimes have a blurry appearance. It almost always looks best to render text at integer co-ordinates, without any scaling or fractional spacing. So I included a rounding correction flag that can be toggled, based on particular needs.
The Colon Case
A character and story-driven murder mystery
Status | In development |
Author | Riley Entertainment |
Genre | Puzzle |
Tags | 2D, Mystery, SFML, Singleplayer |
More posts
- The Colon Case - Font Families in SFMLApr 27, 2021
- The Colon Case - Now Building with CMakeApr 16, 2021
- JsonCpp Library Changes, and a Shift to Considering Using CMakeJan 17, 2021
- The Colon Case - Character Movement and the Game LoopJan 08, 2021
- Development begins on my next game - a murder mysteryJan 06, 2021
Leave a comment
Log in with itch.io to leave a comment.