# Xelatex vs Lualatex and font substitution

As is known, in the Turkish language the i exists as distinct letters in two versions, with and without a dot (with very different pronunciations): the dotted couple i / İ and the dotless couple ı / I.

Plz, consider this code:

\documentclass[a4paper,12pt]{article}
\usepackage{ifxetex,ifluatex}
\usepackage{fontspec}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\ifluatex
\usepackage[turkish,italian]{babel}
\babelfont[italian]{rm}[Ligatures=TeX]{Garamond Premier Pro}
\babelfont[turkish]{rm}[Ligatures=TeX]{Garamond Premier Pro}
\fi

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\ifxetex
\setmainfont[Ligatures=TeX]{Garamond Premier Pro}
\usepackage{polyglossia}
\setmainlanguage[babelshorthands=true]{italian}
\setotherlanguage{turkish}
\fi

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\textbf{Italian}

\verb!\MakeUppercase{aabbccddiixx}! \MakeUppercase{aabbccddiixx}

\verb!\MakeUppercase{aabbccddııxx}! \MakeUppercase{aabbccddııxx}

\verb!\MakeLowercase{AABBCCDDİİ}! \MakeLowercase{AABBCCDDİİ}

\verb!\MakeLowercase{AABBCCDDII}! \MakeLowercase{AABBCCDDII}

fi ffi

\textbf{Turkish}

\selectlanguage{turkish}

\verb!\MakeUppercase{aabbccddiixx}! \MakeUppercase{aabbccddiixx}

\verb!\MakeUppercase{aabbccddııxx}! \MakeUppercase{aabbccddııxx}

\verb!\MakeLowercase{AABBCCDDİİ}! \MakeLowercase{AABBCCDDİİ}

\verb!\MakeLowercase{AABBCCDDII}! \MakeLowercase{AABBCCDDII}

fi ffi

\end{document}


If you compile with Xelatex all substitution work fine. But if you compile with Lualatex, two i disappear:

What does this different behavior depend on? Is there a solution with Lualatex? I can also modify some lookups of the font, but I must first understand the reasons for what happens.

Thank you

Postscriptum 1st August

I realize that there is a new version of turkish.ldf (2019/07/05 v1.4), but compiling the same file I receive:

(/usr/local/texlive/2019/texmf-dist/tex/generic/babel/locale/tr/babel-turkish.t
ex

! LaTeX Error: Can be used only in preamble.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
...

l.13 \StartBabelCommands
*{turkish}{}
?
! Undefined control sequence.
l.14   \SetCase

?
! Missing number, treated as zero.
\relax
l.15     {\uccodei=
İ\relax
?
! Missing number, treated as zero.
\relax
l.16      \uccodeı=
I\relax}
?
! Missing number, treated as zero.
\relax
l.17     {\lccodeİ=
i\relax
?
! Missing number, treated as zero.
\relax
l.18      \lccodeI=
ı\relax}
?
! Undefined control sequence.
l.19   \SetHyphenMap
{%
?

! LaTeX Error: Can be used only in preamble.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
...

l.22 \EndBabelCommands


Giving ENTER every time, finally it compiles... Am I doing something wrong?

• I can reproduce the issue with other fonts, so I don't think it is an issue with the font itself. – Ralf Stubner Jun 26 '19 at 5:26
• I didn't mean to report the problem to that font, mine was just a MWE. But obviously there is a different general behavior in handlign even substitutions in Xelatex and Lualatex. Which the respective logic? Why does Lualatex fail ? – user41063 Jun 26 '19 at 7:07
• Turns out is not a LuaTeX vs XeTeX but a babel vs. polyglossia issue, c.f. github.com/latex3/babel/issues/18. – Ralf Stubner Jun 26 '19 at 10:22
• You shouldn't edit your question like this. Better ask a new question. But beside this: I don't get the error. Delete your auxiliary files (aux, toc etc) and try again. If the error persists show the complete log-file. – Ulrike Fischer Aug 1 '19 at 8:11

turkish.ldf is broken: it is too old and doesn't take into account that the encoding for lualatex has changed from EU2 to TU.

In two places EU1 EU2 in the ldf must be changed to TU:

\StartBabelCommands*{turkish}{captions}
[unicode, charset=utf8, fontenc=EU1 EU2] %<<< e.g. here


Notify the maintainer.

The alternative is to use the new babel interface and to load the language through an ini:

\documentclass[a4paper,12pt]{article}
\usepackage{ifxetex,ifluatex}
\usepackage{fontspec}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{babel}
\babelprovide[import=tr,main]{turkish}
\babelfont[turkish]{rm}[Ligatures=TeX]{arial}

\begin{document}
\textbf{Turkish}

aabbccddııxx AABBCCDDİİ

\verb!\MakeUppercase{aabbccddiixx}! \MakeUppercase{aabbccddiixx}

\verb!\MakeUppercase{aabbccddııxx}! \MakeUppercase{aabbccddııxx}

\verb!\MakeLowercase{AABBCCDDİİ}! \MakeLowercase{AABBCCDDİİ}

\verb!\MakeLowercase{AABBCCDDII}! \MakeLowercase{AABBCCDDII}

fi ffi

\end{document}


• Shouldn’t that be dotlessi in the last line? – Ralf Stubner Jun 26 '19 at 8:29
• @RalfStubner I don't know the exact rules. The uppercase command maps both to I, so it is not quite clear what the lowercase should do. But this could certainly be adapted. – Ulrike Fischer Jun 26 '19 at 8:47
• Right, the uppercase command is probably also incorrect. AFAIK for Turkish the mapping should be ı <-> I and i <-> İ, i.e. the dotted and dotless variants do not mix. That's what one get's when compiling the OP's file with XeTeX. – Ralf Stubner Jun 26 '19 at 8:52
• Found the rules: See figures 5-14 and 5-15 in 5.18 Case Mappings. – Ralf Stubner Jun 26 '19 at 9:05
• – Ralf Stubner Jun 26 '19 at 10:18