Jump to content

String length by pixels, NOT characters???


paco_santigo

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...