ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [metafun] MPenvironment / font switching
@ 2011-06-09 21:20 Philipp Gesang
  2011-06-09 21:31 ` Wolfgang Schuster
  2011-06-10 21:36 ` Mojca Miklavec
  0 siblings, 2 replies; 4+ messages in thread
From: Philipp Gesang @ 2011-06-09 21:20 UTC (permalink / raw)
  To: ntg-context


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

Hi all,

I’m struggling with the font used in metapost. The only way to
actually change it appears to be enclosing the mp graphic in two
statements of \setupbodyfont[…] -- which I need to avoid. In the
following example, the background text should be typeset (drawn)
as lm sans, whereas the main font should be left untouched
(serif).

·································································

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

%\start\setupbodyfont[sans]
\startuseMPgraphic{bg}
  verbatimtex \setupbodyfont[sans] etex ;
  draw btex I wanna get rid of those serifs! etex
    xysized (21cm, 5cm) withcolor blue ;
\stopuseMPgraphic

\definelayer[bg][x=0,y=0,width=\paperwidth,height=\paperheight]
\setlayer[bg]{%
  %\setupbodyfont[sans]
  \useMPgraphic{bg}
}
\setupbackgrounds[paper][background=bg]
\setupbackgrounds[state=repeat]
%\stop

\starttext
\dorecurse{42}{I’d really like to keep my serifs! }
\stoptext

·································································

Wrapping the mp code inside a group is fatal.
\[start|stop]MPenvironment doesn’t seem to have an effect at all
unless called with the “global” flag -- in which case it will
change the main body font as well. Also, inside mp’s
“[verbatim|b]tex ...  etex” font switches refuse to work.

I’m really puzzled here, any hints? Thanks in advance
Philipp


