# [metapost] Open/True Type Fonts

Mojca Miklavec mojca.miklavec.lists at gmail.com
Sun May 18 23:48:28 CEST 2008

On Sun, May 18, 2008 at 2:37 AM, Troy Henderson wrote:
>> \sometxt returns an image. You should be able to use the label macro
>> without any problem.
>
> By "image" I assume you mean "picture" as the label command in MP
> takes 2 arguments where the first is either a string or picture and
> the second is a pair.  Correct?

Sorry, yes, I meant picture, not image.

>  Does \sometxt do the same (or
> similar) as btex ... etex?

It has a similar purpose, but different mechanism. btex ... etex is
just as stupid as it can get. A while ago I wrote some code that
exported gnuplot graphs into ConTeXt. Now imagine 10 graphs with 20
labels each (to label axis with 0, 1, 2, 3, ... 10, a title of the
graph and so on ...). For each image (graph in my case), ConTeXt calls
metapost, so that means 10 metapost runs inside a ConTeXt run. But
then each metapost calls another TeX instance to handle labels. Now,
I'm not really sure if it called TeX a single time or if it called it
20 times, but I wouldn't be surprised if it called it 20 times, which
means running TeX 201 times to draw 10 graphs. Well, because of table
of contents and so on, ConTeXt usually runs twice, so 402 times. In
any case - the running time of compiling my graphs has been reduces
from 15 minutes to 20 seconds when this mechanism has been
implemented.

Apart from that, with btex ... etex you need to specify the
environment separately. The additional TeX run that typesets the
labels doesn't know anything about the environment. Something like
this would not work:

\starttext
\def\a{bla bla}
\startMPmage
draw btex \a etex;
\stopMPpage
\stoptext

but this does:

\starttext
\def\a{bla bla}
\startMPmage
draw \sometxt{\a};
\stopMPpage
\stoptext

and the second solution uses the parent TeX instance to typeset the
label (much more efficient and user friendly), while the first example
would run another TeX in the background just to get the label right
(if it contained some text at all).

>> With LuaTeX (texexec --lua filename) ...
>
> I know little about LuaTeX at this point, but I would love to know
> more.  What are its advantages other than being written in Lua?

If you only need to draw a single metapost image, the advantages are
not so evident (or not evident at all), but if you need several
metapost images per page in a large document, then you notice an
enormous speed-up. LuaTeX has a metapost library embed, so it runs
really fast, and doesn't need to generate intermediate files. With
LuaTeX you can also use any fonts on your system without being bound
to TFM.

http://www.river-valley.tv/conferences/bachotex2008/media/0302-Hans_Hagen/
(fonts drawn with metapost as well)

Mojca