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:336994
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm