[HarfBuzz] Using hb_buffer_add_utf8 and hb_buffer_add_codepoints on same buffer

Behdad Esfahbod behdad.esfahbod at gmail.com
Fri Dec 25 12:55:14 PST 2015


Hi Deepak,

On 15-12-22 04:35 PM, Deepak Jois wrote:
> I was adding support for hb_buffer_add_codepoints in luaharfbuzz[1],
> and I was confused about how clustering works:
> 
> 1. Is it valid, if I initialise a buffer and then call
> hb_buffer_add_utf8, followed by hb_buffer_add_codepoints?

Yes.


> 2. When I try do the above by calling hb_buffer_add_utf8 with UTF8
> string ‘یہ ’ (U+06CC U+06C1 U+0020), followed by calling
> hb_buffer_add_codepoints with an array containing { U+06CC, U+06C1 },
> and then shape the output with Amiri font, I get this (offset and
> advance values elided for simplicity):

Arbitrary cluster values are supported.  So you are allowed to get access to
the buffer and modify cluster values before calling hb_shape().  So, you can
adjust to whatever scheme you like.


> {
>   {
>     cluster = 1,
>     codepoint = 2250,
>>   },
>   {
>     cluster = 0,
>     codepoint = 2106,
>>   },
>   {
>     cluster = 4,
>     codepoint = 3,
>>   },
>   {
>     cluster = 2,
>     codepoint = 2250,
>>   },
>   {
>     cluster = 0,
>     codepoint = 2106,
>>   }
> }
> ---
> 
> What is the right way to correlate the cluster values to the original input?

Really whatever you (the client) want it to mean.

behdad

> Deepak
> 
> [1]:https://github.com/deepakjois/luaharfbuzz
> _______________________________________________
> HarfBuzz mailing list
> HarfBuzz at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/harfbuzz
> 


More information about the HarfBuzz mailing list