LibGdx使用位圖文件(png)來渲染字體。 字體中的每個(gè)字形都具有相應(yīng)的紋理區(qū)域仁堪。
BitmapFont class (code)
BitmapFont在LibGdx 1.5.6版本被重構(gòu)。 This blog 有關(guān)于更改的詳細(xì)信息惹恃,還有一個(gè)小例子展示了如何從1.5.6之前的代碼移動(dòng)到新的API蹄梢。
有關(guān)使用BitmapFont的教程可在LibGDX.info上獲得
字體文件的文件格式規(guī)范
參考文獻(xiàn)指出论熙,bmFont最初由AndreasJ?nsson在AngelCode創(chuàng)建
BMFont - 文件格式的原始規(guī)范沛硅。
Glyph Designer - 有關(guān)輸出的詳細(xì)信息眼刃,包括二進(jìn)制格式。
創(chuàng)建位圖的工具
Hiero - 用于將系統(tǒng)字體轉(zhuǎn)換為位圖的實(shí)用程序
ShoeBox - 允許您從圖像加載自定義的字形摇肌,然后從中創(chuàng)建位圖字體擂红。這里有一篇關(guān)于如何在libgdx使用ShoeBox的教程.。
Glyph Designer - 一種商業(yè)位圖字體工具围小,具有各種陰影昵骤,漸變,筆觸等選項(xiàng)吩抓。
Littera - 在線位圖字體生成器涉茧,具有大量的自定義內(nèi)容(需要Adobe Flash)。
其他工具類
FreeTypeFontGenerator - 為字體生成位圖疹娶,而不是提供由Hiero等實(shí)用程序制作的預(yù)渲染位圖
Examples : (more)
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("data/unbom.ttf"));
FreeTypeFontParameter parameter = new FreeTypeFontParameter();
parameter.size = 18;
parameter.characters = "???/????";
BitmapFont koreanFont = generator.generateFont(parameter);
parameter.characters = FreeTypeFontGenerator.DEFAULT_CHARS;
generator = new FreeTypeFontGenerator(Gdx.files.internal("data/russkij.ttf"));
BitmapFont cyrillicFont = generator.generateFont(parameter);
generator.dispose();
Distance field fonts - 可用于縮放/旋轉(zhuǎn)字體
gdx-smart-font 非官方的libgdx插件伴栓,用于根據(jù)屏幕尺寸自動(dòng)生成和緩存位圖字體。 (使用FreeTypeFontGenerator)