String Of Text (Number of Pixels / Pixel Size / Pixel Length)

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
If I'm putting together a list of links and I want to get add each
item one at a time inside a foreach($aNames as $sName) loop,
is there an easy way to get the number of pixels that the $aName
takes up?

For instance, in creating a set of links...

foreach($aLinks as $sLink) {
 if ((pixelsize($sLink, $sFont, $iFontSize) . pixelsize($sHTML . " ", $sFont, $iFontSize)) < 400) {
  $sHTML .= " " . $sLink;
 } else {
  $sHTML .= "<br />\n" . $sLink;

The goal is to keep the whole link on one and only one line letting
the browser automatically break up any given link.


Jim Carlock
Post replies to the newsgroup.

Re: String Of Text (Number of Pixels / Pixel Size / Pixel Length)

Quoted text here. Click to load it

No.  Indeed, there is no guarantee that your page will be rendered in a
pixel-based browser at all.

The general rule is that you worry about the content, and allow the browser
to worry about the details of presentation.
- Tim Roberts,
  Providenza & Boekelheide, Inc.

Site Timeline