paco_santigo Posted July 9, 2008 Share Posted July 9, 2008 Is there a function to count the length of a string as the pixel length, instead of the character count????Im asking because some characters "W" are wider than others "i".I'm currently using "Strlen", but it doesn't always work.I remember coming across something online awhile ago about em being used somehow to figure this out.... not sure exactly. but is there a way? Link to comment Share on other sites More sharing options...
justsomeguy Posted July 10, 2008 Share Posted July 10, 2008 If you're using a monospaced font then it's easy enough to calculate, all the letters are the same width. The only other way I can think of is using the GD image library, you can create a string in a certain font and it will tell you what the size of the bounding box is for the text.http://www.php.net/manual/en/function.imageftbbox.phphttp://www.php.net/manual/en/function.imagepsbbox.phphttp://www.php.net/manual/en/function.imagettfbbox.php Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.