Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Render fonts in opengl?

3 views
Skip to first unread message

Rui Maciel

unread,
Dec 22, 2009, 7:36:10 AM12/22/09
to
Currently, what is the best way to render fonts in an opengl? A quick google groups
search returned only very old posts, which I believe may not be up to date. Ater a
bit of digging I stumbled on FTGL, which appears to do the trick. Yet, what are
your suggestions?


Thanks in advance,
Rui Maciel

P.S.: On a side note, it appears that google buries comp.graphics.api.opengl in
it's google groups search. I don't understand how a search engine is able to burry
results from this newsgroup, which google claims to have around 1700 subscribers
(grossly inflated, I'm sure), while sticking in the very first result page a link
to a google group labeled as mac-opengl, which has 7 members

fungus

unread,
Dec 22, 2009, 9:12:38 AM12/22/09
to
On Dec 22, 1:36 pm, Rui Maciel <rui.mac...@gmail.com> wrote:
> Currently, what is the best way to render fonts in an opengl?

First you have to decide what you mean by "fonts"...

Do you want to use system fonts or supply font files
with an application? Do you want 2D? 3D? Outline or
filled...?

> A quick google groups
> search returned only very old posts, which I believe may not be up to date.

No, nothing's changed...


--
<\___/>
/ O O \
\_____/ FTB.

http://www.topaz3d.com/ - New 3D editor for real time simulation

Wolfgang Draxinger

unread,
Dec 22, 2009, 9:14:54 AM12/22/09
to
Rui Maciel wrote:

> Currently, what is the best way to render fonts in an opengl? A quick
> google groups search returned only very old posts, which I believe may not
> be up to date. Ater a bit of digging I stumbled on FTGL, which appears to
> do the trick. Yet, what are your suggestions?

The thing is, that the way how one renders text (aka font glyphs) using
OpenGL hasn't much changed during the years. Essentially it's either:

* extract the glyph shapes tesselate into geometry and render as such.

or

* Rasterize glyphs into a pixmap and draw the text using these.

The source code of Blender2.5 has a very nice implementation of the later
method. And years ago I somewhere posted something similar.


Wolfgang


keith

unread,
Dec 23, 2009, 10:41:47 PM12/23/09
to
> * extract the glyph shapes tesselate into geometry and render as such.

Can you give some pointers to implementations of/articles about this
method? AFAIK, TTF fonts are made of splines, so why tesselation?

Hieu Le Trung

unread,
Dec 24, 2009, 3:15:22 AM12/24/09
to
One method is to render the text into GL texture and then apply
texture mapping to a rectangle onscreen as mentioned here
http://changetheworldwithyourpassion.blogspot.com/2009/08/draw-text-with-opengl-and-cairo.html.
This one is not optimized since each text will be put into a surface
and upload to OpenGL as texture which take a lot of time. You can
optimize it by having 1 texture for all glyphs and use Pango along
with OpenGL texture mapping to render it to screen.
The other two methods are using Bitmap font and Primitive font.
For bitmap font, no need to render it into Cairo surface, just map it
using texture mapping.
For primitive font, all you need is to convert it into bunch of
glVertex command in order to render it to screen.

keith

unread,
Dec 24, 2009, 8:20:37 AM12/24/09
to
Hieu Le Trung pravi:

> On Dec 24, 10:41 am, keith <johndoe64...@yahoo.com> wrote:
>>> * extract the glyph shapes tesselate into geometry and render as such.
>> Can you give some pointers to implementations of/articles about this
>> method? AFAIK, TTF fonts are made of splines, so why tesselation?
> One method is to render the text into GL texture and then apply
> texture mapping to a rectangle onscreen as mentioned here
> http://changetheworldwithyourpassion.blogspot.com/2009/08/draw-text-with-opengl-and-cairo.html.
> This one is not optimized since each text will be put into a surface
> and upload to OpenGL as texture which take a lot of time. You can
> optimize it by having 1 texture for all glyphs and use Pango along
> with OpenGL texture mapping to render it to screen.
> The other two methods are using Bitmap font and Primitive font.
> For bitmap font, no need to render it into Cairo surface, just map it
> using texture mapping.

I know and understand all of the above.

> For primitive font, all you need is to convert it into bunch of
> glVertex command in order to render it to screen.

Yes, but how to do the conversion?

fungus

unread,
Dec 24, 2009, 9:26:29 AM12/24/09
to
On Dec 24, 2:20 pm, keith <johndoe64...@yahoo.com> wrote:
> >
> Yes, but how to do the conversion?

There's a library called GLTT ...

Wolfgang Draxinger

unread,
Dec 24, 2009, 8:39:41 AM12/24/09
to
keith wrote:

>> * extract the glyph shapes tesselate into geometry and render as such.
>
> Can you give some pointers to implementations of/articles about this
> method?

Actually I'd rather suggest you to resterize the glyps. The quality will be
alot better than what you get with OpenGL. That is, because antialiasing
methods used by GPUs have not been optimized for font rendering, whereas
libraries like FreeType have been built for exactly that purpose.

FreeType offers you both: A font rasterizer and access to the glyphs' spline
data.

> AFAIK, TTF fonts are made of splines, so why tesselation?

Because the usual GPUs can't deal with splines. The spline evaluators of
OpenGL you might know about (glEvalCoord) are in fact nothing more, than a
tesselation interface, on most common implementations done by the CPU.


Wolfgang

0 new messages