• 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: Bold Text
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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>)

  • Prev by Date: Re: What encoding to use to turn NSData from a subprocess into an NSString?
  • Next by Date: [nextCue setFloatValue:0.0]; doesn't work
  • Previous by thread: Re: Bold Text
  • Next by thread: Re: Bold Text
  • Index(es):
    • Date
    • Thread