Re: NSFontTraitMask Question
Re: NSFontTraitMask Question
- Subject: Re: NSFontTraitMask Question
- From: Vince DeMarco <email@hidden>
- Date: Mon, 7 Oct 2002 15:18:54 -0700
On Monday, October 7, 2002, at 12:00 PM, Tom Gray wrote:
Stumped again.
I have an NSTextView subclass and I am trying to determine if the
character clicked on is "bold".
I can't find a method that will allow me to "read" the font traits of a
character. I can set the font traits with:
[NSTextStorage applyFontTraits:myTraitMask range:myRange];
However, once set, I can't find a method that will allow me to
determine the traits.
Note, the traits (ie. bold) are different then the font attributes.
I am completely stumped. Any ideas?
Get the attributes for the range of text where the selection is.
and look up this key
NSFontAttributeName
NSTextStorage *storage;
NSRange selection;
NSDictionary *attr;
NSFont *font;
storage = [textView textStorage];
selection = [textView selectedRange];
font = [storage attribute: NSFontAttributeName atIndex:
selection.location longestEffectiveRange:NULL
inRange:NSMakeRange(0,[storage length])];
Now you have the font and you can look up whats there etc.
vince
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.