• 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: How to make letters appear in italics?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to make letters appear in italics?


  • Subject: Re: How to make letters appear in italics?
  • From: Iceberg-Dev <email@hidden>
  • Date: Tue, 17 Mar 2009 22:26:19 +0100


On Mar 17, 2009, at 10:16 PM, Jim Correia wrote:

On Mar 17, 2009, at 10:14 AM, Li Fumin wrote:

Hi,all.I am new to cocoa. I am reading Aaron Hillegass's Book "Cocoa Programming for Mac OS X".

I have got some problems with challenge 2 of Chapter 20.I have a custom NSView called BigLetterView, and then it show the input letter on the view.Now I want to make the letter which I just inputted appears in italics. So, I define this method:

- (IBAction) isItalic: (id) sender
{
if ([italicBox state])
{
NSFontManager *fontManager = [NSFontManager sharedFontManager];
[fontManager convertFont: [NSFont fontWithName: @"Helvetica" size: 75]
toHaveTrait: NSItalicFontMask];
}else {
NSFontManager *fontManager = [NSFontManager sharedFontManager];
[fontManager convertFont: [NSFont fontWithName: @"Helvetica" size: 75]
toHaveTrait: NSUnitalicFontMask];
}


	[self setNeedsDisplay: YES];
}

When I click the italics check button. Nothing happens. How do I suppose to make this wok?
How can I get the font the letter is using?

Look at the API doc and method prototype for - convertFont:toHaveTrait:.


It returns a new font. You discard the return value, and don't update any of your own state, so I'm not sure how you envisioned this to work.

In the case where you want to remove the italic attribute, you should be using -convertFont:toNotHaveTrait:.

Does one get the same results (Italic) when you use the NSObliquenessAttributeName attribute? Or are these totally different?
_______________________________________________


Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: How to make letters appear in italics?
      • From: Martin Wierschin <email@hidden>
References: 
 >How to make letters appear in italics? (From: Li Fumin <email@hidden>)
 >Re: How to make letters appear in italics? (From: Jim Correia <email@hidden>)

  • Prev by Date: Re: How to make letters appear in italics?
  • Next by Date: Re: Garbage Collection, Core Foundation, and the -finalize problem
  • Previous by thread: Re: How to make letters appear in italics?
  • Next by thread: Re: How to make letters appear in italics?
  • Index(es):
    • Date
    • Thread