• 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:36:24 +0200

Sorry, I have to correct myself.

It doesn't work with Geneva.

In my code I have

f=[NSFont fontWithName:@"Geneva Bold" size:9.0f];

f is nil after the call.

Instead it work with @"Courier New Bold".



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: editing plist file
  • Previous by thread: Re: Bold Text
  • Next by thread: NSStatusItem and LoginItemAPI
  • Index(es):
    • Date
    • Thread