Skia & UTF8 RTL text rendering

715 views
Skip to first unread message

Wouter Klouwen

unread,
Jan 26, 2015, 11:12:55 AM1/26/15
to skia-d...@googlegroups.com
Hello people,

I'm in the process of developing an application that uses Skia for its font rendering - amongst others - and have a particular enquiry about UTF8 text. While it renders the individual characters without any trouble but when it comes to Arabic & Hebrew amongst others, it's still rendering left to right. There is a flag to indicate whether the text is vertical or not, but not LTR or RTL.

Now, as far as I understand, there needs to be something that does the shaping of the text to ensure that the letters are positioned correctly. I am somewhat confused over whose responsibility that is. In the Skia build tree there is a Harfbuzz external dependency and that is a font layout library. However, it doesn't seem to be referenced anywhere and I didn't find any build flags that would enable it. Passing in the Unicode RTL or RTO codes don't seem to make much difference.

Additionally, there's this old issue: https://code.google.com/p/skia/issues/detail?id=58
It states that whoever uses Skia is responsible for externally positioning the glyphs and rendering them at the correct positions. Is this still correct?

Further searches on the web do reveal references to Harfbuzz in Chromium and WebCore*, which lead me to believe the latter is true.

Can someone help shed a little bit of light?

Thanks,
     W

*: http://www.opensource.apple.com/source/WebCore/WebCore-658.28/platform/graphics/chromium/HarfbuzzSkia.cpp

Ben Wagner

unread,
Jan 26, 2015, 11:21:38 AM1/26/15
to skia-d...@googlegroups.com
Yes, currently Skia is most useful for drawing already positioned glyphs. The support for text to glyph mapping in Skia currently is rather simple, and does not handle general shaping. It mostly exists for the cases where the user is in full control of the strings to be drawn and finds Skia's simple results to be acceptable. The current recommended practice for general text is to use HarfBuzz to do the shaping and then one can use Skia for drawing the glyphs. Chromium no longer uses WebCore, you'd probably be more interested in https://code.google.com/p/chromium/codesearch#chromium/src/third_party/WebKit/Source/platform/fonts/&sq=package:chromium , particularly the 'shaping' directory there. Using HarfBuzz this way is also how Android generally works. We have received a number of requests for some sort of example HarfBuzz integration with Skia so we may do something like that in the future, but it's probably a ways off.

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages