ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* MPLibrabray "txt" broken!?
@ 2013-05-14 12:23 Keith J. Schultz
  2013-05-14 17:57 ` Hans Hagen
  0 siblings, 1 reply; 6+ messages in thread
From: Keith J. Schultz @ 2013-05-14 12:23 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 2402 bytes --]

Hi All, Hans,

I want to use  build_parshape and shapetext with the latest standalone
ConTeXt  ver: 2013.05.12 22:16 MKIV beta  fmt: 2013.5.13  int: english/english

with the Example below I get a small box with the top part of a T in it.

Interresting enough the example works with the TexLive 2012 version!

Running with latest standalone the following files are created: 
-rw-r--r--  1 staff  14410 14 Mai 13:59 test2.log
-rw-r--r--  1 staff   5132 14 Mai 13:59 test2.pdf
-rw-r--r--  1 staff    634 14 Mai 13:59 test2.synctex.gz
-rw-r--r--@ 1 staff    899 14 Mai 13:37 test2.tex
-rw-r--r--  1 staff   8413 14 Mai 13:59 test2.tuc

Using MkIV from TeXLive 2012 the following files are created:
-rw-r--r--  1 staff    561 14 Mai 14:09 test2-mpgraph.mpd
-rw-r--r--  1 staff  19404 14 Mai 14:09 test2.log
-rw-r--r--  1 staff   9638 14 Mai 14:09 test2.pdf
-rw-r--r--  1 staff   3237 14 Mai 14:09 test2.synctex.gz
-rw-r--r--@ 1 staff    899 14 Mai 13:37 test2.tex
-rw-r--r--  1 staff   6079 14 Mai 14:09 test2.tuc

And all is well!

Goofy as I am I tried the standalone again, this works only
partially because the text is not aligned properly.
How can it be the file test2-mograph.mpd was used from the TexLive 2012
version!

So something is astray! I do know that we are using a newer Metapost, but
I assume the problem is the library or how the temporary files are generated
or used.

Any help would be nice.

regards
	Keith.

\useMPlibrary[txt]

\startuseMPgraphic{shape}
  % Shape of the paragraph
  path p ; p := ((0,1)..(-1,0)..(1,0)--cycle) scaled 5cm ;

  build_parshape
  ( p,                     % shape path
   .5*\baselinedistance,  % offset
   .5*\baselinedistance,  % x offset
   .5*\baselinedistance,  % y offset
   \baselinedistance,     % distance between lines
   \strutheight,          % height of a line
   \strutdepth,           % depth of a line
   \strutheight           % height of the first line
  ) ;

  % For visualization purposes only
  draw p ;
\stopuseMPgraphic

% For visualization purposes only
\defineoverlay[shape][\useMPgraphic{shape}]

\setupshapetexts%
  [bodyfont=10pt]

\starttext
\startshapetext[shape]
  \input knuth \endgraf
\stopshapetext


% The \type{background} is set only to visualize the parshape
\startTEXpage[background=shape,offset=2mm]
{\getshapetext}
\stopTEXpage
\stoptext

[-- Attachment #1.2: Type: text/html, Size: 6058 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: MPLibrabray "txt" broken!?
  2013-05-14 12:23 MPLibrabray "txt" broken!? Keith J. Schultz
@ 2013-05-14 17:57 ` Hans Hagen
  2013-05-15  7:36   ` Keith J. Schultz
  0 siblings, 1 reply; 6+ messages in thread
From: Hans Hagen @ 2013-05-14 17:57 UTC (permalink / raw)
  To: ntg-context

On 5/14/2013 2:23 PM, Keith J. Schultz wrote:
> Hi All, Hans,
>
> I want to use  build_parshape and shapetext with the latest standalone
> ConTeXt  ver: 2013.05.12 22:16 MKIV beta  fmt: 2013.5.13  int:
> english/english
>
> with the Example below I get a small box with the top part of a T in it.
>
> Interresting enough the example works with the TexLive 2012 version!
>
> Running with latest standalone the following files are created:
> -rw-r--r--  1 staff  14410 14 Mai 13:59 test2.log
> -rw-r--r--  1 staff   5132 14 Mai 13:59 test2.pdf
> -rw-r--r--  1 staff    634 14 Mai 13:59 test2.synctex.gz
> -rw-r--r--@ 1 staff    899 14 Mai 13:37 test2.tex
> -rw-r--r--  1 staff   8413 14 Mai 13:59 test2.tuc
>
> Using MkIV from TeXLive 2012 the following files are created:
> -rw-r--r--  1 staff    561 14 Mai 14:09 test2-mpgraph.mpd
> -rw-r--r--  1 staff  19404 14 Mai 14:09 test2.log
> -rw-r--r--  1 staff   9638 14 Mai 14:09 test2.pdf
> -rw-r--r--  1 staff   3237 14 Mai 14:09 test2.synctex.gz
> -rw-r--r--@ 1 staff    899 14 Mai 13:37 test2.tex
> -rw-r--r--  1 staff   6079 14 Mai 14:09 test2.tuc
>
> And all is well!
>
> Goofy as I am I tried the standalone again, this works only
> partially because the text is not aligned properly.
> How can it be the file test2-mograph.mpd was used from the TexLive 2012
> version!
>
> So something is astray! I do know that we are using a newer Metapost, but
> I assume the problem is the library or how the temporary files are generated
> or used.

some kind of initialization issue .. i uploaded a fix (crossed fingers)

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: MPLibrabray "txt" broken!?
  2013-05-14 17:57 ` Hans Hagen
@ 2013-05-15  7:36   ` Keith J. Schultz
  2013-05-15 10:15     ` Keith J. Schultz
  0 siblings, 1 reply; 6+ messages in thread
From: Keith J. Schultz @ 2013-05-15  7:36 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 2360 bytes --]

Hi Hans,

Am 14.05.2013 um 19:57 schrieb Hans Hagen <pragma@wxs.nl>:

> On 5/14/2013 2:23 PM, Keith J. Schultz wrote:
>> Hi All, Hans,
>> 
>> I want to use  build_parshape and shapetext with the latest standalone
>> ConTeXt  ver: 2013.05.12 22:16 MKIV beta  fmt: 2013.5.13  int:
>> english/english
>> 
>> with the Example below I get a small box with the top part of a T in it.
>> 
>> Interresting enough the example works with the TexLive 2012 version!
	[snip, snip]

>> So something is astray! I do know that we are using a newer Metapost, but
>> I assume the problem is the library or how the temporary files are generated
>> or used.
> 
> some kind of initialization issue .. i uploaded a fix (crossed fingers)

	Well, the fix work in a way , yet it has introduced a new problem,
	or revealed an unnoticed one.
	
	The text is now display in the shape, yet there is no drawing preformed!
	The draw of the path is no preformed.
	It is even worst. Metapost seems to be doing no drawing at all, even in over
	overlays! The all are related to a similar error :
metapost        > initializing number mode 'scaled'
metapost        > output file 'mpout.log', mode 'w', ftype 'log'
metapost        > output file 'test2-mpgraph.mpd', mode 'w', ftype 0
metapost        > output file 'test2-mpgraph.mpd', mode 'w', ftype 0
metapost        > error: (/Users/quayjay/context/tex/texmf-context/metapost/context/base/mp-text.mpiv)



>> PageFraction
>> false
! Equation cannot be performed (numeric=boolean).
<to be read again> 
                   :
<*> ...0pt; VSize:=597.51323pt; PageFraction:=0>1:
                                                  (1-1)/(0-1)else:1fi; defau...

! Extra tokens will be flushed.
<to be read again> 
                   :
<*> ...0pt; VSize:=597.51323pt; PageFraction:=0>1:
                                                  (1-1)/(0-1)else:1fi; defau...
	I have attached the complete log file and the source.
	The error occurs, also, when the graphic is framed and put into a picture
	environment.
	
	I had deleted the standalone version and reinstalled with:
	sh ./first-setup.sh --modules=all --engine=luatex
	I have running a MacBook Pro 17" with OSX 10.8.3 

	I will also attach the result(test2.pdf) and the result from TexLive 2012(expected.pdf).

regards
	Keith.


	


