Hello,

INTRODUCTION

MetaPost, in fact Metafun, has extensions to include external figures
as well as typeset text.

For example:
\startMPcode
  draw externalfigure("cow") ;
\stopMPcode
would be the equivalent to the ConTeXt command.
\externalfigure [cow]

However, for historical reasons (coming from its implementation in
mkii), the MetaPost externalfigure() function behaves somewhat
differently from the ConTeXt \externalfigure [].

Another very important Metafun extension allows the inclusion of
ConTeXt typeset text. For example:
  \startMPcode
    draw textext("\input knuth") ;
  \stopMPcode
that can be substituted for the traditional MP
  \startMPcode
    label("Some text to be typeset", origin) ;
  \stopMPcode
or its alternate form:
  \startMPcode
    label(btex $5\times10^4$ etex, origin) ;
  \stopMPcode
In MetaFun, these all go through the textext mechanism.

Getting back to external figures, one could also use
  \startMPcode
    draw textext("\externalfigure [cow]") ;
   \stopMPcode
(There is also a rawtextext() variant, which is similar.)

In MetaPost, all of these substitute a box having the appropriate
dimension that gets filled by ConTeXt as the graphic gets shipped-out;
there is no real modification of MetaPost or MPlib itself.

After this long-winded introduction, now comes our question:


PROBLEM

Consider the following MWE:

\setupexternalfigures [location=default]
\starttext

\startMPcode
  draw externalfigure("cow")
    xsized 2cm ;
  draw textext("\externalfigure [cow] [frame=on]")
    xsized 2cm ;
  fill fullcircle scaled 2mm withcolor red ; % origin
\stopMPcode

\stoptext

One notices differences, notably that the Metafun externalfigure()
function distorts the image as it maps it to a unitsquare. Notice also
that I used the xsized transformation rather than scaled since the
textext("\externalfigure[cow]") variant returns the "natural" dimension
of the figure, not a unit-scaled box. The origin of the two images also
differs (lower-left corner vs. center); both behave logically, as
 draw textext.urt("\externalfigure[cow]") xsized 2cm ;
will be placed as expected.

There are other issues, in particular all textexts are cleared at the
exit of each MP code block, as they each occupy a luatex box.


QUESTION

We would like to change the behavior of the MetaPost externalfigure
function, as lua makes their handling easier than in the original mkii
implementation. The purpose of this message is to solicit comments,
requests, and/or objections from users on the mailing list.

Alan (and Hans)
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to