Re: Low-level text, why so hard?
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