[XeTeX] Diacritics in color

Heiko Oberdiek heiko.oberdiek at googlemail.com
Wed Nov 30 02:09:47 CET 2011


On Wed, Nov 30, 2011 at 10:58:23AM +1100, Ross Moore wrote:

> On 30/11/2011, at 10:32 AM, Heiko Oberdiek wrote:
> 
> > or
> >  ^^^^00c4\\
> >  A^^^^0308\\
> >  A\textcolor{red}{^^^^0308}
> > 
> > As you can see, this problem is not related to color,
> > both XeTeX and LuaTeX fail:
> 
> With this font (Latin Modern) yes. I noticed this too.
> 
> But try switching the font:
> 
> \documentclass{minimal}
> \usepackage{fontspec}
> \usepackage{color}
> \pagestyle{empty}
> 
> \setmainfont{Charis SIL}
> 
> \begin{document}
> \fontsize{100pt}{100pt}\selectfont
> \noindent
> ^^^^00e4\\
> a^^^^0308\\
> a\textcolor{red}{^^^^0308}\"a
> \hbox{U^^^^0308} U\textcolor{red}{^^^^0308}\"U
> 
>  ^^^^00c4\\
>  A^^^^0308\\
>  A\textcolor{red}{^^^^0308}
> 
> \end{document}
> 
> 
> Now it *does* depend upon having the color commands.

\documentclass{minimal}
\usepackage{ifluatex}
\usepackage{fontspec}
\ifluatex
  \usepackage{luacolor}
  \pdfobjcompresslevel=0
  \pdfcompresslevel=0
\else
  \usepackage{color}
\fi

\pagestyle{empty}

\setmainfont{CharisSIL-R.ttf}

\begin{document}
\fontsize{100pt}{100pt}\selectfont
\noindent
^^^^00c4\\ % (1)
A^^^^0308\\ % (2)
A\textcolor{red}{^^^^0308}\\ % (3)
A\textcolor{red}{\hbox{^^^^0308}} % (4)
\end{document}

* LuaTeX: "A" + U+0308 gets combined to one glyph U+00C4, the
  color attribute of the diaeresis vanishes and the result is
  black (3). In the last line (4) \hbox prevents the recombination
  and the diaeresis is red, but misplaced.
* XeTeX: The color special prevents the glyph recombination and
  U+0308 is processed separately without knowing the base character
  (3 and 4).

Thus the workaround would be to prevent the recombination and
to fix the placement manually.

Yours sincerely
  Heiko Oberdiek


More information about the XeTeX mailing list