• 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
NSString drawInRect:withAttributes: clips descenders
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSString drawInRect:withAttributes: clips descenders


  • Subject: NSString drawInRect:withAttributes: clips descenders
  • From: Brant Sears <email@hidden>
  • Date: Wed, 3 May 2006 13:55:48 -0400

Hi. I'm trying to use the method drawInRect: withAttributes: method of NSString to draw a single character at a time into an NSImage. The problem that I am having is that descenders are being clipped. So, for example, the character j is being chopped where it descends below the baseline. This affects other descenders like p, q, y, etc.

What can I do to fix this? It seems like this call sets the baseline at the very bottom of the NSRect that is specified in the method.

The method that I am using is as follows:

NSFont * myFont = [NSFont fontWithName:@"Monaco" size:10];

NSDictionary * attsDict = [NSDictionary dictionaryWithObjectsAndKeys:
[NSColor whiteColor], NSForegroundColorAttributeName,
myFont, NSFontAttributeName,
[NSNumber numberWithInt:NSNoUnderlineStyle], NSUnderlineStyleAttributeName,
nil ];
[charStr drawInRect: charRect withAttributes:attsDict];



The context in which I am doing this is that the NSImage has already been locked into focus and had its background filled with black. Is there an attribute I can use to raise the baseline? Also, I have to have this work on 10.2 and up. A 10.4 only solution can be used, but I would still need some other solution for 10.2/10.3.


Thanks!

Brant Sears
_______________________________________________
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


  • Follow-Ups:
    • Re: NSString drawInRect:withAttributes: clips descenders
      • From: "Michael J. Bergin" <email@hidden>
    • Re: NSString drawInRect:withAttributes: clips descenders
      • From: Ondra Cada <email@hidden>
  • Prev by Date: Re: Confused with modal sessions
  • Next by Date: Re: NSString drawInRect:withAttributes: clips descenders
  • Previous by thread: Re: Drag & Drop Question
  • Next by thread: Re: NSString drawInRect:withAttributes: clips descenders
  • Index(es):
    • Date
    • Thread