Drawing complex text in android ics in native c

NB: all of my senario is for ICS with Android only.

My goal is to make the text complex script / indic script. In ICS, this feature was added to WebView (and therefore the Browser). If any displayed text is displayed in a browser or WebView, it is displayed correctly. But in other widgets (TextView, EditText) it breaks.

Now my goal is to reuse the code to correctly draw the displayed text in webcore and use this code to draw the displayed text in a custom widget.

I also checked the use of HTML5 canvas in the browser, and it can display the text in order. I checked android android.graphics.Canvas and was not able to display the text correctly.

libskia is seriously lacking documentation, so I cannot decide how to make text using this.

I checked objdump libwebcore.so and saw that it depends on lib "skia" "libicu". Therefore, I assume that I can draw text using these libraries.

Can anyone suggest how I can draw text using skia and icu? or Can anyone point to a specific code segment in libwebcore?

+4
source share
1 answer

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.

+1
source

All Articles