FontShop

Celebrating 20 years!

Log In

  1. Fonts
  2. Blog
  3. Help

FontCase Developers

Writing plug-ins for FontCase

FontCase can be extended with user-written plug-ins very easily. Plugins need to be written in Cocoa and are intended to act upon the current selection (although they could do significantly more if you wish to). And what's more, you can get a free license key to FontCase if you write a plug-in. This document will explain how FontCase is structured and what tools you can use to interact with FontCase' data. Every plug-in is intended to perform one action which can be invoked through the Fonts or Tools menu:

Cocoa and other Frameworks

As noted above, plug-ins need to be written in Cocoa so you should at least be familiar with it. Also, FontCase uses Apple's robust Core Data-framework to manage the data and any plug-in will have to deal with this, so familiarity with this would also be a helpful. Note that a FontCase plug-in gives you a lot of power so if you don't know what you're doing, you might end up corrupting the users' database. That said, FontCase provides a few helper methods which should make interacting with the data peanuts.

Tutorial: Creating a basic Plug-in

As noted above, plug-ins need to be written in Cocoa so you should at least be familiar with it. Also, FontCase uses Apple's robust Core Data-framework to manage the data and any plug-in will have to deal with this, so familiarity with this would also be a helpful. Note that a FontCase plug-in gives you a lot of power so if you don't know what you're doing, you might end up corrupting the users' database. That said, FontCase provides a few helper methods which should make interacting with the data peanuts.
You need to have Xcode Tools installed and you should be familiar with them, or this will probably go too fast for you.

  • Start out with a new project and chooose Bundle -> Cocoa Bundle.
  • Import the FontCasePluginKit-framework (click to download) but do not copy the items to the destination folder
  • Then create a new class, import the FontCasePluginKit and make it a subclass of FCActionPlugin:
FCActionPlugin:
#import
#import

@interface SomePlugin : FCActionPlugin
{

}
@end
  • Then go to the implementation file and overwrite (some of) these methods:
- (NSString *)displayName;
- (NSString *)keyEquivalent;
- (NSString *)keyEquivalentModifierMask;
- (int)displayMenuPosition;
- (IBAction)performActionOnFonts:(NSArray *)variations
       context:(NSManagedObjectContext *)context;
  • Then go to the implementation file and overwrite (some of) these methods:
  • You need to overwrite the -displayName method, this is the name that will show up in the fonts-menu, so return something that makes sense.
  • . If you want to provide a shortcut for your action, overwrite keyEquivalent and keyEquivalentModifierMask but if not, you don't have to overwrite these methods.
  • The performActionOnFonts:context will be called whenever a user clicks your menu-item. The variations-argument are the variations the user had selected when they clicked your action and the context-argument is the central managedObjectContext you can use to add new entities such as tags, designers, collections and foundries. FontCase declares a very handy category on NSManagedObjectContext so that might be handy for you. Take a look at the Adding new entities-page for the header.
  • If you're making big changes, you might want to update the interface. You can call the -sendUpdate method of FCActionPlugin.
  • If you want your plugin to appear in the 'Tools' menu instead of the 'Fonts' menu, overwrite - (int)displayMenuPosition and return FCDisplayInToolsMenu instead.
  • If your plugin contains more than one class you'll have to provide a principal-class in the info.plist
  • For FontCase to recognise your plugin as a FontCase-plugin,select the target in the sourcelist, press cmd+I, search for Extension and change the 'Wrapper Extension' from 'bundle' to 'fcplugin'.