![font() 笔只能工作一次,然后恢复为默认字体](https://linux22.com/image/326068/font()%20%E7%AC%94%E5%8F%AA%E8%83%BD%E5%B7%A5%E4%BD%9C%E4%B8%80%E6%AC%A1%EF%BC%8C%E7%84%B6%E5%90%8E%E6%81%A2%E5%A4%8D%E4%B8%BA%E9%BB%98%E8%AE%A4%E5%AD%97%E4%BD%93.png)
我正在尝试使用 中安装的自定义字体绘制一堆标签~/Library/Fonts
。为此,我创建了一个pen
使用font()
,然后将该笔与 一起使用label()
:
pen font_pen = font("DejaVuSans", 24);
label("First", (0mm, 0mm), font_pen);
label("Second", (0mm, -10mm), font_pen);
然后我编译该文件如下:
$ asy -f pdf -tex xelatex test_fonts.asy
kpathsea: Running mktextfm DejaVuSans
/opt/local/share/texmf-texlive/web2c/mktexnam: Could not map source abbreviation D for DejaVuSans.
/opt/local/share/texmf-texlive/web2c/mktexnam: Need to update /opt/local/share/texmf-texlive/fonts/map/fontname/special.map?
mktextfm: Running mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input DejaVuSans
This is METAFONT, Version 2.7182818 (TeX Live 2015/MacPorts 2015_7) (preloaded base=mf)
kpathsea: Running mktexmf DejaVuSans
! I can't find file `DejaVuSans'.
<*> ...four; mag:=1; nonstopmode; input DejaVuSans
Please type another input file name
! Emergency stop.
<*> ...four; mag:=1; nonstopmode; input DejaVuSans
Transcript written on mfput.log.
grep: DejaVuSans.log: No such file or directory
mktextfm: `mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input DejaVuSans' failed to make DejaVuSans.tfm.
kpathsea: Appending font creation commands to missfont.log.
kpathsea: Running mktextfm DejaVuSans
/opt/local/share/texmf-texlive/web2c/mktexnam: Could not map source abbreviation D for DejaVuSans.
/opt/local/share/texmf-texlive/web2c/mktexnam: Need to update /opt/local/share/texmf-texlive/fonts/map/fontname/special.map?
mktextfm: Running mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input DejaVuSans
This is METAFONT, Version 2.7182818 (TeX Live 2015/MacPorts 2015_7) (preloaded base=mf)
kpathsea: Running mktexmf DejaVuSans
! I can't find file `DejaVuSans'.
<*> ...four; mag:=1; nonstopmode; input DejaVuSans
Please type another input file name
! Emergency stop.
<*> ...four; mag:=1; nonstopmode; input DejaVuSans
Transcript written on mfput.log.
grep: DejaVuSans.log: No such file or directory
mktextfm: `mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input DejaVuSans' failed to make DejaVuSans.tfm.
kpathsea: Running mktextfm DejaVuSans
/opt/local/share/texmf-texlive/web2c/mktexnam: Could not map source abbreviation D for DejaVuSans.
/opt/local/share/texmf-texlive/web2c/mktexnam: Need to update /opt/local/share/texmf-texlive/fonts/map/fontname/special.map?
mktextfm: Running mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input DejaVuSans
This is METAFONT, Version 2.7182818 (TeX Live 2015/MacPorts 2015_7) (preloaded base=mf)
kpathsea: Running mktexmf DejaVuSans
! I can't find file `DejaVuSans'.
<*> ...four; mag:=1; nonstopmode; input DejaVuSans
Please type another input file name
! Emergency stop.
<*> ...four; mag:=1; nonstopmode; input DejaVuSans
Transcript written on mfput.log.
grep: DejaVuSans.log: No such file or directory
mktextfm: `mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input DejaVuSans' failed to make DejaVuSans.tfm.
kpathsea: Running mktextfm DejaVuSans
/opt/local/share/texmf-texlive/web2c/mktexnam: Could not map source abbreviation D for DejaVuSans.
/opt/local/share/texmf-texlive/web2c/mktexnam: Need to update /opt/local/share/texmf-texlive/fonts/map/fontname/special.map?
mktextfm: Running mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input DejaVuSans
This is METAFONT, Version 2.7182818 (TeX Live 2015/MacPorts 2015_7) (preloaded base=mf)
kpathsea: Running mktexmf DejaVuSans
! I can't find file `DejaVuSans'.
<*> ...four; mag:=1; nonstopmode; input DejaVuSans
Please type another input file name
! Emergency stop.
<*> ...four; mag:=1; nonstopmode; input DejaVuSans
Transcript written on mfput.log.
grep: DejaVuSans.log: No such file or directory
mktextfm: `mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input DejaVuSans' failed to make DejaVuSans.tfm.
kpathsea: Appending font creation commands to missfont.log.
结果如下:
为什么只有第一个标签使用指定的字体,以及如何使用一支指定自定义字体的笔绘制多个标签?
我在 OS X 10.9.5 上使用 Asymptote 2.36。
答案1
快速浏览一下渐近线的文档让我认为font
这种方式不可行,但我不知道为什么它似乎对第一个标签有效。无论如何,这有帮助吗?
texpreamble("\usepackage{fontspec}\setmainfont{American Typewriter}");
label("First", (0mm, 0mm),currentpen+fontsize(36pt)+blue);
label("Second", (0mm, -10mm),currentpen+fontsize(36pt)+red);
进而
$ asy -f pdf -tex xelatex test_fonts.asy
生成:
我使用了 Mac OS X 10.9.5American Typewriter
系统字体。下面是另一种系统字体Herculanum
: