PDA

View Full Version : Possible to display sharp scalable text with FreeType?



meanfox
02-14-2005, 07:48 PM
Hi,

I would like the user to be able to choose the fonts and font sizes for text in my app. I have been tinkering with FreeType. The text comes out sharp when it is large but not at all sharp when it is small. So my questions are:

1. Is this even possible with FreeType? Does anyone have sample code that demonstrates FreeType + OpenGL with crisp small text?

2. If not then what technology should I use?

Thanks a lot!

Tom

Overmind
02-15-2005, 12:29 AM
I haven't actually tried this, but i think for fonts it would make sense to manually generate the mipmaps by generating the font texture using a smaller font size instead of simply scaling down the original texture.

In addition to that, you could also try the LINEAR_MIPMAP_NEAREST filter, so the text would always be rendered based on exactly one mipmap level instead of an interpolation.

Relic
02-15-2005, 01:42 AM
Originally posted by Overmind:
In addition to that, you could also try the LINEAR_MIPMAP_NEAREST filter, so the text would always be rendered based on exactly one mipmap level instead of an interpolation.That's not right. As soon as you use any _MIPMAP_ filter you interpolate between two mipmap levels.
In the above case between the result of 4 texels in the bigger LOD and one texel of the next smaller level.
For single mipmap selection you need to change the min and max LOD or base and max level (see TexParameter in the specs.)

Overmind
02-15-2005, 02:23 AM
No, a linear interpolation between arrays is only done with *_MIPMAP_LINEAR filtering. *_MIPMAP_NEAREST selects only one mipmap level.

See Page 151 and 152 of the OpenGL 1.5 Spec:

For mipmap filters NEAREST_MIPMAP_NEAREST and LINEAR_MIPMAP_NEAREST, the dth mipmap array is selected, where d = [...].
The rules for NEAREST or LINEAR filtering are then applied to the selected array.

For mipmap filters NEAREST_MIPMAP_LINEAR and LINEAR_MIPMAP_LINEAR, the level d1 and d2 mipmap arrays are selected, where d1 = [...], d2 = [...].
The rules for NEAREST or LINEAR filtering are then applied to each of the selected arrays, yielding two corresponding texture values Tau1 and Tau2. The final texture value is then found as [... (linear interpolation formula)]

Relic
02-15-2005, 03:17 AM
Shocking! :) I was always under the impression that the second filter meant the filtering inside the smaller mipmap LOD, not the mipmap LOD selection itself.
Thanks, you'll never stop learning.

meanfox
02-15-2005, 08:48 AM
When I initialize a small font (say 12 pt) and draw it at 1.0 scale, it is still not crisp.

Has anyone added font-selection to their OpenGL app?

Cheers,

Tom

cru
02-15-2005, 12:51 PM
Try ftgl. Pretty good font graphics library for OpenGL.

http://opengl.geek.nz/weblog/archives/000059.html
http://homepages.paradise.net.nz/henryj/code/