0

Whenever I dealt with fonts in libGDX so far, I used the FreeTypeFontGenerator to create a BitmapFont out of a .ttf-File. Now my problem is the following: I want a font that supports not just one, but multiple colours for each character. For example, I'd like to use a font like this one and to choose both a color for the character itself and for its outline. How can I do that? Do I have to create my own BitmapFont file, and if so, how? Or is there any better / easier way?

vauge
  • 771
  • 3
  • 13
  • 28

1 Answers1

1

The only way I can think of is using the Hiero tool (included in the gdx-tools package) to generate the fonts. It supports adding/editing things like outlines and color with a few clicks, but it doesn't work in runtime - you have to pre-render the fonts. This means that you'll be scaling them when drawing in the game, which can cause some ugly artifacts. You could also pre-render a few different sizes and choose the most appropriate one when running. You'd end up with quite a few font files though, as you'd need a file for each combination of a size and a color scheme.

If that's too uncomfortable, I suppose you could try looking at the Hiero and FreeTypeFontGenerator source codes to create a generator that supports such effects and runtime generation, but I'd guess that wouldn't be a simple task.

MPeti
  • 621
  • 4
  • 9