Loading unicode font in OpenGL ES App
I wish to load a unicode font in my openGL ES app using freetype library. I initially considered using Arial Unicode MS, but it is too big, around 24 MB.
Is there 开发者_StackOverflow社区any other unicode font available of smaller size? I also understand that some other unicode font might not be small enough to solve my problem. Is there any alternative approach to solve my issue?
I think you're referring to texture mapped fonts. As you already figured, a full Unicode font consumes rather much space. However changing the font won't make a difference as the memory requirements don't depend on the typeface, but on the resolution the glyphs rendered to a texture atlas times the amount of glyphs that are included into the set.
While texture mapped fonts were a viable option for alphabets with only a limited number of glyphs (Latin, Cyrillic, Greek, Korean, Arabic) it gets rather clumsy if you want to support full internationalization.
There are two considerable options:
Scan the text to be displayed for all glyphs required, only render and upload those; this owever won't work so well for kanji and similar large scripts.
Render the whole text using FreeType and some layout library (Pango or similar) to a buffer.
I recommend rendering using 3 times the screen resolution using grayscale antialiasing. Then modulate with a pixel aligned filter mask texture, or using a fragment shader to implement sub-pixel antialiasing.
There is possible third method, but I never implemented it myself so far: Vector Textures. In essence you implement a antialiasing spline rasterizer in the fragment shader and supply spline parameters through samplers; this allows to render crisp text utilizing GPU acceleration.
精彩评论