Re: Height of an NSAttributedString
Re: Height of an NSAttributedString
- Subject: Re: Height of an NSAttributedString
- From: Philip Dow <email@hidden>
- Date: Wed, 21 Dec 2005 16:32:31 +0100
Unfortunately I can't use size as I require a fixed width and text
wrapping.
-Phil
On Dec 21, 2005, at 4:31 PM, Casey Fleser wrote:
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
_______________________________________________
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