[-- Attachment #1.2.1: Type: text/html, Size: 6343 bytes --]

[-- Attachment #1.2.2: test2.tex --]
[-- Type: application/octet-stream, Size: 901 bytes --]

\useMPlibrary[txt]

\startuseMPgraphic{shape}
  % Shape of the paragraph
  path p ; p := ((0,1)..(-1,0)..(1,0)--cycle) scaled 5cm ;
 
  
  build_parshape
  ( p,                     % shape path
   .5*\baselinedistance,  % offset
   .5*\baselinedistance,  % x offset
   .5*\baselinedistance,  % y offset
   \baselinedistance,     % distance between lines
   \strutheight,          % height of a line
   \strutdepth,           % depth of a line
   \strutheight           % height of the first line
  ) ;

% For visualization purposes only
  draw p;
 \stopuseMPgraphic

% For visualization purposes only
\defineoverlay[shape][\useMPgraphic{shape}]

\setupshapetexts%
  [bodyfont=10pt]

\starttext
\startshapetext[shape]
  \input knuth \endgraf
\stopshapetext


% The \type{background} is set only to visualize the parshape
\startTEXpage[background=shape,offset=2mm]
{\getshapetext}
\stopTEXpage
\stoptext

[-- Attachment #1.2.3: Type: text/html, Size: 227 bytes --]

[-- Attachment #1.2.4: test2.log --]
[-- Type: application/octet-stream, Size: 17211 bytes --]

(/Users/quayjay/context/tex/texmf-context/tex/context/base/cont-yes.mkiv

ConTeXt  ver: 2013.05.14 19:42 MKIV beta  fmt: 2013.5.14  int: english/english

system          > 'cont-new.mkiv' loaded
(/Users/quayjay/context/tex/texmf-context/tex/context/base/cont-new.mkiv)
system          > files > jobname 'test2', input './test2', result 'test2'
fonts           > latin modern fonts are not preloaded
languages       > language 'en' is active
("/Users/quayjay/Documents/Private/CoTeXt Testers/MP Stuff/test2.tex"
metapost        > library 'txt' is loaded (/Users/quayjay/context/tex/texmf-context/tex/context/base/meta-imp-txt.mkiv){/Users/quayjay/context/tex/texmf-context/fonts/map/pdftex/context/mkiv-base.map}
fonts           > preloading latin modern fonts (second stage)
fonts           > typescripts > unknown library 'loc'
{/Users/quayjay/context/tex/texmf/fonts/map/dvips/lm/lm-math.map}{/Users/quayjay/context/tex/texmf/fonts/map/dvips/lm/lm-rm.map}
fonts           > 'fallback modern rm 12pt' is loaded
metapost        > initializing instance 'metafun' using format 'metafun'
metapost        > loading 'metafun' as '/Users/quayjay/context/tex/texmf-context/metapost/context/base/metafun.mpiv' using method 'default'
metapost        > initializing number mode 'scaled'
metapost        > output file 'mpout.log', mode 'w', ftype 'log'
metapost        > output file 'test2-mpgraph.mpd', mode 'w', ftype 0
metapost        > output file 'test2-mpgraph.mpd', mode 'w', ftype 0
metapost        > error: (/Users/quayjay/context/tex/texmf-context/metapost/context/base/mp-text.mpiv)



>> PageFraction
>> false
! Equation cannot be performed (numeric=boolean).
<to be read again> 
                   :
<*> ...0pt; VSize:=597.51323pt; PageFraction:=1>1:
                                                  (1-1)/(1-1)else:1fi; defau...

! Extra tokens will be flushed.
<to be read again> 
                   :
<*> ...0pt; VSize:=597.51323pt; PageFraction:=1>1:
                                                  (1-1)/(1-1)else:1fi; defau...




[1]

no-error
metapost        > output file 'test2-mpgraph.mpd', mode 'w', ftype 0
metapost        > output file 'test2-mpgraph.mpd', mode 'w', ftype 0
metapost        > error: 

>> PageFraction
>> false
! Equation cannot be performed (numeric=boolean).
<to be read again> 
                   :
<*> ...0pt; VSize:=597.51323pt; PageFraction:=1>1:
                                                  (1-1)/(1-1)else:1fi; defau...

! Extra tokens will be flushed.
<to be read again> 
                   :
<*> ...0pt; VSize:=597.51323pt; PageFraction:=1>1:
                                                  (1-1)/(1-1)else:1fi; defau...




[1]

no-error
(test2-mpgraph.mpd) (/Users/quayjay/context/tex/texmf-context/tex/context/sample/knuth.tex)
metapost        > output file 'test2-mpgraph.mpd', mode 'w', ftype 0
metapost        > output file 'test2-mpgraph.mpd', mode 'w', ftype 0
metapost        > error: 


>> PageFraction
>> false
! Equation cannot be performed (numeric=boolean).
<to be read again> 
                   :
<*> ...42pt; VSize:=274.1488pt; PageFraction:=1>1:
                                                  (1-1)/(1-1)else:1fi; defau...

! Extra tokens will be flushed.
<to be read again> 
                   :
<*> ...42pt; VSize:=274.1488pt; PageFraction:=1>1:
                                                  (1-1)/(1-1)else:1fi; defau...




[1]

no-error
metapost        > output file 'test2-mpgraph.mpd', mode 'w', ftype 0
metapost        > output file 'test2-mpgraph.mpd', mode 'w', ftype 0
metapost        > error: 

>> PageFraction
>> false
! Equation cannot be performed (numeric=boolean).
<to be read again> 
                   :
<*> ...42pt; VSize:=274.1488pt; PageFraction:=1>1:
                                                  (1-1)/(1-1)else:1fi; defau...

! Extra tokens will be flushed.
<to be read again> 
                   :
<*> ...42pt; VSize:=274.1488pt; PageFraction:=1>1:
                                                  (1-1)/(1-1)else:1fi; defau...




[1]

no-error
backend         > xmp > using file '/Users/quayjay/context/tex/texmf-context/tex/context/base/lpdf-pdx.xml'
pages           > flushing realpage 1, userpage 1
 ) )</Users/quayjay/context/tex/texmf/fonts/opentype/public/lm/lmroman10-regular.otf>

system          > files > start used files

used files      >    1: filename=cont-yes.mkiv filetype=tex foundname=/Users/quayjay/context/tex/texmf-context/tex/context/base/cont-yes.mkiv usedmethod=database
used files      >    2: filename=cont-new.mkiv filetype=tex foundname=/Users/quayjay/context/tex/texmf-context/tex/context/base/cont-new.mkiv usedmethod=database
used files      >    3: filename=lang-us.lua filetype=lua foundname=/Users/quayjay/context/tex/texmf-context/tex/context/patterns/lang-us.lua usedmethod=database
used files      >    4: filename=/Users/quayjay/Documents/Private/CoTeXt Testers/MP Stuff/test2.tex foundname=/Users/quayjay/Documents/Private/CoTeXt Testers/MP Stuff/test2.tex usedmethod=direct
used files      >    5: filename=meta-imp-txt.mkiv filetype=tex foundname=/Users/quayjay/context/tex/texmf-context/tex/context/base/meta-imp-txt.mkiv usedmethod=database
used files      >    6: filename=mkiv-base.map filetype=map format=map foundname=/Users/quayjay/context/tex/texmf-context/fonts/map/pdftex/context/mkiv-base.map usedmethod=database
used files      >    7: filename=lm.lfg filetype=tex foundname=/Users/quayjay/context/tex/texmf-context/tex/context/fonts/lm.lfg usedmethod=database
used files      >    8: filename=lm-math.lfg filetype=tex foundname=/Users/quayjay/context/tex/texmf-context/tex/context/fonts/lm-math.lfg usedmethod=database
used files      >    9: filename=lm-math.map filetype=map format=map foundname=/Users/quayjay/context/tex/texmf/fonts/map/dvips/lm/lm-math.map usedmethod=database
used files      >   10: filename=lm-rm.map filetype=map format=map foundname=/Users/quayjay/context/tex/texmf/fonts/map/dvips/lm/lm-rm.map usedmethod=database
used files      >   11: filename=lmroman12-regular filetype=otf format=otf foundname=/Users/quayjay/context/tex/texmf/fonts/opentype/public/lm/lmroman12-regular.otf usedmethod=database
used files      >   12: filename=latinmodern-math.otf filetype=opentypefonts foundname=/Users/quayjay/context/tex/texmf/fonts/opentype/public/lm-math/latinmodern-math.otf usedmethod=database
used files      >   13: filename=latinmodern-math.otf filetype=otf format=otf foundname=/Users/quayjay/context/tex/texmf/fonts/opentype/public/lm-math/latinmodern-math.otf usedmethod=database
used files      >   14: filename=lmroman10-regular filetype=otf format=otf foundname=/Users/quayjay/context/tex/texmf/fonts/opentype/public/lm/lmroman10-regular.otf usedmethod=database
used files      >   15: filename=metafun.mpiv filetype=mp foundname=/Users/quayjay/context/tex/texmf-context/metapost/context/base/metafun.mpiv usedmethod=database
used files      >   16: filename=mp-base.mpiv filetype=mp format=mp foundname=/Users/quayjay/context/tex/texmf-context/metapost/context/base/mp-base.mpiv usedmethod=database
used files      >   17: filename=mp-tool.mpiv filetype=mp format=mp foundname=/Users/quayjay/context/tex/texmf-context/metapost/context/base/mp-tool.mpiv usedmethod=database
used files      >   18: filename=mp-mlib.mpiv filetype=mp format=mp foundname=/Users/quayjay/context/tex/texmf-context/metapost/context/base/mp-mlib.mpiv usedmethod=database
used files      >   19: filename=mp-page.mpiv filetype=mp format=mp foundname=/Users/quayjay/context/tex/texmf-context/metapost/context/base/mp-page.mpiv usedmethod=database
used files      >   20: filename=mp-butt.mpiv filetype=mp format=mp foundname=/Users/quayjay/context/tex/texmf-context/metapost/context/base/mp-butt.mpiv usedmethod=database
used files      >   21: filename=mp-shap.mpiv filetype=mp format=mp foundname=/Users/quayjay/context/tex/texmf-context/metapost/context/base/mp-shap.mpiv usedmethod=database
used files      >   22: filename=mp-grph.mpiv filetype=mp format=mp foundname=/Users/quayjay/context/tex/texmf-context/metapost/context/base/mp-grph.mpiv usedmethod=database
used files      >   23: filename=mp-grid.mpiv filetype=mp format=mp foundname=/Users/quayjay/context/tex/texmf-context/metapost/context/base/mp-grid.mpiv usedmethod=database
used files      >   24: filename=mp-form.mpiv filetype=mp format=mp foundname=/Users/quayjay/context/tex/texmf-context/metapost/context/base/mp-form.mpiv usedmethod=database
used files      >   25: filename=mp-figs.mpiv filetype=mp format=mp foundname=/Users/quayjay/context/tex/texmf-context/metapost/context/base/mp-figs.mpiv usedmethod=database
used files      >   26: filename=mp-func.mpiv filetype=mp format=mp foundname=/Users/quayjay/context/tex/texmf-context/metapost/context/base/mp-func.mpiv usedmethod=database
used files      >   27: filename=mp-text.mpiv filetype=mp format=mp foundname=/Users/quayjay/context/tex/texmf-context/metapost/context/base/mp-text.mpiv usedmethod=database
used files      >   28: filename=test2-mpgraph.mpd foundname=test2-mpgraph.mpd usedmethod=direct
used files      >   29: filename=knuth filetype=tex foundname=/Users/quayjay/context/tex/texmf-context/tex/context/sample/knuth.tex usedmethod=database
used files      >   30: filename=lpdf-pdx.xml filetype=tex foundname=/Users/quayjay/context/tex/texmf-context/tex/context/base/lpdf-pdx.xml usedmethod=database

system          > files > stop used files


system          > structure > start used structure

used structure  > text: test2

system          > structure > stop used structure


system          > files > start used files

used file       >    1: filename=cont-yes.mkiv filetype=tex foundname=/Users/quayjay/context/tex/texmf-context/tex/context/base/cont-yes.mkiv usedmethod=database
used file       >    2: filename=cont-new.mkiv filetype=tex foundname=/Users/quayjay/context/tex/texmf-context/tex/context/base/cont-new.mkiv usedmethod=database
used file       >    3: filename=lang-us.lua filetype=lua foundname=/Users/quayjay/context/tex/texmf-context/tex/context/patterns/lang-us.lua usedmethod=database
used file       >    4: filename=/Users/quayjay/Documents/Private/CoTeXt Testers/MP Stuff/test2.tex foundname=/Users/quayjay/Documents/Private/CoTeXt Testers/MP Stuff/test2.tex usedmethod=direct
used file       >    5: filename=meta-imp-txt.mkiv filetype=tex foundname=/Users/quayjay/context/tex/texmf-context/tex/context/base/meta-imp-txt.mkiv usedmethod=database
used file       >    6: filename=mkiv-base.map filetype=map format=map foundname=/Users/quayjay/context/tex/texmf-context/fonts/map/pdftex/context/mkiv-base.map usedmethod=database
used file       >    7: filename=lm.lfg filetype=tex foundname=/Users/quayjay/context/tex/texmf-context/tex/context/fonts/lm.lfg usedmethod=database
used file       >    8: filename=lm-math.lfg filetype=tex foundname=/Users/quayjay/context/tex/texmf-context/tex/context/fonts/lm-math.lfg usedmethod=database
used file       >    9: filename=lm-math.map filetype=map format=map foundname=/Users/quayjay/context/tex/texmf/fonts/map/dvips/lm/lm-math.map usedmethod=database
used file       >   10: filename=lm-rm.map filetype=map format=map foundname=/Users/quayjay/context/tex/texmf/fonts/map/dvips/lm/lm-rm.map usedmethod=database
used file       >   11: filename=lmroman12-regular filetype=otf format=otf foundname=/Users/quayjay/context/tex/texmf/fonts/opentype/public/lm/lmroman12-regular.otf usedmethod=database
used file       >   12: filename=latinmodern-math.otf filetype=opentypefonts foundname=/Users/quayjay/context/tex/texmf/fonts/opentype/public/lm-math/latinmodern-math.otf usedmethod=database
used file       >   13: filename=latinmodern-math.otf filetype=otf format=otf foundname=/Users/quayjay/context/tex/texmf/fonts/opentype/public/lm-math/latinmodern-math.otf usedmethod=database
used file       >   14: filename=lmroman10-regular filetype=otf format=otf foundname=/Users/quayjay/context/tex/texmf/fonts/opentype/public/lm/lmroman10-regular.otf usedmethod=database
used file       >   15: filename=metafun.mpiv filetype=mp foundname=/Users/quayjay/context/tex/texmf-context/metapost/context/base/metafun.mpiv usedmethod=database
used file       >   16: filename=mp-base.mpiv filetype=mp format=mp foundname=/Users/quayjay/context/tex/texmf-context/metapost/context/base/mp-base.mpiv usedmethod=database
used file       >   17: filename=mp-tool.mpiv filetype=mp format=mp foundname=/Users/quayjay/context/tex/texmf-context/metapost/context/base/mp-tool.mpiv usedmethod=database
used file       >   18: filename=mp-mlib.mpiv filetype=mp format=mp foundname=/Users/quayjay/context/tex/texmf-context/metapost/context/base/mp-mlib.mpiv usedmethod=database
used file       >   19: filename=mp-page.mpiv filetype=mp format=mp foundname=/Users/quayjay/context/tex/texmf-context/metapost/context/base/mp-page.mpiv usedmethod=database
used file       >   20: filename=mp-butt.mpiv filetype=mp format=mp foundname=/Users/quayjay/context/tex/texmf-context/metapost/context/base/mp-butt.mpiv usedmethod=database
used file       >   21: filename=mp-shap.mpiv filetype=mp format=mp foundname=/Users/quayjay/context/tex/texmf-context/metapost/context/base/mp-shap.mpiv usedmethod=database
used file       >   22: filename=mp-grph.mpiv filetype=mp format=mp foundname=/Users/quayjay/context/tex/texmf-context/metapost/context/base/mp-grph.mpiv usedmethod=database
used file       >   23: filename=mp-grid.mpiv filetype=mp format=mp foundname=/Users/quayjay/context/tex/texmf-context/metapost/context/base/mp-grid.mpiv usedmethod=database
used file       >   24: filename=mp-form.mpiv filetype=mp format=mp foundname=/Users/quayjay/context/tex/texmf-context/metapost/context/base/mp-form.mpiv usedmethod=database
used file       >   25: filename=mp-figs.mpiv filetype=mp format=mp foundname=/Users/quayjay/context/tex/texmf-context/metapost/context/base/mp-figs.mpiv usedmethod=database
used file       >   26: filename=mp-func.mpiv filetype=mp format=mp foundname=/Users/quayjay/context/tex/texmf-context/metapost/context/base/mp-func.mpiv usedmethod=database
used file       >   27: filename=mp-text.mpiv filetype=mp format=mp foundname=/Users/quayjay/context/tex/texmf-context/metapost/context/base/mp-text.mpiv usedmethod=database
used file       >   28: filename=test2-mpgraph.mpd foundname=test2-mpgraph.mpd usedmethod=direct
used file       >   29: filename=knuth filetype=tex foundname=/Users/quayjay/context/tex/texmf-context/tex/context/sample/knuth.tex usedmethod=database
used file       >   30: filename=lpdf-pdx.xml filetype=tex foundname=/Users/quayjay/context/tex/texmf-context/tex/context/base/lpdf-pdx.xml usedmethod=database

system          > files > stop used files


system          > options > start commandline options

used option     > autogenerate="true"
used option     > currentrun="3"
used option     > fulljobname="./test2.tex"
used option     > input="./test2.tex"
used option     > kindofrun="2"
used option     > maxnofruns="8"
used option     > no-parse-first-line="true"
used option     > synctex="1"

system          > options > stop commandline options

system          > options > start commandline files

used file       >    1: ./test2.tex

system          > options > stop commandline files



mkiv lua stats  > used config file: selfautoparent:/texmf/web2c/texmfcnf.lua
mkiv lua stats  > used cache path: /Users/quayjay/context/tex/texmf-cache/luatex-cache/context/5fe67e0bfe781ce0dde776fb1556f32e
mkiv lua stats  > synctex tracing: synctex has been enabled (extra log file generated)
mkiv lua stats  > resource resolver: loadtime 0.005 seconds, 3 scans with scantime 0.003 seconds, 0 shared scans, 30 found files, scanned paths: /Library/Fonts /System/Library/Fonts /Users/quayjay/Library/Fonts
mkiv lua stats  > stored bytecode data: 327 modules (0.123 sec), 69 tables (0.003 sec), 396 chunks (0.126 sec)
mkiv lua stats  > cleaned up reserved nodes: 41 nodes, 9 lists of 442
mkiv lua stats  > node memory usage: 4 glue, 4 penalty, 15 attribute, 29 glue_spec, 5 attribute_list
mkiv lua stats  > node list callback tasks: 6 unique task lists, 5 instances (re)created, 47 calls
mkiv lua stats  > used backend: pdf (backend for directly generating pdf output)
mkiv lua stats  > loaded patterns: en::2
mkiv lua stats  > jobdata time: 0.001 seconds saving, 0.001 seconds loading
mkiv lua stats  > callbacks: 214 direct, 571 indirect, 785 total
mkiv lua stats  > randomizer: resumed with value 0.40857777716991
mkiv lua stats  > lxml preparation time: 0.000 seconds, 0 nodes, 15 lpath calls, 0 cached calls
mkiv lua stats  > result saved in file: test2.pdf, compresslevel 3, objectcompreslevel 3
mkiv lua stats  > loaded fonts: 3 files: latinmodern-math.otf (experimental), lmroman10-regular.otf, lmroman12-regular.otf
mkiv lua stats  > fonts load time: 0.206 seconds 
mkiv lua stats  > luatex banner: this is luatex, version beta-0.76.0-2013040508  (tex live 2013/dev)(rev 4627)
mkiv lua stats  > control sequences: 37402 of 65536 + 100000
mkiv lua stats  > current memory usage: 53 MB (ctx: 53 MB)
mkiv lua stats  > runtime: 0.496 seconds, 1 processed pages, 1 shipped pages, 2.016 pages/second


[-- Attachment #1.2.5: Type: text/html, Size: 227 bytes --]

[-- Attachment #1.2.6: test2.pdf --]
[-- Type: application/pdf, Size: 9419 bytes --]

[-- Attachment #1.2.7: Type: text/html, Size: 227 bytes --]

[-- Attachment #1.2.8: expected.pdf --]
[-- Type: application/pdf, Size: 9655 bytes --]

[-- Attachment #1.2.9: Type: text/html, Size: 418 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: MPLibrabray "txt" broken!?
  2013-05-15  7:36   ` Keith J. Schultz
@ 2013-05-15 10:15     ` Keith J. Schultz
  2013-05-15 11:04       ` Hans Hagen
  0 siblings, 1 reply; 6+ messages in thread
From: Keith J. Schultz @ 2013-05-15 10:15 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1721 bytes --]

Hi Hans, Everybody,

Am 15.05.2013 um 09:36 schrieb "Keith J. Schultz" <keithjschultz@web.de>:

> Hi Hans,
> 
> Am 14.05.2013 um 19:57 schrieb Hans Hagen <pragma@wxs.nl>:
> 
>> 
[snip, snip]
>> some kind of initialization issue .. i uploaded a fix (crossed fingers)
> 
> 	Well, the fix work in a way , yet it has introduced a new problem,
> 	or revealed an unnoticed one.
> 	
> 	The text is now display in the shape, yet there is no drawing preformed!
> 	The draw of the path is no preformed.
> 	It is even worst. Metapost seems to be doing no drawing at all, even in over
> 	overlays! The all are related to a similar error :
> metapost        > initializing number mode 'scaled'
> metapost        > output file 'mpout.log', mode 'w', ftype 'log'
> metapost        > output file 'test2-mpgraph.mpd', mode 'w', ftype 0
> metapost        > output file 'test2-mpgraph.mpd', mode 'w', ftype 0
> metapost        > error: (/Users/quayjay/context/tex/texmf-context/metapost/context/base/mp-text.mpiv)
> 
> 
> 
> >> PageFraction
> >> false
> ! Equation cannot be performed (numeric=boolean).
> <to be read again> 
>                    :
> <*> ...0pt; VSize:=597.51323pt; PageFraction:=0>1:
>                                                   (1-1)/(0-1)else:1fi; defau...

I believe the source of this is in meta-ini.mkiv:
\startMPinitializations
    PageFraction:=\lastpage>1:(\realfolio-1)/(\lastpage-1)else:1fi;
\stopMPinitializations

Should this not be:
\startMPinitializations
    PageFraction:=if \lastpage>1:(\realfolio-1)/(\lastpage-1)else:1fi;
\stopMPinitializations

O.K. just rebuilt formats!

Works.

Attaching new meta-ini.mkiv

Thanx!

reagrds
	Keith.




[-- Attachment #1.2.1: Type: text/html, Size: 5287 bytes --]

[-- Attachment #1.2.2: meta-ini.mkiv --]
[-- Type: application/octet-stream, Size: 45126 bytes --]

%D \module
%D   [       file=meta-ini,
%D        version=2008.03.25,
%D          title=\METAPOST\ Graphics,
%D       subtitle=Initialization,
%D         author=Hans Hagen,
%D           date=\ currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

% initializations:
%
% - pass settings from tex to mp (delayed expansion)
% - used by context core (and modules)
% - cummulative definitions
% - flushed each graphic
% - can be disabled per instance
% - managed at the tex end
%
% extensions:
%
% - add mp functionality (immediate expansion)
% - cummulative
% - all instances or subset of instances
% - can be disabled per instance
% - managed at the lua/mp end
% - could be managed at the tex end but no real reason and also messy
%
% definitions:
%
% - add mp functionality (delayed expansion)
% - cummulative
% - per instance
% - managed at the tex end
%
% inclusions:
%
% - add mp functionality (delayed expansion)
% - cummulative only when [+]
% - per instance
% - managed at the tex end
%
% order of execution:
%
%   definitions
%   extensions
%   inclusions
%   beginfig
%     initializations
%     graphic
%   endfig

% The instance will be implemented stepwise ... I should redo some code in order to
% make the macros look better than they do now.

\writestatus{loading}{MetaPost Graphics / Initializations}

\registerctxluafile{meta-ini}{1.001}

\unprotect

\newtoks \everyMPgraphic          % mp % public or not ?

\appendtoks
    \restoreendofline % see interferences-001.tex
\to \everyMPgraphic

\def\MPruntimefile    {mprun}
\def\currentMPformat  {metafun}
\def\defaultMPinstance{metafun}

%installcorenamespace{graphicvariable} % todo
\installcorenamespace{mpinstance}
\installcorenamespace{mpinclusions}
\installcorenamespace{mpdefinitions}
\installcorenamespace{mpgraphic}
\installcorenamespace{mpstaticgraphic}
\installcorenamespace{mpclip}

\newtoks \t_meta_initializations  % tex, each
\def     \t_meta_inclusions     {\csname\??mpinclusions \currentMPinstance\endcsname} % token register
\def     \t_meta_definitions    {\csname\??mpdefinitions\currentMPinstance\endcsname} % token register

% The next command is, of course, dedicated to Mojca, who
% needs it for gnuplot. Anyway, the whole multiple engine
% mechanism is to keep her gnuplot from interfering.

\unexpanded\def\startMPdefinitions
  {\dosinglegroupempty\meta_start_definitions}

\def\meta_start_definitions#1#2\stopMPdefinitions
  {\let\m_meta_saved_instance\currentMPinstance
   \edef\currentMPinstance{#1}%
   \ifx\currentMPinstance\empty
     \let\currentMPinstance\defaultMPinstance
   \fi
   \global\t_meta_definitions\expandafter{\the\t_meta_definitions#2}%
   \let\currentMPinstance\m_meta_saved_instance}

\let\stopMPdefinitions\relax

\unexpanded\def\startMPextensions
  {\dosinglegroupempty\meta_start_extensions}

\def\meta_start_extensions#1#2\stopMPextensions % we could use buffers instead
  {\ctxlua{metapost.setextensions("#1",\!!bs#2\!!es)}}

\let\stopMPextensions\relax

\unexpanded\def\startMPinitializations#1\stopMPinitializations % for all instances, when enabled
  {\global\t_meta_initializations\expandafter{\the\t_meta_initializations#1}}

\let\stopMPinitializations\relax

\unexpanded\def\startMPinclusions
  {\dosingleempty\meta_start_inclusions}

\unexpanded\def\meta_start_inclusions[#1]%
  {\edef\m_meta_option{#1}%
   \dosinglegroupempty\meta_start_inclusions_indeed}

\def\meta_start_inclusions_indeed#1#2\stopMPinclusions
  {\let\m_meta_saved_instance\currentMPinstance
   \edef\currentMPinstance{#1}%
   \ifx\currentMPinstance\empty
     \let\currentMPinstance\defaultMPinstance
   \fi
   \ifx\m_meta_option\!!plustoken \else
     \global\t_meta_inclusions\emptytoks
   \fi
   \global\t_meta_inclusions\expandafter{\the\t_meta_inclusions#2}%
   \let\currentMPinstance\m_meta_saved_instance}

\let\stopMPinclusions\relax

\unexpanded\def\MPinclusions
  {\dosingleempty\meta_inclusions}

\def\meta_inclusions[#1]%
  {\edef\m_meta_option{#1}%
   \dosinglegroupempty\meta_inclusions_indeed}

\def\meta_inclusions_indeed#1#2%
  {\let\m_meta_saved_instance\currentMPinstance
   \edef\currentMPinstance{#1}%
   \ifx\currentMPinstance\empty
     \let\currentMPinstance\defaultMPinstance
   \fi
   \ifx\m_meta_option\!!plustoken \else
     \global\t_meta_inclusions\emptytoks
   \fi
   \global\t_meta_inclusions\expandafter{\the\t_meta_inclusions#2}%
   \let\currentMPinstance\m_meta_saved_instance}

\def\meta_preset_definitions
  {\edef\overlaywidth    {\overlaywidth    \space}%
   \edef\overlayheight   {\overlayheight   \space}%
   \edef\overlaylinewidth{\overlaylinewidth\space}%
   \edef\currentwidth    {\the\hsize       \space}%
   \edef\currentheight   {\the\vsize       \space}}

\installcommandhandler \??mpinstance {MPinstance} \??mpinstance

\setupMPinstance
  [\s!format=metafun,
   \s!extensions=\v!no,
   \s!initializations=\v!no,
   \c!method=\s!default,
   \c!textstyle=,
   \c!textcolor=]

\appendtoks
    \ifcsname\??mpdefinitions\currentMPinstance\endcsname \else
        \expandafter\newtoks\csname\??mpdefinitions\currentMPinstance\endcsname
    \fi
    \ifcsname\??mpinclusions\currentMPinstance\endcsname \else
        \expandafter\newtoks\csname\??mpinclusions\currentMPinstance\endcsname
    \fi
    \t_meta_definitions\emptytoks % in case we redefine
    \t_meta_inclusions \emptytoks % in case we redefine
\to \everydefineMPinstance

\unexpanded\def\resetMPinstance[#1]%
  {\writestatus\m!metapost{reset will be implemented when needed}}

\def\meta_analyze_graphicname[#1]%
 %{\normalexpanded{\meta_analyze_graphicname_indeed[#1::::]}}
  {\normalexpanded{\meta_analyze_graphicname_indeed[#1}::::]}

\unexpanded\def\meta_analyze_graphicname_indeed[#1::#2::#3]% instance ::
  {\edef\currentMPgraphicname{#2}%
   \ifx\currentMPgraphicname\empty
     \edef\currentMPgraphicname{#1}%
     \let\currentMPinstance\defaultMPinstance
   \else\ifcsname\??mpdefinitions#1\endcsname
     \edef\currentMPinstance{#1}%
   \else
     \let\currentMPinstance\defaultMPinstance
   \fi\fi
   \edef\currentMPformat{\MPinstanceparameter\s!format}}

\def\currentMPinstance{\defaultMPinstance}
\def\currentMPformat  {\currentMPinstance}

\defineMPinstance[metafun]   [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes]
\defineMPinstance[extrafun]  [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes]
\defineMPinstance[doublefun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes,\c!method=\s!double]
\defineMPinstance[decimalfun][\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes,\c!method=\s!decimal]
\defineMPinstance[mprun]     [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes]
\defineMPinstance[metapost]  [\s!format=mpost]
\defineMPinstance[nofun]     [\s!format=mpost]

\newconditional\c_meta_include_initializations

\def\meta_begin_graphic_group#1%
  {\begingroup
   \meta_analyze_graphicname[#1]}

\def\meta_end_graphic_group
  {\endgroup}

\def\MPaskedfigure{false}

\def\meta_flush_current_initializations
  {\ifconditional\c_meta_include_initializations
     \the\t_meta_initializations
   \fi
   \theMPrandomseed;}

\def\meta_flush_current_inclusions
  {\the\t_meta_inclusions}

\def\meta_flush_current_definitions
  {\the\t_meta_definitions}

\def\meta_start_current_graphic
  {\begingroup
   \meta_enable_include
   \the\everyMPgraphic
   \meta_preset_definitions
   \setMPrandomseed % this has to change
   \edef\p_initializations{\MPinstanceparameter\s!initializations}%
   \ifx\p_initializations\v!yes
     \settrue \c_meta_include_initializations
   \else
     \setfalse\c_meta_include_initializations
   \fi
   \edef\p_setups{\MPinstanceparameter\c!setups}%
   \ifx\p_setups\empty \else
     \setups[\p_setups]%
   \fi
   \useMPinstancestyleandcolor\c!textstyle\c!textcolor}

\def\meta_stop_current_graphic
  {\global\t_meta_definitions\emptytoks
   \global\t_meta_inclusions\emptytoks
   \endgroup}

\def\meta_process_graphic_start
  {\setbox\b_meta_graphic\hbox\bgroup}

\def\meta_process_graphic_stop
  {\egroup
   \meta_place_graphic}

\unexpanded\def\meta_process_graphic_instance#1%
  {\edef\currentMPinstance{#1}%
   \ifx\currentMPinstance\empty
     \let\currentMPinstance\defaultMPinstance
   \fi
   \edef\currentMPformat{\MPinstanceparameter\s!format}%
   \meta_process_graphic}

\unexpanded\def\meta_process_graphic#1% todo: extensions and inclusions outside beginfig
  {\meta_start_current_graphic
   \forgetall
   \edef\p_extensions{\MPinstanceparameter\s!extensions}%
   \meta_process_graphic_start
     \normalexpanded{\noexpand\ctxlua{metapost.graphic {
       instance        = "\currentMPinstance",
       format          = "\currentMPformat",
       data            = \!!bs#1;\!!es,
       initializations = \!!bs\meta_flush_current_initializations\!!es,
%      useextensions   = "\MPinstanceparameter\s!extensions",
\ifx\p_extensions\v!yes
       extensions      = \!!bs\ctxcommand{getmpextensions("\currentMPinstance")}\!!es,
\fi
       inclusions      = \!!bs\meta_flush_current_inclusions\!!es,
       definitions     = \!!bs\meta_flush_current_definitions\!!es,
       figure          = "\MPaskedfigure",
       method          = "\MPinstanceparameter\c!method",
     }}}%
   \meta_process_graphic_stop
   \meta_stop_current_graphic}

\let\meta_process_graphic_figure_start\relax
\let\meta_process_graphic_figure_stop \relax

\unexpanded\def\processMPfigurefile#1% special case: obeys beginfig .. endfig and makes pages
  {\begingroup
   \let\normal_meta_process_graphic_start\meta_process_graphic_start
   \let\normal_meta_process_graphic_stop \meta_process_graphic_stop
   \let\meta_process_graphic_start\relax
   \let\meta_process_graphic_stop \relax
   \def\meta_process_graphic_figure_start{\startTEXpage\normal_meta_process_graphic_start}%
   \def\meta_process_graphic_figure_stop {\normal_meta_process_graphic_stop\stopTEXpage}
   \def\MPaskedfigure{all}%
   \meta_process_graphic{input "#1" ;}%
   \endgroup}

\newif\ifsetMPrandomseed \setMPrandomseedtrue % false by default

\def\setMPrandomseed
  {\let\theMPrandomseed\empty
   \ifsetMPrandomseed \ifx\getrandomnumber\undefined \else
     \getrandomnumber\localMPseed\zerocount{4095}%
     \def\theMPrandomseed{randomseed:=\localMPseed}%
   \fi\fi}

%D Calling up previously defined graphics.

\def\includeMPgraphic#1% gets expanded !
  {\ifcsname\??mpgraphic#1\endcsname
     \csname\??mpgraphic#1\endcsname ; % ; is safeguard
   \fi}

\unexpanded\def\meta_enable_include % public
  {\let\meta_handle_use_graphic     \thirdofthreearguments
   \let\meta_handle_reusable_graphic\thirdofthreearguments}

%D Drawings (stepwise built):

\newif\ifMPdrawingdone \MPdrawingdonefalse

\unexpanded\def\finalizeMPdrawing
  {\MPdrawingdonetrue}

\let\MPdrawingdata\empty

\unexpanded\def\resetMPdrawing
  {\global\let\MPdrawingdata\empty
   \global\MPdrawingdonefalse}

\unexpanded\def\pushMPdrawing
  {\globalpushmacro\MPdrawingdata
   \global\let\MPdrawingdata\empty}

\unexpanded\def\popMPdrawing
  {\globalpopmacro\MPdrawingdata}

\unexpanded\def\getMPdrawing
  {\ifMPdrawingdone
     \expandafter\meta_process_graphic\expandafter{\MPdrawingdata}% is this expansion still needed?
   \fi}

\def\startMPdrawing
  {\dosingleempty\meta_start_drawing}

\def\meta_start_drawing[#1]#2\stopMPdrawing
  {\relax
   \bgroup
   \meta_enable_include
   \meta_preset_definitions % in case #2 has measures
   \doifelse{#1}{-}{\convertargument#2\to\asciia}{\def\asciia{#2}}%
   \xdef\MPdrawingdata{\MPdrawingdata\asciia}%
   \egroup}

\let\stopMPdrawing\relax

\def\MPdrawing#1%
  {\relax
   \bgroup
   \meta_enable_include
   \meta_preset_definitions
   \xdef\MPdrawingdata{\MPdrawingdata#1}%
   \egroup}

\unexpanded\def\startMPclip#1#2\stopMPclip % todo: store at the lua end or just store less
  {\setgvalue{\??mpclip#1}{#2}}

\let\stopMPclip\relax

\unexpanded\def\meta_grab_clip_path#1#2#3#4% #4 is alternative (called in backend code)
  {\begingroup
   \edef\width {#2\space}\let\overlaywidth \width
   \edef\height{#3\space}\let\overlayheight\height
   \ifcsname\??mpclip#1\endcsname
     \meta_start_current_graphic
       \xdef\MPclippath{\normalexpanded{\noexpand\ctxlua{metapost.theclippath {
            instance        = "\currentMPinstance",
            format          = "\currentMPformat",
            data            = \!!bs\getvalue{\??mpclip#1}\!!es,
            initializations = \!!bs\meta_flush_current_initializations\!!es,
            useextensions   = "\MPinstanceparameter\s!extensions",
            inclusions      = \!!bs\meta_flush_current_inclusions\!!es,
            method          = "\MPinstanceparameter\c!method",
       }}}}%
     \meta_stop_current_graphic
     \ifx\MPclippath\empty
       \xdef\MPclippath{#4}%
     \fi
   \else
     \xdef\MPclippath{#4}%
   \fi
   \endgroup}

%D Since we want lables to follow the document settings, we
%D also set the font related variables.

\unexpanded\def\MPfontsizehskip#1%
  {\dontleavehmode
   \begingroup
   \definedfont[#1]%
   \hskip\cldcontext{fonts.hashes.parameters[font.current()].designsize}sp\relax
   \endgroup}

\startMPinitializations % scale is not yet ok
    defaultfont:="\truefontname{Regular}";
    defaultscale:=\the\bodyfontsize/10pt;
\stopMPinitializations

% watch out, this is a type1 font because mp can only handle 8 bit fonts

\startMPinitializations % scale is not yet ok
    defaultfont:="rm-lmtt10";
\stopMPinitializations

%D A signal that we're in combined \CONTEXT||\METAFUN mode:

\startMPextensions
    string contextversion;
    contextversion:="\contextversion"; % expanded
\stopMPextensions

%D \macros
%D   {setupMPvariables}
%D
%D When we build collections of \METAPOST\ graphics, like
%D background and buttons, the need for passing settings
%D arises. By (mis|)|using the local prefix that belongs to
%D \type {\framed}, we get a rather natural interface to
%D backgrounds. To prevent conflicts, we will use the \type
%D {-} in \METAPOST\ specific variables, like:
%D
%D \starttyping
%D \setupMPvariables[meta:button][size=20pt]
%D \stoptyping

% \lineheight  2pt  2  \scratchcounter  red  0.4  .5\bodyfontsize
%
% see cont-loc for test code
%
% currently the inheritance of backgrounds does not work and
% we might drop it anyway (too messy)

\newbox\b_meta_variable_box

\let \currentmpvariableclass          \empty
\let \m_meta_current_variable         \empty
\let \m_meta_current_variable_template\empty

\installcorenamespace{graphicvariable}

\def \meta_prepare_variable_default   {\MPcolor{black}} % just to be sure we use a color but ...
\edef\meta_unknown_variable_template  {\??graphicvariable:\s!unknown}

\letvalue{\??graphicvariable:\s!unknown}\empty

\unexpanded\def\setupMPvariables
  {\dodoubleempty\meta_setup_variables}

\def\meta_setup_variables[#1][#2]%
  {\ifsecondargument
     \getrawparameters[\??graphicvariable#1:][#2]%
   \else
     \getrawparameters[\??graphicvariable:][#1]%
   \fi}

\unexpanded\def\presetMPvariable
  {\dodoubleargument\meta_preset_variable}

\def\meta_preset_variable[#1][#2=#3]%
  {\ifcsname\??graphicvariable#1:#2\endcsname \else
     \setvalue{\??graphicvariable#1:#2}{#3}%
   \fi}

\def\MPrawvar#1#2% no checking
  {\csname\??graphicvariable#1:#2\endcsname}

\def\MPvariable#1% todo: could be a framed chain
  {\csname\??graphicvariable\currentmpvariableclass:#1\endcsname}

\unexpanded\def\useMPvariables
  {\dodoubleargument\meta_use_variables}

\def\meta_use_variables[#1][#2]%
  {\edef\currentmpvariableclass{#1}%
   \meta_prepare_variables{#2}}

\unexpanded\def\meta_prepare_variables#1%
  {\processcommalist[#1]\meta_prepare_variable}

\unexpanded\def\meta_prepare_variable#1%
  {\edef\m_meta_current_variable_template
     {\??graphicvariable\currentmpvariableclass:#1}%
   \edef\m_meta_current_variable
     {\csname\ifcsname\m_meta_current_variable_template\endcsname
        \m_meta_current_variable_template\else\meta_unknown_variable_template
      \fi\endcsname}%
   \ifx\m_meta_current_variable\empty
     \expandafter\meta_prepare_variable_nop
   \else
     \expandafter\meta_prepare_variable_yes
   \fi}

\unexpanded\def\meta_prepare_instance_variables
  {\expandafter\processcommalist\expandafter[\m_meta_instance_variables]\meta_prepare_instance_variable}

\unexpanded\def\meta_prepare_instance_variable#1%
  {\edef\m_meta_current_variable_template
     {\??graphicvariable\currentmpvariableclass:#1}%
   \edef\m_meta_current_variable
     {\csname
        \ifcsname\m_meta_current_variable_template\endcsname
          \m_meta_current_variable_template
        \else\ifcsname\??graphicvariable\currentMPgraphicname:#1\endcsname
          \??graphicvariable\currentMPgraphicname:#1%
        \else
          \meta_unknown_variable_template
        \fi\fi
      \endcsname}%
   \ifx\m_meta_current_variable\empty
     \expandafter\meta_prepare_variable_nop
   \else
     \expandafter\meta_prepare_variable_yes
   \fi}

\def\meta_prepare_variable_nop
  {\expandafter \let\csname\m_meta_current_variable_template\endcsname\meta_prepare_variable_default}

\def\meta_prepare_variable_color
  {\expandafter\edef\csname\m_meta_current_variable_template\endcsname{\MPcolor\m_meta_current_variable}}

\def\meta_prepare_variable_number
  {\expandafter\edef\csname\m_meta_current_variable_template\endcsname{\number\m_meta_current_variable}}% also accepts 0.number

\def\meta_prepare_variable_dimension
  {\expandafter\edef\csname\m_meta_current_variable_template\endcsname{\the\dimexpr\m_meta_current_variable}}

\def\meta_prepare_variable_yes
  {\defconvertedcommand\ascii\m_meta_current_variable % otherwise problems
   \doifcolorelse \ascii                              % with 2\bodyfontsize
     {\meta_prepare_variable_color}
     {\begingroup
      \setbox\b_meta_variable_box\hbox{\scratchdimen\m_meta_current_variable sp}%
      \ifzeropt\wd\b_meta_variable_box
        \endgroup\meta_prepare_variable_number
      \else
        \endgroup\meta_prepare_variable_dimension
      \fi}}

\let\MPvar         \MPvariable
\let\setMPvariables\setupMPvariables

%D \macros
%D   {startuniqueMPgraphic, uniqueMPgraphic}
%D
%D This macros is probably of most use to myself, since I like
%D to use graphics that adapt themselves. The next \METAPOST\
%D kind of graphic is both unique and reused when possible.
%D
%D \starttyping
%D \defineoverlay[example][\uniqueMPgraphic{test}]
%D
%D \startuniqueMPgraphic {test}
%D   draw unitsquare xscaled \overlaywidth yscaled \overlayheight ;
%D \stopuniqueMPgraphic
%D \stoptyping

\def\overlaystamp % watch the \MPcolor, since colors can be redefined
  {\overlaywidth:\overlayheight:\overlaydepth:\MPcolor\overlaycolor:\MPcolor\overlaylinecolor}

%D A better approach is to let additional variables play a role
%D in determining the uniqueness. In the next macro, the
%D second, optional, argument is used to guarantee the
%D uniqueness, as well as prepare variables for passing them to
%D \METAPOST.
%D
%D \starttyping
%D \startuniqueMPgraphic{meta:hash}{gap,angle,...}
%D \stoptyping
%D
%D The calling macro also accepts a second argument. For
%D convenient use in overlay definitions, we use \type {{}}
%D instead of \type {[]}.
%D
%D \starttyping
%D \uniqueMPgraphic{meta:hash}{gap=10pt,angle=30}
%D \stoptyping

\newcount\c_meta_object_counter
\newbox  \b_meta_graphic

% hm, isn't this already done elsewhere?

\unexpanded\def\meta_obey_box_depth
  {\setbox\b_meta_graphic\hbox\bgroup
     \raise\MPlly\box\b_meta_graphic
   \egroup}

\unexpanded\def\meta_ignore_box_depth
  {\normalexpanded
     {\meta_obey_box_depth % hence the \unexpanded
      \wd\b_meta_graphic\the\wd\b_meta_graphic
      \ht\b_meta_graphic\the\ht\b_meta_graphic
      \dp\b_meta_graphic\the\dp\b_meta_graphic}}

\unexpanded\def\meta_obey_box_origin
  {\setbox\b_meta_graphic\hbox\bgroup
     \kern\MPllx\raise\MPlly\box\b_meta_graphic
   \egroup}

\unexpanded\def\obeyMPboxdepth  {\let\meta_relocate_box\meta_obey_box_depth  }
\unexpanded\def\ignoreMPboxdepth{\let\meta_relocate_box\meta_ignore_box_depth}
\unexpanded\def\obeyMPboxorigin {\let\meta_relocate_box\meta_obey_box_origin }
\unexpanded\def\normalMPboxdepth{\let\meta_relocate_box\relax              }

\let\meta_relocate_box\relax

\unexpanded\def\meta_place_graphic % the converter also displaces so in fact we revert
  {\meta_relocate_box
   \box\b_meta_graphic}

\unexpanded\def\meta_reuse_box#1#2#3#4#5% space delimiting would save some tokens
  {\MPllx#2\MPlly#3\MPurx#4\MPury#5%
   \hbox{\forcecolorhack\getobject{MP}{#1}}} % else no proper color intent

\def\meta_handle_unique_graphic#1#2#3% when there are too many, we can store data at the lua end, although,
  {\begingroup                  % when there are that many they're probably not that unique anyway
   \edef\currentmpvariableclass{#1}%
   \extendMPoverlaystamp{#2}% incl prepare
   \ifcsname\??mpgraphic\overlaystamp:#1\endcsname\else
     \meta_enable_include % redundant
     \global\advance\c_meta_object_counter\plusone
     \setobject{MP}{\number\c_meta_object_counter}\hbox{\meta_process_graphic{#3}}% was vbox, graphic must end up as hbox
     \setxvalue{\??mpgraphic\overlaystamp:#1}{\meta_reuse_box{\number\c_meta_object_counter}{\the\MPllx}{\the\MPlly}{\the\MPurx}{\the\MPury}}%
   \fi
   \getvalue{\??mpgraphic\overlaystamp:#1}%
   \endgroup}

\unexpanded\def\startuniqueMPgraphic
  {\dodoublegroupempty\meta_start_unique_graphic}

% \def\meta_start_unique_graphic#1#2#3\stopuniqueMPgraphic
%   {\setgvalue{\??mpgraphic#1}{\meta_handle_unique_graphic{#1}{#2}{#3}}}

\def\meta_start_unique_graphic#1%
  {\normalexpanded{\meta_start_unique_graphic_indeed{#1}}}

\unexpanded\def\meta_start_unique_graphic_indeed#1#2#3\stopuniqueMPgraphic
  {\setgvalue{\??mpgraphic#1}{\meta_handle_unique_graphic{#1}{#2}{#3}}}

\let\stopuniqueMPgraphic\relax

\unexpanded\def\uniqueMPgraphic
  {\dodoublegroupempty\meta_unique_graphic}

\def\meta_unique_graphic#1#2%
  {\meta_begin_graphic_group{#1}%
%    \setupMPvariables[\currentMPgraphicname][#2]%
   \setupMPvariables[#1][#2]%
   \getvalue{\??mpgraphic#1}\empty
   \meta_end_graphic_group}

\def\meta_handle_use_graphic#1#2#3%
  {\begingroup
   \edef\currentmpvariableclass{#1}%
   \edef\m_meta_instance_variables{#2}%
   \ifx\m_meta_instance_variables\empty \else
     \meta_prepare_instance_variables
   \fi
   \meta_enable_include % redundant
   \meta_process_graphic{#3}%
   \endgroup}

\unexpanded\def\startuseMPgraphic
  {\dodoublegroupempty\meta_start_use_graphic}

% \def\meta_start_use_graphic#1#2#3\stopuseMPgraphic
%   {\setgvalue{\??mpgraphic#1}{\meta_handle_use_graphic{#1}{#2}{#3}}}
%
% better, expansion of #1:
%
% \def\meta_start_use_graphic#1#2#3\stopuseMPgraphic
%  %{\setgvalue{\??mpgraphic#1}{\meta_handle_use_graphic{#1}{#2}{#3}}}
%  %{\setxvalue{\??mpgraphic#1}{\noexpand\meta_handle_use_graphic{#1}{\normalunexpanded{#2}}{\normalunexpanded{#3}}}}
%   {\global\expandafter\gdef\csname\??mpgraphic#1\expandafter\endcsname\expandafter{\expandafter\meta_handle_use_graphic\expandafter{\normalexpanded{#1}}{#2}{#3}}}
%
% cleaner:

\def\meta_start_use_graphic#1%
  {\normalexpanded{\meta_start_use_graphic_indeed{#1}}}

\unexpanded\def\meta_start_use_graphic_indeed#1#2#3\stopuseMPgraphic
  {\setgvalue{\??mpgraphic#1}{\meta_handle_use_graphic{#1}{#2}{#3}}}

\let\stopuseMPgraphic\relax

\unexpanded\def\startusableMPgraphic % redundant but handy
  {\dodoublegroupempty\meta_start_usable_graphic}

% \def\meta_start_usable_graphic#1#2#3\stopusableMPgraphic
%   {\setgvalue{\??mpgraphic#1}{\meta_handle_use_graphic{#1}{#2}{#3}}}

\def\meta_start_usable_graphic#1%
  {\normalexpanded{\meta_start_usable_graphic_indeed{#1}}}

\unexpanded\def\meta_start_usable_graphic_indeed#1#2#3\stopusableMPgraphic
  {\setgvalue{\??mpgraphic#1}{\meta_handle_use_graphic{#1}{#2}{#3}}}

\let\stopusableMPgraphic\relax

\def\meta_handle_reusable_graphic#1#2#3%
  {\begingroup
   \edef\currentmpvariableclass{#1}%
   \edef\m_meta_instance_variables{#2}%
   \ifx\m_meta_instance_variables\empty \else
     \meta_prepare_instance_variables
   \fi
   \meta_enable_include % redundant
   \global\advance\c_meta_object_counter\plusone
   \setobject{MP}{\number\c_meta_object_counter}\hbox{\meta_process_graphic{#3}}% was vbox, graphic must end up as hbox
   \setxvalue{\??mpgraphic#1}{\meta_reuse_box{\number\c_meta_object_counter}{\the\MPllx}{\the\MPlly}{\the\MPurx}{\the\MPury}}%
   \getvalue{\??mpgraphic#1}%
   \endgroup}

\unexpanded\def\startreusableMPgraphic
  {\dodoublegroupempty\meta_start_reusable_graphic}

% \def\meta_start_reusable_graphic#1#2#3\stopreusableMPgraphic
%   {\setgvalue{\??mpgraphic#1}{\meta_handle_reusable_graphic{#1}{#2}{#3}}}

\def\meta_start_reusable_graphic#1%
  {\normalexpanded{\meta_start_reusable_graphic_indeed{#1}}}

\unexpanded\def\meta_start_reusable_graphic_indeed#1#2#3\stopreusableMPgraphic
  {\setgvalue{\??mpgraphic#1}{\meta_handle_reusable_graphic{#1}{#2}{#3}}}

\let\stopreusableMPgraphic\relax

\unexpanded\def\useMPgraphic
  {\dodoublegroupempty\meta_use_graphic}

\def\meta_use_graphic#1#2%
  {\meta_begin_graphic_group{#1}%
%    \doifsomething{#2}{\setupMPvariables[\currentMPgraphicname][#2]}%
   \doifsomething{#2}{\setupMPvariables[#1][#2]}%
   \getvalue{\??mpgraphic#1}\empty
   \meta_end_graphic_group}

\let\reuseMPgraphic   \useMPgraphic   % we can save a setup here if needed
\let\reusableMPgraphic\reuseMPgraphic % we can save a setup here if needed

\unexpanded\def\meta_enable_include
  {\let\meta_handle_use_graphic     \thirdofthreearguments
   \let\meta_handle_reusable_graphic\thirdofthreearguments}

%D \macros
%D   {startuniqueMPpagegraphic,uniqueMPpagegraphic}
%D
%D Experimental.

\def\m_meta_page_prefix{\doifoddpageelse oe}

\def\overlaypagestamp
  {\m_meta_page_prefix:\overlaywidth:\overlayheight:\overlaydepth:\MPcolor\overlaycolor:\MPcolor\overlaylinecolor}

\unexpanded\def\startuniqueMPpagegraphic
  {\dodoublegroupempty\meta_start_unique_page_graphic}

% \def\meta_start_unique_page_graphic#1#2#3\stopuniqueMPpagegraphic              % inefficient, double storage
%   {\setgvalue{\??mpgraphic o:#1}{\meta_handle_unique_graphic{o:#1}{#2}{#3}}%   % but these also keep the state
%    \setgvalue{\??mpgraphic e:#1}{\meta_handle_unique_graphic{e:#1}{#2}{#3}}}   % and meaning will be redefined

\def\meta_start_unique_page_graphic#1%
  {\normalexpanded{\meta_start_unique_page_graphic_indeed{#1}}}

\unexpanded\def\meta_start_unique_page_graphic_indeed#1#2#3\stopuniqueMPpagegraphic % inefficient, double storage
  {\setgvalue{\??mpgraphic o:#1}{\meta_handle_unique_graphic{o:#1}{#2}{#3}}%        % but these also keep the state
   \setgvalue{\??mpgraphic e:#1}{\meta_handle_unique_graphic{e:#1}{#2}{#3}}}        % and meaning will be redefined

\let\stopuniqueMPpagegraphic\relax

\unexpanded\def\uniqueMPpagegraphic
  {\dodoublegroupempty\meta_unique_page_graphic}

\def\meta_unique_page_graphic#1#2%
  {\meta_begin_graphic_group{#1}%
   \let\overlaystamp\overlaypagestamp
%    \setupMPvariables[\m_meta_page_prefix:\currentMPgraphicname][#2]% prefix is new here
   \setupMPvariables[\m_meta_page_prefix:#1][#2]% prefix is new here
   \getvalue{\??mpgraphic\m_meta_page_prefix:#1}{}%
   \meta_end_graphic_group}

%D One way of defining a stamp is:
%D
%D \starttyping
%D \def\extendMPoverlaystamp#1%
%D   {\def\docommand##1%
%D      {\edef\overlaystamp{\overlaystamp:\MPvariable{##1}}}%
%D    \processcommalist[#1]\docommand}
%D \stoptyping

%D Since we need to feed \METAPOST\ with expanded dimensions,
%D we introduce a dedicated expansion engine.

%D We redefine \type {\extendMPoverlaystamp} to preprocess
%D variables using \type {\meta_prepare_variable}.

\unexpanded\def\extendMPoverlaystamp#1%
  {\processcommalist[#1]\meta_extend_overlay_stamp}

\def\meta_extend_overlay_stamp#1%
  {\meta_prepare_instance_variable{#1}%
   \edef\overlaystamp{\overlaystamp:\MPvariable{#1}}}

%D \macros
%D   {MPdatafile}
%D
%D We redefine a macro from \type {supp-mps.tex}:

% This will change ...

\def\MPdataMPDfile{\jobname-mpgraph.mpd}
\def\MPdataMPOfile{\jobname-mpgraph.mpo}
\def\MPdataMPYfile{\jobname-mpgraph.mpy}

\startMPinitializations
    boolean collapse_data; collapse_data:=true;
    def data_mpd_file = "\MPdataMPDfile" enddef ;
    def data_mpo_file = "\MPdataMPOfile" enddef ;
    def data_mpy_file = "\MPdataMPYfile" enddef ;
\stopMPinitializations

\unexpanded\def\getMPdata
  {\let\MPdata\secondoftwoarguments
   \startreadingfile
   % \startnointerference % no, else we need to do all data global
   \readlocfile\MPdataMPDfile\donothing\donothing
   % \stopnointerference
   \stopreadingfile}

% We need this trick because we need to make sure that the tex scanner
% sees newlines and does not quit. Also, we do need to flush the buffer
% under a normal catcode regime in order to expand embedded tex macros.
% As usual with buffers, \type {#1} can be a list.

\unexpanded\def\processMPbuffer
  {\dosingleempty\meta_process_buffer}

\def\meta_process_buffer[#1]%
  {\meta_begin_graphic_group{#1}%
   \meta_process_graphic{\ctxcommand{feedback("\currentMPgraphicname")}}%
   \meta_end_graphic_group}

\unexpanded\def\runMPbuffer
  {\dosingleempty\meta_run_buffer}

\def\meta_run_buffer[#1]% processing only
  {\startnointerference\meta_process_buffer[#1]\stopnointerference}

%D \macros
%D   {startMPenvironment, resetMPenvironment}
%D
%D In order to synchronize the main \TEX\ run and the runs
%D local to \METAPOST, environments can be passed.

% \unexpanded\def\startMPenvironment % second arg gobbles spaces, so that reset gives \emptytoks
%   {\dodoubleempty\dostartMPenvironment}

% \def\dostartMPenvironment[#1][#2]#3\stopMPenvironment
%   {\edef\m_meta_option{#1}
%    \ifx\m_meta_option\s!reset
%      \resetMPenvironment % reset mp toks
%    \else\ifx\m_meta_option\v!global
%      #3%                 % use in main doc too
%    \else\ifx\m_meta_option\!!plustoken
%      #3%                 % use in main doc too
%    \fi\fi\fi
%    \ctxlua{metapost.tex.set(\!!bs\detokenize{#3}\!!es)}}

\unexpanded\def\startMPenvironment
  {\begingroup
   \catcode\endoflineasciicode \ignorecatcode
   \dosingleempty\meta_start_environment}

\def\meta_start_environment[#1]#2\stopMPenvironment
  {\endgroup
   \edef\m_meta_option{#1}
   \ifx\m_meta_option\s!reset
     \resetMPenvironment % reset mp toks
   \else\ifx\m_meta_option\v!global
     #2%                 % use in main doc too
   \else\ifx\m_meta_option\!!plustoken
     #2%                 % use in main doc too
   \fi\fi\fi
   \ctxlua{metapost.tex.set(\!!bs\detokenize{#2}\!!es)}}

\let\stopMPenvironment\relax

\unexpanded\def\resetMPenvironment
  {\ctxlua{metapost.tex.reset()}}

\unexpanded\def\useMPenvironmentbuffer[#1]%
  {\ctxlua{metapost.tex.set(buffers.content("#1"))}}

%D This command takes \type {[reset]} as optional
%D argument.
%D
%D \starttyping
%D \startMPenvironment
%D   \setupbodyfont[pos,14.4pt]
%D \stopMPenvironment
%D
%D \startMPcode
%D   draw btex \sl Hans Hagen etex scaled 5 ;
%D \stopMPcode
%D \stoptyping
%D
%D The most simple case:

\unexpanded\def\startMPcode
  {\dosinglegroupempty\meta_start_code}

\def\meta_start_code
  {\iffirstargument
     \expandafter\meta_start_code_instance
   \else
     \expandafter\meta_start_code_standard
   \fi}

\def\meta_start_code_instance#1#2\stopMPcode
  {\begingroup
   \edef\currentMPinstance{#1}%
   \let\currentMPgraphicname\empty
   \edef\currentMPformat{\MPinstanceparameter\s!format}%
   \meta_enable_include
   \meta_process_graphic{#2}%
   \endgroup}

\def\meta_start_code_standard#1#2\stopMPcode
  {\begingroup
   \let\currentMPinstance\defaultMPinstance
   \let\currentMPgraphicname\empty
   \edef\currentMPformat{\MPinstanceparameter\s!format}%
   \meta_process_graphic{#2}%
   \endgroup}

\let\stopMPcode\relax

\unexpanded\def\MPcode
  {\dodoublegroupempty\meta_code}

\def\meta_code
  {\ifsecondargument
     \expandafter\meta_code_instance
   \else
     \expandafter\meta_code_standard
   \fi}

\def\meta_code_instance#1#2%
  {\meta_begin_graphic_group{#1}%
   \meta_enable_include
   \meta_process_graphic{#2}%
   \meta_end_graphic_group}

\def\meta_code_standard#1#2%
  {\let\currentMPinstance\defaultMPinstance
   \meta_enable_include
   \meta_process_graphic{#1}}

% a bit nasty (also needed for compatibility:

% \startMPrun input mp-www.mp ; \stopMPrun
% \externalfigure[mprun.3][width=10cm,height=8cm]

% \startMPrun{mprun} input mp-www.mp ; \stopMPrun % instance
% \externalfigure[mprun.4][width=10cm,height=8cm]

\let\MPruninstance\defaultMPinstance

\unexpanded\def\useMPrun#1#2% name n
  {\begingroup
   \def\MPaskedfigure{#2}%
   \doifelsenothing{#1}
     {\useMPgraphic{mprun}}%
     {\useMPgraphic{#1}}%
   \endgroup}

\unexpanded\def\startMPrun
  {\dosinglegroupempty\meta_start_run}

\def\meta_start_run#1#2\stopMPrun
  {\iffirstargument
     \startuseMPgraphic{#1}#2\stopuseMPgraphic
   \else
     \startuseMPgraphic{mprun}#2\stopuseMPgraphic
   \fi}

\let\stopMPrun\relax

%D The \type {\resetMPenvironment} is a quick way to erase
%D the token list.
%D
%D You should be aware of independencies. For instance, if you use a font
%D in a graphic that is not used in the main document, you need to load the
%D typescript at the outer level (either directly or by using the global
%D option).
%D
%D \starttyping
%D \usetypescript[palatino][texnansi]
%D
%D \startMPenvironment
%D     \usetypescript[palatino][texnansi]
%D     \enableregime[utf]
%D     \setupbodyfont[palatino]
%D \stopMPenvironment
%D
%D \startMPpage
%D     draw btex aap‒noot coördinatie – één etex ;
%D \stopMPpage
%D \stoptyping

%D Loading specific \METAPOST\ related definitions is
%D accomplished by:

\unexpanded\def\useMPlibrary[#1]{\ctxcommand{useMPlibrary(\!!bs#1\!!es)}}

%D \macros
%D   {setMPtext, MPtext, MPstring, MPbetex}
%D
%D To be documented:
%D
%D \starttyping
%D \setMPtext{identifier}{text}
%D
%D \MPtext  {identifier}
%D \MPstring{identifier}
%D \MPbetex {identifier}
%D \stoptyping

\installcorenamespace{mptext}

\unexpanded\def\setMPtext#1#2% todo : #1 must be made : safe
  {\defconvertedargument\ascii{#2}%
   \dodoglobal\letvalue{\??mptext#1}\ascii}

\def\MPtext  #1{\executeifdefined{\??mptext#1}\empty}
\def\MPstring#1{"\executeifdefined{\??mptext#1}\empty"}
\def\MPbetex #1{btex \executeifdefined{\??mptext#1}\empty\space etex}

%D In order to communicate conveniently with the \TEX\
%D engine, we introduce some typesetting variables.

% \setupcolors[state=stop,conversion=never] % quite tricky ... type mismatch

% A dirty trick, ** in colo-ini.lua (mpcolor).

\def\m_meta_colo_initializations{% no vardef, goes wrong with spot colors
    def OverlayLineColor=\MPcolor{\overlaylinecolor} enddef;
    def OverlayColor=\MPcolor{\overlaycolor} enddef;
}

\startMPextensions
    color OverlayColor,OverlayLineColor;
\stopMPextensions

\startMPinitializations
    CurrentLayout:="\currentlayout";
    OverlayWidth:=\overlaywidth;
    OverlayHeight:=\overlayheight;
    OverlayDepth:=\overlayheight;
    OverlayLineWidth:=\overlaylinewidth;
    %
    \m_meta_colo_initializations
    %
    BaseLineSkip:=\the\baselineskip;
    LineHeight:=\the\baselineskip;
    BodyFontSize:=\the\bodyfontsize;
    %
    TopSkip:=\the\topskip;
    StrutHeight:=\strutheight;
    StrutDepth:=\strutdepth;
    %
    CurrentWidth:=\the\hsize;
    CurrentHeight:=\the\vsize;
    %
    EmWidth:=\the\emwidth;
    ExHeight:=\the\exheight;
    %
    PageNumber:=\the\pageno;
    RealPageNumber:=\the\realpageno;
    LastPageNumber:= \lastpage;
\stopMPinitializations

\appendtoks
    \disablediscretionaries
    \disablecompoundcharacters
\to \everyMPgraphic

% \appendtoks % before color, inefficient, replace by low level copy
%     \doregistercolor{currentcolor}\currentcolorname
% \to \everyMPgraphic

% \color[green]{abc \startMPcode
% fill fullcircle scaled 3cm withoutcolor;
% fill fullcircle scaled 2cm withcolor \MPcolor{currentcolor} ;
% fill fullcircle scaled 1cm withcolor \MPcolor{red} ;
% \stopMPcode def}

\appendtoks
    \baselineskip1\baselineskip
    \lineheight  1\lineheight
    \topskip     1\topskip
\to \everyMPgraphic

\appendtoks
    \let \# \letterhash
    \let \_ \letterunderscore
    \let \& \letterampersand
    \let \{ \letteropenbrace
    \let \} \letterclosebrace
\to \everyMPgraphic

\startMPinitializations
    prologues:=0;
    mpprocset:=1;
\stopMPinitializations

%D \macros
%D   {PDFMPformoffset}
%D
%D In \PDF, forms are clipped and therefore we have to take
%D precautions to get this right. Since this is related to
%D objects, we use the same offset as used there.

\def\PDFMPformoffset{\objectoffset}

% %D \macros
% %D   {insertMPfile}
% %D
% %D Bypassing the special driver and figure mechanism is not
% %D that nice but saves upto 5\% time in embedding \METAPOST\
% %D graphics by using the low level \PDF\ converter directly,
% %D given of course that we use \PDFTEX. As a result we need to
% %D fool around with the object trigger.

\newtoks\everyinsertMPfile

\startMPextensions
    def initialize_form_numbers =
        do_initialize_numbers;
    enddef;
\stopMPextensions

\startMPinitializations
    HSize:=\the\hsize ;
    VSize:=\the\vsize ;
\stopMPinitializations

\startMPextensions
    vardef ForegroundBox =
        unitsquare xysized(HSize,VSize)
    enddef ;
    PageFraction := 1 ;
\stopMPextensions

\startMPinitializations
    PageFraction:=if \lastpage>1:(\realfolio-1)/(\lastpage-1)else:1fi;
\stopMPinitializations

%D And some more. These are not really needed since we
%D don't use the normal figure inclusion macros any longer.

\appendtoks
    \externalfigurepostprocessors\emptytoks % safeguard
\to \everyinsertMPfile

%D We also take care of disabling fancy figure features, that
%D can terribly interfere when dealing with symbols,
%D background graphics and running (postponed) graphics.
%D You won't believe me if I tell you what funny side effects
%D can occur. One took me over a day to uncover when
%D processing the screen version of the \METAFUN\ manual.

\def\doifelseMPgraphic#1%
  {\ifcsname\??mpgraphic   #1\endcsname \expandafter      \firstoftwoarguments  \else
   \ifcsname\??mpgraphic o:#1\endcsname \doubleexpandafter\firstoftwoarguments  \else
   \ifcsname\??mpgraphic e:#1\endcsname \tripleexpandafter\firstoftwoarguments  \else
                                        \tripleexpandafter\secondoftwoarguments \fi\fi\fi}

\let\doifMPgraphicelse\doifelseMPgraphic

%D New:

\definelayerpreset % no dx,dy - else nasty non-mp placement
  [mp]
  [\c!y=-\MPury,
   \c!x=\MPllx,
   \c!method=\v!fit]

\definelayer
  [mp]
  [\c!preset=mp]

%D Usage:
%D
%D \starttyping
%D \defineviewerlayer[one][state=start]
%D \defineviewerlayer[two][state=stop]
%D
%D \startuseMPgraphic{step-1}
%D   fill fullcircle scaled 10cm withcolor red ;
%D \stopuseMPgraphic
%D
%D \startuseMPgraphic{step-2}
%D   fill fullcircle scaled 5cm withcolor green ;
%D \stopuseMPgraphic
%D
%D \setlayer[mp]{\viewerlayer[one]{\useMPgraphic{step-1}}}
%D \setlayer[mp]{\viewerlayer[two]{\useMPgraphic{step-2}}}
%D
%D \ruledhbox{\flushlayer[mp]}
%D \stoptyping
%D
%D Reusing graphics is also possible (now):
%D
%D \starttyping
%D \startreusableMPgraphic{axis}
%D   tickstep := 1cm ; ticklength := 2mm ;
%D   drawticks unitsquare xscaled 4cm yscaled 3cm shifted (-1cm,-1cm) ;
%D   tickstep := tickstep/2 ; ticklength := ticklength/2 ;
%D   drawticks unitsquare xscaled 4cm yscaled 3cm shifted (-1cm,-1cm) ;
%D \stopreusableMPgraphic
%D
%D \startuseMPgraphic{demo}
%D   drawpoint "1cm,1.5cm" ;
%D \stopuseMPgraphic
%D
%D \definelayer[mp][preset=mp]
%D \setlayer[mp]{\reuseMPgraphic{axis}}
%D \setlayer[mp]{\useMPgraphic{demo}}
%D \ruledhbox{\flushlayer[mp]}
%D \stoptyping

%D \macros
%D   {startstaticMPfigure,useMPstaticfigure}
%D
%D Static figures are processed only when there has been
%D something changed. Here is Aditya Mahajan's testcase:
%D
%D \startbuffer
%D \startstaticMPfigure{circle}
%D   fill fullcircle scaled 1cm withcolor blue;
%D \stopstaticMPfigure
%D
%D \startstaticMPfigure{axis}
%D   drawarrow (0,0)--(2cm,0) ;
%D   drawarrow (0,0)--(0,2cm) ;
%D   label.llft(textext("(0,0)") ,origin) ;
%D \stopstaticMPfigure
%D \stopbuffer
%D
%D \typebuffer \getbuffer

\unexpanded\def\startstaticMPfigure#1#2\stopstaticMPfigure
  {\startreusableMPgraphic{\??mpstaticgraphic#1}#2\stopreusableMPgraphic}

\unexpanded\def\startstaticMPgraphic
  {\dodoublegroupempty\meta_start_static_graphic}

\def\meta_start_static_graphic#1#2#3\stopstaticMPgraphic
  {\startreusableMPgraphic{\??mpstaticgraphic#1}{#2}#3\stopreusableMPgraphic}

\let\stopstaticMPfigure \relax
\let\stopstaticMPgraphic\relax

\unexpanded\def\usestaticMPfigure
  {\dodoubleempty\meta_use_static_figure}

\def\meta_use_static_figure[#1][#2]%
  {\ifsecondargument
     \scale[#2]{\reuseMPgraphic{\??mpstaticgraphic#1}}%
   \else
     \reuseMPgraphic{\??mpstaticgraphic#1}%
   \fi}

%D Goody for preventing overflows:

\def\MPdivten[#1]{\withoutpt\the\dimexpr#1pt/10\relax}

%D There is no way to distinguish the black color that you get when
%D you issue a \type {draw} without color specification from a color
%D that has an explicit black specification unless you set the
%D variable \type {defaultcolormodel} to 1. Hoewever, in that case
%D you cannot distinguish that draw from one with a \type
%D {withoutcolor} specification. This means that we have to provide
%D multiple variants of inheritance.
%D
%D In any case we need to tell the converter what the inherited color
%D is to start with. Case~3 is kind of unpredictable as it closely
%D relates to the order in which paths are flushed. If you want to
%D inherit automatically from the surrounding, you can best stick to
%D variant 1. Variant 0 (an isolated graphic) is the default.
%D
%D \startbuffer
%D \startuseMPgraphic{test}
%D     drawoptions(withpen pencircle scaled 1pt) ;
%D     def shift_cp = currentpicture := currentpicture shifted (-15pt,0) ; enddef ;
%D     draw fullcircle scaled 10pt withoutcolor  ; shift_cp ;
%D     fill fullcircle scaled 10pt               ; shift_cp ;
%D     draw fullcircle scaled 10pt withoutcolor  ; shift_cp ;
%D     fill fullcircle scaled 10pt withcolor red ; shift_cp ;
%D     draw fullcircle scaled 10pt withoutcolor  ; shift_cp ;
%D     fill fullcircle scaled 10pt               ; shift_cp ;
%D \stopuseMPgraphic
%D
%D \starttabulate
%D \NC 0\quad \NC \MPcolormethod0 \green XX\quad \useMPgraphic{test}\quad XX \NC \NR
%D \NC 1\quad \NC \MPcolormethod1 \green XX\quad \useMPgraphic{test}\quad XX \NC \NR
%D \NC 2\quad \NC \MPcolormethod2 \green XX\quad \useMPgraphic{test}\quad XX \NC \NR
%D \NC 3\quad \NC \MPcolormethod3 \green XX\quad \useMPgraphic{test}\quad XX \NC \NR
%D \stoptabulate
%D \stopbuffer
%D
%D \typebuffer \getbuffer

\newconstant\MPcolormethod

\appendtoks
    \ctxlua{metapost.setoutercolor(\number\MPcolormethod,\number\attribute\colormodelattribute,\number\attribute\colorattribute,\number\dogetattribute{transparency})}%
\to \everyMPgraphic

\startMPinitializations
    defaultcolormodel := \ifcase\MPcolormethod1\or1\or3\else3\fi;
\stopMPinitializations

%D \macros
%D   {setupMPgraphics}
%D
%D Here is a generic setup command:

\installcorenamespace{MPgraphics}

\installsetuponlycommandhandler \??MPgraphics {MPgraphics}

%D Here we hook in the outer color. When \type {color} is set to \type
%D {global} we get the outer color automatically. If you change this
%D setting, you should do it grouped in order not to make other graphics
%D behave in unexpected ways.

\appendtoks
    \doifelse{\directMPgraphicsparameter\c!color}\v!global{\MPcolormethod\plusone}{\MPcolormethod\zerocount}%
\to \everysetupMPgraphics

\setupMPgraphics
  [\c!color=\v!local]

%D Done.

\protect \endinput

[-- Attachment #1.2.3: Type: text/html, Size: 264 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: MPLibrabray "txt" broken!?
  2013-05-15 10:15     ` Keith J. Schultz
@ 2013-05-15 11:04       ` Hans Hagen
  2013-05-15 14:23         ` Keith J. Schultz
  0 siblings, 1 reply; 6+ messages in thread
From: Hans Hagen @ 2013-05-15 11:04 UTC (permalink / raw)
  To: ntg-context

On 5/15/2013 12:15 PM, Keith J. Schultz wrote:

> O.K. just rebuilt formats!

i had that already fixed last night so you probably missed an upload

Hans


-- 

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: MPLibrabray "txt" broken!?
  2013-05-15 11:04       ` Hans Hagen
@ 2013-05-15 14:23         ` Keith J. Schultz
  0 siblings, 0 replies; 6+ messages in thread
From: Keith J. Schultz @ 2013-05-15 14:23 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi Hans,

I had updated around 2100 last night. 
Did not catch your upload after 2300.

Sorry.

Am 15.05.2013 um 13:04 schrieb Hans Hagen <pragma@wxs.nl>:

> On 5/15/2013 12:15 PM, Keith J. Schultz wrote:
> 
>> O.K. just rebuilt formats!
> 
> i had that already fixed last night so you probably missed an upload
> 
> 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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-05-15 14:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-14 12:23 MPLibrabray "txt" broken!? Keith J. Schultz
2013-05-14 17:57 ` Hans Hagen
2013-05-15  7:36   ` Keith J. Schultz
2013-05-15 10:15     ` Keith J. Schultz
2013-05-15 11:04       ` Hans Hagen
2013-05-15 14:23         ` Keith J. Schultz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).