libs-gui icon indicating copy to clipboard operation
libs-gui copied to clipboard

NSFontManager doesn't set a delegate; doesn't call changeFont: callback

Open sgharms opened this issue 3 months ago • 2 comments

Per: https://www.gnustep.org/resources/OpenStepSpec/ApplicationKit/Classes/NSFontManager.html

NSFontManager accepts messages from font conversion user-interface objects such as the Font menu or the Font panel (see NSFontPanel for more details) and appropriately converts the current font in the selection by sending a changeFont: message up the responder chain.

Based on experimentation:

2025-09-30 04:36:17.583 TextEdit[80363:100990] Begin responder enumeration:
2025-09-30 04:36:17.584 TextEdit[80363:100990] NSPanel responds to changeFont:: NO
2025-09-30 04:36:17.584 TextEdit[80363:100990] NSApplication responds to changeFont:: NO

No responder is found that could possibly respond to this message.

It's notable that there's a FIXME note at

https://github.com/gnustep/libs-gui/blob/master/Source/NSFontManager.m#L1031-L1034

In application code that invokes the panel, there is also an implementation of changeFont: implying that the original author expected the invoking object to be part of the responder chain.

  1. Should the invoking object be part of the responder chain "for free"

or

  1. Should the invoking object be required to set itself as the delegate and a code change in NSFontManager is required to try the delegate first before spray-n-praying to the responder chain?

I'm very unpracticed at ObjC/GS development, so I don't know whether the caller should be rolled into the responding chain automatically. That'd be ergonomic, but it's Magic ™️ . The latter is unmagical, reqiures one more line in application code, but is traceable and very unsurprising. It would require a small code change.

If 2 is viable, I'd be happy to submit the patch I'm using which Works for Me ™️

sgharms avatar Sep 30 '25 05:09 sgharms

I don't quite understand what the issue here is. What isn't working for you? The code that passes on the font conversion is in NSTextView (https://github.com/gnustep/libs-gui/blob/d0bcf87c91222e4f70d849fd6d7d83ac5c3fc44b/Source/NSTextView.m#L3309) And the last time I tried it worked fine. Although I must admit that was a long time ago.

fredkiefer avatar Sep 30 '25 21:09 fredkiefer

@fredkiefer

Thanks for the swift response.

Based on https://github.com/gnustep/libs-gui/blob/d0bcf87c91222e4f70d849fd6d7d83ac5c3fc44b/Source/NSTextView.m#L3501-L3522, the pattern is you get a [[NSFontManager sharedFontManager] setSelectedFont:isMultiple:]. That should summon the NSFontPanel and, upon making whatever changes and striking Set, your changeFont: method at ln 3309 should run. Assuming my read of the docs and code are correct, that's what we all should agree is happening.

As far as I can tell, that's the same pattern was what I see in TextEdit.app; however, when I compile this and run it, changeFont: is never called. Indeed an NSFontPanel pops up, but striking Set does not call the changeFont: method.

sgharms avatar Oct 01 '25 04:10 sgharms