• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: boundingRectWithSize:Option: and height constraint
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: boundingRectWithSize:Option: and height constraint


  • Subject: Re: boundingRectWithSize:Option: and height constraint
  • From: Aki Inoue <email@hidden>
  • Date: Wed, 11 Nov 2009 09:26:21 -0800

The request is reasonable.

Please file a bug.

Thanks,

Aki

On 2009/11/11, at 5:53, Bill Cheeseman wrote:

> Over the past 5 years, according to Google, many people have asked why -[NSAttributedString boundingRectWithSize:options] does not honor the proposed height constraint, but nobody has posted the answer. Can somebody explain this to me?
>
> The bounding rect of myMutableAttributedString is {{0, 0}, {450.117, 1285}}, when the width is constrained to 486 and the height is not contrained (i.e., height is set to 0.0). When I eyeball the string in its window on the screen, these dimensions appear to be about right.
>
> With a printing page height of 612, it should take 3 pages to print. To get the bounding rect for the first page to print, I run this code fragment in my printing NSView object:
>
> NSSize proposedSize = NSMakeSize(486, 612);
> NSLog(@"proposedSize: %@", NSStringFromSize(proposedSize));
> NSRect pageRect = [myMutableAttributedString boundingRectWithSize:proposedSize options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading | NSStringDrawingDisableScreenFontSubstitution];
> NSLog(@"pageRect: %@", NSStringFromRect(pageRect));
>
> These values are logged in the console:
>
> proposedSize: {486, 612]
> pageRect: {{0, 0}, {450.117, 1285}}
>
> Why isn't pageRect being returned as something close to {{0, 0}, {450.117, 612}? -- where the 612 page height would of course be expected to come out a little less than 612 to accommodate the vertical line heights.
>
> Including NSStringDrawingTruncatesLastVisibleLine in options doesn't change anything.
>
> The documentation leaves me with the impression that the whole point of this method is to return the largest rect that will honor the size constraint by cutting off the text at the height constraint while it is being laid out within the width constraint. Have I misunderstood?
>
> --
>
> Bill Cheeseman
> email@hidden
>
> _______________________________________________
>
> 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

_______________________________________________

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

References: 
 >boundingRectWithSize:Option: and height constraint (From: Bill Cheeseman <email@hidden>)

  • Prev by Date: Re: How to detect mac version (macbook version xx, mac version xx etc.)
  • Next by Date: Re: boundingRectWithSize:Option: and height constraint
  • Previous by thread: boundingRectWithSize:Option: and height constraint
  • Next by thread: Re: boundingRectWithSize:Option: and height constraint
  • Index(es):
    • Date
    • Thread