There are several alternative text stacks that are widely used, but none of them are directly displayed through the Android NDK. At a basic level, you need to:
- Divide the text into runs of one script in one font in one direction, in one line.
- Converting a sequence of characters in each run into a sequence of glyphs.
- Expand these glyphs in 2D space, maybe go back to step (1) if your line doesn't work.
- Rasterize glyphs at selected positions.
The most popular stack for this is about (1) fribidi, (2) harfbuzz-ng, (3) more harfbuzz-ng, (4) libfreetype. All of these projects run fairly easily on Android; The quality of documentation is changing.
There is also a Pango project that sits on top of the described stack but provides a higher level interface. Unfortunately, Pango has quite a few dependencies, so there may be more effort to enable Pango than just using the stack directly. If nothing else, Pango serves as excellent documentation on how to use the stack.
As an alternative stack, various parts of libicu can replace fribidi, harfbuzz-ng, and Pango (the latter with the almost undocumented ParagraphLayout class); you still need libfreetype to deal with fonts and rasterization. Keep in mind that parts of libicu move to harbuzz-ng, so these stacks are not completely different; and while parts of libicu are excellent and updated regularly, other parts are more crazy.
source share