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

Patrick Gundlach patrick at gundla.ch
Mon Feb 3 14:16:21 CET 2020


Hello all, 

I am still struggling with this. And I don't know if this is a harfbuzz question or a LuaTeX question.

I have a truetype font (Zapfino.ttf), and I don't understand the values returned from shape_full (codepoint) or what to put into the char filed in the glyph nodes.


Doing shape_full with the letters "Za" gives me the code points 104 and 504, which seem to be the glyph ids for this font.

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

So everything is fine for simple letters.


But this seems to cover only parts of the font. For example the 'pf' ligature gives codepoint 1108, which has no unicode counterpart from the method above. 

What should I do with the 1108 to get a value to put into the char entry of a glyph node?

Patrick



> Am 10.01.2020 um 10:46 schrieb Patrick Gundlach <patrick at gundla.ch>:
> 
> 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.