# Adjust diacritic position in emph mode

I use the the additionnal letters , ĥ, and . With the CMU font in emph mode.

So, with the following MWE:

\documentclass{article}
\usepackage{fontspec}

\setmainfont{CMU Serif}

\begin{document}

\emph{ḧ ĥ ḋ}

\end{document}

I get this rendering:

But the diacritics seems a little bit unbalanced, especially when it is followed by other characters with the same diacritic, as you can see bellow:

So, the goal is to horizontally move the diacritics to adjust it according to the following table:

Is it possible to do that?

• Fix the font. No other way. – egreg Jun 19 '18 at 8:21
• @egreg, I think so, finally. But how can I close this topic correctly? – fauve Jun 19 '18 at 20:14
• would an answer about metafont be off-topic on this SE site? – galex-713 Jun 20 '18 at 18:17
• I don’t think so. Metafont still related to LaTeX. – fauve Jun 20 '18 at 18:30
• Personally I’d disagree with a such font since in the roman (not slanted nor italic form) variant the diacritic is centered at this place too, this would be inconsistent, and already having standard typography saying that diacritic should be centered on the character rather than on the bar or highest point or arbitrary point of the character is simpler to implement. – galex-713 Jun 20 '18 at 19:51

The position of the diacritics can be adjusted using stackinset from the stackengine package. The idea is to define a separate macro for every combination of letter and diacritic. This defeats the purpose of using unicode, but the result is as required.

The arguments of \stackinset are horizontal align of the inserted symbol relative to the base symbol (left, center, right), horizontal offset (positive or negative), vertical align, vertical offset, inserted symbol (called inset), base symbol (called anchor).

MWE:

\documentclass{article}
\usepackage{fontspec}
\usepackage{stackengine}

\setmainfont{CMU Serif}

\begin{document}
\emph{ḧ ĥ ḋ} (default)

\def\huml{\stackinset{c}{-1pt}{t}{-2pt}{\"{}}{h}}
\def\hcar{\stackinset{c}{-1pt}{t}{-2.5pt}{\^{}}{h}}
\def\ddot{\stackinset{c}{2.5pt}{t}{-3.5pt}{$\cdot$}{d}}

\vspace{2mm}

\emph{\huml\ \hcar\ \ddot} (with \texttt{\textbackslash stackinset})

\end{document}

Result: