How to get an italic font
How to get an italic font
- Subject: How to get an italic font
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Fri, 4 Dec 2009 14:15:03 +0700
I want an italic font corresponding to an existing font.
I tried:
NSFontDescriptor *fd1 = [ NSFontDescriptor fontDescriptorWithName: @"Times" size: textFontSize ];
NSLog(@"%s text NSFontDescriptor %@",__FUNCTION__, fd1);
// NSFontNameAttribute = Times; NSFontSizeAttribute = 16;
fontText = [ NSFont fontWithDescriptor: fd1 size: textFontSize ];
NSLog(@"%s text NSFont %@",__FUNCTION__, fontText);
// "Times-Roman 16.00 pt. P [] (0x1190e0f90) fobj=0x1190e0590, spc=4.00"
So far so good.
Now I try to make the italic variant:
NSFontSymbolicTraits symbolicTraits = NSFontItalicTrait;
NSFontDescriptor *fdi = [ fd1 fontDescriptorWithSymbolicTraits: symbolicTraits ];
NSLog(@"%s italic NSFontDescriptor %@",__FUNCTION__, fdi);
// NSCTFontTraitsAttribute = { NSCTFontSymbolicTrait = 1; }; NSFontSizeAttribute = 16;
Note: NSFontNameAttribute has disappeared
The documentation says: "Returns a new font descriptor that is the same as the receiver but with the specified symbolic traits taking precedence over the existing ones."
italicText = [ NSFont fontWithDescriptor: fdi size: textFontSize ];
NSLog(@"%s italic NSFont %@",__FUNCTION__, italicText);
// "LucidaGrande 16.00 pt. P [] (0x1190e0f90) fobj=0x10046adb0, spc=5.06"
This is comple nonsense: Lucida Grande is not italic and does not have an italic variant (only normal and bold).
I would have expected something like Times-Italic.
So: how to get an italic variant to a given font without hardcoding font names?
Kind regards,
Gerriet.
_______________________________________________
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