Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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.

share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.