NSTextView not always accepting a Favorite style from NSFontPanel
NSTextView not always accepting a Favorite style from NSFontPanel
- Subject: NSTextView not always accepting a Favorite style from NSFontPanel
- From: "Russell Finn" <email@hidden>
- Date: Fri, 19 Sep 2008 11:27:52 -0400
I am struggling with a puzzling problem involving an NSTextView and
the Favorites list in the NSFontPanel. I'm hoping someone on the list
has seen something like this before and/or can offer any pointers.
My program is a document-based application with a main document window
that includes an NSTextView. [Technically it is a subclass of
NSTextView, but I have substituted an actual NSTextView without
changing the behavior.] I load some rich text from an RTF file into
my NSTextView, and select some text whose font has the bold or
underlined trait (e.g., Helvetica-Bold). I open the font panel and
click on a style from the Favorites list (e.g. Impact). If I do this,
the style of the text in the NSTextView does *not* appear to change.
If, however, I initially select text that does *not* have the bold or
underlined trait (e.g., plain Helvetica), the selected style *is*
correctly applied to my text as well.
If I perform the same steps in TextEdit, it behaves as I expect: the
text font is replaced by the selected style from the font panel,
regardless of the original font of the text.
I used some method swizzling to break into the changeFont: method of
the text view and insert some additional debugging code. I am able to
get the selected text's NSFont and send it directly to the
NSFontManager's convertFont: method. If the selected text's NSFont is
Helvetica-Bold, I get Helvetica-Bold back; if it is plain Helvetica, I
get Impact back. If I manually strip the bold trait from the
Helvetica-Bold font, giving me a plain Helvetica, and send *that* to
the NSFontManager, I still get Helvetica-Bold back.
I see analogous behavior if I select italic text, in that I get
Helvetica-Oblique back from the NSFontManager. I also see the same
thing if I send the font to the font panel for conversion (via
panelConvertFont:). It is as if I'm getting back the font panel's
represention of the currently selected font in my text, instead of the
font I click in the Favorites list -- but only if that font has a bold
or italic trait. Finally, selecting an item from the Recently Used
list produces the same anamolous behavior as the Favorites list.
I am at a loss to explain this. Clearly there must be some difference
in the context of my program, compared to TextEdit, but I have been
unable to determine what that is. I inherited this code base from
another developer, and there are some oddities in the coding style,
but I have not found anything relating to the font panel or text
system that would explain this difference in behavior. (My program is
normally built against the 10.3.9 SDK, but changing it to the 10.5 SDK
to match TextEdit does not alter the behavior either.)
Has anyone seen this kind of behavior before, or has any kind of
insight into where I might look? I'm running out of ideas and any
suggestions would be appreciated.
Thanks -- Russell
_______________________________________________
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