# Weird font/spacing issue with LuaTeX & Asana Math

Trying to use LuaTeX font support in some big document, everything went fine except a little glitch with Asana Math font. Here is the issue:

\documentclass{standalone}
\usepackage{unicode-math}

\begin{document}
\setmathfont{Asana Math} %(probably unrelated, but without this nothing will show up)

Spacing issues:
\begin{tabular}{cccccccc}
\setmathfont{Asana Math}
$α_1$ & $ω_a$ & $ωa$ & $ω_1$ & $ω^a$ & $\omega_1$ & $Ω_1$ & $λ_k$ \\
\setmathfont{XITS Math}
$α_1$ & $ω_a$ & $ωa$ & $ω_1$ & $ω^a$ & $\omega_1$ & $Ω_1$ & $λ_k$ \\
\end{tabular}

\end{document}


ω has a little problem with subscripts (and superscripts). Updated the font and unicode-math with the last versions available on CTAN, but the problem remains.

Any idea of what can cause this? Any workaround that won't require to spot every occurence of "ω_"?

-
Bugs in Asana, I guess? –  Taco Hoekwater Jul 27 '11 at 19:48
Compiling the document with xelatex doesn't exhibit the problem. –  Caramdir Jul 27 '11 at 19:54
@Taco: Looks like it, but I know nothing about font formats/metrics. Any ideas for places to look at would be appreciated. –  Stéphane Gimenez Jul 27 '11 at 19:57
You should report this bug (see tug.org/pipermail/xetex/2011-March/020252.html). –  Caramdir Jul 27 '11 at 23:02
@Caramdir: Done, thanks for the link. –  Stéphane Gimenez Jul 28 '11 at 16:10

I'm pretty sure this is a font bug. As can be seen using FontForge, the anchor for bottom-right subscripts is too far away from the glyph (the anchor is the small dot on the baseline in the third panel):

And the result is the same in Microsoft Word, which is the reference implementation for OpenType math:

This "works" in XeTeX because XeTeX's OpenType math implementation is less sophisticated than the implementations of LuaTeX and MS Word: XeTeX simply ignores the math kern, therefore you (and presumably the creator of Asana Math) don't see the bug there.

Here is an example how to fix such bugs while loading fonts in LuaTeX. This simply removes the offending kern info (no kern seems to look ok, otherwise you can use any kern array you want):

\documentclass[pagesize=auto, version=last]{scrartcl}

\usepackage{unicode-math}
\usepackage{luacode}

\begin{luacode*}
local function patch_asana(fnt)
if fnt.psname == "Asana-Math" then
fnt.characters[0x1D714].mathkern.bottom_right = nil
end
end
\end{luacode*}

\setmathfont{Asana Math}

\begin{document}

$\omega_a$

\end{document}

-
Thanks, I guess fontforge can be used to fix that easily? –  Stéphane Gimenez Jul 27 '11 at 21:42
Perfect! I used .mathkern = nil to remove them all. I also tried to use fontforge, but couldn't find an automatic way to 'guess' mathkerns. Anyway, thanks again. –  Stéphane Gimenez Jul 27 '11 at 22:45
@Stéphane: If guessing math kerns were so easy, we wouldn't need a way to do it manually ;-) Can you perhaps report the kerning bug to the author of Asana Math? –  Philipp Jul 28 '11 at 8:50
Did you inform the package author of this bug, so it can be fixed? –  Ingo Feb 15 '12 at 9:36