سؤال

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?

هل كانت مفيدة؟

المحلول

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.

نصائح أخرى

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"));
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top