• 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
drawing a simple string with NSFont
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

drawing a simple string with NSFont


  • Subject: drawing a simple string with NSFont
  • From: Scott F Bayes <email@hidden>
  • Date: Tue, 7 Aug 2007 18:29:23 +0900

I'm trying to draw an NSString on a NSView while in its drawRect, using
- (void)drawInRect:(NSRect)aRect withAttributes:(NSDictionary *) attribute


from the AppKit NSString additions. I can draw the string where I want to without problem, but I want to select a font and a font size. "Simple Text Drawing" in the Drawing Guide says:
"For an NSString object, you can apply basic attributes (such as font, color, and style settings) to the entire string during drawing." Perfect!


It sounds like setting font&size can be accomplished either with the NSDictionary *withAttributes for drawInRect above, or by [myFont set] while in drawRect.

I find I can create what appears to be a valid NSFont, no problem. But [myFont set] in drawRect doesn't appear to do anything, and I don't know how to construct the NSDictionary mentioned above, assuming it's what I need; I can't figure out what key to use.

Documentation has led me through enough twists and turns that I'm now thoroughly confused.

Any advice or a short example would be appreciated.



Scott B

_______________________________________________

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: drawing a simple string with NSFont
      • From: Douglas Davidson <email@hidden>
    • Re: drawing a simple string with NSFont
      • From: Felix Franz <email@hidden>
  • Prev by Date: Re: GUI not responding possibly because of NSRunLoop, what can I do?
  • Next by Date: Re: drawing a simple string with NSFont
  • Previous by thread: Re: image buttons + weird "focus" highlights
  • Next by thread: Re: drawing a simple string with NSFont
  • Index(es):
    • Date
    • Thread