[HarfBuzz] Using hb_buffer_add_utf8 and hb_buffer_add_codepoints on same buffer

Deepak Jois deepak.jois at gmail.com
Tue Dec 22 07:35:52 PST 2015


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?

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):

---
{
  {
    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?

Deepak

[1]:https://github.com/deepakjois/luaharfbuzz


More information about the HarfBuzz mailing list