[texhax] Character bounding boxes

Ranjith Unnikrishnan roninlord at gmail.com
Wed Sep 24 20:01:55 CEST 2008

Forgive my ignorance, but it seems like Philip's suggestion (
http://tug.org/pipermail/texhax/2008-September/010964.html) gives a way to
get a compact pdf file for a given text (or equation) string, and that your
suggestion is to do this procedure for each character, and then compute the
dimensions of each resulting image as the bounding box for the respective
character. But that is not what I want at all!

Following the above procedure would give me the dimensions that each
character requires *in isolation*. Working with my previous example, if my
text is $y = x ^2$, I want the coordinates (not the dimensions!) of the
bounding boxes of the individual characters  ("y", "=", etc.) as they would
occur when rendered within the whole $y=x^2$ string.

Consider the image obtained from rendering $y=x^2$. Imagine a 2D coordinate
system on this image with the origin at the bottom left of the image, its x
axis ranging from 0 to the width of the image and  its y-axis ranging from 0
to the height of the image. I'd like output in the form of a set of tuples
(left, top, right, bottom) for each of the 4 characters in the y=x^2
example, and the resulting bbox coordinates of "y" should reflect, for
instance, that its "left" field is smaller in value than, say, that of the
"=" character which is placed to the right of "y" when rendered in the
image. So I'm essentially looking the intermediate results after the
procedure that decides where exactly the characters are to be placed in the
image of $y=x^2$.

And no, these values cannot be obtained by simply using the bounding box
dimensions of the characters rendered in isolation. For instance the
dimensions of the "2" would be much larger when rendered in isolation as
$2$, than when it appears as a superscript to "x" in $y=x^2$.

Hope that makes the problem a little clearer. Suggestions? Thanks!

On Wed, Sep 24, 2008 at 8:09 AM, William Adams <will.adams at frycomm.com>wrote:

> On Sep 24, 2008, at 10:35 AM, Ranjith Unnikrishnan wrote:
>  My intention is *not* to get one bounding box for all the characters
>> together, but to get the bounding box coordinates of *each* character in the
>> input text. So if the text I want to render is "$y = x^2$", I'd like to be
>> able to obtain the bbox coordinates of "y", "=", "x" and "2".
> Then put each character into a box and measure each box.
> See Philip Taylor's response in the ``compile to a small pdf'' thread for a
> code sample which can be adapted to single characters.
> William
> --
> William Adams
> senior graphic designer
> Fry Communications
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://tug.org/pipermail/texhax/attachments/20080924/1dd21cd4/attachment.html 

More information about the texhax mailing list