Re: NSString/NSFont/Dingbats and the SnowFlake symbol
Re: NSString/NSFont/Dingbats and the SnowFlake symbol
- Subject: Re: NSString/NSFont/Dingbats and the SnowFlake symbol
- From: Nick Zitzmann <email@hidden>
- Date: Wed, 24 Nov 2010 11:02:46 -0700
On Nov 24, 2010, at 10:46 AM, Stephen Blinkhorn wrote:
> Hi all,
>
> This seems like a lame question to be fair. I would like to be able to access the snowflake symbol from the 'Zapf Dingbats' font and simply draw it into a custom control applying attributes like font colour to it.
>
> Charecter details are:
>
> Name: 'SNOWFLAKE'
> Unicode: 2744
> UTF8: E2 9D 84
>
> What's the best way to achieve this in 10.4/10.5 and 10.6 simultaneously?
Try something like this: (written in Mail, untested, use at your own risk)
unichar snowflake = 0x2744;
NSString *snowflakeStr = [NSString stringWithCharacters:&snowflake length:1UL];
NSDictionary *attributes = {add your attributes here, like font and color};
NSAttributedString *snowflakeAttributedStr = [[[NSAttributedString alloc] initWithString:snowflakeStr attributes:attributes] autorelease];
[snowflakeAttributedStr drawInRect:{some rectangle}];
Alternately, if you need more control than that, you could use NSLayoutManager/NSTextStorage to get a glyph for the character, and then draw it using NSColor and NSBezierPath. But that might be overkill.
Nick Zitzmann
<http://www.chronosnet.com/>
_______________________________________________
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