我一直在输入一份使用拉丁文、西里尔文和格鲁吉亚文字符的多语言文档,但我完全不知道如何让 fontspec 选择正确的字体。
如果我使用下面的 MWE,它有点起作用,但格鲁吉亚语文本中的逗号和句号会显示为方框,因为 Noto Serif 格鲁吉亚语不包含这些字符(大概是为了链接到 Noto Serif)。理想情况下,我会fontspec
根据要渲染的字符自动选择子字体,这样我就不需要专门创建命令了\georgianfont
。
\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}
编辑我尝试使用ucharclasses
下面推荐的包,但更新后的 MWE 根本不起作用:
\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 至少会让我电脑死机 15 分钟,然后才会崩溃,而 xelatex 似乎是导致此问题的原因,但我不知道它想做什么。输出到此为止,然后在那里停留了几分钟,直到最终我的整个电脑都锁定了:
$ 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)
^C
如果五分钟后还没有发生任何事情,我通常会采取这种措施。
答案1
我对其内部结构一无所知ucharclasses
,但手册中对该命令的用法有些可疑\fontspec{}
——通常不建议使用该命令定期更改字体。
目前尚不清楚这是否曾经有效但发生了一些变化fontspec
,但您应该使用\newfontfamily
如下所示的方法:(不同的字体但相同的想法)
\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}