font_obj = createobject("java","java.awt.Font").init('Tahoma',1,8);
font_metrics_obj =
createobject("java","java.awt.Toolkit").getDefaultToolkit().getFontMetrics(font_obj);
Pixel_Width = font_metrics_obj.stringWidth('My co-worker is mean');
I have a question though....I tried to do
createobject("java","java.awt.FontMetrics").init(font_obj) and it
gave me an error:
Unable to find a constructor for class java.awt.FontMetrics that
accepts parameters of type ( java.awt.Font )
Any ideas what I was doing wrong?
Adam H
On Wed, 11 Aug 2004 11:34:06 -0500, Mark W. Breneman
<[EMAIL PROTECTED]> wrote:
> So if I understand you correctly you need to know how long some text is, not
> the number of letters that makes it up.
>
> Just off the top of my head, if you know the font and point size you will be
> using in the PDF, you could build a look up table for each letter and return
> the pix with then add them together. You would need a record for all chrs a
> user would enter in your look up table.
>
> Its not a good idea but....
>
> Mark W. Breneman
> -Cold Fusion Developer
> -Network Administrator
> Vivid Media
> [EMAIL PROTECTED]
> www.vividmedia.com <http://www.vividmedia.com/>
> 608.270.9770
>
> _____
>
> From: Dirk Sieber [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, August 11, 2004 11:13 AM
> To: CF-Talk
> Subject: Determining physical length of text string (not char count)
>
>
> Hello everyone,
>
> We're trying to figure out if there's a way in CF to figure out the
> actual, physical length of a string of text - eg, in pixels, inches,
> whatever.
>
> The issue - we need to be able to accept user data for a field, that
> will eventually be printed to a PDF. That PDF has strict specs as to
> how long a line of text can be. Of course, that'd be simple enough, if
> it was printed in a fixed-width font... but it's not, and we don't have
> the option of changing it.
>
> So... I need to find a way to detemine how long a string of text will
> be, given the font type, style, & point size. Anyone have any ideas how
> to do this from within CF? (This is under MX, BTW).
>
> Many thanks for any suggestions!
> Dirk
> _____
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

