From fb351db5f5752bcc4821c09845408ba4e710bb70 Mon Sep 17 00:00:00 2001 From: Martin Fuhrer Date: Wed, 20 Feb 2008 05:32:21 +0000 Subject: [PATCH] Mac OS X updates: Force Fontconfig to build font cache prior to splashscreen. Remove requirement for an administrator password/account by referencing fonts.conf file from application bundle rather than copying the file to '/Library/Application Support/TuxPaint' --- macosx/Info.plist | 12 ++++++------ macosx/SDLMain.h | 2 +- macosx/SDLMain.m | 46 +++++++++++++++++++++++++------------------- macosx/wrapperdata.h | 1 - 4 files changed, 33 insertions(+), 28 deletions(-) diff --git a/macosx/Info.plist b/macosx/Info.plist index ccb68a950..d05e60fcf 100644 --- a/macosx/Info.plist +++ b/macosx/Info.plist @@ -1,29 +1,29 @@ - + CFBundleDevelopmentRegion English CFBundleExecutable Tux Paint + CFBundleGetInfoString + 0.9.19, Copyright 2008, Tux Paint Development Team CFBundleIconFile tuxpaint.icns CFBundleIdentifier com.newbreedsoftware.tuxpaint CFBundleInfoDictionaryVersion 6.0 - CFBundleName + CFBundleName Tux Paint CFBundlePackageType APPL - CFBundleShortVersionString + CFBundleShortVersionString 0.9.19 - CFBundleGetInfoString - 0.9.19, Copyright 2008, Tux Paint Development Team CFBundleSignature TXPT CFBundleVersion - 2008-02-05 + 2008-02-21 NSMainNibFile SDLMain NSPrincipalClass diff --git a/macosx/SDLMain.h b/macosx/SDLMain.h index ae2284fb5..2cfb43ac4 100755 --- a/macosx/SDLMain.h +++ b/macosx/SDLMain.h @@ -14,7 +14,7 @@ @interface SDLMain : NSObject { - IBOutlet NSPanel *messagePanel; + IBOutlet NSWindow *messagePanel; IBOutlet NSTextField *messageText; IBOutlet NSTextField *messageStatus; IBOutlet NSProgressIndicator *messageProgress; diff --git a/macosx/SDLMain.m b/macosx/SDLMain.m index e4b759251..8fad05cda 100644 --- a/macosx/SDLMain.m +++ b/macosx/SDLMain.m @@ -12,6 +12,7 @@ #include #include +#include #include #import "macosx_print.h" @@ -142,7 +143,7 @@ static NSString *getApplicationName(void) path = @"/Library/Application Support/TuxPaint"; [path getCString:(macosx.globalPreferencesPath)]; - } +} -(void) fontsPath; { @@ -487,11 +488,9 @@ static void CustomApplicationMain (argc, argv) NSString *arguments = [NSString stringWithCString:(macosx.globalPreferencesPath)]; char command[4096]; - sprintf(command, "\"%s\" \"%s\"", [executable cStringUsingEncoding:NSASCIIStringEncoding], [arguments cStringUsingEncoding:NSASCIIStringEncoding]); + sprintf(command, "\"%s\" \"%s\"", [executable cString], [arguments cString]); - //displayMessage(MSG_FONT_CACHE); int result = system(command); - //hideMessage(); return (BOOL)result; } @@ -521,12 +520,10 @@ static void CustomApplicationMain (argc, argv) char *arguments[] = { "/Library/Application Support/TuxPaint", NULL }; FILE *communicationsPipe = NULL; - strcpy(executable, [fcInstallerPath cStringUsingEncoding:NSASCIIStringEncoding]); + strcpy(executable, [fcInstallerPath cString]); flags = kAuthorizationFlagDefaults; - //displayMessage(MSG_FONT_CACHE); status = AuthorizationExecuteWithPrivileges(authorizationRef, executable, flags, arguments, &communicationsPipe); - //hideMessage(); } AuthorizationFree(authorizationRef, kAuthorizationFlagDefaults); @@ -546,13 +543,15 @@ static void CustomApplicationMain (argc, argv) return filesExist; } -/* Install files required by Fontconfig */ -- (void) installFontconfig +/* Set up Fontconfig */ +- (void) setupFontconfig { - NSFileManager *fileManager = [NSFileManager defaultManager]; - BOOL filesExist = TRUE; + /* Tell Fontconfig to use font configuration file in application bundle */ + setenv ("FONTCONFIG_PATH", [[[NSBundle mainBundle] resourcePath] cString], 1); - filesExist = [self fontconfigFilesAreInstalled]; + /* Install font configuration file */ + /* + BOOL filesExist = [self fontconfigFilesAreInstalled]; if (!filesExist) { [self installFontconfigFiles]; @@ -565,14 +564,21 @@ static void CustomApplicationMain (argc, argv) exit(-1); } } - + */ + + /* Determine if Fontconfig cache needs to be built */ NSString *globalPreferencesPath = [NSString stringWithCString:(macosx.globalPreferencesPath)]; NSString *globalCachePath = [globalPreferencesPath stringByAppendingString:@"/fontconfig/cache"]; NSString *userCachePath = [[NSString stringWithString:@"~/.fontconfig"] stringByExpandingTildeInPath]; - if ([fileManager fileExistsAtPath:globalCachePath] || [fileManager fileExistsAtPath:userCachePath]) - macosx.buildingFontCache = 0; - else - macosx.buildingFontCache = 1; + + NSFileManager *fileManager = [NSFileManager defaultManager]; + if (![fileManager fileExistsAtPath:globalCachePath] && ![fileManager fileExistsAtPath:userCachePath]) + { + /* Build Fontconfig cache */ + displayMessage( MSG_FONT_CACHE ); + FcBool initSuccess = FcInit(); + hideMessage(); + } } /* @@ -634,6 +640,7 @@ static void CustomApplicationMain (argc, argv) - (void) applicationDidFinishLaunching: (NSNotification *) note { int status; + sdlMain = self; /* Allow Cocoa events to be processed */ setenv ("SDL_ENABLEAPPEVENTS", "1", 1); @@ -641,8 +648,8 @@ static void CustomApplicationMain (argc, argv) /* Set up Cocoa to SDL bridge */ [self setupBridge]; - /* Install any files required by fontconfig */ - [self installFontconfig]; + /* Set up Fontconfig */ + [self setupFontconfig]; /* Set the working directory to the .app's parent directory */ [self setupWorkingDirectory:gFinderLaunch]; @@ -651,7 +658,6 @@ static void CustomApplicationMain (argc, argv) /* Set the main menu to contain the real app name instead of "SDL App" */ [self fixMenu:[NSApp mainMenu] withAppName:getApplicationName()]; #endif - sdlMain = self; /* Hand off to main application code */ gCalledAppMainline = TRUE; diff --git a/macosx/wrapperdata.h b/macosx/wrapperdata.h index 1809a1368..c9050f2d3 100644 --- a/macosx/wrapperdata.h +++ b/macosx/wrapperdata.h @@ -18,7 +18,6 @@ struct WrapperDataStruct char preferencesPath[2048]; // path to the user's Tux Paint preferences folder char globalPreferencesPath[2048]; // path to all users' Tux Paint preferences folder char fontsPath[2048]; // path to the user's fonts folder - int buildingFontCache; // is fontconfig cache being built? int foundSDL; // was SDL.framework found? int foundSDL_image; // was SDL_image.framework found? int foundSDL_mixer; // was SDL_mixer.framework found?