-
Notifications
You must be signed in to change notification settings - Fork 77
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 does not work great with Transform::scale #617
Comments
This is the expected behavior. The problem you're seeing here is that text doesn't scale up very well; you're blowing up a 12px font to 40 times its size. If you want to render text at a scale of 480px per line, you'll need to pick a much larger font size. |
The problem is that, by picking a larger font, the size also increases, thus, it is still messy... the only way I know of is to temporarily scale the transform back to (1, 1), and than draw text, witch is not ideal to say the least... Also I am posting this because other gfx draws, namely fill and stroke still look great, as opposed to text. |
One possible solution (and, it is how unity does it if I am not mistaken) is to have a separate font size and character size. That way, I can load a font and say its glyphs need to render as for example 40px but actual render them at 12px. This way the detail every glyph has gets separated from the draw size, making scaling like this possible without much if any problem. To get the same effect now you would need to render these bigger glyphs first to a texture and then scale the texture appropriately yourself. |
I like that approach @lenscas. I think I'll add a new method to make dealing with different "font" and "character" sizes optional, because for many use cases that's just additional complexity. @IgneousRed Images will also scale far less well than stroke or fill of shapes, as an inherent property of scaling. When you scale a filled rectangle, the points of the rectangle change and the shape is filled on the GPU. When you scale an image, the points of the image's draw target change and the image pixels have to be stretched on the GPU. For performance reasons, text characters are rendered as images behind the scenes. |
Making that extra bit optional is indeed the best choice. I still remember the first time I tried to get my fonts to look nice on unity until I learned about that second value. And after I learned it, I just set it to 400 or something like that just so I didn't have to deal with it. |
I know the graphic basics, just think that, to use translate scale and text, you must reset before any text rendering is a bit messy... |
Describe the bug
When your use Graphics::set_transform to increase the scale, text rendering breaks (see image). Images drawn with Graphics::draw_subimage_tinted() do not seem to be effected by this bug.
To Reproduce
The text was updated successfully, but these errors were encountered: