[XeTeX] \XeTeXglyphbounds question

Adam Twardoch (List) list.adam at twardoch.com
Fri Feb 4 18:37:48 CET 2011


On 11-02-04 14:27, Jonathan Kew wrote:
> Unfortunately, I don't think there's currently any way to do that. (Well, no way within xetex, that is -- you could of course ship the box to the output file, then post-process that with a tool of some kind to determine the glyph ID, and then re-run the job using that information as input. But that's a terribly cumbersome way to get to where you're trying to go!)
>
> It might be nice to have a command that could "look inside" boxes like that and tell you the glyph IDs.... but then you'll probably find yourself wanting their positions, too.... and then what if the contents of the box are more complex than just a series of glyphs? Figuring out a usable TeX-level interface to this could become awfully complex.......
Ah, I was afraid you're going to say that :)

I do like the way \XeTeXglyphmetrics works, because, as you could see in
my sample file I sent you offline, by typesetting two boxes, one with
the command =0 and another =1, I can get the \ht and \dp dimensions and
compare them, thus getting a reliable difference in "font height" and
"glyph-derived height", and -- which is very important -- I get the two
values separately (height and depth). And that does work on "any" box,
i.e. if I put some non-textual objects there, the results will be the
same, so what.

As you might imagine, my second goal would be to get the left
"sidebearing" and the right "sidebearing" (i.e. the differences between
the inked bounding box and the declared typesetting origin).
\XeTeXglyphbounds gives me that for a single glyph, but since there is
no way to determine which glyphs will be used after a typesetting
process, \XeTeXglyphbounds is only of theoretical value.

I think the usefulness of having just the two edge values (the "left"
and the "right" bounds) for a box would be sufficient for a large amount
of purposes. This could be used to do custom margin alignment and
perform any sort of corrections to the horizontal positioning of the
box. Just like in case of \XeTeXglyphmetrics, I don't really desperately
need to know WHICH glyph is "bumping up" the overall vertical height of
a box, when I use it vs. not use it. The mere ability to measure the
difference _per box_ is already very helpful.

So, ideally something like \XeTeXboxbounds would be great: work the same
way as \XeTeXglyphbounds but for a box (taking 1, 2, 3, 4 as parameter,
and a box). As I said, that would already be extremely useful in a
variety of cases, even though I wouldn't have access to individual glyph
IDs and position inside the box. Just the outer differences between the
box size and the rendered glyph stream size. It's much less common a
case that I need to know all the details of my glyph stream (and, as you
said, it's hard to report reliably the inner structure of a box if its
contents is complex). But a simple interface to report the difference
between the "inked" bounding box and the metrics reported using standard
means would be a huge helper.

I don't know how feasible this is, though.

Many thanks for your help so far!

Best,
Adam




More information about the XeTeX mailing list