[metapost] Problem with glyph command
Laurence Finston
Laurence.Finston at gmx.de
Fri Apr 15 20:09:24 CEST 2022
Hello,
In January I posted a feature request regarding `glyph'. I've attached an example of the problem to this message.
The character is "g" from cmr10.
In short, the problem is that in order to put letters together into words properly, i.e., as closely as possible to the way TeX would do it, one would need the reference point and the width, height and depth of the characters. Unfortunately, it's not really possible to get accurate values for these things with a reasonable amount of effort.
Page 1 of `cmrm_test.pdf' shows on the left the result of using `glyph' and scaling the paths by .25.
In the middle is a label with the letter using cmr10 scaled 25750. The black lines are
done with \vrules within the label text (btex ... etex). They may be slightly off, but
I'm pretty sure by < 1pt in any direction. They correspond to the \ht, \wd and \dp of the
character.
The red box was obtained by means of `boxit'. It would match up with the outer lines of the black box, except that the latter, and the character inside it, have been shifted in an attempt to make it match up with the glyph to the left.
As is obvious from the picture, the bounding box of the glyph simply surrounds the character. While the origin is approximately at the position of the reference point of the character, it's not exactly right, as comparison to the picture in the middle shows.
The scaling value of 25750 for the character in the label was arrived at by trial-and-error. which is not really practical.
The size of the (unscaled) glyph is a bit of a mystery to me. The MP manual says this:
"Finally, the picture returned by the glyph operator is
scaled, such that one font design unit equals one PostScript point (bp). A usual font design unit is a
thousandth part of the font design size. Therefore, the returned picture will typically have a height
of around 1000bp." (mpman, p. 51).
In this case, the height is 659bp: y2 - y1 == 659. I don't understand why.
On the right is part of the dvi output from generating cmr10 in "proofing" mode (page 2 shows the whole page).
It shows, as expected, that the points used for making the character in the first place, while some of them have some relationship to the points on the paths returned by `glyph', are generally not the same and that this information is not really usable, again, with a reasonable amount of effort.
It seems to me that without the reference point and the wd, ht and dp of the characters from `glyph', this feature is not as usable as it might be.
I've also attached the MP and TeX source code.
Thanks.
Laurence
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cmrm_test.mp
Type: application/octet-stream
Size: 7200 bytes
Desc: not available
URL: <https://tug.org/pipermail/metapost/attachments/20220415/647e1489/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cmrm_test.pdf
Type: application/pdf
Size: 72750 bytes
Desc: not available
URL: <https://tug.org/pipermail/metapost/attachments/20220415/647e1489/attachment-0001.pdf>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cmrm_test.tex
Type: application/x-tex
Size: 550 bytes
Desc: not available
URL: <https://tug.org/pipermail/metapost/attachments/20220415/647e1489/attachment-0001.tex>
More information about the metapost
mailing list.