[metapost] Beginners question
Aditya Mahajan
adityam at umich.edu
Tue Sep 12 15:49:48 CEST 2023
On Tue, 12 Sep 2023, Patrick Gundlach wrote:
> Hello all,
>
> I try to define a user interface such as:
>
> draw "some text" infont "myfontfamily" withstyle "bold";
>
> where infant ... and withstyle ... are optional ( and the defaults should be "text" and "regular").
>
> (How) Is it possible to achieve this?
>
> Is it advisable do to so? Or should I rather create an interface such as
>
> draw text ("some text", "myfontfamily", "bold")?
IMHO, both interfaces are okay and it is a matter of personal preference.
Another option is to have a key value option:
draw Text [ font="myfontfamily", style="bold", text="some text" ];
It is relatively simply to define such key-value interface in ConTeXt. For example, see:
https://adityam.github.io/context-blog/post/new-metafun-interface/
Everything is defined in metafun, so it might also work in metapost+metafun as well but I have never tested this outside context.
Aditya
More information about the metapost
mailing list.