SDL_ttf
SDL_ttf copied to clipboard
Proposal: Add a function like `TTF_SizeTextWrapped`
I am proposing a feature that would give back to the user the correct dimensions of a surface with the supplied text of whatever format added. A cstring and UTF-8 implementation would be needed. It would roughly have this signature:
// SDL_Rect is placeholder for a tuple of width and height
SDL_Rect TTF_SizeTextWrapped(TTF_Font *font, const char *text, int *wrap_width);
SDL_Rect TTF_SizeUTF8Wrapped(TTF_Font *font, const char *text, int *wrap_width);
The idea behind this is that wrap_width
would be the maximum width of the surface, if text
does not reach the wrap_width
then output width is shrunk to the width of the text supplied. After this point width will be the minimum of wrap_width
and the longest line of text in the wrapped input.
This is in line with a feature I am adding to pygame-ce
which adds the very same feature so I would be able to supply this feature also.
I back this!