3

When using metapost in ConTeXt, I would like to have all my labels in sans by default. Which option can configure it and which environment should I use to pass it (MPinclusions?)

I am aware of this post but did not fully understand how to implement it (I am compiling with lmtx at home and mkiv at school).

\setuppapersize [S3]
\setupbodyfont[sans]

\startreusableMPgraphic{Label} label ("Typeset in \METAFUN\ ",origin); % this is what I do know, making the code less readable % and error-prone, waisting also my time… % label ("{\ss Typeset in \METAFUN\ }",origin); \stopreusableMPgraphic

\starttext

Typeset by \CONTEXT\

\blank[big] \reuseMPgraphic{Label}

\stoptext

output: sans in ConTeXt, serif in METAPOST

sztruks
  • 3,074

2 Answers2

4

The following works both with LMTX and MkIV:

\setuppapersize[S3]
%%% From meta-ini.mkxl
\definefontsynonym[MetafunDefault][Sans*default]

%%% Already set. You can choose another font as default. %\startMPinitializations %defaultfont:="\truefontname{MetafunDefault}"; %\stopMPinitializations

\startreusableMPgraphic{Label} label ("Typeset in \METAFUN\ ",origin); \stopreusableMPgraphic

\starttext Typeset by \CONTEXT

\blank[big] \reuseMPgraphic{Label}

\stoptext

enter image description here

  • 2
    Thanks. For the record, I digged into ConTeXt font documentation, and found that if I want to change also default metapost font size (for example 11pt in a 12pt ConTeXt document), I should do something like \definefontsynonym[MetafunDefault][Sans*default at 11pt] – sztruks Aug 28 '21 at 15:06
2

One could also use textext around your string.

In the example below I also added the \setupbodyfont inside the \startMPenvironment and \stopMPenvironment, since it allows for a completely different setup than what is in your main document.

\setupbodyfont[termes,ss,12pt]

\startMPenvironment \setupbodyfont[termes,ss,8pt] \stopMPenvironment

\startreusableMPgraphic{Label} label (textext("Typeset in \METAFUN\ "),origin); \stopreusableMPgraphic

\startTEXpage[offset=3bp]

Typeset by \CONTEXT\

\blank[big] \reuseMPgraphic{Label}

\stopTEXpage

a lot of sans serif text

mickep
  • 8,685