
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

On Wed, 6 Jul 2022, Henning Hraban Ramm via ntg-context wrote:
How can I change the font size of labels within one picture?
(Untested): See https://www.contextgarden.net/Command/setupMPinstance \setupMPinstance[metafun][textstyle=sans] Or define a new instance, which sets the textstyle to sans. Aditya

My stupid way to get labels of different sizes:
\starttext
\startMPcode
label("normal label", (0, 0));
label("\setsmallbodyfont small label", (0, 18));
label("\setbigbodyfont big label", (0, -18));
\stopMPcode
\stoptext
Henning Hraban Ramm via ntg-context

On 7/6/2022 12:19 PM, fv leung via ntg-context wrote:
Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------

I've used something like the following before.
\starttext
\startMPcode
label("normal label", (0, 0));
label("{\switchtobodyfont[3pt] tiny label}", (0, 18));
label("{\switchtobodyfont[72pt] giant label}", (0, -72));
\stopMPcode
\stoptext
Henning Hraban Ramm via ntg-context

On 7/6/2022 1:36 PM, Henning Hraban Ramm via ntg-context wrote: that would interfere with whatever else goes into a label text because we support arbitrary tex ... no way to figure out what struts, line distances, spacing, either of not adapt to current situation, delayed vs immediate inclusion, etc ... you can't have both worlds if course you can make some macro (or define a highlight) and use that in the labels Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------

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.

Am 06.07.22 um 15:24 schrieb Fabrice L:
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.
Thank you (all), I resolved to using the usual \tfx or \definedfont. Hraban
participants (5)
-
Aditya Mahajan
-
Fabrice L
-
fv leung
-
Hans Hagen
-
Henning Hraban Ramm