Exposition:
I’m writting an OpenGL app in Java via JOGL. The built in fonts with GLUT are very basic. I want to be able to take a Java Font, render all the characters in it to a 2D array of bytes (a greyscale image representing the characters), which I can then load as a texture in OpenGL.
Problem:
I can load the textures in OpenGL; I can use JOGL. My only problem is going from the “Font java cn read” –> “2D greyscale image of all the characters step”. What functions / libraries should I be using?
I’m not sure I quite understand what you’re looking for. I think what you want is some code that will generate grayscale bitmap images of a given size for every glyph in a font.
There isn’t a way (that I am aware of anyway) to get all the glyphs a font supports (oddly, you can get the number of glyphs… so yeah, I may just be missing something, bah). However, you can get glyph metrics for given characters quite easily.
Something along these lines should work for you.
Note that I’m clipping rather than rounding in some places, which could potentially be an issue.