• 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
Stealth leading in NSAttributedString drawing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Stealth leading in NSAttributedString drawing


  • Subject: Stealth leading in NSAttributedString drawing
  • From: Nick Zitzmann <email@hidden>
  • Date: Tue, 12 Dec 2006 21:18:47 -0700

I have an NSAttributedString with the only attributes set being the font and the color. I want to draw the string in a space with a fixed width but a variable height, so I've been using the method described at <http://developer.apple.com/documentation/Cocoa/Conceptual/ TextLayout/Tasks/StringHeight.html#//apple_ref/doc/uid/20001809> to calculate the height for the text given the width. (Don't tell me about -boundingRectWithSize:options:. It does not work. I've tried it.)

The problem is, even though there is no paragraph style set in the NSAttributedString, and [[NSParagraphStyle defaultParagraphStyle] lineSpacing] is returning 0, NSAttributedString is inserting a phantom vertical line in between rows of text when drawing using the plain -drawInRect: method. So obviously my method of calculating the text height is off by 1 vertical pixel per text row, and the bottom of the text is being cut off.

If, during the height calculation, I use an NSParagraphStyle that has a line spacing of 1 in the NSTextStorage used to calculate the height, then the problem goes away. That's kind of crazy, though. Why is NSAttributedString inserting lines between rows of text when it's not supposed to be doing that? How do I make it quit doing that?

Nick Zitzmann
<http://www.chronosnet.com/>


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


  • Follow-Ups:
    • Re: Stealth leading in NSAttributedString drawing
      • From: "Dan Bernstein" <email@hidden>
  • Prev by Date: Re: init char buffer to null
  • Next by Date: Re: init char buffer to null
  • Previous by thread: Re: init char buffer to null
  • Next by thread: Re: Stealth leading in NSAttributedString drawing
  • Index(es):
    • Date
    • Thread