我似乎无法让 ConTeXt 与系统字体配合使用。让我们从关于 tex.SE 的另一个问题 :
\usemodule[simplefonts][size=12pt]
\setmainfont[liberationsans]
\starttext
Test text
\stoptext
它不会编译:
$ context aa.tex
mtx-context | run 1: luatex --fmt="/opt/context/tex/texmf-cache/luatex-cache/context/5fe67e0bfe781ce0dde776fb1556f32e/formats/luatex/cont-en" --jobname="aa" --lua="/opt/context/tex/texmf-cache/luatex-cache/context/5fe67e0bfe781ce0dde776fb1556f32e/formats/luatex/cont-en.lui" --no-parse-first-line --c:currentrun=1 --c:fulljobname="./aa" --c:input="./aa" --c:kindofrun=1 --c:maxnofruns=9 "cont-yes.mkiv"
This is LuaTeX, Version beta-0.81.0 (TeX Live 2016/dev) (rev 5350)
\write18 enabled.
system > callbacks > not registering frozen 'find_format_file'
open source > 1 > 1 > /opt/context/tex/texmf-context/tex/context/base/cont-yes.mkiv
ConTeXt ver: 2015.10.09 21:28 MKIV beta fmt: 2015.10.21 int: english/english
system > 'cont-new.mkiv' loaded
open source > 2 > 2 > /opt/context/tex/texmf-context/tex/context/base/cont-new.mkiv
close source > 2 > 2 > /opt/context/tex/texmf-context/tex/context/base/cont-new.mkiv
system > files > jobname 'aa', input './aa', result 'aa'
fonts > latin modern fonts are not preloaded
languages > language 'en' is active
open source > 2 > 3 > /data/LédiFrance/catalogues/automatic/aa.tex
resolvers > modules > 'simplefonts' is loaded
open source > 3 > 4 > /opt/context/tex/texmf-modules/tex/context/third/simplefonts/t-simplefonts.mkiv
loading > ConTeXt User Module / Simplefonts
resolvers > lua > loading file '/opt/context/tex/texmf-modules/tex/context/third/simplefonts/t-simplefonts.lua' succeeded
close source > 3 > 4 > /opt/context/tex/texmf-modules/tex/context/third/simplefonts/t-simplefonts.mkiv
fonts > defining > source file 'LiberationSans-Regular.ttf' is not found
backend > xmp > using file '/opt/context/tex/texmf-context/tex/context/base/lpdf-pdx.xml'
pages > flushing realpage 1, userpage 1
close source > 2 > 4 > /data/LédiFrance/catalogues/automatic/aa.tex
close source > 1 > 4 > /opt/context/tex/texmf-context/tex/context/base/cont-yes.mkiv
!LuaTeX error: cannot find OpenType font file for reading ()
==> Fatal error occurred, no output PDF file produced!
mtx-context | fatal error: return code: 1
如果我理解正确的话,它会失败defining > source file 'LiberationSans-Regular.ttf' is not found
。然而,该文件被找到mtx-run
(并且所有人都有读取权限):
$ mtxrun --script fonts --list --all --pattern=Liberation
liberationmono liberationmono /usr/share/fonts/liberation/LiberationMono-Regular.ttf
liberationmonobold liberationmonobold /usr/share/fonts/liberation/LiberationMono-Bold.ttf
liberationmonobolditalic liberationmonobolditalic /usr/share/fonts/liberation/LiberationMono-BoldItalic.ttf
liberationmonoitalic liberationmonoitalic /usr/share/fonts/liberation/LiberationMono-Italic.ttf
liberationmononormal liberationmono /usr/share/fonts/liberation/LiberationMono-Regular.ttf
liberationmonoregular liberationmono /usr/share/fonts/liberation/LiberationMono-Regular.ttf
liberationsans liberationsans /usr/share/fonts/liberation/LiberationSans-Regular.ttf
liberationsansbold liberationsansbold /usr/share/fonts/liberation/LiberationSans-Bold.ttf
liberationsansbolditalic liberationsansbolditalic /usr/share/fonts/liberation/LiberationSans-BoldItalic.ttf
liberationsansitalic liberationsansitalic /usr/share/fonts/liberation/LiberationSans-Italic.ttf
liberationsansnormal liberationsans /usr/share/fonts/liberation/LiberationSans-Regular.ttf
liberationsansregular liberationsans /usr/share/fonts/liberation/LiberationSans-Regular.ttf
liberationserif liberationserif /usr/share/fonts/liberation/LiberationSerif-Regular.ttf
liberationserifbold liberationserifbold /usr/share/fonts/liberation/LiberationSerif-Bold.ttf
liberationserifbolditalic liberationserifbolditalic /usr/share/fonts/liberation/LiberationSerif-BoldItalic.ttf
liberationserifitalic liberationserifitalic /usr/share/fonts/liberation/LiberationSerif-Italic.ttf
liberationserifnormal liberationserif /usr/share/fonts/liberation/LiberationSerif-Regular.ttf
liberationserifregular liberationserif /usr/share/fonts/liberation/LiberationSerif-Regular.ttf
我错过了什么?
(顺便说一句,我从上面列出的问题的答案中了解到simplefonts
应该输入的输出mtx-run
,但是哪一列 ?)
答案1
LuaTeX(或者更确切地说kpsepath
)不会递归搜索字体目录。即使使用OSFONTDIR="/usr/share/fonts//"
(注意两个尾部斜杠)建议kpsewhich --var-value=OSFONTDIR
. 虽然给出了预期的路径,但是并没有帮助。
使用此方法作为解决方法:
mkdir $HOME/.fonts
export OSFONTDIR="$OSFONTDIR:$HOME/.fonts"
for ii in $(find /usr/share/fonts -name "*.ttf") $(find /usr/share/fonts -name "*.otf"); do ln -s $ii ~/.fonts/; done
这将创建$HOME/.fonts
、 目录,将其添加到OSFONTDIR
,并将所有otf
和ttf
文件递归链接/usr/share/fonts
到$HOME/.fonts
。
类似的方法:
rm -rf $HOME/.fonts
mkdir $HOME/.fonts
cd $HOME/.fonts
for i in $(echo $OSFONTDIR | sed -e 's/:/ /g') ; do
for j in $(find $i -type f); do
ln -s $j .;
done;
done
该脚本使用当前$OSFONTDIR
值并递归遍历目录以将所有字体文件链接到$HOME/.fonts
。然后更新(例如$HOME/.bashrc
):
OSFONTDIR=$HOME/.fonts
export OSFONTDIR
答案2
我的系统上没有 Liberation,因此无法测试,但这应该可行。模块的功能simplefonts
已集成到 context 的核心中,因此您不再需要它。并且它所需的参数不在 的字体脚本中mtxrun
,而是字体的系列名称。因此,对于您的情况,您应该尝试:
\definefontfamily [test] [sans] [Liberation Sans]
\setupbodyfont [test,ss,12pt]
\starttext
Test text
\stoptext