Thanks- main() is the only place that works. I tried run() and even init() of 
the application, but even they were too late.

It does prove my working theory - that NSTextView is accessing NSFontManager 
directly rather than using the sender passed to -changeFont:, even though 
Apple’s docs tell the rest of us to do it that way. It’s a pity, because it 
means that I now need a ”thick” shim instead of a “thin” one to intercept font 
changing operations sent to text views (by which I mean I now have to subclass 
NSFontManager instead of passing a simple object as sender that can intercept 
the callback to -[<sender> convertFont:]. Bah.

Am I alone in thinking the design of the font changing mechanism is simply 
horrible? No wonder the Font Panel itself is so horrible, with all of the 
different text properties and attributes conflated into an indistinct porridge 
of settings that are hard to separate out. Just look at NSFontAction to see 
what I mean.


—Graham





> On 12 Nov 2015, at 1:07 PM, Ken Thomases <[email protected]> wrote:
> 
> Probably best to put it in main().
> 
> The app delegate is typically instantiated in the MainMenu NIB (or 
> storyboard, I guess).  Therefore, there's no possibility that any method will 
> be invoked on it until that NIB is loaded.  If the NIB contains a placeholder 
> for the shared font manager or anything which uses it (like the Font menu), 
> then you can't get in front of it reliably in methods of the app delegate.  
> So, you have to make the call before the NIB is loaded.  main() is the 
> easiest place for that.
> 
> If that doesn't work, you may need to use a custom subclass of NSApplication 
> and put it in an override of -run, before calling through to super.
> 
> Regards,
> Ken
> 


_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to