• 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: vertically aligning my NSAttributed text in its NSRect when drawn
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: vertically aligning my NSAttributed text in its NSRect when drawn


  • Subject: Re: vertically aligning my NSAttributed text in its NSRect when drawn
  • From: Fritz Anderson <email@hidden>
  • Date: Tue, 6 Jun 2006 14:26:23 -0500

On 6 Jun 2006, at 1:02 PM, Graham wrote:

How?

It's seldom a good idea to reduce one's questions to something that will fit in a Subject: line. I admire the impulse to make questions as succinct as possible, but this question goes further than that.


What do you mean by "vertically aligning in its NSRect?" Do you mean you want the text drawn across the top, across the bottom, or across the middle of a target rectangle? Do you mean that given a bounds rect returned by something like -[NSAttributedString boundingRectWithSize:options], you want to align the tops of the glyphs, the bottoms, or the baselines? Do you anticipate wrapping an over-wide string, or is this something like a label in the middle of a box on a chart?

For the most general solution to positioning wrapped text vertically in a target rectangle, have a look at the excellent "Text System Overview" at <http://developer.apple.com/documentation/Cocoa/ Conceptual/TextArchitecture/index.html>. The fully-general approach would be to set up a text-system stack (text storage, layout manager, and container) using the target rectangle as the bounds of the container. From that, have the layout manager measure the bounding rectangle of the text you're using. Calculate how you want to position the bounds rectangle in the target, and have the layout manager draw the text.

	-- F
 --
Fritz Anderson -- http://www.manoverboard.org/
Consulting Programmer -- http://resume.manoverboard.org/
Step into Xcode, Fun for Young and Old -- http://six.manoverboard.org/

_______________________________________________
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


References: 
 >vertically aligning my NSAttributed text in its NSRect when drawn (From: Graham <email@hidden>)

  • Prev by Date: Re: mark the Dock dirty - NSApp setApplicationIconImage
  • Next by Date: Make controllers talk to each other
  • Previous by thread: vertically aligning my NSAttributed text in its NSRect when drawn
  • Next by thread: Re: mark the Dock dirty - NSApp setApplicationIconImage
  • Index(es):
    • Date
    • Thread