• 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
Height of an NSAttributedString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Height of an NSAttributedString


  • Subject: Height of an NSAttributedString
  • From: Philip Dow <email@hidden>
  • Date: Wed, 21 Dec 2005 16:09:14 +0100

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:

This email sent to email@hidden
  • Follow-Ups:
    • Re: Height of an NSAttributedString
      • From: Douglas Davidson <email@hidden>
    • Re: Height of an NSAttributedString
      • From: Casey Fleser <email@hidden>
  • Prev by Date: Re: Versioning via build settings?
  • Next by Date: Re: NSSpeechSynthesizer leaking
  • Previous by thread: Re: Lots of items in an NSOutline view.
  • Next by thread: Re: Height of an NSAttributedString
  • Index(es):
    • Date
    • Thread