Font metrics in OpenGL

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Font metrics in OpenGL

elect
Hallo,

In Java 2D we have font metrics to detect how much high and long is our text... does anything similar exist in OpenGL?
Reply | Threaded
Open this post in threaded view
|

Re: Font metrics in OpenGL

robbiezl
this code is a sample in my project,i hope this can help u!

textRenderer.begin3DRendering();
textRenderer.setColor(255, 255, 255, 255);
Rectangle2D r2d=textRenderer.getBounds(flatLegendPicInforText);
float scaleFactor=0.0015f;
float textWidth3D=(float) (r2d.getWidth()*scaleFactor);
textRenderer.draw3D(flatLegendPicInforText, x-textWidth3D/2, y,z,scaleFactor);
textRenderer.flush();
textRenderer.end3DRendering();
Reply | Threaded
Open this post in threaded view
|

Re: Font metrics in OpenGL

elect
Great, thank you very much robbiezl :)
Reply | Threaded
Open this post in threaded view
|

Re: Font metrics in OpenGL

gouessej
Administrator
Hi

robbiezl showed an example of use with the legacy text renderer that uses Java2D fonts. I don't know how it works with the "new" shader-based text renderer.
Julien Gouesse | Personal blog | Website