# Problem using Thai script with Babel and FreeSerif typeface

The following code with compiles with a warning on Windows 10 using LuaLatex although produces a readable document.

\documentclass{article}
\usepackage{babel}
\babelprovide[main, import]{thai}
\babelfont{rm}{FreeSerif}
\begin{document}
สวัสดี
\end{document}


Warning:

font2.tex|| Package fontspec Warning: Language 'Thai' not available for font 'FreeSerif' with script 'Thai'.


The following triggers an extra warning and produces a document with the Thai text missing altogether.

\documentclass{article}
\usepackage[english,thai]{babel}
\babelprovide[import]{thai}
\babelfont{rm}{FreeSerif}
\begin{document}
Hello.

\begin{otherlanguage}{thai}
สวัสดี
\end{otherlanguage}
\end{document}


Warnings:

font_problem.tex|| Package fontspec Warning: Language 'Thai' not available for font 'FreeSerif' with script 'Thai'.
font_problem.tex|| LaTeX Font Warning: Font shape LTH/FreeSerif(0)/m/n' undefined using LTH/norasi/m/n' instead on input line 3.


What is causing this and how can I solve it? FreeSerif does include Thai glyphs and the first code is taken straight from the Latex WikiBooks's example.

• A font can have Thai glyphs, but not necessarily have the correct Thai “Script” and/or Thai “Language” setup. So this could be a font bug (or something else). May 9, 2020 at 2:44
• @RuixiZhang I doubt that's the case, for FreeSerif is widely used in examples, including in Babel's own documentation. When I tried this demo from Overleaf, I got a warning not just for Thai, but also for Russian and French. Even switching to Google's Noto font doesn't help. May 9, 2020 at 3:02

You must change the preamble slightly:

\documentclass{article}
\usepackage[english]{babel}
\babelprovide[import, main]{thai} % Remove main if the main language is english
\babelfont{rm}{FreeSerif}
\begin{document}
Hello.

\begin{otherlanguage}{thai}
สวัสดี
\end{otherlanguage}
\end{document}


As to the warnings, they are usually harmless and are not errors. They are explained in the manual and also in Avoid fontspec warning with babel.

• Thank you, but wouldn't that make Thai the main language? English is the main language in my document. May 9, 2020 at 6:34
• @bongbang In your original post thai was the last option when loading babel, so I assumed it was the main language. If it's not, just remove main. May 9, 2020 at 6:49
• I now see that I actually misread the manual. Thank you. Putting the main language last is so counter-intuitive to me that my brain automatically "fixed" it. May 9, 2020 at 7:05

Javier Bezos solved your problem, but for a bit more of an explanation.

The babel package is great, but you just ran into one of its biggest problems. You loaded

\usepackage[english,thai]{babel}


When you passed the thai option, babel loaded a file called thai.ldf. It tries to load an 8-bit font and does not work with Unicode. The dead giveaway is that you got an error message

LaTeX Font Warning: Font shape LTH/FreeSerif(0)/m/n' undefined using LTH/norasi/m/n' instead [...]


LTH is an 8-bit Local THai encoding. Any time XeLaTeX or LuaLaTeX try to use an encoding other than TU, some package thinks it’s still in 8-bit world.

The example that worked did this instead:

\usepackage{babel}
\babelprovide[main, import]{thai}


This loads a definition of Thai that works in LuaLaTeX and XeLaTeX.

So, use \babelprovide to load languages, then? I thought so for a while. Here’s the problem. Javier Bezos, who maintains babel, tells me that’s wrong. You’ll notice he fixed this with

\usepackage[english]{babel}
\babelprovide[import, main]{thai} % Remove main if the main language is english


As of 2020, you’re supposed to load some languages as package options to babel. Others only work with \babelprovide[import].

Which way to load which language is not well-documented. I originally wrote, but deleted, a list of the clues you do get in the documentation about which to use, but the takeaway was: you need to figure it out by trial and error.

• You've got a point. I'll try to clarify it either in the wiki or in the manual (or both). Oct 7, 2020 at 5:47
• And here is a preliminary draft: github.com/latex3/babel/wiki/Which-method-for-which-language . Suggestions are welcome. Oct 17, 2020 at 15:19
• @JavierBezos Looks like a big improvement. I have some recommendations on the font list, but I’m not sure where to leave them, and also, it’s bikeshedding. Oct 17, 2020 at 16:41
• You can contact me here: texnia.com/contact.html . Oct 17, 2020 at 16:45
• @JavierBezos Sent. Oct 17, 2020 at 20:46

The code below gets around the error and renders properly. Although the thread that Javier Bezos references provides clues as to what was wrong and could potentially go wrong, I still don't understand of all the things I've tried that seem to make sense in light of the information therein, only this solution works.

\documentclass{article}
\usepackage{babel}
\babelprovide[import, language=Default, main]{english}
\babelprovide[import, language=Default]{thai}
\babelfont{rm}{FreeSerif}

\begin{document}
Hello.

\begin{otherlanguage}{thai}
สวัสดี
\end{otherlanguage}
\end{document}