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 14:56:03 -0700
- Thread-topic: Font Size Problem in NSTableView
The bounding boxes for the characters in each cell are positioned along the
top edge of the cell - in other words the characters "drop down" from the
top of each row. Therefore the baseline for the characters drawn in a tall
font will be lower than the baseline of characters drawn with a shorter
font.
To align the baselines of characters of varying fonts, the strings in the
smaller font have to be shifted down by the difference of the maximum ascent
of the tallest font subtracted by and the maximum ascent of font of the
characters being drawn. See
http://developer.apple.com/documentation/Cocoa/Conceptual/FontHandling/index
.html for a helpful font metrics diagram.
In fact this "subscript" value by which to shift the characters can be
specified as a property of the attributed string itself (with the property
NSSuperscriptAttributeName as a negative int). And this approach is probably
the one that requires the least amount of custom code.
Greg
On 5/2/06 12:28 PM, "David Emme" <email@hidden> wrote:
> --- On 5/2/06 12:05 PM (-0700), Greg Herlihy wrote:
>
>> The formula for calculating the font height is incorrect. The font
>> height would actually be:
>>
>> ascender + descender + leading
>>
>
> You would think so, but as it turns out, descender returns a negative
> value. so "- descender" produces the desired result.
>
>
>> You might also have to send a tile message to the table for it to
>> adjust to the new row heights.
>
> setRowHeight: is documented to send a tile message itself, and seems to
> do so. The row height does change when I expect it to, it just seems
> that the baseline is set "wrong".
>
> -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