[-- Attachment #1.2: Type: application/pgp-signature, Size: 198 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] 4+ messages in thread

* Re: [metafun] MPenvironment / font switching
  2011-06-09 21:20 [metafun] MPenvironment / font switching Philipp Gesang
@ 2011-06-09 21:31 ` Wolfgang Schuster
  2011-06-09 21:51   ` Philipp Gesang
  2011-06-10 21:36 ` Mojca Miklavec
  1 sibling, 1 reply; 4+ messages in thread
From: Wolfgang Schuster @ 2011-06-09 21:31 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 09.06.2011 um 23:20 schrieb Philipp Gesang:

> Hi all,
> 
> I’m struggling with the font used in metapost. The only way to
> actually change it appears to be enclosing the mp graphic in two
> statements of \setupbodyfont[…] -- which I need to avoid. In the
> following example, the background text should be typeset (drawn)
> as lm sans, whereas the main font should be left untouched
> (serif).
> 
> ·································································
> 
> \startMPenvironment %[global]
>  \switchtobodyfont[sans]
>  %\setupbodyfont[sans]
> \stopMPenvironment
> 
> %\start\setupbodyfont[sans]
> \startuseMPgraphic{bg}
>  verbatimtex \setupbodyfont[sans] etex ;
>  draw btex I wanna get rid of those serifs! etex
>    xysized (21cm, 5cm) withcolor blue ;
> \stopuseMPgraphic
> 
> \definelayer[bg][x=0,y=0,width=\paperwidth,height=\paperheight]
> \setlayer[bg]{%
>  %\setupbodyfont[sans]
>  \useMPgraphic{bg}
> }
> \setupbackgrounds[paper][background=bg]
> \setupbackgrounds[state=repeat]
> %\stop
> 
> \starttext
> \dorecurse{42}{I’d really like to keep my serifs! }
> \stoptext
> 
> ·································································
> 
> Wrapping the mp code inside a group is fatal.
> \[start|stop]MPenvironment doesn’t seem to have an effect at all
> unless called with the “global” flag -- in which case it will
> change the main body font as well. Also, inside mp’s
> “[verbatim|b]tex ...  etex” font switches refuse to work.
> 
> I’m really puzzled here, any hints? Thanks in advance

ConTeXt postpones fontloading till \starttext, as you won’t get any
text for elements (e.g. layers) which are set before the font was loaded
the typewriter font is used as fallback and this is what you get.

Add “\setupbodyfont[modern]” before your layer settings and switch
the style in the MP graphic with “… btex \ss I wanna get rid … etex …”.

Wolfgang


___________________________________________________________________________________
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] 4+ messages in thread

* Re: [metafun] MPenvironment / font switching
  2011-06-09 21:31 ` Wolfgang Schuster
@ 2011-06-09 21:51   ` Philipp Gesang
  0 siblings, 0 replies; 4+ messages in thread
From: Philipp Gesang @ 2011-06-09 21:51 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

On 2011-06-09 <23:31:49>, Wolfgang Schuster wrote:
> 
> Am 09.06.2011 um 23:20 schrieb Philipp Gesang:

<snip/>

> > ·································································
> > 
> > \startMPenvironment %[global]
> >  \switchtobodyfont[sans]
> >  %\setupbodyfont[sans]
> > \stopMPenvironment
> > 
> > %\start\setupbodyfont[sans]
> > \startuseMPgraphic{bg}
> >  verbatimtex \setupbodyfont[sans] etex ;
> >  draw btex I wanna get rid of those serifs! etex
> >    xysized (21cm, 5cm) withcolor blue ;
> > \stopuseMPgraphic
> > 
> > \definelayer[bg][x=0,y=0,width=\paperwidth,height=\paperheight]
> > \setlayer[bg]{%
> >  %\setupbodyfont[sans]
> >  \useMPgraphic{bg}
> > }
> > \setupbackgrounds[paper][background=bg]
> > \setupbackgrounds[state=repeat]
> > %\stop
> > 
> > \starttext
> > \dorecurse{42}{I’d really like to keep my serifs! }
> > \stoptext
> > 
> > ·································································

<snip/>

> ConTeXt postpones fontloading till \starttext, as you won’t get any
> text for elements (e.g. layers) which are set before the font was loaded
> the typewriter font is used as fallback and this is what you get.
> 
> Add “\setupbodyfont[modern]” before your layer settings and switch
> the style in the MP graphic with “… btex \ss I wanna get rid … etex …”.

Thanks a lot, this does indeed achieve what I intended.
Philipp


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

-- 
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments

[-- Attachment #1.2: Type: application/pgp-signature, Size: 198 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] 4+ messages in thread

* Re: [metafun] MPenvironment / font switching
  2011-06-09 21:20 [metafun] MPenvironment / font switching Philipp Gesang
  2011-06-09 21:31 ` Wolfgang Schuster
@ 2011-06-10 21:36 ` Mojca Miklavec
  1 sibling, 0 replies; 4+ messages in thread
From: Mojca Miklavec @ 2011-06-10 21:36 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Thu, Jun 9, 2011 at 23:20, Philipp Gesang wrote:
> Hi all,
>
> I’m struggling with the font used in metapost. The only way to
> actually change it appears to be enclosing the mp graphic in two
> statements of \setupbodyfont[…] -- which I need to avoid. In the
> following example, the background text should be typeset (drawn)
> as lm sans, whereas the main font should be left untouched
> (serif).

An alternative to Wolfgang's answer when you want to use complex font
definitions (or other complex commands) is to use \sometxt.

\usetypescript[iwona]
\definetextext[myfont]{\switchtobodyfont[iwona,ss,30pt]\bi}

\starttext
\startuseMPgraphic{bg}
 draw \sometxt[myfont]{I wanna get rid of those serifs!} withcolor blue ;
\stopuseMPgraphic

\useMPgraphic{bg}
\stoptext

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
___________________________________________________________________________________

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

end of thread, other threads:[~2011-06-10 21:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-09 21:20 [metafun] MPenvironment / font switching Philipp Gesang
2011-06-09 21:31 ` Wolfgang Schuster
2011-06-09 21:51   ` Philipp Gesang
2011-06-10 21:36 ` Mojca Miklavec

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).