On 2008 Apr, 13, at 1:38, Jeff wrote:

Any way to take an NSTextField containing some amount of text, and resize it vertically so all the text fits within the frame? The sizeToFit message
seems to do this, except on the horizontal axis.

If you mean one line of text, there was [NSFont defaultLineHeightForFont] but that's depracated in 10.4 and you're supposed to use a layout manager (NSLayoutManager).

If you mean multiple lines of text, you must calculate it using a layout manager. But I could never find a typesetter behavior which gave a reliably accurate answer for an NSTextField. The closest is NSTypesetterBehavior_10_2_WithCompatibility. It seems to me that Apple discourages multi-line NSTextFields. (You can't make one in Interface Builder). My advice: If it's more than one line, use NSTextView instead. A few months ago I put together a demo which explains these issues. You might want to run it, read the comments at the top of NS(Attributed)String+Geometrics.h, and/or check out the references.

http://sheepsystems.com/sourceCode/sourceStringGeometrics.html

Let me know if I made any conceptual errors in that thing.

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to