Reply to Re: [PHP] Image Generation: Centering Text

Your name:

Reply:


Posted by Richard Davey on 05/02/05 19:07

Hello Richard,

Monday, May 2, 2005, 4:47:42 PM, you wrote:

RC> But I need to center the text in the image that is generated. As I
RC> am using the same font and it is fixed at 10px I was thinking of
RC> doing something like:

RC> (Get Length of Text in Chars * Width of Average Char) DIV 2.

RC> (Width of Image DIV 2) - Above = starting point on the x axis.

RC> or can anyone think of a better way to do it?

There's nothing wrong with this method at all. When using a fixed
width font I would do it like this, it's pretty much perfect. When
using a True Type font I would use imagettfbbox() instead to get the
width of the text and then center that accordingly.

Best regards,

Richard Davey
--
http://www.launchcode.co.uk - PHP Development Services
"I do not fear computers. I fear the lack of them." - Isaac Asimov

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация