[Tex/LaTex] TeX accents do not seem to work with fontspec and xe/lua/latex

accentsfontsfontspecluatexxetex

I am using Minion Pro as mainfont and it does not have in its glyph table the character U+1E47 Latin small letter with dot below which I need only once in my document. Rather than change to another font, I thought that I would generate it using \d{n}.

I give below a minimal file illustrating the problem:

\documentclass{minimal}
\usepackage{fontspec}
    \defaultfontfeatures{Ligatures=TeX}
    \setmainfont{Minion Pro} % Comment out optionally
\begin{document}
U+1E47 Latin small letter with dot below: \d{n}

U+0101 Latin small letter a with macron: \={a}
\end{document}

I do not get the desired letter n with dot below although the a with macron exists in the font and is available. Commenting out \usepackage{fontspec} gives the desired output with CMR as default font.

The behaviour is the same with xelatex and lualatex although the former indicates the missing letter with a crossed box.

I believe that with the Ligatures=TeX setting, I should be able to get missing letters using TeX accents. I do not think I need to load the xunicode package as it is already loaded by fontspec.

Can someone tell me what a I am doing wrong, please?

Thank you.

Best Answer

The "standard way" would be to say

\UndeclareUTFcomposite[\UTFencname]{x1E47}{\d}{n}

in order to use the combining character instead of the missing character at U+1E47, but unfortunately Minion Pro has nothing in slot U+0323 (COMBINING DOT BELOW). We need to go the hard way: write the following in the preamble

\UndeclareUTFcomposite[\UTFencname]{x1E47}{\d}{n}
\makeatletter
\renewcommand{\d}[1]
   {\hmode@bgroup
    \o@lign{\relax#1\crcr\hidewidth\ltx@sh@ft{-1ex}.\hidewidth}\egroup}
\makeatother

so that you'll use the standard definition for \d. If other characters of that sort are needed, look in xunicode.sty for their definition; it starts with \DeclareUTFcomposite, it's sufficient to copy the line in your preamble and to change \Declare... into \Undeclare....

Let's look also at the "line below", which is again missing in Minion Pro. Here's a similar way to cope with the case, using the macron (U+00AF) for emulating the line below:

\documentclass{article}
\usepackage{fontspec,newunicodechar}
\defaultfontfeatures{Ligatures=TeX}
\setmainfont{Minion Pro} % Comment out optionally

\UndeclareUTFcomposite[\UTFencname]{x1E47}{\d}{n}
\UndeclareUTFcomposite[\UTFencname]{x1E49}{\b}{n}
\makeatletter
\let\d\relax
\DeclareRobustCommand{\d}[1]
   {\hmode@bgroup
    \o@lign{\relax#1\crcr\hidewidth\ltx@sh@ft{-1ex}.\hidewidth}\egroup}
\let\b\relax
\DeclareRobustCommand{\b}[1]
   {\hmode@bgroup\o@lign{\relax#1\crcr\hidewidth\ltx@sh@ft{-3ex}%
     \vbox to.2ex{\hbox{\char"AF}\vss}\hidewidth}\egroup}
\makeatother
\newunicodechar{ṇ}{\d{n}}
\newunicodechar{ṉ}{\b{n}}

\begin{document}
U+1E47 Latin small letter n with dot below: \d{n}ṇ

U+1E49 Latin small letter n with line below: \b{n}ṉ

U+0101 Latin small letter a with macron: \={a}ā

\end{document}

It's perhaps better to declare \b and \d as robust commands. Moreover, with newunicodechar we can also input the characters directly.

enter image description here

Related Question