• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Font Size Problem in NSTableView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Font Size Problem in NSTableView
      • From: "Michael J. Bergin" <email@hidden>
  • Prev by Date: Re: Font Size Problem in NSTableView
  • Next by Date: Re: NSString intValue
  • Previous by thread: Re: Font Size Problem in NSTableView
  • Next by thread: Re: Font Size Problem in NSTableView
  • Index(es):
    • Date
    • Thread