(none) imager-devel
/ help / lists / applications / search /

Re: understanding the bounding_box

From: Arnar Mar Hrafnkelsson (
Date: Tue 31 Jul 2001 - 20:26:22 UTC

  • Next message: 02891@xyz.molar.is: "Re: understanding the bounding_box"

    The general way that I think about centering is this:

    Suppose you have an image 300 pixels wide, and the text is 100 pixels wide
    (as you find out with the bounding box).

    Calculate the center of the image, 150 in this case, and subtract from
    that half the width of the text which is 50, resulting in a left edge of
    the text at 100.

    So when you draw the image you tell the font routines to start at 100.
    as a check, you start at 100, and add 100 giving 200. So the text is
    100 pixels from either edge.

    -- Arnar

    On Tue, 31 Jul 2001, Michael wrote:

    > Hi folks;
    > I'm writing to see if I understand what the use of the "bounding_box"
    > will allow me to do.
    > I need to centre the text on an image regardless of font size or number
    > of characters in the string.
    > I take it then by using the bounding_box I can then determine the size
    > of the string in pixels(for example 200 pixels) and then based on this,
    > given my image is say 300 pixels I know to start at 50 pixels with my
    > x_coord and wind up with the text centered.
    > Is this the correct thinking/use for the bounding_box??
    > Or am I missing the whole concept of what it is supposed to do?
    > --
    > best regards
    > -michael