4

NB: My whole senario is for only android version ICS.

My Goal is to render text having complex script/indic script. In ICS, this feature has been added in WebView (and so Browser). If any indic text is rendered in Browser or WebView it renders correctly. But in other widgets (TextView,EditText) it renders broken.

Now my goal is to re-use the code for properly drawing indic text in webcore and use that code to draw indic text in a custom widget.

I also tested using HTML5 canvas in browser and it can render indic text fine. I have tested android's android.graphics.Canvas and it failed to render indic text properly.

libskia seriously lacks of documentation so i cant work out how to render text using this.

I checked the objdump of libwebcore.so and saw that it depends on lib "skia" "libicu". So i'm assuming i can draw indic text using these libraries.

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

Dheeraj Vepakomma
  • 26,870
  • 17
  • 81
  • 104
Sarim
  • 3,124
  • 2
  • 20
  • 20
  • 1
    You probably don't want to release build-specific code that links against non-public details of libraries. While Android vendors/carriers are often slow to push updates, when they do push updates they tend to be mandatory. Also you may find that it does not work across vendors. Can you perhaps use a webview for your rendering? – Chris Stratton Dec 19 '12 at 16:54
  • @ChrisStratton using webview is overkill actually. it slows things down. and i think can pack these libraries with my app or figure something out. i'm not think about releasing/distributing right now, i want to do it first somehow. – Sarim Dec 19 '12 at 17:17

1 Answers1

1

There are a couple of alternate text stacks that are in common use, but neither is directly exposed through the Android NDK. At the base level, you need to:

  1. Break your text into runs of a single script, in a single font, in a single direction, on a single line.
  2. Convert the sequence of characters in each run into a sequence of glyphs.
  3. Lay out those glyphs in 2D space, potentially going back to step (1) if your linebreak didn't work out.
  4. Rasterize the glyphs in the chosen positions.

The most popular stack for this is approximately (1) fribidi, (2) harfbuzz-ng, (3) more harfbuzz-ng, (4) libfreetype. All of these projects are pretty easy to get running on Android; documentation quality varies.

There's also the Pango project, which sits on top of the stack just described, but provides a higher level interface. Unfortunately, Pango has quite a few dependencies, such that it might be more effort to incorporate Pango than to just use the stack directly. If nothing else, Pango serves as great documentation for how to use the stack.

As an alternate stack, the various parts of libicu can replace fribidi, harfbuzz-ng, and Pango (the last with the nearly-undocumented ParagraphLayout class); you'll still need libfreetype to actually deal with fonts and rasterization. Be aware that parts of libicu are being moved over to harbuzz-ng, so these stacks are not completely distinct; and while parts of libicu are both excellent and updated regularly, other parts are a but fuzzier.

addaon
  • 1,097
  • 9
  • 25
  • ICU recommends using harfbuzz for the things harfbuzz does. (the icu-le library). I'm not sure what's indistinct about the stack- would be curious what you mean. – Steven R. Loomis Sep 09 '13 at 22:57