# XeLaTeX : Problem with diacritics (using Gentium font)

I get three diacritical points in ' ї ' (U+0457) symbol using XeLaTeX and Gentium font, instead of two. This may be an issue only with Gentium, as other fonts work well.

\documentclass[12pt,a4paper]{article}
\usepackage{polyglossia}
\newfontfamily\cyrillicfont[Script=Cyrillic]{Gentium}
\setdefaultlanguage{ukrainian}

\begin{document}
ї      %   three diacritical points - wrong symbol
\"\i   %   right symbol
\ Ї    %   right capital symbol (U+0407)
\end{document}

-

The character U+0457 doesn't exist in Gentium, so \"i is used, which is obviously wrong.

You can use newunicodechar to test if the character exists:

\documentclass[12pt,a4paper]{article}
\usepackage{polyglossia}
\newfontfamily\cyrillicfont[Script=Cyrillic]{Gentium}
\setdefaultlanguage{ukrainian}

\usepackage{newunicodechar}
\newunicodechar{ї}{\iffontchar\fontїї\else\"\i\fi}

\begin{document}
ї      %   right symbol
\"{\i} %   right symbol
Ї      %   right capital symbol (U+0407)
\end{document}


-
U+0457 exists in Gentium Plus. But it’s still useful to know how to test for it. –  Thérèse Aug 4 '13 at 19:20

Elaborating on egreg’s answer, what happens is that HarfBuzz (the OpenType layout engine used by XeTeX) tries its best to render any given charter, and since Gentium does not support U+0457 it tries to decompose it into its canonically equivalent decomposed form; U+0457 + U+0308 since both are supported by the font. However, the font does not correctly handle combining U+0457 with diacritical marks (it is a soft dotted character, so it should lose its dot when combined with combining marks), and so this is considered a font bug. See this HarfBuzz mailing list thread for more discussion on this.

-
I was asking myself which component was responsible of the substitution. This feature of HarfBuzz seems very interesting. –  egreg Aug 5 '13 at 15:10

Gentium Basic has more weights but a smaller character set than Gentium, and Gentium Plus expands on Gentium to offer almost complete support for Latin, Cyrillic, and Greek. See the Gentium FAQ if you want more details. For your purposes, simply change \newfontfamily\cyrillicfont[Script=Cyrillic]{Gentium} to \newfontfamily\cyrillicfont[Script=Cyrillic]{Gentium Plus}`.

-

Gentium has no smarts in it. Instead we recommend using Gentium Plus that has the full range of smarts found in SIL's other Roman fonts (Charis, Andika, Doulos).

-