Search code examples
c++openglsdlsdl-ttf

SDL ttf with opengl, font size issues


I am working with sdl ttf for rendering text to opengl, actually everything it's fine, but like you know, when you open a ttf sdl file you specify it on pixels, and you can't change the font size. Actually you can change the font size but you need to close and re-open the font, and that will be a little slow, so, is there any way to change the font size or something like that?

I need to do the following: Font size that can get resized and adjusted to the window screen (like the opengl -1.0f - 1.0f range that works with something similar to percent), multiline rendering support with no background.


Solution

  • You could put it on a surface and scale the surface. That will probably deform the text, which might be an issue.

    Or you could have an array of text sizes. Load the same font with a range of text sizes. As you scale your image, use the different fonts instead of changing the size of one font.