Open replabrobin opened 4 months ago
I don't think you are ever supposed to set the cluster manually. HarfBuzz does that for you, but there are three "levels" of operation, giving different results:
hb.BufferClusterLevel.DEFAULT
aka hb.BufferClusterLevel.MONOTONE_GRAPHEMES
hb.BufferClusterLevel.MONOTONE_CHARACTERS
hb.BufferClusterLevel.CHARACTERS
https://harfbuzz.github.io/working-with-harfbuzz-clusters.html
In the context of your example, you would set the level like this:
buf.cluster_level = hb.BufferClusterLevel.CHARACTERS
Thanks for that info. I don't need cluster.setter then. I really don't want to get into the horrid details of harfbuzz. The layout problems that result from using a shaper are enough. I suppose reportlab will need a new kind of font to allow input shaping and after line breaking the line drawing will need additional positioning. I doubt that we will end up with just one way to do it :(
Setting clusters on the buffer is sometimes useful. For example, in hb-view
we reset them to be Unicode character index, instead of UTF-8
index.
I wanted to set the buffer info cluster value before shaping so I could use the returned cluster numbers as a guide to the input colours etc etc. I had to add a setter to make this possible
but although I can set the cluster values prior to shaping the returned clusters are all zero
so this code
produces this output
and all the returned clusters seem to be zero.
I find that if I use buf.cluster_level = 1 after creation then I do see a difference of clusters ie gid137 gets a cluster value 4