Scale a Bitmapfont in LibGDX

后端 未结 3 1100
我寻月下人不归
我寻月下人不归 2021-02-07 03:05

How can I scale a Bitmapfont object in LibGDX? It seems the method setScale is no longer available.

相关标签:
3条回答
  • 2021-02-07 03:42

    It is not recommended to scale Bitmap font, because it looks pixlated when enlarged(which I believe is ugly)

    It is recommended to use freetype generator for resizing your fonts

    If you still want use bitmapFont Tenfour04 is correct

    0 讨论(0)
  • 2021-02-07 03:54

    Use bitmapFont.getData().setScale(float x, float y).

    0 讨论(0)
  • 2021-02-07 03:55

    As Fish mentioned, it is recommended to use freetype generator as following:

    FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/timesBold.ttf"));
    FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
    

    Then change the font size in parameter and initialize BitmapFont:

    fontParameter.size = 18;
    BitmapFont font = fontGenerator.generateFont(fontParameter);
    

    It is also needed to include libgdx-freetype.so in armeabi folder of your project.

    0 讨论(0)
提交回复
热议问题