The Lightweight Java Game Font library (LWJGFont) is a solution for use any true type fonts on LWJGL. LWJGFont makes images which any characters of the true type font was drawn on, and packages into jar which contains these images and classes to use the characters with LWJGL.
First of all, pre-compile your font file to use as texture on LWJGL.
$ mvn clean package
$ java -jar target/lwjgfont-1.0.jar -x
$ java -jar target/lwjgfont-1.0.jar sample/migu-1p-regular.ttf:35
So myfont-1.0-SNAPSHOT.jar and myfont-1.0-SNAPSHOT.pom.xml will be generated on current directory.
This jar file contains subclass off net.chocolapod.lwjgfont.LWJGFont to use the specified font: migu-1p-regular.ttf (its size is 35.)
$ mvn install:install-file -Dfile=myfont-1.0-SNAPSHOT.jar -DpomFile=myfont-1.0-SNAPSHOT.pom.xml \
-DgroupId=net.chocolapod.lwjgfont -DartifactId=myfont -Dversion=1.0-SNAPSHOT -Dpackaging=jar
Add the dependencies of the generated jar and LWJGFont into pom.xml.
<dependency>
<groupId>net.chocolapod.lwjgfont</groupId>
<artifactId>myfont</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
Now, draw a string on Java.
// Load the font with LWJGFont.
LWJGFont font = new Migu1pRegularH35Font();
// Draw a string on the specified location.
font.drawString("いろはにほへと ちりぬるを", 100, 50, 0);
All generated classes by LWJGFont are subclass of LWJGFont.
LWJGFont has many utility methods to render strings on LWJGL.
These classes are included in net.chocolapod.lwjgfont package.
This software is released under the MIT License,
see LICENSE.txt or http://lwjgfont.chocolapod.net/LICENSE.txt
- The Lightweight Java Game Library (LWJGL) : The greatest Java game library.
- もさもさフォント created by @Longsword : The cool font which is used in LWJGFont unit test.