I need to use glyphlayout
so that I can centre the text, but I found if I do the text gets distorted due to the spacing being incorrect.
public SimpleButton(String text, float x, float y, float w, float h, BitmapFont font) {
pos = new Vector2(x, y);
this.w = w;
this.h = h;
this.text = text;
this.font = font;
glyphLayout.setText(font, text);
hitbox = new Rectangle(x, y - h, w, h);
}
public void render(SpriteBatch batch) {
font.draw(batch, text, pos.x, pos.y);
}
Like this it displays fine:
But using glyphlayout
to draw it the spacing for some reason is different:
public void render(SpriteBatch batch) {
font.draw(batch, glyphLayout, pos.x, pos.y);
}
Glyphlayout seems to be changing the spacing here, but I couldn't see any options for setting the spacing with it.
These are the settings for the Bitmap font in Hiero. No special fx, padding and spacing set to zero:
.fnt
file for the font look like? Is there kerning information in it? Can you share the font (both.fnt
and the bitmap)? \$\endgroup\$glyphlayout
. It's somethingglyphlayout
is doing or not doing. \$\endgroup\$glyphlayout
. It seems to be a bug withglyphlayout
. I saw someone posted about this problem a few days ago at the badlogic forums but no one replied and the forum seems to be dead anyway (registration disabled, emails to the moderator fail to send). \$\endgroup\$