Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Add a function like TTF_SizeTextWrapped #292

Open
PurityLake opened this issue Jul 12, 2023 · 1 comment
Open

Proposal: Add a function like TTF_SizeTextWrapped #292

PurityLake opened this issue Jul 12, 2023 · 1 comment
Milestone

Comments

@PurityLake
Copy link
Contributor

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.

@otidev
Copy link

otidev commented Nov 19, 2023

I back this!

@slouken slouken added this to the 3.0 milestone Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants