• 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: calculating line heights in a NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: calculating line heights in a NSTextView


  • Subject: Re: calculating line heights in a NSTextView
  • From: Douglas Davidson <email@hidden>
  • Date: Tue, 21 May 2002 14:34:57 -0700

On Tuesday, May 21, 2002, at 01:59 PM, Scott Royston wrote:

Anyone have any pointers on how to calculate each line's height in a NSTextView?
Looking through the documentation, the only things that look promising are the LayoutManager's lineFragmentUsedRectForGlyphAtIndex functions, or maybe the paragraph attributes in the TextStorage...

The layout manager will tell you the positioning and size of each line within the container, via lineFragmentRectForGlyphAtIndex:effectiveRange: and lineFragmentUsedRectForGlyphAtIndex:effectiveRange:. The difference between the two is that the first tells you the entire rect chosen by the text container for the line, while the second tells you how much of that line is actually occupied by glyphs.

You can iterate through these using NSMaxRange() on the effective glyph range to tell you where the next line starts. Keep in mind that everything is in container coordinates, not view coordinates; to convert to view coordinates, you would add the NSTextView's textContainerOrigin. Of course, this doesn't affect sizes, only positions.

Douglas Davidson
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >calculating line heights in a NSTextView (From: Scott Royston <email@hidden>)

  • Prev by Date: Re: Newbie question: setting a NSNumber
  • Next by Date: Ints in NSDictionaries
  • Previous by thread: calculating line heights in a NSTextView
  • Next by thread: Ints in NSDictionaries
  • Index(es):
    • Date
    • Thread