Michele Buzzoni
Michele Buzzoni

Reputation: 207

libgdx-freetype new lib issue with letter spacing

I had a game with the old version of FreeType lib. For some reason, I update the lib but there was some change to do, so I did. But after I have a problem with the letter spacing. I show you 2 images, before and after:enter image description here enter image description here

there is some code (of the last image):

AssetLoader.java:

public static BitmapFont font12;
public static GlyphLayout font12G = new GlyphLayout();

font12 = generator2.generateFont(parameterText); 
        font12.setColor(Color.BLACK);
        font12.getData().setScale(0.04f, 0.04f);

public static String leaderboards = "LEADERBOARD";

GameRender.java:

private void drawLeaderMenu() {
        AssetLoader.font12G.setText(AssetLoader.font12, AssetLoader.leaderboards);
        AssetLoader.font12.draw(batcher, AssetLoader.leaderboards, (GameScreen.gameWidth / 4)
                - (AssetLoader.font12G.width) / 2, circle.getR().y + 20);
    }

I don't understand what is the problem

Upvotes: 0

Views: 290

Answers (2)

jorundtm
jorundtm

Reputation: 16

Try setting font.setUseIntegerPositions(false), the default is true.

Upvotes: 0

AAryan
AAryan

Reputation: 20140

Try to set size in FreeTypeFontParameter instead of font scaling.

FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("BUBBLEGUM.TTF"));
FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();

parameter.color = Color.WHITE;
parameter.magFilter = Texture.TextureFilter.Linear; // used for resizing quality
parameter.minFilter = Texture.TextureFilter.Linear;

parameter.size=20; 
font=generator.generateFont(parameter);
font.getRegion().getTexture().setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
font.setColor(1.0f, 0.0f, 0.0f, 1.0f);

 generator.dispose();   // Don't forget to dispose

Upvotes: 2

Related Questions