We tried your code and the text you used worked great, but when we
substituted other text, the image was not centered in the bounding box and
the bounding box was too small.  I think you may be right about the style
not being applied properly.  How would you code an if or case statement
properly to use the "javaStyle" for plain, bold, and italic?  I tried using
Font.Bold, etc,  and it didn't seem to like that (threw an error).

Using the code from Ben's original code on your site, we were able to get
horizontal centering, but now we have the issue of the vertical centering
not being right.  If I do not have any modifier on the offset calculation,
font size of 30 works great.  If I drop it to 16, it is on the bottom of the
box.  If I subtract 5 from the calculation, it is centered.  Add to that not
all fonts use the same modified at the same font size (for instance, Times
New Roman at 16 is centered, but Copperplate Gothic is off a bit and I have
to use a mod of -6 (might have been -4...not in front of my code right now).
Any ideas on how to mathematically account for this or if there is another
function I can use to accommodate this variance?

Eric

-----Original Message-----
From: Leigh [mailto:[email protected]] 
Sent: Tuesday, September 14, 2010 8:46 AM
To: cf-talk
Subject: RE: ImageUtils.cfc and CFImage


Yes, that is my entry. I found the measurements are not always pixel perfect
with every font. But in my experience TextLayout is a little more accurate
with certain styles and characters. Keep in mind the two methods return
different areas. For example, the one used by ImageUtils.cfc includes the
"leading" area, whereas the TextLayout bounds does not. So it is not a
straight substitution ..

>> With text layout you have to further
>> differentiate bold and
>> italics as a BitOr operation...

Well, since both use java.awt.Font objects, that is required with either
method. That is what seemed a little off to me about GetTextDimensions(). I
only ran a few tests, but it seemed to return the same size no matter what
style was used. When I used the methods described in the entry however, I
got a different width. 

I am not sure if this is the same font you are using, with the settings
below, GetTextDimensions() returned h=31 and w=175 versus roughly h=31 and
w=193 using the two (2) methods in the entry. Using "plain" returns the same
h=31 and w=175.  So my guess is maybe the font style is not being applied
properly.

<cfset text.prop = {font="BakerSignet BT Roman", size="25",
style="bolditalic", javaStyle= BitOr(Font.BOLD, Font.ITALIC)}>
<cfset results = util.GetTextDimensions(text="Joe's Funeral home",
FontProperties=text.prop )>



-Leigh



      



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:337007
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to