Re: Font Size Problem in NSTableView
Re: Font Size Problem in NSTableView
- Subject: Re: Font Size Problem in NSTableView
- From: David Emme <email@hidden>
- Date: Tue, 2 May 2006 15:09:02 -0700
--- On 5/2/06 5:02 PM (-0400), Michael J. Bergin wrote:
>How are you retrieving the ascender, descender and leading values?
// Compute and return the table row height needed for aStr.
- (NSNumber *)rowHeightForString:(NSAttributedString *)attrStr
{
NSRange limitRange;
NSRange effectiveRange;
NSFont * fontAttr;
float answer = 0.0;
limitRange = NSMakeRange(0, [attrStr length]);
while (limitRange.length > 0) {
fontAttr = [attrStr attribute:NSFontAttributeName
atIndex:limitRange.location
longestEffectiveRange:&effectiveRange
inRange:limitRange];
float thisHeight = [self computeRowHeightForFont:fontAttr];
answer = (thisHeight > answer ? thisHeight : answer);
limitRange = NSMakeRange(NSMaxRange(effectiveRange),
NSMaxRange(limitRange) -
NSMaxRange(effectiveRange));
}
return [NSNumber numberWithFloat:answer];
}
// Compute max. row height for given font.
- (float)computeRowHeightForFont:(NSFont *)fontAttr
{
float answer = [fontAttr ascender] - [fontAttr descender] +
[fontAttr leading];
answer = answer + 1.0; // add white space as needed
return answer;
}
-Dave
--
Back up my hard drive? How do I put it in reverse?
_______________________________________________
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