Skip to content

Error on accessing kerns via fonts.handlers.otf.getkern/fonts.handlers.otf.getgsub with some fonts #329

Description

@a-j-cain

The LuaLaTeX code below uses fonts.handlers.otf.getkern to query kerning between T and e.

\documentclass{article}

\usepackage{fontspec}

\setmainfont{texgyretermes-regular.otf} % OK
% \setmainfont{Alegreya-Regular.otf} % Error

\begin{document}

Test

\directlua{
  local fnt = font.current()
  local tfmdata = fonts.hashes.identifiers[fnt]
  local T = string.byte("T")
  local e = string.byte("e")
  print('KERN=' .. tostring(fonts.handlers.otf.getkern(tfmdata,T,e,"kern")))
}

\end{document}

It works fine with TeX Gyre Termes and the result KERN=-55705.6 is printed, but switching to Alegreya (OFL, available here) produces the error luaotfload/fontloader-2023-12-28.lua:19928: 'for' limit must be a number.

The same error appears with certain other fonts, e.g. Minion 3 (non-free), so it seems not to be a problem with the Alegraya font specifically.

Ignoring the error, the document compiles and T and e in ‘Test’ are correctly kerned.

getkern calls font.handlers.otf.getgsub. Calling font.handlers.otf.getgsub(tfmdata,T,"kern") directly gives the same error with Alegreya, but trying other lookups (e.g. "c2sc") in place of "kern" shows no error. I think nofsteps is not being set for the kern lookup, but I do not know why or where.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions