Why not just use some system library to write into a texture and then use that in your game?
Why not just use some system library to write into a texture and then use that in your game?
It's actually so much work that you probably want your game engine to do it internally in a way that is consistent cross-platform. Fortunately, most of the guts have already been figured out for you by the amazing people that work on HarfBuzz. The basic formula is to take your Unicode string, take your font, and feed it to HarfBuzz to have HarfBuzz figure out the metrics and glyph offsets. You then use the metrics to do layout and line breaks.
It is a lot of work, but it turns out to be less work than figuring out how to this working cross-platform using system libraries. This is also, generally speaking, how web browsers deal with their text. There are a couple other pieces that you need like text segmentation but these are tractable.
if you are making any non-trivial software that is supposed to run on two different operating systems, you never never never want to use the OS font rendering, as you'll get text slightly wider, line breaks at different places, stuff that fits neatly in a pixmap on Windows will be 3 pixels too wide on macOS and suddenly won't fit your button, baselines are a bit different, there's the 72 / 96 dpi mess, users will complain that their document don't look the same across OSes... it's an endless can of worms. Just ship & use freetype & harfbuzz everywhere (or use Qt which can do that for you automatically).
fonts are hard