Re: Bold Text
Re: Bold Text
- Subject: Re: Bold Text
- From: Paolo Bertani <email@hidden>
- Date: Wed, 24 May 2006 08:20:47 +0200
Moray, thank you very much.
I was going right this way before my post, but I noticed that this
doesn't work for some fonts, like Courier.
For example
NSFont * Font = [NSFont fontWithName:@"Courier Bold" size:10.0f];
returns nil.
I thought that every font could be Bold-faced...
Regards,
Paolo.
Written directly in Mail, so apologies for mistakes
This code should be in your NSView subclass
- (void) drawRect:(NSRect) r {
NSString * Text = @"My string!";
// create the attributed string
NSFont * Font = [NSFont fontWithName:@"Geneva Bold" size:10.0f];
NSMutableDictionary * Styles = [[[NSMutableDictionary alloc]
init] autorelease];
[Styles setObject:Font forKey:NSFontAttributeName];
NSAttributedString * as = [[[NSAttributedString alloc]
initWithString:Text attributes:Styles] autorelease];
[as drawAtPoint:NSMakePoint(10,10)];
}
Note, if you care about speed, you may want to cache the string you
create, and not create it every time the NSView draws itself, like
my example does.
If you need any more info, feel free to contact me off list.
Cheers
Moray
_______________________________________________
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
References: | |
| >Bold Text (From: Paolo Bertani <email@hidden>) |
| >Re: Bold Text (From: Moray Taylor <email@hidden>) |