Re: [NTG-context] Font for MetaPost graphics

2012-05-10 Thread Procházka Lukáš Ing . - Pontex s . r . o .

Hello,

many thanks Marco for wikifying.

On Tue, 08 May 2012 21:57:04 +0200, Marco net...@lavabit.com wrote:


Thanks a lot Hans for implementing this.

Wikified:

http://wiki.contextgarden.net/Command/defineMPinstance
http://wiki.contextgarden.net/Command/setupMPinstance


Best wishes

Marco



With the permission, I tried to replace the tag texcode with context to get 
source and result.

context mode=mkiv source=yes text=Gives:
...
/context

Unfortunately, the result doesn't appear.

So, what to do to make the example work?

Will it work automatically once the Ctx/MP engine updates on wiki?

Best regards,

Lukas


--
Ing. Lukáš Procházka [mailto:l...@pontex.cz]
Pontex s. r. o.  [mailto:pon...@pontex.cz] [http://www.pontex.cz]
Bezová 1658
147 14 Praha 4

Tel: +420 244 062 238
Fax: +420 244 461 038

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

Re: [NTG-context] Font for MetaPost graphics

2012-05-10 Thread Marco
On 2012-05-10 Procházka Lukáš Ing. - Pontex s. r. o. l...@pontex.cz wrote:

 With the permission, I tried to replace the tag texcode with context to
 get source and result.
 
 context mode=mkiv source=yes text=Gives:
 ...
 /context
 
 Unfortunately, the result doesn't appear.

The code is MkIV only and the wiki uses MkII.

 So, what to do to make the example work?

Find someone who has time to implement and administrate a working
MkIV wiki solution.

 Will it work automatically once the Ctx/MP engine updates on wiki?

*If* the engine gets updated someday, it will probably work, yes.


Marco


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

Re: [NTG-context] Font for MetaPost graphics

2012-05-08 Thread Marco
On 2012-05-05 Hans Hagen pra...@wxs.nl wrote:

This code fails:

\defineMPinstance [mympinstance] [metafun] [textcolor=red]

\starttext

\startMPcode
draw textext(some text) ;
\stopMPcode

\startMPcode{mympinstance}
draw textext(some text) ;
\stopMPcode

\stoptext

Marco


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


Re: [NTG-context] Font for MetaPost graphics

2012-05-08 Thread Hans Hagen

On 8-5-2012 19:01, Marco wrote:

On 2012-05-05 Hans Hagenpra...@wxs.nl  wrote:


Did I?


This code fails:

\defineMPinstance [mympinstance] [metafun] [textcolor=red]

\starttext

\startMPcode
draw textext(some text) ;
\stopMPcode

\startMPcode{mympinstance}
draw textext(some text) ;
\stopMPcode

\stoptext

Marco


It works here.

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
___


Re: [NTG-context] Font for MetaPost graphics

2012-05-08 Thread Marco
On 2012-05-08 Hans Hagen pra...@wxs.nl wrote:

 On 8-5-2012 19:01, Marco wrote:
  On 2012-05-05 Hans Hagenpra...@wxs.nl  wrote:
 
 Did I?

My bad ;)

  This code fails:
 
  \defineMPinstance [mympinstance] [metafun] [textcolor=red]
 
  \starttext
 
  \startMPcode
  draw textext(some text) ;
  \stopMPcode
 
  \startMPcode{mympinstance}
  draw textext(some text) ;
  \stopMPcode
 
  \stoptext
 
  Marco
 
 It works here.

Fails here, source and log are attached.

current version: 2012.05.08 13:45

Marco
\defineMPinstance [mympinstance] [metafun] [textcolor=red]

\starttext

\startMPcode
	draw textext(some text) ;
\stopMPcode

\startMPcode{mympinstance}
	draw textext(some text) ;
\stopMPcode

\stoptext
(g.tex

ConTeXt  ver: 2012.05.08 13:45 MKIV  fmt: 2012.5.8  int: english/english

system   cont-new.mkiv loaded
(/home/zewz/context/tex/texmf-context/tex/context/base/cont-new.mkiv
system   beware: some patches loaded from cont-new.mkiv
)
system   g.top loaded

system   options  start used options

used options % runtime options files (command line driven)
used options \unprotect
used options % feedback and basic job control
used options % handy for special styles
used options \startluacode
used options document = document or { }
used options document.arguments={
used options  [once]=true,
used options }
used options document.files={
used options  g,
used options }
used options \stopluacode
used options % process info
used options \setupsystem[inputfile=g]
used options \setupsystem[\c!n=3,\c!m=1]
used options \enabledirectives[system.runonce]
used options % modes
used options % options (not that important)
used options \startsetups *runtime:options
used options \stopsetups
used options % styles and modules
used options \startsetups *runtime:modules
used options \stopsetups
used options % done
used options \protect \endinput

system   options  stop used options

(g.top)
fontslatin modern fonts are not preloaded
languageslanguage en is active
{/home/zewz/context/tex/texmf-context/fonts/map/pdftex/context/mkiv-base.map}
fontspreloading latin modern fonts (second stage)
fontstypescripts  unknown: library 'loc'
{/home/zewz/context/tex/texmf/fonts/map/dvips/lm/lm-math.map}{/home/zewz/context/tex/texmf/fonts/map/dvips/lm/lm-rm.map}
fontsvirtual math  unable to resolve name mapsfromchar
fontsfallback modern rm 12pt is loaded
metapost initializing instance 'metafun' using format 'metafun'
metapost loading 'metafun': /home/zewz/context/tex/texmf-context/metapost/context/base/metafun.mpiv
metapost initializing instance 'mympinstance' using format 'metafun'
metapost loading 'metafun': /home/zewz/context/tex/texmf-context/metapost/context/base/metafun.mpiv
! terminal:  OverlayLineColor
 (0,0,0)
! Equation cannot be performed (numeric=color).
to be read again 
   ;
* ...ineWidth:=0pt  ; OverlayLineColor:=(0,0,0);
   OverlayColor:=(0,0,0); Ba...

 OverlayColor
 (0,0,0)
! Equation cannot be performed (numeric=color).
to be read again 
   ;
* ...yLineColor:=(0,0,0); OverlayColor:=(0,0,0);
   BaseLineSkip:=14.4816pt; ...


.

system   tex  error on line 11 in file g.tex: terminal:  OverlayLineColor
 (0,0,0)
! Equation cannot be performed (numeric=color).
to be read again 
   ;
* ...ineWidth:=0pt  ; OverlayLineColor:=(0,0,0);
   OverlayColor:=(0,0,0); Ba...

 OverlayColor
 (0,0,0)
! Equation cannot be performed (numeric=color).
to be read again 
   ;
* ...yLineColor:=(0,0,0); OverlayColor:=(0,0,0);
   BaseLineSkip:=14.4816pt; ...


 ...

 1 \defineMPinstance [mympinstance] [metafun] [textcolor=red]
 2 
 3 \starttext
 4 
 5 \startMPcode
 6 	draw textext(some text) ;
 7 \stopMPcode
 8 
 9 \startMPcode{mympinstance}
10 	draw textext(some text) ;
11   \stopMPcode
12 
13 \stoptext
14 

inserted text ...0;;]===], [===[;;]===], false)}
  
\meta_process_graphic ...!!es , \MPaskedfigure )}}
  \egroup \placeMPgraphic \m...
\meta_start_code_instance ..._process_graphic {#2}
  \meta_end_graphic_group 
l.11 \stopMPcode

? x

system   files  start used files

used files  1: filename=g | filetype=tex | foundname=g.tex | usedmethod=filesystem
used files  2: filename=cont-new.mkiv | filetype=tex | foundname=/home/zewz/context/tex/texmf-context/tex/context/base/cont-new.mkiv | usedmethod=database
used files 

Re: [NTG-context] Font for MetaPost graphics

2012-05-08 Thread Hans Hagen

On 8-5-2012 19:19, Marco wrote:

On 2012-05-08 Hans Hagenpra...@wxs.nl  wrote:


On 8-5-2012 19:01, Marco wrote:

On 2012-05-05 Hans Hagenpra...@wxs.nl   wrote:


Did I?


My bad ;)


This code fails:

\defineMPinstance [mympinstance] [metafun] [textcolor=red]

\starttext

\startMPcode
draw textext(some text) ;
\stopMPcode

\startMPcode{mympinstance}
draw textext(some text) ;
\stopMPcode

\stoptext

Marco


It works here.


Fails here, source and log are attached.


ok, can you add this to cont-new.mkiv (after \unprotect):

\def\m_meta_colo_initializations{%
vardef OverlayLineColor=\MPcolor{\overlaylinecolor} enddef;
vardef OverlayColor=\MPcolor{\overlaycolor} enddef;
}

I have that in my local experimental code. It has to do with the fact 
that mp's color spaces are not compatible with each other. As I've used 
that patch for quite a while now I could probably move it to the core.


Maybe more users can test this.

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
___


Re: [NTG-context] Font for MetaPost graphics

2012-05-08 Thread Marco
On 2012-05-08 Hans Hagen pra...@wxs.nl wrote:

 ok, can you add this to cont-new.mkiv (after \unprotect):
 
 \def\m_meta_colo_initializations{%
  vardef OverlayLineColor=\MPcolor{\overlaylinecolor} enddef;
  vardef OverlayColor=\MPcolor{\overlaycolor} enddef;
 }

That works.

 As I've used that patch for quite a while now I could probably
 move it to the core.

Since you use it for a while it seems to work ⇒ into the core

Thanks a lot Hans for implementing this.

Wikified:

http://wiki.contextgarden.net/Command/defineMPinstance
http://wiki.contextgarden.net/Command/setupMPinstance


Best wishes

Marco


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

Re: [NTG-context] Font for MetaPost graphics

2012-05-05 Thread Hans Hagen

On 4-5-2012 13:09, Marco wrote:

On 2012-05-04 Aditya Mahajanadit...@umich.edu  wrote:


On Fri, 4 May 2012, Mojca Miklavec wrote:



But my guess is that the  argument goes into the opposite way. I
past (and still in MKII) one *had  to* set up fonts twice - once
for the main  document and once for MetaPost  since MetaPost did
its own processing of labels and MetaPost didn't see the ConTeXt
font setups. So  it was difficult to convince  MetaPost to use
the same font.


I agree, it's  a big step forward towards  usability and consistency
to have  MetaPost automatically inherit ConTeXts  settings. However,
it went out-of-control now.


well, you still get text and not something random, so out-of-control is 
a bit too strong


anyhow, we can do

\newconditional\MPLIBtextgetdone

