Re: NSAttributedString boundingRectWithSize vs. paragraph margins
Re: NSAttributedString boundingRectWithSize vs. paragraph margins
- Subject: Re: NSAttributedString boundingRectWithSize vs. paragraph margins
- From: Kyle Sluder <email@hidden>
- Date: Thu, 24 Jan 2013 11:52:23 -0800
On Thu, Jan 24, 2013, at 06:14 AM, Matt Neuburg wrote:
>
> On Jan 23, 2013, at 11:01 PM, Kyle Sluder <email@hidden> wrote:
>
> >> It may be that the height is right despite the narrowed width, but since the narrowed width is unexpected, it would be nice to be assured of this. m.
> >
> > Why is the narrowed width unexpected? You told the text system to use 20pt margins on each side of a 100pt text container.
>
> I expect this method to tell me the size of a rectangle (e.g. a bitmap
> context) such that if I draw my attributed string into that rectangle, it
> will all fit. When I say "all" I mean "all", including the margins.
Considering the method is named -boundingRect…, I wouldn't expect this.
What you're looking for is the line fragment rect, and I can understand
why you would think passing NSStringDrawingUsesLineFragmentOrigin as an
option would yield this information. Instead, it seems to offer the
bounding rect of the glyph range in line fragment coordinates, which I
would surmise is more useful information in NSStringDrawing's primary
intended use cases.
> Therefore I believe this is a bug. I asked for the bounding rect of my
> string, but the system gave me the bounding rect of a *different* string,
> a string that has no margins. m.
I don't know if it's a bug, per se, because the text system
documentation is pretty religious about boundingRect referring only to
the bounds of glyphs, and using lineFragmentRect to refer to the value
you're looking for. Perhaps you should file an enhancement request for a
-lineFragmentRectWithSize:… method.
In the meantime, it looks like you're going to have to drop down to Core
Text.
--Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden