For a LuaLaTeX package I need to read the kerning values of certain character pairs as they are defined by the current font. If the Node renderer is used, I can use the following code, where first_node and second_node are glyph nodes:

    local current_font = font.getfont(first_node.font)
    local kern = 0
    if current_font and current_font.resources
    and current_font.resources.sequences then
      for _, t in ipairs(current_font.resources.sequences) do
        if t.features and t.features.kern and t.steps and t.steps[1]
        and t.steps[1].coverage and t.steps[1].coverage[first_node.char]
        and t.steps[1].coverage[first_node.char][second_node.char] then
          kern = t.steps[1].coverage[first_node.char][second_node.char]
        end
      end
    end

However, I cannot be sure that the Node renderer is used, it may be the case that HarfBuzz is used. But with HarfBuzz the font structure is different and the above code does not return the kerning value needed. HarfBuzz defines a C function hb_font_glyph_h_kerning(), but this function does not have a Lua equivalent (unlike others listed in section 13.1 of the LuaTeX manual).

Could anyone tell me how to get the kerning values with HarfBuzz?

Reply via email to