[HarfBuzz] Rendering Thai

Theppitak Karoonboonyanan thep at linux.thai.net
Thu Jan 19 00:02:17 PST 2012


On Thu, Jan 19, 2012 at 11:46 AM, Behdad Esfahbod <behdad at behdad.org> wrote:
> On 01/18/2012 11:37 PM, Theppitak Karoonboonyanan wrote:
>> On Thu, Jan 19, 2012 at 11:09 AM, Behdad Esfahbod <behdad at behdad.org> wrote:
>>> On 11/11/2011 04:41 AM, Theppitak Karoonboonyanan wrote:
>>>> No. I mean, the default routine in harfbuzz should be fixed for this case.
>>>
>>> So, can you please explain to me what the Thai-specific rendering requirements
>>> are?
>>
>> In John's examples, Sara Am is decomposed, but then rendered
>> in wrong order with tone mark. The correct order is that tone mark
>> is put above Nikhahit (the O-ring). But without decomposition GSUB
>> in the font, Harfbuzz appears to put Nikhahit above the tone mark
>> instead, which is wrong.
>
> Right.  But what is a shaping engines supposed to do beyond the generic
> OpenType shaping to achieve that?  The MS spec doesn't suggest anything extra.

What I wanted to say here was that the the combining characters
should be correctly normalized. Just that.

PUA shaping can be an option for legacy font support.
("Legacy" here means Windows XP, which still dominates the
market, though.)

>> PUA shaping.
>
> Ok, what's that?  From what I understand different vendors approached solving
> the problem differently, using PUA space?  How exactly?

I can't find reference documents right now. But you can see
sample implementations in Pango Thai module, and also in
libthai under the "thrend" module.

The PUA space has been used by localized versions of Windows
and Mac since before the Unicode age. So, there are 2 versions
of each vendor's tables: 8-bit and 16-bit code points.
The PUA glyph sets for Mac and Windows are the same,
only their code points differ.

>>> HarfBuzz kinda normalizes text now.  Is it doing anything better?
>>
>> I wonder what's the simple way to test harfbuzz-ng, so I can see
>> it myself. Is it currently used in Pango?
>
> The hb-view tool included in the HarfBuzz repo under util/.

It's severely broken in my box. See the attached p.png for the
output of the command:
./hb-view /usr/share/fonts/truetype/tlwg/Loma.ttf
»èÓ«éÓ¾èÍ»Ùè¾Õè»Õè®Ø°Ø­Ø > p.png

>>> If I understand correctly, this is related to the issue recently brought up by
>>> Sairus (Adobe) on the OpenType list:
>>>
>>> "It's recently come to my attention that the MS Thai layout spec
>>> http://www.microsoft.com/typography/otfntdev/thaiot/features.aspx  doesn't
>>> require layout engines to do the sara am decomposition and reordering. I'm
>>> told that some engines do the sara am decomposition and reordering e.g.
>>> Uniscribe and Adobe's CTS, and others don't e.g. Harfbuzz."
>>>
>>> Are we talking about the same thing?  If yes, I can look into this.
>>
>> I'm not sure. From John's examples, it looks like Harfbuzz has already
>> decomposed it. Otherwise, it's impossible to produce that wrong order.
>
> Right, we decompose.  But what's the reordering?  I believe that's where the
> problem is.

Yes, it looks like the reordering (or normalization) stage is missing
after the decomposition stage.

>> To test it, you can try the sample text "»èÓ". When decomposed and
>> shaped with PUA, both Nikhahit and the tone mark should be shifted
>> left to avoid overlapping with the long stem of the base character.
>
> Can you suggest a free font I can test with?  Can you send me right/wrong
> screenshots also?  My Thai script comprehension is less than perfect, you know :).

You can use fonts from thaifonts-scalable project here:

ftp://linux.thai.net/pub/thailinux/software/thai-ttf/thai-ttf-0.4.17.tar.gz

I've also attached the proper output for the hb-view command
above (20120119-thai-loma-render.png).

Regards,
-- 
Theppitak Karoonboonyanan
http://linux.thai.net/~thep/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p.png
Type: image/png
Size: 1276 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/harfbuzz/attachments/20120119/0b68b97f/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 20120119-thai-loma-render.png
Type: image/png
Size: 5405 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/harfbuzz/attachments/20120119/0b68b97f/attachment-0001.png>


More information about the HarfBuzz mailing list