How can I render text using the new(ish) JOGL GPU curve rendering classes?

I'm fairly new to OpenGL/JOGL, working through various tutorials and books and making steady progress. Text, however, is an area where I'm stuck. I figured out one way using BufferedImage and Graphics2D to draw strings and then swizzle the pixels and copy to an OpenGL texture, but the quality is low, it is resolution dependent, and it's not efficient.

I found this: http://forum.jogamp.org/GPU-based-Resolution-Independent-Curve-Rendering-td2764277.html. Unfortunately while there are some demos in the GitHub repo I can't quite get my head around them. The code I've tried to use is below:

In the init() method:

    InputStream fontFile = getClass().getResourceAsStream("media/futura.ttf");
try {
font = FontFactory.get(fontFile, true);
} catch (IOException e) {
System.err.println("Couldn't open font!");
e.printStackTrace();
}

RenderState renderState = RenderState.createRenderState(SVertex.factory());
renderState.setColorStatic(1, 1, 1, 1);

renderer = RegionRenderer.create(renderState, RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable);
renderer.init(gl, Region.VBAA_RENDERING_BIT);

util = new TextRegionUtil(Region.VBAA_RENDERING_BIT);


In the display() method:

    PMVMatrix pmv = renderer.getMatrix();
pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
pmv.glTranslatef(0, 0, -300);
float pixelSize = font.getPixelSize(32, 96);
util.drawString3D(gl, renderer, font, pixelSize, "Test", null, samples);


I've searched and searched for a tutorial on this stuff or a simple, commented code example explaining how it works but to no avail. If anyone can help me I'd be extremely grateful!

• If you are new to OpenGL, you should stick with simpler approaches to text rendering, like Bitmap fonts. – Alexandre Desbiens Jun 16 '15 at 19:40
• @AlexandreDesbiens why? – Andy Apr 8 '17 at 17:21

renderer.enable(gl, true);

• reshapeOrtho torpedos all of the prexisting stuff I was drawing, leaving me with a blank screen...yet I can't find where in the code it's actually calling glViewport or anything that would affect my other stuff. Any advice on how to get it to work with preexisting code? These guys are too smart to make an easy to use text API... – Andy Apr 8 '17 at 17:19