LuaLaTeX – How to Manage Dot-Below Accent Placement with Various Text Fonts

accentscomputer-modernfontspeclatin-modernluatex

There seem to be significant differences in the horizontal alignment of the "dot-under" accent depending on whether pdfLaTeX, XeLaTeX, or LuaLaTeX is in use. (I use MacTeX2016, which (still) uses LuaTeX 0.95, with all packages updated thru today (2/22).)

With pdfLaTeX:

enter image description here

With XeLaTeX (and fontspec):

enter image description here

With LuaLaTeX (and fontspec):

enter image description here

The placement of the dot-under accents with pdfLaTeX and XeLaTeX is fairly similar, but it's rather different and, in some cases, rather haphazard-looking with LuaTeX; cf. the location of the dot-under accent below the letter i. The placement of the dot-under accent below the letter e isn't exactly too hot either.

Is there something a LuaLaTeX user can do to "fix" the placement of the dot-under accents?

Incidentally, if EB Garamond is used instead of Computer/Latin Modern, the placement of the dot-under accents is fairly similar (and, in particular, not objectionable) for pdfLaTeX, XeLaTeX, and LuaLaTeX.

\documentclass[border=0.5pt]{standalone}
\usepackage{ifluatex,ifxetex}
\ifluatex
    \usepackage{fontspec,luatex85}
\else
   \ifxetex
       \usepackage{fontspec}
   \else
       \usepackage[T1]{fontenc}
   \fi
\fi
\begin{document}
\d{a} \d{e} \d{i} \d{o} \d{u}
\end{document}

Best Answer

What happens, at the moment, is that no \d composites are declared in the TU encoding, so \d{a} and so on are realized as combinations with the combining dot below (U+0323).

However, with XeLaTeX, the HarfBuzz library will seize the initiative and if the precomposed character exists in the font, it will use it. This doesn't happen with LuaTeX.

This is a grey area, I'd say. If the composite are declared, you get nothing if the font doesn't support the characters, if not, you have to rely on good positioning.

Indeed, if I try \showoutput with LuaLaTeX, I get for \d{i}

....\TU/lmr/m/n/10 i
....\TU/lmr/m/n/10 ̣

whereas XeLaTeX shows

....\TU/lmr/m/n/10 ị

Unfortunately, Latin Modern is quite weak in positioning certain combining characters, other fonts are better in this respect.

You can fix the issue, provisionally, by defining yourself the necessary composites:

\documentclass{article}
\usepackage{fontspec,ifluatex}

\makeatletter
% fix the hidden feature in tuenc.def
\def\add@unicode@accent#1#2{%
  \if\relax\detokenize{#2}\relax^^a0\else#2\fi
  \char#1\relax
}
\makeatother

\ifluatex
\usepackage{luatex85}
\DeclareTextComposite{\d}\UnicodeEncodingName{A}{"1EA0}
\DeclareTextComposite{\d}\UnicodeEncodingName{a}{"1EA1}
\DeclareTextComposite{\d}\UnicodeEncodingName{E}{"1EB8}
\DeclareTextComposite{\d}\UnicodeEncodingName{e}{"1EB9}
\DeclareTextComposite{\d}\UnicodeEncodingName{I}{"1ECA}
\DeclareTextComposite{\d}\UnicodeEncodingName{i}{"1ECB}
\DeclareTextComposite{\d}\UnicodeEncodingName{O}{"1ECC}
\DeclareTextComposite{\d}\UnicodeEncodingName{o}{"1ECD}
\DeclareTextComposite{\d}\UnicodeEncodingName{U}{"1EE4}
\DeclareTextComposite{\d}\UnicodeEncodingName{u}{"1EE5}
\fi    

\begin{document}
\d{a} \d{e} \d{i} \d{o} \d{u}
\end{document}

enter image description here

For the “hidden feature”, see How to place a dot below for example: e?

Related Question