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
TextField should have a setFontScale method like Label #5719
Comments
I'm not a fan of Label |
Thank you for the response. I thought about using a single texture with multiple BitmapFonts, but each instance had to parse the whole .fnt file, it doesn't feel like a good solution when working with 10+ font sizes. The BitmapFontData can't be shared since all fonts have a different scale. Each wrapper also creates a new font cache which is more or less lightweight. The BitmapFontData can't be shared because the scale has to be set not only when drawing, but also on measurements, like lineHeight, ascent, descent, etc. Some of those values are available through the BitmapFont (eg: I don't know how you would make a wrapper, but I feel like the font classes would need a major refactoring for it to work efficiently. Unless again, I'm missing something. |
I have not implemented a good solution for my apps, sorry. I just load multiple fonts, but I generally only need 4-5 max. Maybe we could support creating a new, scaled BitmapFontData from an existing one? You'd load one, then copy and scale it. It still takes up the same memory for the glyphs, but at least you don't need to parse the font data file many times. |
That would be a great addition. I usually end up setting transform and resizing the widgets this way, but it is... hacky. |
+1 for this, it's very unfortunate that i can set the font scale on my entire UI including TextButton and Label, but not on TextField. Edit: i was able to work around this by creating 5 pointers to the same font in my skin and scaling the 5 fonts differently. Maybe this workaround is acceptable, but i do feel that the inconsistency of the current API is not ideal. IMO either |
+1 for this. I've been doubling the font programmatically for all my UI elements, but can't call setFontScale for text fields. |
The
Label
class has asetFontScale(scaleX, scaleY)
method which allows to set the scale of the bitmap font used for layout calculations and drawing. This is very useful when using a distance field font as the font size can be set easily.However, the
TextField
class lacks such a method. Furthermore, most of the methods doing the layout are package-private (e.g.: updateDisplayText), so the font scale cannot be set withbitmapFont.getData().setScale(...)
by subclassing.Unless I'm missing something, this situation makes it impossible to have two TextFields with different font sizes without creating two BitmapFonts when using a distance field font.
If there's no workaround, I can make a pull request.
The text was updated successfully, but these errors were encountered: