• 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: Low-level text, why so hard?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Low-level text, why so hard?


  • Subject: Re: Low-level text, why so hard?
  • From: Jeff Schriebman <email@hidden>
  • Date: Mon, 24 Dec 2012 06:01:44 -0800

> On Sun, Dec 23, 2012, at 09:32 PM, Graham Cox wrote:
>> I need to use Quartz to draw a single character - a check mark - in a
>> graphics context. I don't need anything elaborate, no typesetting etc, I
>> just want to draw a single checkmark.


I use the following code to put an arbitrary unicode string into a CGContextRef. It might be useful in your situation.

NSString *downArrow = @"\u2B07";
[self showUnicodeString:ctx xPosition:x yPosition:y usingString:downArrow usingColor:[NSColor redColor]];


- (void)showUnicodeString:(CGContextRef)ctx xPosition:(CGFloat)x yPosition:(CGFloat)y usingString:(NSString *)theString usingColor:(NSColor *)theColor
{
NSDictionary* fontAttrs = [NSDictionary dictionaryWithObjectsAndKeys:
					theColor, NSForegroundColorAttributeName,
					[NSFont systemFontOfSize:12], NSFontAttributeName,
					nil];
CGContextSaveGState(ctx);
[theString drawAtPoint:NSMakePoint(x, y) withAttributes:fontAttrs];
CGContextRestoreGState(ctx);
CGContextSetTextMatrix(ctx, CGAffineTransformIdentity);
}


Jeff Schriebman
An educated mind can entertain a thought without accepting it - Aristotle





_______________________________________________

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

References: 
 >Low-level text, why so hard? (From: Graham Cox <email@hidden>)
 >Re: Low-level text, why so hard? (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: Window resizing autolayout?
  • Next by Date: Re: Window resizing autolayout?
  • Previous by thread: Re: Low-level text, why so hard?
  • Next by thread: Window resizing autolayout?
  • Index(es):
    • Date
    • Thread