[Tex/LaTex] XeLaTex – Arabic script letters mirrored

arabicright-to-leftxetex

I'll try to inlcude arabic script in my document, but it shows the odd behavior that the arabic letters are not "connecting" to each other in the final pdf output, they are shown as single letters. Usually some kind of RTL problem I guess, but I can't figure it out.

% !TEX TS-program = xelatex
% !TEX encoding = UTF-8

\documentclass[12pt]{article} % use larger type; default would be 10pt
\usepackage{fontspec} % Font selection for XeLaTeX; see fontspec.pdf for documentation
\defaultfontfeatures{Mapping=tex-text} % to support TeX conventions like ``---''
\usepackage{xunicode} % Unicode support for LaTeX character names (accents, European chars, etc)
\usepackage{xltxtra} % Extra customizations for XeLaTeX
\setmainfont{Charis SIL} % set the main body font (\textrm), assumes Charis SIL is installed
\usepackage{polyglossia}
\setdefaultlanguage{english}
\setotherlanguage{arabic}
\newfontfamily\arabicfont{Scheherazade}
\begin{document}
\selectlanguage{arabic}
%Below the arabic script which does appear in single letters in pdf 
جدول المحتويات
\end{document}

Update: Added PDF output

PDF output

Best Answer

To get the letters connected, you need to set the option Script=Arabic when you load the font, i. e. load the font with \newfontfamily\arabicfont[Script=Arabic]{⟨font⟩}, as stated in section 4 “Font setup” in the polyglossia documentiation and section 10.18 “OpenType scripts and languages” in the fontspec documentation.

NB: The actual polyglossia command for selecting the other language is \textarabic[⟨options⟩]{…} or \begin{Arabic}[⟨options⟩] for longer texts, not \selectlanguage{arabic}. Also confer section 3 “Language-switching commands” of the fontspec documentation.

Related Question