On Wed, 4 Jun 2003, Martin Moss wrote: > Date: Wed, 4 Jun 2003 14:46:52 +0100 > From: Martin Moss <[EMAIL PROTECTED]> > To: [EMAIL PROTECTED] > Subject: font width to pixel width in perl - but also offtopic in > javascript > > Hi All, > > I'm sure this can't be an issue that hasn't been tackled, but I couldn't > find anything in the archives so:- > > I'm trying to find a way in which I can calculate the pixel width of a > string in a given font. > I'm doing this to feed a javascript file, so I am also looking at doing this > in javascript also. > > currently all I can find is the php 'imagefontwidth' function. Does anybody > know of an equivalent in perl? > I remember having issues like this in TK, but not sure the solution there > would be appropriate. > > I guess this is fuzzily on topic, but if anybody has any off topic > experience I'd be greatful. any approx solutions which can 'guarentee' a > 'larger than the minimum space required' would also suffice, e.g. is there > an approximation which I can use based upon the maximum character width > possible for a font etc... > > Regards > > Marty
Just a wild guess, but perhaps you could load GD.pm and get various font widths from there? ky