Sorry, it does not works completely.
With any font :(

It seems that some fonts just do not work.



-----Original Message-----
From: Steve Steinitz [mailto:stevestein...@gmail.com] 
Sent: Monday, November 14, 2011 7:45
To: cocoa-dev@lists.apple.com
Cc: Dany Golubitsky
Subject: Re: Troubles with Bold and Italic fonts - Cocoa

Hi Dany,

I'm not sure what's wrong but, for what its worth, I use:

NSFont  * aFont = [NSFont fontWithName: @"Cochin" size: 10.0];
                aFont = [fontManager convertFont: aFont 
                                                   toHaveTrait: NSBoldFontMask];

Cheers,

Steve

On 14 Nov 11, at 4:15pm, cocoa-dev-requ...@lists.apple.com wrote:

> I am trying to make cocoa application draw bold or/and italic fonts. Here is 
> the code I use:
> 
>    NSFontTraitMask fontStyle = 0;
>    if (m_bBold)
>        fontStyle |= NSBoldFontMask;
>    if (m_bItalic)
>        fontStyle |= NSItalicFontMask;
> 
>    NSFontManager* fontManager = [NSFontManager sharedFontManager];
>    NSFont* font   = [fontManager fontWithFamily:@"Helvetica" traits:fontStyle 
> weight:5 size:12];
> 
> As far as I understand all that fontManager does is just convert to the 
> correct font name.
> So it works fine. It converts Helvetica to Helvetica-Bold or Verdana to 
> Verdana-Bold.
> 
> However, the displayed font is not always what I asked. For example, It works 
> with Verdana (I see it bold). But it does not works with Helvetica. Although 
> the name is converted to Helvetica-Bold, the fonts are still regular.
> 
> What is the mistake here?

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please 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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to