I’m sure you guys have heard this question a million times before, and for that I apologize, but countless google searches have turned up very little that’s actually helpful.
Here’s my situation: I need a way to render text in my OpenGL application. It has to be cross-platform, it has to support unicode, it has to be capable to rendering arabic, chinese, japanese, or whatever the user wants it to, and it has to be as fast as possible. I’m using OpenGL 3.3 with the core profile, so no display list nonsense.
I’d like to use Freetype 2 to handle to actual nitty-gritty of the glyph rendering, as it seems to be the most convenient library around for that. From there, I’ve seen a number of different implementation tricks and I’m not sure which one to use.
One very common solution is to make a really, really big texture that holds every possible glyph, and have each rendered glyph be a textured quad (or two triangles) whose texture co-ordinates point to the correct glyph in the cached texture. The problem with this quickly becomes apparent when you consider that the Japanese language alone has somewhere around 30,000 glyphs. Even if it were possible to get a texture big enough to store everything, said texture would alone take up half of the memory on the user’s video card (which is a bad thing).
Another solution is to use Freetype to render each individual string from scratch once, the first time said string appears, rendering the whole string as a single textured quad. This quad, and the texture created by Freetype, would be cached in memory for as long as the string exists on the screen. This works well enough for static strings (which, admittedly, is what 90% of the application’s text will end up being), but what about dynamic text? Text input boxes, etc. What about memory? If there are many strings being rendered, for instance in an online chat, could memory usage be a concern?
How do operating systems and/or web browsers typically handle it?
What are some solutions that you have come up with? Are there some good (up to date) tutorials on the subject (trust me, I’ve looked)? Any advice that you could share to point me in the right direction would be much appreciated.