5

LuaLaTeX (via luaotfload and fontspec) knows many properties of font glyphs, and many of them can be shown to the user. So it seems to me that what I am about to ask is "possible".

EDIT: As David Carlisle answered (below), none of this was necessary.

MWE:

\documentclass{article}
% compile using lualatex
\RequirePackage{fontspec}
\begin{document}
HALT!\par
HAL\raisebox{-.2em}{T}!\par
HAL\lower.2em\hbox{T}!
\end{document}

Result: HALT result of codee

As you see, The LT is kerned when the T is not moved. But raising or lowering the T requires using a box, and the box breaks the kern. So, the lowered T is slightly to the right of where it should be.

Since Lua knows the glyph outline bounding boxes (not just the character advance width), I imagine that it is possible to grab only the glyph itself (unboxed) and displace it. The kerning algorithm, which (presumably) knows nothing about that displacement, would still perform kerning.

Application is text-only, not math mode or tables.

Can it be done? Point me in the direction, and I will attempt it myself (if possible).

I realize that I could manually apply kerning. I seek a solution that does not require that knowledge, since the font may change. Also, the \smash command (my favorite) nevertheless breaks kerning.

0

1 Answer 1

5

even in classic tex you can add the missing kern (difference of width \hbox{LT} and \hbox{L\hbox{}T})

enter image description here

\documentclass{article}
% compile using lualatex
\RequirePackage{fontspec}
\begin{document}
HALT!\par
HAL\sbox0{LT}\kern\wd0\sbox0{L\hbox{}T}\kern-\wd0\raisebox{-.2em}{T}!\par
HAL\sbox0{LT}\kern\wd0\sbox0{L\hbox{}T}\kern-\wd0\lower.2em\hbox{T}!
\end{document}
1
  • Ha, ha! Once my mind was focused on font editing and Lua code, I could not see a simple thing like that. Thanks.
    – user287367
    Commented May 8, 2023 at 18:00

You must log in to answer this question.