Re: NSTableView, variable row heights, small fonts
Re: NSTableView, variable row heights, small fonts
- Subject: Re: NSTableView, variable row heights, small fonts
- From: Jerry Krinock <email@hidden>
- Date: Wed, 19 Oct 2005 21:07:29 -0700
- Thread-topic: NSTableView, variable row heights, small fonts
on 05/10/19 15:58, Ken Victor at email@hidden wrote:
> i've got an NSTableView that has a single column and each row is an
> NSAttributedString. in my data source for the table i return the
> height returned by [NSAttributedString size] as the height for each
> row. the problem is that if my strings are small font sizes (less
> than 13), the table appears to clip the bottom of the characters.
I use NSFont's -boundingRectForFont to set the heights for my rows, and I
find the opposite problem; at least with the System font. For font sizes of
12 or more, I find that I can use a row height 4 pixels less than the height
of the returned NSRect, and for font sizes of 11 or less, I can use 3 pixels
less. I suspect that these 3 or 4 pixels may be margins required for
worst-case glyphs in some non-Roman script.
Another alternative is to read this which I think may be a more "supported"
way of doing what you want:
ADC Home > Reference Library > Documentation > Cocoa > Text & Fonts > Text
Layout Programming Guide > Calculating Text Height
This shows how to calculated text height for a given width. In another part
of my app, I wanted the opposite, to calculate the width for a given height.
It was an obvious modification of the code to do that, but even though I do
use this method I found that in order to avoid another line wrap sometimes I
had to add a 15-pixel fudge margin to the calculated width.
_______________________________________________
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