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
Support for loading BitmapFonts from TextureAtlases #2110
Support for loading BitmapFonts from TextureAtlases #2110
Conversation
-Added a field to the BitmapFontParameter -Improved documentation a bit
Makes sense to add support for this. Your current implementation has a couple of flaws. E.g. if an atlas is given, you still request textures as deps as well. Also not sure if ref counting works properly with this setup (e.g. does the font own the atlas and disposes of it?). |
import com.badlogic.gdx.graphics.g2d.TextureRegion; | ||
import com.badlogic.gdx.scenes.scene2d.ui.Skin; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That doesn't seem right,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's probably for the Skin reference in the javadocs (for better or worse).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep.
-Whoops, they shouldn't have been there in the first place
regs[i] = new TextureRegion(manager.get(data.getImagePath(i), Texture.class)); | ||
if (parameter.atlasName != null) { | ||
// If we want to load this font from a texture atlas... | ||
if (manager.getLoader(TextureAtlas.class) == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do this check?
Fixed things up myself |
I haven't actually tested this yet, I'm in the process of doing that, but I wanted to get some feedback first.
Anyway, isn't it weird that
BitmapFont
s can be created fromTextureRegion
s, but you can't do so within aBitmapFontLoader
? Being able to do so would be really, really convenient. Putting your fonts in the same atlas as your sprites would improve performance, and this PR makes it easier to do so.An update to the
BitmapFontTest
is on the way.