|
Posted by Rik on 06/07/07 23:49
On Thu, 07 Jun 2007 19:24:39 +0200, -Lost <maventheextrawords@techie.com>
wrote:
> -Lost wrote:
>> gbbulldog wrote:
>>> On 6 Jun, 05:34, -Lost <maventheextrawo...@techie.com> wrote:
>>>> Anyone know offhand how to center a text within the bounding box of an
>>>> image (width-wise at least) without the Freetype library?
>>>>
>>>> GD- or ImageMagick-specifc code would do nicely.
>>>>
>>> 1. Determine the width of the image.
>>> 2. Determine the width of the text, (I'm assuming you'll be outputting
>>> text using TTF?), using imagettfbbox()
>>> 3. The left-hand position of the text should be : (image's width / 2)
>>> - (text width / 2)
>> Thanks!
>
> Ooops! I have no clue why I said thanks.
>
> I specifically said "without the Freetype library."
>
> That function depends on its functionality to work as expected.
Write your own variant of the freetypre library if it isn't available,
that's the only solution. There's no other way you can know the width of
dynamic text with an arbitrary font. Yes, it's a pain, so if the library
isn't available seriously consider changing hosts and/or change the server.
--
Rik Wasmus
[Back to original message]
|