[NTG-context] MetaPost label font size

Fabrice L fabrice.alpha at gmail.com
Wed Jul 6 15:24:49 CEST 2022



> Le 5 juill. 2022 à 19:00, Henning Hraban Ramm via ntg-context <ntg-context at ntg.nl> a écrit :
> 
> How can I change the font size of labels within one picture?
> 
> Hraban
> 
> \startMPpage
> defaultfont := "\truefontname{Sans}";
> defaultfontsize := \the\bodyfontsize;
> 
> label.top(defaultfontsize, (0,0));
> 
> defaultfontsize := 4bp;
> 
> label.top(defaultfontsize, (50,0));
> % shows that the variable changed,
> % but font size is the same
> 
> \stopMPpage

Here are slightly different syntax that could be useful perhaps ? In the second one, the scaled parameter can be replaced easily with a variable, so you can decide and change the size of the label during the course of a picture.

\starttext

\startMPpage
defaultfont := "\truefontname{Sans}";
defaultfontsize := \the\bodyfontsize;

defaultscale := 0.5;
label.top("small label", (-10,0));

defaultscale := 1.0;
label.top("normal label", (50,5));
label.top("another normal label", (50,-5));

defaultscale := 2.0;
label.top("Huge label", (10,-25));

\stopMPpage

\startMPpage

 draw textext.top("small label") scaled 0.5 
 	shifted (-10,0) ;
 draw textext.top("normal label") scaled 1 
 	shifted (50,5) ;
 draw textext.top("second normal label") scaled 1 
 	shifted (50,-5) ;
 draw textext.top("Huge label") scaled 2 
 	shifted (10,-25) ;
 	
\stopMPpage

\stoptext

Fabrice.




More information about the ntg-context mailing list