Re: NSFont & bold
Re: NSFont & bold
- Subject: Re: NSFont & bold
- From: Jeff Gilbert <email@hidden>
- Date: Thu, 21 Apr 2005 12:44:41 -0500
Hi Luc,
On Thursday, April 21, 2005, at 12:17PM, Luc Vandal <email@hidden> wrote:
>Hi!
>
>It seems that it's not possible to set a font as bold. Is there a way
>to do this or fonts handling is very different compared to Windows?
You need to use NSFontManager to convert a font. You could use convertFont:toHaveTrait: to return a new font with the bold trait. For example, you could use
NSFont* boldHelvetica = [fontManager convertFont:helvetica toHaveTrait:NSBoldFontMask];
However, not all fonts have a Bold variant; they may have a Black or Heavy variant and setting the bold trait will not use these variants, so you are left with the original font. I found the most reliable way is to use the NSFontManager method convertWeight:ofFont: to increase the weight to the next bolder weight, like this:
NSFont* bolderHelvetica = [fontManager convertWeight:YES ofFont:helvetica];
For more information, see the documentation of NSFontManager.
Hope this helps,
Jeff Gilbert
_______________________________________________
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