LWJGL3 STB TTF - How to create a font atlas

Hello.

In my previous engine, to draw fonts, I simply created a buffered image, loaded a java awt font, and drew the letters onto the image. Then I just drew some textured quads that corresponded with the text.

However with lwjgl3, since I cannot used BufferedImages (or anything awt), I was wondering how to properly create a texture atlas containing every letter/number/symbol on the English keyboard.

Here is what I tried so-far, but my understanding of the stb library is very minimal. Most of the code was copied from the lwjgl repo. http://pastebin.com/EGCWMYKh It does not run, it crashes the JVM.

Fixed the crash, and the image outputs. However, it is just a series of lines.

Here is the updated code:
http://pastebin.com/qkhg72Ad

Now, however, the format is limited to just a bitmap. I would prefer having a color and an alpha channel.

[EDIT]
Changing the stride to 0 fixed the problem with rendering the bitmap. Though it still is limited to just that, a bitmap. I suppose I could write a shader that fixes this for me…

[EDIT2]
I played around with the resultant byte-buffer, and turned it into an RGBA texture so it works with my engine. So far so good.

If anyone wants the finished code to generate a bitmap and all the glyphs sizes, here you go: http://pastebin.com/cKj1uWjX