-
Notifications
You must be signed in to change notification settings - Fork 419
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
Text whitespace handling issues, \t ignored #805
Comments
This one is tricky 'cause the amount of layout done by the text rendering is kinda limited. Related: #687 . |
leading or trailing \n, neither changes dimensions() and both change how its drawn (just that trailing makes no difference). It seems consistent to me |
@jgarvin Do the things you mentioned pose a problem to you in any way, or did you just stumble over some inconsistency and simply wanted to make us aware of them? Since whitespace is generally not considered part of the dimensions of text in glyph-brush the one real bug hiding in all of this seems to be \t not working at all. I opened an issue for this problem on the glyph-brush repo, but to make life easier for them it would be good to know whether tabs in text are actually something you (or anyone else reading this) really needs in ggez. If so, the next question would be: How exactly would you expect \t to behave? (i.e. would representing a \t through 4 times space be enough for you?) |
I was able to work around it, but it does create the need for special cases around text rendering. I used ggez to create a text adventure (with some minor graphical elements). Naturally for a text adventure you need to render paragraphs of text, with indentation. In a text adventure you're often rendering a mix of pre-programmed string literals and dynamic content. You might have a string literal like "Item List:\n\n" and then iterate through a |
That use case would already work with fragments no? let mut text = Text::new();
text.push("Item List:\n\n");
for item in items {
text.push(item);
text.push("\n");
} But if you must have it separate, you could just manually calculate it by offsetting the text by (font size * 2), it shouldn't be that much extra work. I don't think it's worth adding extra API for such a niche use case. |
Describe the bug
There seem to be some minor inconsistencies with how whitespace rendering is handled.
To Reproduce
Draw strings with \t, or draw strings with \n at the beginning or end with
ggez::graphics::Text
.Expected behavior
Always respect and render whitespace and report it as part of text dimensions.
Hardware and Software:
The text was updated successfully, but these errors were encountered: