Is it possible to use OpenType fonts in MetaPost labels?
I use MiKTeX 2.9. I hoped something like mpost --tex=dvilualatex <myfile>.mp
might work, but no luck.
Suggestions?
I tried this, but I get an empty box where my label should be, even if I use the default fonts.
\startMPdefinitions
\stopMPdefinitions
\starttext
\startMPpage
beginfig(1);
draw(0, 0)--(200,200);
dotlabel.bot("ABCDEFG", (100,100));
endfig;
\stopMPpage
\stoptext
Best Answer
Aside from ConTeXt, it is also possible to include OpenType fonts in MetaPost labels if you use MetaPost through Lua(La)TeX.
As it was noted in the comments, thanks to Dohyun Kim the
btex … etex
flags are now recognized byluamplib
, but in the recents versions it goes much further than that:luamplib
now also includes atextext
function that is pretty much the same as its namesake in MetaFun/ConTeXt.Like the
btex … etex
flags,textext()
(which takes a string of characters as argument) uses by default the fonts of the current Lua(La)TeX document, OpenType or not, to typeset the labels. But it has two big advantages on thebtex … etex
flags:\mplibtextextlabel{enable}
instruction in the preamble, it is enough to give the string itself as argument to thelabel
commands;textext
is called to typeset it, but in the background. Very handy if you have a great bunch of labels to typeset!So the following program:
gives exactly the same result as this:
Either way you get 12pt-sized OpenType text and math fonts from XITS (which are themselves adaptation of the STIX fonts) in the label: