我正在尝试使用 中安装的自定义字体绘制一堆标签~/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
: