• 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
Line Spacing: NSTextField ~10% > NSTextView for same font
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Line Spacing: NSTextField ~10% > NSTextView for same font


  • Subject: Line Spacing: NSTextField ~10% > NSTextView for same font
  • From: Jerry Krinock <email@hidden>
  • Date: Sun, 17 Feb 2008 21:24:31 -0800

For a couple years, I've been calculating text height for programmatically-created text using the Apple-recommended procedure [1]. But the height that it gave me was sometimes too small unless I added a 10% fudge factor.

Today, I found that the fudge factor is only needed for text drawn in NSTextFields. The problem is that the line spacing in a wrapped NSTextField is about 10% higher than for text drawn in an NSTextView of the same font. Here's a screenshot of a demo:

http://sheepsystems.com/engineering/SGDemo.png

The Apple-recommended procedure is apparently only good for NSTextViews, not NSTextFields.

Does anyone know why a wrapped NSTextField has a slightly larger line spacing than NSTextView with the same font?
What is a good way to predict the required string height for text which will be drawn in a wrapped NSTextField?


Thanks,

Jerry Krinock

[1] http://developer.apple.com/documentation/Cocoa/Conceptual/TextLayout/Tasks/StringHeight.html

I believe that the following line in there causes an additional error so I currently don't use it:
[textContainer setLineFragmentPadding:0.0] ;
_______________________________________________


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


  • Follow-Ups:
    • Re: Line Spacing: NSTextField ~10% > NSTextView for same font
      • From: Joshua Scott Emmons <email@hidden>
    • Re: Line Spacing: NSTextField ~10% > NSTextView for same font
      • From: Jerry Krinock <email@hidden>
  • Prev by Date: Re: Where to enforce paragraph-cohesion policy in text system?
  • Next by Date: Re: Creating an CGAffineTransform From Sample Points
  • Previous by thread: Re: Creating an CGAffineTransform From Sample Points
  • Next by thread: Re: Line Spacing: NSTextField ~10% > NSTextView for same font
  • Index(es):
    • Date
    • Thread