0

So i am creating font using this code

FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/font.ttf"));
        FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
        parameter.size =SCREEN_WIDTH/12;
      //  generator.scaleForPixelHeight((int)Math.ceil(SCREEN_WIDTH/12));
        parameter.genMipMaps = true;
      //  parameter.minFilter = Texture.TextureFilter.MipMapLinearLinear;
        parameter.magFilter = Texture.TextureFilter.Linear;
        parameter.borderStraight  =true;
        font = generator.generateFont(parameter);

but font end up being blurry no matter what texture filtering i am using i keep screen resolution low due to performance issues

SCREEN_WIDTH = 180;
SCREEN_HEIGHT = 320 

is there a way to create nice and crisp font on this res, or this is as good as it gets ?

Atyoum Ustainof
  • 394
  • 1
  • 8

1 Answers1

0

Your font is blurry because it's resolution is too small.

To solve this you could use the tool Hiero (scroll to the bottom) which is mentioned in the libgdx wiki for creating bitmap fonts.

Open the tool and select the desired font from your system fonts (or from a file).

Then use the size option in this tool to set a big resolution for your font, according to your game (size ~50 may be enough).

Save the font files (.png and .fnt) and use it in your game. Now the font should not be blurry anymore.

trinity420
  • 670
  • 7
  • 19
  • I know this question is almost a year old but how do I use the png and fnt files for my game? Shouldn't it be a ttf file? – DreamsInHD Jul 27 '17 at 08:41
  • @DreamsInHD Sure, if the size of your font is big enough you could just use a .ttf file, check [this code](https://stackoverflow.com/a/20044550/3871673). If you want to use a bitmap font (which a fixed size, predefined in e.g. the tool Hiero) then check [this code](https://stackoverflow.com/a/15689992/3871673). – trinity420 Jul 27 '17 at 08:56