I want to render the same text with a couple of different fonts, but when I do the following:
import settings;
import fontsize;
settings.tex="lualatex";
outformat="pdf";
size(9cm);
defaultpen(fontsize(10pt));
defaultpen(0.1);
texpreamble("\usepackage{fontspec}\setmainfont{Courier New}");
draw(scale(0.1) * texpath("text"));
texreset();
texpreamble("\usepackage{fontspec}\setmainfont{Arial}");
draw(shift(3, 0) * scale(0.1) * texpath("text"));
The resulting picture contains text written only in Courier New. If I change lines 11 and 13 to:
draw(scale(0.1) * texpath("text1"));
draw(shift(3, 0) * scale(0.1) * texpath("text2"));
The text renders correctly. What is going on here, and how can I render the same text with different fonts? I am using TeX Live 2017 on Windows 7. On a related note, LuaLaTeX generates errors when I try to render the text with labels like this:
texpreamble("\usepackage{fontspec}\setmainfont{Courier New}");
label("text", (0,0));
texreset();
texpreamble("\usepackage{fontspec}\setmainfont{Arial}");
label("text", (3,0));
The error:
asy -V font_change_test.asy
Process started (PID=4768) >>>
warning [unbounded]: y scaling in picture unboundedThis is LuaTeX, Version 1.0.4 (TeX Live 2017/W32TeX)
restricted system commands enabled.
LaTeX2e <2017-04-15>
(using write cache: C:/Users/Computer/.texlive2017/texmf-var/luatex-cache/generic)(using read cache: C:/texlive/2017/texmf-var/luatex-cache/generic C:/Users/Computer/.texlive2017/texmf-var/luatex-cache/generic)
luaotfload | main : initialization completed in 0.157 secondsBabel <3.15> and hyphenation patterns for 1 language(s) loaded.
(./font_change_test_.tex (c:/texlive/2017/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(c:/texlive/2017/texmf-dist/tex/latex/base/size12.clo(load luc: C:/Users/Comput
er/.texlive2017/texmf-var/luatex-cache/generic/fonts/otl/lmroman12-regular.luc)
)) (c:/texlive/2017/texmf-dist/tex/latex/fontspec/fontspec.sty
(c:/texlive/2017/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
(c:/texlive/2017/texmf-dist/tex/latex/l3kernel/expl3.sty
(c:/texlive/2017/texmf-dist/tex/latex/l3kernel/expl3-code.tex)
(c:/texlive/2017/texmf-dist/tex/latex/l3kernel/l3pdfmode.def)))
(c:/texlive/2017/texmf-dist/tex/latex/fontspec/fontspec-luatex.sty
(c:/texlive/2017/texmf-dist/tex/latex/base/fontenc.sty
(c:/texlive/2017/texmf-dist/tex/latex/base/tuenc.def))
(c:/texlive/2017/texmf-dist/tex/latex/fontspec/fontspec.cfg)(load luc: C:/Users
/Computer/.texlive2017/texmf-var/luatex-cache/generic/fonts/otl/lmroman12-bold.
luc)(load luc: C:/Users/Computer/.texlive2017/texmf-var/luatex-cache/generic/fo
nts/otl/lmroman12-italic.luc)))(load luc: C:/Users/Computer/.texlive2017/texmf-
var/luatex-cache/generic/fonts/otl/arial.luc)(load luc: C:/Users/Computer/.texl
ive2017/texmf-var/luatex-cache/generic/fonts/otl/arialbi.luc)(load luc: C:/User
s/Computer/.texlive2017/texmf-var/luatex-cache/generic/fonts/otl/arialbd.luc)(l
oad luc: C:/Users/Computer/.texlive2017/texmf-var/luatex-cache/generic/fonts/ot
l/ariali.luc) (c:/texlive/2017/texmf-dist/tex/latex/graphics/graphicx.sty
(c:/texlive/2017/texmf-dist/tex/latex/graphics/keyval.sty)
(c:/texlive/2017/texmf-dist/tex/latex/graphics/graphics.sty
(c:/texlive/2017/texmf-dist/tex/latex/graphics/trig.sty)
(c:/texlive/2017/texmf-dist/tex/latex/graphics-cfg/graphics.cfg)
(c:/texlive/2017/texmf-dist/tex/latex/graphics-def/luatex.def)))
(c:/texlive/2017/texmf-dist/tex/latex/graphics/color.sty
(c:/texlive/2017/texmf-dist/tex/latex/graphics-cfg/color.cfg))
! Undefined control sequence.
<recently read> \pdfpagewidth
l.24 \pdfpagewidth
=251.189971bp
! LaTeX Error: Missing \begin{document}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.24 \pdfpagewidth=
251.189971bp
! Undefined control sequence.
l.28 \pdfpageheight
=9.680209bp
(./font_change_test_.aux)
(c:/texlive/2017/texmf-dist/tex/context/base/mkii/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (c:/texlive/2017/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty
(c:/texlive/2017/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
(c:/texlive/2017/texmf-dist/tex/latex/oberdiek/grfext.sty
(c:/texlive/2017/texmf-dist/tex/generic/oberdiek/kvdefinekeys.sty
(c:/texlive/2017/texmf-dist/tex/generic/oberdiek/ltxcmds.sty)))
(c:/texlive/2017/texmf-dist/tex/latex/oberdiek/kvoptions.sty
(c:/texlive/2017/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty
(c:/texlive/2017/texmf-dist/tex/generic/oberdiek/etexcmds.sty
(c:/texlive/2017/texmf-dist/tex/generic/oberdiek/ifluatex.sty))))
(c:/texlive/2017/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty
(c:/texlive/2017/texmf-dist/tex/generic/oberdiek/ifpdf.sty))
(c:/texlive/2017/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg)) [1{c:/texl
ive/2017/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./font_change_test_.aux))
(see the transcript file for additional information)
386 words of node memory still in use:
3 hlist, 1 vlist, 1 rule, 2 glue, 4 attribute, 49 glue_spec, 4 attribute_lis
t, 1 write nodes
avail lists: 2:45,3:3,4:6,5:26,6:34,7:18,8:1,9:19
<c:/Windows/fonts/arial.ttf>
Output written on font_change_test_.pdf (1 page, 16115 bytes).
Transcript written on font_change_test_.log.
C:/texlive/2017/texmf-dist\asymptote/plain_shipout.asy: 87.10: runtime: shipout failed
C:\texlive\2017\bin\win32\runscript.tlu:708: command failed with exit code 1:
asy -V font_change_test.asy
<<< Process finished (PID=4768). (Exit code 1)
================ READY ================
\newfontfamily\myfont[<font features>]{<name of font>}
instead of thetexreset();
. I checked that this works if I use xelatex. However, I could not test it with lualatex.