Interesting idea.  I did not know that CSS had any "output" vars. How would
one go about getting the length from a div?  How is this possible when CSS
is rendered in the browser?


Mark W. Breneman
-Cold Fusion Developer
-Network Administrator
  Vivid Media
  [EMAIL PROTECTED]
  www.vividmedia.com <http://www.vividmedia.com/>
  608.270.9770

  _____  

From: Burns, John D [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 11, 2004 3:10 PM
To: CF-Talk
Subject: RE: Determining physical length of text string (not char count)

I haven't been paying much attention today, so I'm not 100% sure what's
been said on this thread, but something I was thinking was that you
could put that string in a <div> and then check the width of the div.
There's a css property to give the actual width of the div as opposed to
the assigned "width" attribute so maybe that would help some.  It'd be a
little extra work to get that variable into CF, but it seems doable.

John

-----Original Message-----
From: Adam Haskell [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 11, 2004 3:22 PM
To: CF-Talk
Subject: Re: Determining physical length of text string (not char count)

I came up with this (you could easily turn it into a function):

font_obj = createobject("java","java.awt.Font").init('Tahoma',1,8);
font_metrics_obj =
createobject("java","java.awt.Toolkit").getDefaultToolkit().getFontMetri
cs(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]

Reply via email to