Re: NSTextView Linked Text Font Attribute Issues
Re: NSTextView Linked Text Font Attribute Issues
- Subject: Re: NSTextView Linked Text Font Attribute Issues
- From: Ricky Sharp <email@hidden>
- Date: Sat, 29 Dec 2007 16:19:22 -0600
On Dec 29, 2007, at 4:05 PM, Robb Albright wrote:
On Dec 28, 2007, at 12:01 PM, email@hidden wrote:
I'm having issued with a subclassed NSTextView displaying linked text
as I'd like it to. The link text attributes I specify are working,
except for the font name attribute. The link text appears to be
rendered in the Helvetica font, while my default attributes call for
Monaco.
<snip>
myDefaultLinkTextAttributes =
[[NSDictionary alloc] initWithObjectsAndKeys:
[NSFont fontWithName: @"Monaco" size: 12.0], NSFontNameAttribute,
[NSColor lightGrayColor], NSForegroundColorAttributeName,
[NSColor clearColor], NSBackgroundColorAttributeName,
[NSNumber numberWithInt: NSUnderlineStyleNone],
NSUnderlineStyleAttributeName,
[NSCursor pointingHandCursor], NSCursorAttributeName,
nil];
The key "NSFontNameAttribute" should be set to an NSString instance
(the font name), not an NSFont instance.
So, for the first attribute key, instead of:
[NSFont fontWithName: @"Monaco" size: 12.0], NSFontNameAttribute,
use:
@"Monaco", NSFontNameAttribute,
NSFontNameAttribute (and others that have a pattern of
NSFont*Attribute] are for working with NSFontDescriptor.
The original code was almost correct; just change the key name to
NSFontAttributeName. As with other keys that can be used, the pattern
is NS*AttributeName. And, for this particular key, you do in fact
want to provide the actual font instance.
___________________________________________________________
Ricky A. Sharp mailto:email@hidden
Instant Interactive(tm) http://www.instantinteractive.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