jME-TrueTypeFont Rendering Library

Okay if you head back to the link in my original post you will see the new jME-TrueTypeFontLite package is now available. This packages strips jME-TrueTypeFont of the ability to create scaleable mesh texts, but retains the ability to create UI texts. This removes the jDelaunay and JTS Topology Suite dependencies.

I went ahead and took this opportunity to add an additional feature to both jME-TrueTypeFont and jME-TrueTypeFontLite. You can now draw an outline around your UI texts. Just specify an outline size, in pixels, in the TrueTypeKey constructor:

TrueTypeKey ttk = new TrueTypeKey("Interface/Fonts/myTypeface.ttf", 
    java.awt.Font.PLAIN, 48, 2);

TrueTypeFont ttf = (TrueTypeFont)assetManager.loadAsset(ttk);

The last value in the constructor is the thickness of the outline. Once you have an outline:

Geometry geom = ttf.getBitmapGeom("Hello World", new ColorRGBA(1, 1, 1, 0.5f), ColorRGBA.Blue);

int x = (settings.getWidth() / 2) - (ttf.getLineWidth("Hello World") / 2);
int y = (settings.getHeight() / 2) - (ttf.getVisualLineHeight("Hello World") / 2);

geom.setLocalTranslation(x, y, 0);

guiNode.attachChild(geom);

The first ColorRGBA in getBitmapGeom is the color of the text, the second is the color of the outline.

The above is a 48pt font scaled to 38pt using the TrueTypeFont.setScale(float scale) method.

4 Likes