user1240988
user1240988

Reputation: 45

FreeTypeFontGenerator for GWT

I'm using Libgdx to write an Android and HTML5 app. I have found out that FreeTypeFontGenerator doesn't work for a GWT application and truetype is deprecated. What shall I use if I want to use fonts in a GWT application?

Upvotes: 1

Views: 1472

Answers (2)

Chase
Chase

Reputation: 3183

You use BitmapFont just like you do in any LibGDX application, it is the standard mechanism to support fonts in LibGDX. FreeTypeFontGenerator is an extension that doesn't work for GWT because it features native code. If you need to pre-generate some new font files of different sizes and types you can use Hiero or my favorite BMFont.

Upvotes: 2

MPeti
MPeti

Reputation: 621

There might be some better way, but if you can't find any, you can prerender the font in a few sizes with the Hiero tool built into the gdx-tools project, and choose the most fitting one at runtime. Hiero generates a .png and a file describing the characters in that image which you can simply load, e.g.:

BitmapFont font = new BitmapFont(Gdx.files.internal("data/font/font"+sizeNum+".fnt"));

Upvotes: 0

Related Questions