Skip to content
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

Freetype font kerning on Android not working #5124

Open
1 task done
ChaseWaylon opened this issue Mar 9, 2018 · 0 comments
Open
1 task done

Freetype font kerning on Android not working #5124

ChaseWaylon opened this issue Mar 9, 2018 · 0 comments
Labels

Comments

@ChaseWaylon
Copy link

Issue details

Freetype font kerning works just fine when I run my code as desktop app, I can set kerning to true or false.

But on android device setting kerning true of false makes no difference, kerning is not there either way.

Tested with 3 different phones with different Android versions, issue is always present.

Below is an example. I downloaded the latest libGDX setup App and added some freetype font words to a newly generated default project.

The font I used is OpenSans-Bold.ttf, downloaded from Google Fonts, but I have tried other fonts too.

A screenshot

Reproduction steps/code

package com.mygdx.game;

import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;

public class MyGdxGame extends ApplicationAdapter {
	SpriteBatch batch;
	Texture img;
	BitmapFont font;

	@Override
	public void create () {

		FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("OpenSans-Bold.ttf"));
		FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
		parameter.size = 50;
		parameter.color = Color.WHITE;

		parameter.kerning = true;

		font = generator.generateFont(parameter); // font size 12 pixels
		generator.dispose(); // don't forget to dispose to avoid memory leaks!

		batch = new SpriteBatch();
		img = new Texture("badlogic.jpg");
	}

	@Override
	public void render () {
		Gdx.gl.glClearColor(1, 0, 0, 1);
		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
		batch.begin();
		batch.draw(img, 0, 0);

		font.draw(batch, "START Yawn", 50, 460);

		batch.end();
	}
	
	@Override
	public void dispose () {
		batch.dispose();
		img.dispose();
	}
}

Version of LibGDX and/or relevant dependencies

  • libGDX 1.9.8
  • Freetype extension checked in libGDX setup app

Please select the affected platforms

  • Android
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants