Click here to Skip to main content
15,892,839 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to make cocoa application draw bold or/and italic fonts. Here is the code I use:

C++
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?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900