# XeLaTeX with Polyglossia and Thai

The following example displays the English text alright, but not the Thai text. It is simply left blank in the PDF result.

\documentclass{report}

\usepackage{fontspec}
\setmainfont{Times New Roman}
\setsansfont{Arial}
\newfontfamily\thaifont{Norasi}
\newfontfamily\thaifontsf{Loma}

\usepackage{polyglossia}
\setdefaultlanguage{english}

\begin{document}
Here comes some Thai: สารบัญ

{\sffamily Here comes some Thai: สารบัญ}
\end{document}


If I change the \setdefaultlanguage to thai, it works, but that's not the idea as this is an English document.

Any suggestions?

-

You are nowhere telling xelatex that you wish to switch to thai. Use either \setotherlanguage{thai} and \selectlanguage{thai}, or at least use the \thaifont command.
I thought the whole idea of Unicode input in XeLaTeX was that XeLaTeX "just works" with that. In any case, I've added the \setotherlanguage{thai} line but that has no effect. Your other suggestions require that I know in advance that the following text actually will be in Thai. In my case, that's not practical as I process unknown text automatically. –  kongo09 Aug 3 '11 at 14:11
Sorry, I misunderstood you. \setotherlanguage{thai} obviously only works together with \selectlanguage{thai}. Yes, that works. But unfortunately leaves me with the problem that I would have to know where in the text the Thai script is sitting. I guess the solution would be to find a rather complete unicode font that has the scripts like Thai covered and use that as main font. –  kongo09 Aug 3 '11 at 14:17
It is possible (with \XeTeXintercharclass/\XeTeXinterchartoks) to setup things so that XeTeX automatically switch to another font. –  Ulrike Fischer Aug 3 '11 at 14:27
That's interesting! This lead me to the ucharclasses package, which doesn't seem to be part of the large standard distributions. A simple \setTransitionTo{Thai}{\fontspec{Norasi}} does the trick. Unfortunately, the package seems to be very computationally intensive as it makes the whole process quite slow. –  kongo09 Aug 3 '11 at 15:18