To: CF-Talk
Subject: CF8 Image function - get size of text written
Does anyone know a way for getting the size of the text written to an
image? For example. Lets say that I have an image that is 50 pixels high
and 400 pixels wide and I write some text on the image starting at the
first pixel
Interesting stuff. I've been wanting to do something like this for a
while now, but a bit different. Given the string X, and an image
Canvas, put X so that is centered horiz and vert. If you had the W/H
of a set of text, it would be trivial.
On Jan 16, 2008 10:46 AM, Ben Nadel [EMAIL PROTECTED]
You may want to try using TextLayout instead of FontMetrics getStringBounds()
for a more accurate measurement. The Font API mentions
The logical bounds does not always enclose all the text. For example, in some
languages and in some fonts, accent marks can be positioned above the ascent or
Does anyone know a way for getting the size of the text written to an image?
For example. Lets say that I have an image that is 50 pixels high and 400
pixels wide and I write some text on the image starting at the first pixel and
the text only takes a width of 212 pixels. How can I tell that
I am looking for something like the getdimensions() method from
cfx_imageflare
http://efflare.com/products/cfx_imageflare/documentation/font.html
My first response did not show up, so I am resending.
Anyway, you might try java.awt.font.TextLayout. I do not think CF image objects
retain the
5 matches
Mail list logo