Re: Font Size Problem in NSTableView
Re: Font Size Problem in NSTableView
- Subject: Re: Font Size Problem in NSTableView
- From: Greg Herlihy <email@hidden>
- Date: Tue, 02 May 2006 12:05:51 -0700
- Thread-topic: Font Size Problem in NSTableView
The formula for calculating the font height is incorrect. The font height
would actually be:
ascender + descender + leading
Alternatively, you could call pointSize and have it add up the numbers.
You might also have to send a tile message to the table for it to adjust to
the new row heights.
Greg
On 5/2/06 10:32 AM, "David Emme" <email@hidden> wrote:
> I have an NSTableView with two text columns, both set to Lucida Grande
> 11 in IB. The first column is not user-modifiable and the font does not
> change. The second column is user-modifiable, via a separate
> NSTextField, and the user is allowed to change the font, font size, and
> color of these attributed strings.
>
> I am trying to get the NSTableView to respond "properly" to these
> attributed strings with differing font properties. I go thru each
> attributed string, getting the font information for each range and
> computing a row height for that string as MAX(ascender - descender +
> leading) (plus 1 for good measure :-). I then send the NSTableView a
> setRowHeight: with the largest computed row height (since I can't see
> how to set the row heights for individual rows).
>
> This seems (by eye) to produce row heights of an appropriate size.
> However, the baseline seems too low for some non-Lucida-Grande rows, and
> some fonts, especially those larger than the default 11 point, have
> their descenders clipped, while having what seems to be more than enough
> white space at the top of the NSTableView cell. The strings with Lucida
> Grande 11 stay at the tops of their cells, but those with other fonts
> seem to move too far to the bottoms of their cells.
>
> I'm not doing any custom drawing in the problem cells; I'm just setting
> the cell contents to the NSAttributedString in a datasource method:
>
> - (id)tableView:(NSTableView *)tableView
> objectValueForTableColumn:(NSTableColumn *)column row:(int)row
> {
> NSString * identifier = [column identifier];
> Reminder * rem = [reminderDoc reminderAtIndex:row];
> id answer = [rem valueForKey:identifier];
> return answer;
> }
>
> Is there something I can do to have these attributed strings drawn
> without this clipping?
>
> TIA,
> -Dave
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden