4

I've been typing a multilingual document that uses Latin, Cyrillic and Georgian characters, and I'm utterly stumped as to how to get fontspec to select the right fonts.

If I use the MWE below, it kind of works, but the comma and full stop in the Georgian text show up as boxes because Noto Serif Georgian doesn't include those characters (presumably it's meant to link to Noto Serif). Ideally I'd get fontspec to automatically select the sub-font based on what characters are being rendered, so I wouldn't need to specifically create a \georgianfont command.

\documentclass{article}
\usepackage{fontspec}
\setmainfont[Ligatures=TeX]{Noto Serif}
\newfontfamily\georgianfont{Noto Serif Georgian}
\usepackage{polyglossia}
\setmainlanguage{english}
\setotherlanguage{georgian}

\begin{document}

{\georgianfont გუშინ ორი საათი ვწერე ერ სტატია, მაგრამ ვერ დავწერე ბოლომდე.}

For two hours yesterday I wrote this article, but I could not complete it.

В течение двух часов я вчера написал этот документ, но не смог завершить его.

\end{document}

EDIT I tried using the ucharclasses package as recommended below, and the updated MWE doesn't work at all:

\documentclass{article}
\usepackage{fontspec}
\usepackage[Latin, Georgian, Cyrillic]{ucharclasses}
\setmainfont[Ligatures=TeX]{Noto Serif}
\setDefaultTransitions{\fontspec{Noto Serif}}{}
\setTransitionTo{Georgian}{\fontspec{Noto Serif Georgian}}
\usepackage{polyglossia}
\setmainlanguage{english}
\setotherlanguage{georgian}

\begin{document}

გუშინ ორი საათი ვწერე ერ სტატია, მაგრამ ვერ დავწერე ბოლომდე.

For two hours yesterday I wrote this article, but I could not complete it.

В течение двух часов я вчера написал этот документ, но не смог завершить его.


\end{document}

latexmk hangs my computer for at least 15 mins before crashing, and xelatex seems to be the cause of the issue, but I don't know what it's trying to do. The output gets this far, and then sits there for many minutes until eventually my entire computer locks up:

$ xelatex georgian.tex
This is XeTeX, Version 3.14159265-2.6-0.99992 (TeX Live 2015/Arch Linux) (preloaded format=xelatex)
 restricted \write18 enabled.
entering extended mode
(./georgian.tex
LaTeX2e <2015/10/01> patch level 2
Babel <3.9m> and hyphenation patterns for 79 languages loaded.
(/usr/share/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/share/texmf-dist/tex/latex/base/size10.clo))
(/usr/share/texmf-dist/tex/latex/fontspec/fontspec.sty
(/usr/share/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/share/texmf-dist/tex/latex/l3kernel/expl3-code.tex)
(/usr/share/texmf-dist/tex/latex/l3kernel/l3unicode-data.def)
(/usr/share/texmf-dist/tex/latex/l3kernel/l3xdvipdfmx.def))
(/usr/share/texmf-dist/tex/latex/l3packages/xparse/xparse.sty)
(/usr/share/texmf-dist/tex/latex/fontspec/fontspec-patches.sty)
(/usr/share/texmf-dist/tex/latex/fontspec/fontspec-xetex.sty
(/usr/share/texmf-dist/tex/latex/base/fontenc.sty
(/usr/share/texmf-dist/tex/latex/euenc/eu1enc.def)
(/usr/share/texmf-dist/tex/latex/euenc/eu1lmr.fd))
(/usr/share/texmf-dist/tex/xelatex/xunicode/xunicode.sty
(/usr/share/texmf-dist/tex/latex/tipa/t3enc.def
(/usr/share/texmf-dist/tex/latex/euenc/eu1lmss.fd))
(/usr/share/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/share/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/share/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/share/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/share/texmf-dist/tex/latex/latexconfig/graphics.cfg)
(/usr/share/texmf-dist/tex/xelatex/xetex-def/xetex.def
(/usr/share/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
(/usr/share/texmf-dist/tex/generic/oberdiek/ltxcmds.sty)))))
(/usr/share/texmf-dist/tex/latex/fontspec/fontspec.cfg)))
(/usr/share/texmf-dist/tex/xelatex/ucharclasses/ucharclasses.sty
(/usr/share/texmf-dist/tex/generic/ifxetex/ifxetex.sty)) (./georgian.aux)
(/usr/share/texmf-dist/tex/latex/tipa/t3cmr.fd)

I usually resort to ^C if it hasn't done anything after five minutes.

  • Just to check (since I know nothing about Georgian), Georgian does use the same punctuation characters as English, does it? – cfr Mar 12 '16 at 14:08
  • I’ve not yet had occasion to use the package, but this looks like the problem ucharclasses was designed to solve. – Thérèse Mar 12 '16 at 16:29
  • @cfr Yes, it does. – Robbie Mar 13 '16 at 1:40
  • @Thérèse I just tried using that package on my MWE and it locked up my computer for 25 minutes before crashing o_O – Robbie Mar 13 '16 at 1:41
  • @zoqaeski — don't use latexmk then. Just run xelatex on the document and see what happens. It sounds like latexmk is mis-interpreting your file for some reason. – Will Robertson Mar 13 '16 at 1:59
1

I don't know anything about the internals of ucharclasses, but there's some suspicious usage of the \fontspec{} command in the manual — generally that command isn't recommended for changing fonts regularly.

Whether this used to work but something changed in fontspec is unclear, but you should be using \newfontfamily instead as shown here: (different fonts but same idea)

\documentclass{article}
\usepackage{fontspec}
\usepackage[Latin,Georgian,Cyrillic]{ucharclasses}
\setmainfont[Ligatures=TeX]{Palatino}

%%%%
\newfontfamily\pala{Palatino}
\newfontfamily\helv{Helvetica}
\setDefaultTransitions{\pala}{}
\setTransitionTo{Georgian}{\helv}
%%%%

\usepackage{polyglossia}
\setmainlanguage{english}
\setotherlanguage{georgian}
\begin{document}
გუშინ ორი საათი ვწერე ერ სტატია, მაგრამ ვერ დავწერე ბოლომდე.

For two hours yesterday I wrote this article, but I could not complete it.

В течение двух часов я вчера написал этот документ, но не смог завершить его.
\end{document}
  • This compiles and fixes the crashing issue—but I still get boxes with the Georgian text using the Noto fonts unless I add a space before the comma and full stop. I think the solution might be to add a zero-width space immediately before non-Georgian characters, which is annoying but better than crashing. – Robbie Mar 14 '16 at 12:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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