Re: Height of an NSAttributedString
Re: Height of an NSAttributedString
- Subject: Re: Height of an NSAttributedString
- From: Casey Fleser <email@hidden>
- Date: Wed, 21 Dec 2005 09:31:57 -0600
NSAttributedString's size has been working well enough for me:
- (NSSize) size
Returns the bounding box of the marks that the receiver draws.
Casey
On Dec 21, 2005, at 9:09 AM, Philip Dow wrote:
This relates to a recent post on determining the width of a string
to resize a scroll view but deserves its own thread I think. At the
time, a piece of apple documentation was referred to which shows
how to calculate height for a given string:
http://developer.apple.com/documentation/Cocoa/Conceptual/
TextLayout/Tasks/StringHeight.html#//apple_ref/doc/uid/20001809.
It is necessary to set up a text storage, text container and layout
manager, manually connect them, then grab the height using
usedRectForTextContainer or as John Stiles points out,
boundingRectForGlyphRange:inTextContainer: John also found a
simpler way to do this, creating a textview and then asking for the
frame's height after layouting out the associated glyphs.
This works fine for an NSString, however, when I attempt to do this
with an NSAttributedString containing multiple fonts as well as
graphics, I am unable to get an accurate total height, no matter
how I go about it. Has anyone had experience getting height for an
attributed string given a specific width? Is there something in the
layout manager I'm missing which is preventing it from taking into
account the graphics and various fonts?
-Phil
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40griffintechnology.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden