• 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: size of a NSFont
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: size of a NSFont


  • Subject: Re: size of a NSFont
  • From: Half Activist <email@hidden>
  • Date: Wed, 7 Mar 2007 09:19:23 +0100

Hi Ewan,
actually the NSFont method you're looking for is -(float)pointSize

I guess there's no lineHeight method because an NSFont object is representing
a font typeface, it's not linked to a text drawing context, so a lineHeight method would be pointless.


Furthermore, even when drawing text, you can have a line height that's smaller than the max font height,
i mean the biggest height for the font, the result would be crappy but why couldn't you do this.


If you want to know the height of a string rendered in a given font, you could use NSString's sizeWithAttributes:
or use NSTextLayout, that - i think - will bring you line height etc etc.


Regards.

On Mar 7, 2007, at 8:43 AM, email@hidden wrote:

Hello all,

even after reading the documentation I'm still confused on how to access
the size of a NSFont. I need it in a piece of code like this :


 (*starting with an NSFont oldFont*)

   float oldSize=[myFont size];
  float newSize=oldSize/2;

   NSFont* newFont=[[NSFontManager sharedFontManager]
                   convertFont: oldFont toSize: newSize];

Unfortunately, there's no method called "size" for an NSFont. In terms
of figure 1 in
Text&Fonts>Font Handling>Getting Font Metrics, that would be the "line
height."
There are "capHeight,xHeight" methods for NSFont, why is there not a
"lineHeight" method ?



In the documentation I have seen many methods for NSFont that are
certainly related,
but it's not clear to me which one I should use. I should like the method
to make no
assumption of the font, since it is intended for use in a text editor ;
even if
it is initialized with a standard user font, it may have been
modified arbitrarily by the user afterwards.


Ewan




_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
40gmail.com


This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >size of a NSFont (From: email@hidden)

  • Prev by Date: size of a NSFont
  • Next by Date: "exponent" action in NSTextView subclass
  • Previous by thread: size of a NSFont
  • Next by thread: "exponent" action in NSTextView subclass
  • Index(es):
    • Date
    • Thread