afraid to start digging. :) I'll take a look at that - thanks.
We actually thought of the table of widths approach, but it's incredibly
cumbersome, especially considering we need to deal with multiple point
sizes, and also variations (bold/italic). I'm hoping to avoid that. :)
Thanks!
Dirk
-----Original Message-----
From: Barney Boisvert [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 11, 2004 9:25 AM
To: CF-Talk
Subject: SUSPECT: Re: Determining physical length of text string
(not char count)
If you're not scared of Java, one approach would be to use the
java.awt.FontMetrics class (probably via a temp image's Graphics
instance), specifically the getStringBounds method. That'll
give you
all kinds of goodies about the font and strings written using
that
font.
If you don't want that complexity, you could record the pixel
width of
each character in your desired font into a struct, and loop over
the
string, summing up a length. Won't be exactly perfect, because
of
ligatures and kerning, but it should be close, and I believe
that'll
never underestimate, but that'll might not be true.
cheers,
barneyb
On Wed, 11 Aug 2004 12:12:31 -0400, Dirk Sieber
<[EMAIL PROTECTED]> wrote:
> 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
--
Barney Boisvert
[EMAIL PROTECTED]
360.319.6145
http://www.barneyb.com
_____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

