[metapost] Beginners question

Laurence.Finston at gmx.net Laurence.Finston at gmx.net
Tue Sep 12 18:48:23 CEST 2023


> I have my own routine that typesets a text and gets back a hbox with the text.

I don't quite understand this.  What language is your routine in and where is it used?  MetaPost has no concept of hboxes (or vboxes for that matter).
Obviously, ultimately you're using TeX. When you call TeX from MP to typeset text, the result is a `picture'.  It's easy to get the dimensions of a `picture' using the `box' macros, which must be included separately.  That is, they are not in `plain.mp' but rather in `boxes.mp', which is in the same directory (in my installation and almost certainly in everybody else's).  They are also documented separately, namely in "Drawing Boxes in MetaPost" (`mpboxes.mp').  _However_, what isn't so easy is getting the dimensions of the hbox or vbox, i.e., the height, width and depth.  If it has depth and you want to know where the baseline is, you're out of luck (unless someone else knows a way of doing this).  MetaPost doesn't store this information anywhere.

It is possible to get it by using the writing facilities of TeX and the reading facilities of MetaPost.  I can't recall if MetaPost provides a way of opening a shell (on a Unix-like system) and calling arbitrary programs.  If so, it's not too difficult.  I've implemented exactly this feature in GNU 3DLDF, but that wouldn't help you if you want to use MP directly, unless possibly as an example, and would be off-topic for this mailing list, anyway.

"The MFbook" lesen schadet nicht. (Reading "The MFbook" won't do you any harm.)

> Gesendet: Dienstag, 12. September 2023 um 18:18 Uhr
> Von: "Patrick Gundlach" <patrick at gundla.ch>
> An: metapost at tug.org
> Betreff: Re: [metapost] Beginners question
>
>
>
> > Am 12.09.2023 um 17:18 schrieb Laurence.Finston at gmx.net:
> >
> > However, I don't think it does anything than `label' would.  What do you mean by "font implementation"?
>
> I have my own routine that typesets a text and gets back a hbox with the text. I need some kind of macro for the user to be able to specify the text, the font family (this is system dependent) and a style. Both the font family and the style should be optional.
>
> I will check out Aditya's and Tacos solution and read the MetaFont manual.
>
> Thanks
>   Patrick
>
>
>
> --
> http://tug.org/metapost/
>



More information about the metapost mailing list.