Re: Review: Function that measures the width of a text string in pixels.

From: Date: Thu, 28 Oct 2004 22:26:37 +0000
Subject: Re: Review: Function that measures the width of a text string in pixels.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-200587@lists.php.net to get a copy of this message
On Fri, 2004-10-29 at 00:11 +0200, Jacob Friis wrote: > I have created a function that will measure the width of a text string > in pixels. It works ok. > If you have optimizations, please let me know. > Thanks, > Jacob > > function txt_width ($txt) { > $width = 0; > $txt_len = strlen($txt); > for ($n = 1; $n <= $txt_len; $n++) { > switch (substr($txt, $n, 1)) { > case 'l'; > case '.'; > case ' '; > case '-'; > case 't'; > $width += 3; > break; > default : > $width += 8; > break; > } > } > return $width; > } > ..and how do you plan to account for things such as, font sizes on all platforms, font types, etc? -- /*************************************** * Robby Russell | Owner.Developer.Geek * PLANET ARGON | www.planetargon.com * Portland, OR | robby@planetargon.com * 503.351.4730 | blog.planetargon.com * PHP/PostgreSQL Hosting & Development * --- Now supporting PHP5 --- ****************************************/

Attachment: [application/pgp-signature] This is a digitally signed message part signature.asc
« previous php.general (#200587) next »