-
-void addFontResources()
-{
-#ifdef __APPLE__
- CFBundleRef myAppBundle = CFBundleGetMainBundle();
- CFURLRef myAppResourcesURL, FontsURL;
- FSRef fontDirRef;
- FSSpec fontDirSpec;
- CFStringRef filePath = CFStringCreateWithBytes(kCFAllocatorDefault,
- (UInt8 *) "fonts", strlen("fonts"),
- kCFStringEncodingISOLatin1, false);
-
- myAppResourcesURL = CFBundleCopyResourcesDirectoryURL(myAppBundle);
- FontsURL = CFURLCreateCopyAppendingPathComponent(kCFAllocatorDefault,
- myAppResourcesURL, filePath, true);
- if (lyxerr.debugging(Debug::FONT)) {
- UInt8 buf[255];
- if (CFURLGetFileSystemRepresentation(FontsURL, true, buf, 255))
- lyxerr << "Adding Fonts directory: " << buf << endl;
- }
- CFURLGetFSRef (FontsURL, &fontDirRef);
- OSStatus err = FSGetCatalogInfo (&fontDirRef, kFSCatInfoNone,
- NULL, NULL, &fontDirSpec, NULL);
- if (err)
- lyxerr << "FSGetCatalogInfo err = " << err << endl;
- err = FMActivateFonts (&fontDirSpec, NULL, NULL,
- kFMLocalActivationContext);
- if (err)
- lyxerr << "FMActivateFonts err = " << err << endl;
-#elif defined(HAVE_FONTCONFIG_FONTCONFIG_H)
- // Register BaKoMa truetype fonts with fontconfig
- string const fonts_dir =
- addPath(package().system_support().absFilename(), "fonts");
- if (!FcConfigAppFontAddDir(0, (FcChar8 const *)fonts_dir.c_str()))
- lyxerr << "Unable to register fonts with fontconfig." << endl;
-#endif
-}
-
-
-void restoreFontResources()
-{
-#if defined(HAVE_FONTCONFIG_FONTCONFIG_H) && !defined(__APPLE__)
- FcConfigAppFontClear(0);
-#endif
-}
-