PDA

View Full Version : Working with Unicode fonts



Ehsan Kamrani
11-12-2007, 01:12 PM
Hi there
I should render Farsi fonts in an application.I haven't worked with Unicode fonts before. How to render such fonts with OpenGL?Are there any articles to discuss about the unicode fonts in OpenGL? Are there any useful codes that render the Unicode fonts with OpenGL?

Korval
11-12-2007, 02:20 PM
Are there any articles to discuss about the unicode fonts in OpenGL?

No, but it shouldn't be all that different from any tutorial on using FreeType to render fonts. FreeType worked in Unicode Points. Unfortunately, most font rendering tutorials are not written to be fully useful demonstrations, so they tend to do silly things like put each character in display lists and render a string by assuming each character represents a display list name for that character.

Basically, what you need is the code to use FreeType and extract images into textures. After that, the rendering you'll have to deal with using your Unicode-aware string interpretation classes.

Ehsan Kamrani
11-12-2007, 02:28 PM
Basically, what you need is the code to use FreeType and extract images into textures. After that, the rendering you'll have to deal with using your Unicode-aware string interpretation classes.

OK, but how?

Seth Hoffert
11-12-2007, 02:37 PM
Try QuesoGLC: http://quesoglc.sourceforge.net/

Korval
11-12-2007, 02:59 PM
OK, but how?

How what? How to use FreeType to extract images from a font file? That's a Google search away.

How to use a Unicode-aware string?

First, read up on Unicode (http://en.wikipedia.org/wiki/Unicode) and Unicode encodings (http://en.wikipedia.org/wiki/Comparison_of_Unicode_encodings), so that we know what we're talking about.

Ultimately, any font rendering is going to need to convert the array of some Unicode encoding into an array of Unicode points, because the font only holds the mapping from Unicode points to font glyphs. How you do that is up to you; there are any number of libraries for handling Unicode strings. Probably the least intrusive one is utf-8 cpp (http://sourceforge.net/projects/utfcpp/); that's what I use at any rate.

So, once you can extract an image for a particular Unicode point from FreeType, and you can turn your input string into an array of Unicode points, all you need to do is render that image. Normal usage would be to do the extraction process ahead of time, storing the images in a large texture, then pulling out the pieces you need as needed.