Notifications are messages you can receive from ATS for Fonts that inform you of changes to the font database. Available starting in Mac OS X 10.2, notifications provide an efficient way for your application to keep up-to-date on font activations and deactivations.
Notifications aren’t sent to you automatically. Your application must subscribe to them and must supply a callback function to handle any notification you receive. Once you sign up to receive notifications, you never need to check the generation of the font database to track changes. You also don’t need to iterate periodically through fonts and font families to check for changes.
You can set up notifications in your application by following these steps:
Create a callback to handle the notification. Your callback can update the user interface or perform other tasks as appropriate. Your callback should look similar to the following:
static void MyNotificationCallback (ATSFontNotificationInfoRef Info, |
void * refCon) |
{ |
// Your code to handle the notification |
MyRefreshFontUserInterface (. . .); |
} ] |
Inform ATS for Fonts to send your application notifications by calling the function ATSFontNotificationSubscribe and registering the callback you created as shown in the following code:
status = ATSFontNotificationSubscribe ( |
MyNotificationCallback, |
kATSFontNotifyOptionDefault, |
NULL, // iRefCon |
¬ifyRef ); |
As of Mac OS X v10.4, the iRefCon parameter is an arbitrary 32-bit value specified by your application and that you want passed to your callback function. You can pass NULL if your callback does not need any data or if your application runs in an earlier version of Mac OS X.
When your application no longer needs to receive notifications, call the function ATSFontNotificationUnsubscribe, as follows:
status = ATSFontNotificationUnsubscribe (notifyRef); |
You must supply the notification reference you obtained when you subscribed to notifications.
Note: Subscriptions are cumulative. You must unsubscribe from each notification you subscribed to. Subscriptions are cleaned up automatically when your applications quits.
Last updated: 2007-12-11