• 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: Thu, 4 May 2006 09:14:00 -0700

--- On 5/4/06 2:23 AM (-0500), Mike Wright wrote:

>I have an approach that I came up with by trial and error. I use it
>to calculate table row heights, and it seems to work pretty well.
>Some fonts, like the aforementioned Ayuthaya 18 (which has zero
>leading, by the way), draw with the descenders just barely inside the
>frame, with a big chunk of white above the text, but at least they
>don't get truncated.
>
>Here's how I calculate row height:
>
>   // create new font based on settings, with NSString *fieldsFontName
>   // and float fieldsFontSize
>   NSFont *newFont = [NSFont fontWithName:fieldsFontName
>           size:fieldsFontSize];
>
>   // make some adjustment for fonts with low baseline
>   float ascender = [newFont ascender];
>   float leading = [newFont leading];
>   float descender = (-[newFont descender]);
>   float rowHeight = ascender + descender + leading + (fieldsFontSize /
>           4.0) + 0.5;
>
>   // make sure that we don't end up with something really stupid
>   float defaultLineHeight = [newFont defaultLineHeightForFont];
>   if (rowHeight < defaultLineHeight)
>       rowHeight = defaultLineHeight;
>
>   // set the row height
>   [listTableView setRowHeight:rowHeight];

Thanks! That pretty much solves the problem for me.

-Dave
--
Believe nothing, no matter where you read it, or who said it -- even
if I have said it -- unless it agrees with your own reason and your
own common sense.
   - Gautama Buddha
 _______________________________________________
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

References: 
 >Re: Font Size Problem in NSTableView (From: Mike Wright <email@hidden>)

  • Prev by Date: Hiding find panel in NSTextView
  • Next by Date: Expanding a window and adding controlls dynammicaly.
  • Previous by thread: Re: Font Size Problem in NSTableView
  • Next by thread: binding a textfield value like a popup button
  • Index(es):
    • Date
    • Thread