6

I am using a BitmapFont to render text the problem is that I decided to use TrueTypeFontFactory.createBitmapFont method to create the BitmapFont so I can use my own font instead of the default one. The text is rendered with no problems except it is fliped in the y axis, before using the TrueTypeFontFactory.createBitmapFont method I would just create a BitmapFont and pass true in the constructor in order to flip it, but now that I am using the TrueTypeFontFactory I can't do it that way, and I don't seem to be able to do it after the BitmapFont is created because there are no methods to do so. So I was wondering how could I flip the font in this case?

Leonso Medina Lopez
  • 777
  • 1
  • 10
  • 21

3 Answers3

13

You could try calling font.setScale(1, -1); after it is created, but I don't know of a better way.

Zoodinger
  • 152
  • 7
2

You can use FreeTypeFontParameter of flip=true function (parameter.flip=true) default is false

    FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("font/font.ttf"));
    FreeTypeFontParameter parameter = new FreeTypeFontParameter();
    parameter.size = 12;
    parameter.flip=true;
    BitmapFont font = generator.generateFont(parameter); // font size 12 pixels 

Src : https://github.com/libgdx/libgdx/wiki/Gdx-freetype

Ferhat KOÇER
  • 3,890
  • 1
  • 26
  • 26
1

Set the boolean argument in the BitmapFont constructor to true:

//to load custom font:
font = new BitmapFont(Gdx.files.internal("data/fonts/font.fnt"), Gdx.files.internal("data/fonts/font.png"), true);
//to load default arial font:
font = new BitmapFont(true);
Alexi Akl
  • 1,934
  • 1
  • 21
  • 20