\def\MPLIBsettext#1% #2%
  {\ifconditional\MPLIBtextgetdone
   \else
 \cldcontext{metapost.tex.get()}%
 \settrue\MPLIBtextgetdone % no \global needed
   \fi
   \dowithnextbox{\ctxlua{metapost.settext(\number\nextbox,#1)}}\hbox}

\def\MPLIBresettexts
  {\ctxlua{metapost.resettextexts()}%$
   \setfalse\MPLIBtextgetdone}

\starttext

Serif

\startMPcode
draw textext(\ss Sans) ;
\stopMPcode

Serif

\startMPenvironment
\ss
\stopMPenvironment

\startMPcode
draw textext(Sans) ;
\stopMPcode

Serif

\stoptext



A better alternative would to define

\setupMPtext
 [
  style=...,
  color=...,
  setups=...,
 ]

that can be used to set the style for metapost text.


this is ok for me, but then we mighe as well drop \startMPenviroment 
(and someone has to wikify that then)


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
___


Re: [NTG-context] Font for MetaPost graphics

2012-05-05 Thread Hans Hagen

On 4-5-2012 09:13, Aditya Mahajan wrote:

On Fri, 4 May 2012, Mojca Miklavec wrote:


I can think of many workarounds to this, but I agree that there is a
valid reason why
\startMPenvironment
(or some other command) should be able to change the font inside
metapost labels only.


A better alternative would to define

\setupMPtext
[
style=...,
color=...,
setups=...,
]

that can be used to set the style for metapost text.


As we already have instances, I've extended that mechanism, so one can say:

\startsetups mp:instance:one
indeed:\space
\stopsetups

\setupMPinstance
  [metafun]
  [textstyle=bold,
   textcolor=darkgreen,
   setups=mp:instance:one]

\defineMPinstance
  [mympinstance]
  [metafun]
  [textcolor=red]

\starttext

\startMPcode
draw textext(some text) ;
\stopMPcode

\startMPcode{mympinstance}
draw textext(some text) ;
\stopMPcode

\stoptext

 +1

 Marco

So .. we know who is going to wikify this ...

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
___


Re: [NTG-context] Font for MetaPost graphics

2012-05-05 Thread Marco
On 2012-05-05 Hans Hagen pra...@wxs.nl wrote:

That means, MPenvironment will be dropped, right? But what is the
new interface, \setupMPtext or MPinstance?

   +1
  
   Marco
 
 So .. we know who is going to wikify this ...

You're welcome :)

Marco


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


Re: [NTG-context] Font for MetaPost graphics

2012-05-05 Thread Aditya Mahajan

On Sat, 5 May 2012, Marco wrote:


On 2012-05-05 Hans Hagen pra...@wxs.nl wrote:

That means, MPenvironment will be dropped, right? But what is the
new interface, \setupMPtext or MPinstance?


\setupMPinstance

The advantage is that you can have multiple instances in parallel.

Aditya
___
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
___


Re: [NTG-context] Font for MetaPost graphics

2012-05-04 Thread Mojca Miklavec
On Thu, May 3, 2012 at 3:13 AM, Marco wrote:

 The text in Metapost adapts to the text set in ConTeXt. But the font
 setup should *only* be set for MetaPost, not regular text.

 Does that mean, that MPenvironment is deprecated and does not work
 at all?

Please don't rely on my answer since I haven't been following the
development as closely as I used to in past.

But my guess is that the argument goes into the opposite way. I past
(and still in MKII) one *had to* set up fonts twice - once for the
main document and once for MetaPost since MetaPost did its own
processing of labels and MetaPost didn't see the ConTeXt font setups.
So it was difficult to convince MetaPost to use the same font.

Now (as Aditya explained) metapost automatically inherits font setups
from the main document and it might be that nobody ever thought of /
requested / needed to have a special setup for using different font
for MetaPost labels.

I can think of many workarounds to this, but I agree that there is a
valid reason why
\startMPenvironment
(or some other command) should be able to change the font inside
metapost labels only.

Mojca
___
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
___


Re: [NTG-context] Font for MetaPost graphics

2012-05-04 Thread Aditya Mahajan

On Fri, 4 May 2012, Mojca Miklavec wrote:


I can think of many workarounds to this, but I agree that there is a
valid reason why
   \startMPenvironment
(or some other command) should be able to change the font inside
metapost labels only.


A better alternative would to define

\setupMPtext
   [
style=...,
color=...,
setups=...,
   ]

that can be used to set the style for metapost text.

Aditya
___
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
___


Re: [NTG-context] Font for MetaPost graphics

2012-05-04 Thread Marco
On 2012-05-04 Aditya Mahajan adit...@umich.edu wrote:

 On Fri, 4 May 2012, Mojca Miklavec wrote:

  But my guess is that the  argument goes into the opposite way. I
  past (and still in MKII) one *had  to* set up fonts twice - once
  for the main  document and once for MetaPost  since MetaPost did
  its own processing of labels and MetaPost didn't see the ConTeXt
  font setups. So  it was difficult to convince  MetaPost to use
  the same font.

I agree, it's  a big step forward towards  usability and consistency
to have  MetaPost automatically inherit ConTeXts  settings. However,
it went out-of-control now.

 A better alternative would to define
 
 \setupMPtext
 [
  style=...,
  color=...,
  setups=...,
 ]
 
 that can be used to set the style for metapost text.

+1

Marco


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


Re: [NTG-context] Font for MetaPost graphics

2012-05-02 Thread Aditya Mahajan

On Thu, 3 May 2012, Marco wrote:


The wiki claims setting up an MPenvironment is enough to change the
font in MetaPost graphics:

\startMPenvironment%[global]
\switchtobodyfont [sans]
\stopMPenvironment

\starttext
This should be serif.

\startMPcode
draw textext(This should be in sans.);
\stopMPcode
\stoptext

However, this has no effect. All text is in default serif font. If
[global] is provided, all text is in sans font. I am aware of a
similar issue in a thread last year¹, but the solution didn't really
address the problem. textext(\sans This should be sans.) works
here, but the point is that the MPenvironment fails. Why is that?


Metapost now runs as a library. All the text is first typeset by ConTeXt 
and metapost only knows the bounding box of the labels.


You can try (untested):

\starttext

This is serif

\switchtobodyfont[sans]
\startMPcode
draw textext(This should be sans);
\stopMPcode

\stoptext

Aditya___
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
___

Re: [NTG-context] Font for MetaPost graphics

2012-05-02 Thread Marco
On 2012-05-02 Aditya Mahajan adit...@umich.edu wrote:

 Metapost now runs as a library. All the text is first typeset by ConTeXt 
 and metapost only knows the bounding box of the labels.
 
 You can try (untested):
 
 \starttext
 
 This is serif
 
 \switchtobodyfont[sans]
 \startMPcode
 draw textext(This should be sans);
 \stopMPcode
 
 \stoptext

This works, of course. However it continues with sans font even
after \stopMPcode. This is better (but clumsy):

\start
\switchtobodyfont[sans]
\startMPcode
draw textext(This should be sans);
\stopMPcode
\stop
Here serif again.

The text in Metapost adapts to the text set in ConTeXt. But the font
setup should *only* be set for MetaPost, not regular text.

Does that mean, that MPenvironment is deprecated and does not work
at all?

Marco


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