cocoadelegatesfilteringnsfontmanager

Filtering Fonts from NSFontPanel?


According to the documentation, you should set an <NSFontManagerDelegate> to the shared instance of NSFontManager. The delegate should implement a method

- (BOOL) fontManager:(id)sender willIncludeFont:(NSString *)fontName;

which will then be called repeatedly. Unfortunately, there is no documentation of <NSFontManagerDelegate> available, and in fact the protocol is missing. All the same, I created an instance of NSObject that implements the method mentioned above, and set it as a delegate of NSFontManager. Unfortunately, the method is never called. After some googling, I learned that fontManager:willIncludeFont: is deprecated since OS X 10.3.

Is there any alternative? What should I do if my application only supports mono-spaced fonts?


Solution

  • subclass NSFontManager, override - (NSArray *)collectionNames, return a list of font collections.[1]