Re: Font Size Problem in NSTableView
Re: Font Size Problem in NSTableView
- Subject: Re: Font Size Problem in NSTableView
- From: "Michael J. Bergin" <email@hidden>
- Date: Wed, 3 May 2006 22:31:28 -0400
Have you looked at http://www.cocoadev.com/index.pl?NSTextViewSizeToFit
-
Michael J. Bergin
email@hidden
Odology, inc.
www.odology.com
Launch any app, anywhere, in under a second
Launcher by Odology
www.odology.com/launcher
On May 2, 2006, at 6:09 PM, David Emme wrote:
--- 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:
40odology.com
This email sent to email@hidden
_______________________________________________
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