Re: Set TableView font and rowHeight
Re: Set TableView font and rowHeight
- Subject: Re: Set TableView font and rowHeight
- From: Ivan C Myrvold <email@hidden>
- Date: Mon, 2 Apr 2007 14:07:42 +0200
OK, I think I got it right, with help from this message http://
www.cocoabuilder.com/archive/message/cocoa/2006/3/22/159388
So what I now is doing is:
NSDictionary *attr = [NSDictionary dictionaryWithObject:[self
newFont] forKey:NSFontAttributeName];
NSSize defaultTextSize = [@"" sizeWithAttributes:attr];
float fheight = defaultTextSize.height;
[aTableView setRowHeight: fheight];
This seems to make the text in the NSTableView show the text correct
in all sizes and fonts.
Ivan
Den 2. apr. 2007 kl. 13.15 skrev Ivan C Myrvold:
If I use the defaultLineHeightForFont setting the table views
rowHeight, as suggested in the layout chart, that should correspond
to line height, the text is still getting clipped for large font
sizes.
When my application starts up, the default font is LucidaGrande
13.00 pt., and the rowHeight of the table is 17.000000. The fonts
defaultLineHeightForFont is 16.000000. The ascender is 12.568359
and descender is -2.742188.
I can't see how this adds up to 17, which is the NSTableView's
rowHeight.
Ivan
There's a nice layout chart that illustrates how the different
font metrics work together:
<file:///Developer/ADC Reference Library/documentation/Cocoa/
Conceptual/FontHandling/Tasks/GettingFontMetrics.html>
Also online:
<http://developer.apple.com/documentation/Cocoa/Conceptual/
FontHandling/Tasks/GettingFontMetrics.html>
sherm--
Web Hosting by West Virginians, for West Virginians: http://wv-
www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
_______________________________________________
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
_______________________________________________
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