We're starting to run into that as well...some of the numbers seem to be
quite off - just when we thought we had a solution.  Anyone have any
other ideas on how we can accomplish this?  This doesn't have to be
cross-platform - any way to call a native Windows function to get the
correct size?


Thanks,
Dirk

-----Original Message-----
From: Craig Dudley [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 17, 2004 2:37 AM
To: CF-Talk
Subject: SUSPECT: RE: slow Java call - Determining physical
length of string - Pt 2


I had a play with this myself, and found that the pixel width
retruned
by the funtion is a LONG way out of the actual length of the
string
rendered in a browser.

e.g.

<cfscript>
font_obj =
createobject("java","java.awt.Font").init('Arial',1,8);
font_metrics_obj =

createobject("java","java.awt.Toolkit").getDefaultToolkit().getFontMetri
cs(font_obj);
Pixel_Width = font_metrics_obj.stringWidth('the pixel width is
miles
out?');
</cfscript>

<cfoutput>
#Pixel_Width#
<br>
<img src="" width="<cfoutput>#Pixel_Width#</cfoutput>"
height="1"
alt="" border="0">
<br>
<div align="left" style="font-family:Arial;font-size:8pt;">the
pixel
width is miles out?</div>
</cfoutput>

You'll need a test gif of course.

Still, I'm not sure why, maybe java just renders fonts entirely
differently to browsers. I tried several fonts and many font
sizes, none
of them are even close, or did I miss something?

Craig.
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to