[luatex] Harfbuzz: how to get unicode values for ligature?

Patrick Gundlach patrick at gundla.ch
Fri Jan 10 10:46:52 CET 2020


Hello all,

I try to use the Harfbuzz shaper. I use, for example, the Zapfino truetype font which is pre-installed on the Mac.

I add the utf8 encoded characters Z and a to a buffer and call harfbuzz.shape_full() with the default font features. The result is:

glyphs = {
  [1] = {
    ["y_advance"] = "0"
    ["x_advance"] = "416"
    ["cluster"] = "0"
    ["codepoint"] = "104"
    ["y_offset"] = "0"
    ["x_offset"] = "0"
  },
  [2] = {
    ["flags"] = "1"
    ["y_advance"] = "0"
    ["x_advance"] = "264"
    ["cluster"] = "1"
    ["codepoint"] = "504"
    ["y_offset"] = "0"
    ["x_offset"] = "-21"
  },
},

Then I try to get the two unicode values of the glyph ids 104 and 504 which map to 90 ('Z') and 97 ('a') and create glyph nodes with the char value of 90 and 97 and output these as a novelist. The PDF looks fine.

When I try to do the same with the word Zapfino, which gets rendered as one ligature, I get

glyphs = {
  [1] = {
    ["y_advance"] = "0"
    ["x_advance"] = "2333"
    ["cluster"] = "0"
    ["codepoint"] = "1059"
    ["y_offset"] = "0"
    ["x_offset"] = "0"
  },
},

which is what I expect. Now the problem is, that I can't find out the unicode value which I need for the glyph node. Can anybody help me with this step?

I get the unicode values from a font with

face:collect_unicodes() 

and iterate over the resulting unicode values to get the glyph id with

glyphid = font:get_nominal_glyph(<unicode-codepoint>)

Thank you!
  Patrick





More information about the luatex mailing list