[luatex] Bizarre bug with fontspec, math, and hat/tilde positioning

Andrew Lutomirski luto at mit.edu
Sat Aug 6 00:17:14 CEST 2011

I'm having trouble with the positioning of hats and tildes in
lualatex.  To test this, you'll need Linux Libertine OpenType 5.1.3
unpacked into your current directory.  The issue is that hats and
tildes (but not both, if the brackets are appropriately positioned)
are positioned way too far to the left.

xelatex gets this right.  The no-math option to fontspec gets it a lot
closer to correct.  The older Libertine fonts that come with TexLive
seem to work as well.

\mathit{\tilde A} has all kinds of different weird issues.

I don't really know if this is the right list for this, since I don't
know where the bug is.

--- cut here ---

\documentclass[english]{article}
\usepackage[letterpaper]{geometry}
\usepackage{babel}

% With no-math, everything works.
\usepackage{fontspec}

\usepackage{amsmath}

% A new font (5.1.3) in the local directory has issues with LuaTeX.
\setromanfont[ExternalLocation=./,Mapping=tex-text,UprightFont=*_R,ItalicFont=*_RI,Extension=.otf,Numbers={OldStyle,Proportional}]{LinLibertine}

% An older font that TexLive bundles is OK.
%\setromanfont[ExternalLocation=/usr/share/texlive/texmf-dist/fonts/opentype/public/libertine/,Mapping=tex-text,UprightFont=*r,ItalicFont=*ri,Extension=.otf,Numbers={OldStyle,Proportional}]{fxl}

% But the system version get all but \mathit right.
%\setromanfont{Linux Libertine O}

\begin{document}

$\tilde A$

${\tilde A}$

$\hat A$

% If amsmath is enabled, then this draws a hat and tilde in the wrong place.
%$%\hat \tilde A %$

% If amsmath is enabled, then this draws a hat and tilde in the right place (!)
$\hat{\tilde A}$

$\mathit{\tilde A}$

\end{document}