I am developing this game in LibGDX and I have a BitmapFont
that I am using to write the score on the screen. The font comes out with weird spacing and it changes when it moves. How can I fix that? Here are some examples of how the text shows up:
Here is the code for the font:
generator = new FreeTypeFontGenerator(Gdx.files.internal("font/komika.ttf"));
parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
parameter.size = 100;
defaultFont = generator.generateFont(parameter);
Here is the code for the label:
topScoreLabel = new Label(String.valueOf("Best : " + topScore), skin);
topScoreLabel.setColor(Color.RED);
topScoreLabel.setBounds(GAME_WORLD_WIDTH - 30, GAME_WORLD_HEIGHT - 20 * aspectRatio, 25, 20 * aspectRatio);
topScoreLabel.setFontScale(0.05f);
topScoreLabel.setAlignment(Align.right);
I am using such a big font because it should scale well in big screens, which it didn't if I had any smaller. How do I fix this issue?
Use font.setUseIntegerPositions(false)
. It's on by default, because text is typically used with a pixel-perfect camera/viewport and looks less blurry if the sprites are aligned with the screen pixels.