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'

This commit is contained in:
Martin Fuhrer 2008-02-20 05:32:21 +00:00
parent c546a9756e
commit fb351db5f5
4 changed files with 33 additions and 28 deletions

View file

@ -1,29 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>English</string> <string>English</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>Tux Paint</string> <string>Tux Paint</string>
<key>CFBundleGetInfoString</key>
<string>0.9.19, Copyright 2008, Tux Paint Development Team</string>
<key>CFBundleIconFile</key> <key>CFBundleIconFile</key>
<string>tuxpaint.icns</string> <string>tuxpaint.icns</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>com.newbreedsoftware.tuxpaint</string> <string>com.newbreedsoftware.tuxpaint</string>
<key>CFBundleInfoDictionaryVersion</key> <key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string> <string>6.0</string>
<key>CFBundleName</key> <key>CFBundleName</key>
<string>Tux Paint</string> <string>Tux Paint</string>
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>0.9.19</string> <string>0.9.19</string>
<key>CFBundleGetInfoString</key>
<string>0.9.19, Copyright 2008, Tux Paint Development Team</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>TXPT</string> <string>TXPT</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>2008-02-05</string> <string>2008-02-21</string>
<key>NSMainNibFile</key> <key>NSMainNibFile</key>
<string>SDLMain</string> <string>SDLMain</string>
<key>NSPrincipalClass</key> <key>NSPrincipalClass</key>

View file

@ -14,7 +14,7 @@
@interface SDLMain : NSObject @interface SDLMain : NSObject
{ {
IBOutlet NSPanel *messagePanel; IBOutlet NSWindow *messagePanel;
IBOutlet NSTextField *messageText; IBOutlet NSTextField *messageText;
IBOutlet NSTextField *messageStatus; IBOutlet NSTextField *messageStatus;
IBOutlet NSProgressIndicator *messageProgress; IBOutlet NSProgressIndicator *messageProgress;

View file

@ -12,6 +12,7 @@
#include <Security/Authorization.h> #include <Security/Authorization.h>
#include <Security/AuthorizationTags.h> #include <Security/AuthorizationTags.h>
#include <fontconfig/fontconfig.h>
#include <stdlib.h> #include <stdlib.h>
#import "macosx_print.h" #import "macosx_print.h"
@ -142,7 +143,7 @@ static NSString *getApplicationName(void)
path = @"/Library/Application Support/TuxPaint"; path = @"/Library/Application Support/TuxPaint";
[path getCString:(macosx.globalPreferencesPath)]; [path getCString:(macosx.globalPreferencesPath)];
} }
-(void) fontsPath; -(void) fontsPath;
{ {
@ -487,11 +488,9 @@ static void CustomApplicationMain (argc, argv)
NSString *arguments = [NSString stringWithCString:(macosx.globalPreferencesPath)]; NSString *arguments = [NSString stringWithCString:(macosx.globalPreferencesPath)];
char command[4096]; 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); int result = system(command);
//hideMessage();
return (BOOL)result; return (BOOL)result;
} }
@ -521,12 +520,10 @@ static void CustomApplicationMain (argc, argv)
char *arguments[] = { "/Library/Application Support/TuxPaint", NULL }; char *arguments[] = { "/Library/Application Support/TuxPaint", NULL };
FILE *communicationsPipe = NULL; FILE *communicationsPipe = NULL;
strcpy(executable, [fcInstallerPath cStringUsingEncoding:NSASCIIStringEncoding]); strcpy(executable, [fcInstallerPath cString]);
flags = kAuthorizationFlagDefaults; flags = kAuthorizationFlagDefaults;
//displayMessage(MSG_FONT_CACHE);
status = AuthorizationExecuteWithPrivileges(authorizationRef, executable, flags, arguments, &communicationsPipe); status = AuthorizationExecuteWithPrivileges(authorizationRef, executable, flags, arguments, &communicationsPipe);
//hideMessage();
} }
AuthorizationFree(authorizationRef, kAuthorizationFlagDefaults); AuthorizationFree(authorizationRef, kAuthorizationFlagDefaults);
@ -546,13 +543,15 @@ static void CustomApplicationMain (argc, argv)
return filesExist; return filesExist;
} }
/* Install files required by Fontconfig */ /* Set up Fontconfig */
- (void) installFontconfig - (void) setupFontconfig
{ {
NSFileManager *fileManager = [NSFileManager defaultManager]; /* Tell Fontconfig to use font configuration file in application bundle */
BOOL filesExist = TRUE; setenv ("FONTCONFIG_PATH", [[[NSBundle mainBundle] resourcePath] cString], 1);
filesExist = [self fontconfigFilesAreInstalled]; /* Install font configuration file */
/*
BOOL filesExist = [self fontconfigFilesAreInstalled];
if (!filesExist) if (!filesExist)
{ {
[self installFontconfigFiles]; [self installFontconfigFiles];
@ -565,14 +564,21 @@ static void CustomApplicationMain (argc, argv)
exit(-1); exit(-1);
} }
} }
*/
/* Determine if Fontconfig cache needs to be built */
NSString *globalPreferencesPath = [NSString stringWithCString:(macosx.globalPreferencesPath)]; NSString *globalPreferencesPath = [NSString stringWithCString:(macosx.globalPreferencesPath)];
NSString *globalCachePath = [globalPreferencesPath stringByAppendingString:@"/fontconfig/cache"]; NSString *globalCachePath = [globalPreferencesPath stringByAppendingString:@"/fontconfig/cache"];
NSString *userCachePath = [[NSString stringWithString:@"~/.fontconfig"] stringByExpandingTildeInPath]; NSString *userCachePath = [[NSString stringWithString:@"~/.fontconfig"] stringByExpandingTildeInPath];
if ([fileManager fileExistsAtPath:globalCachePath] || [fileManager fileExistsAtPath:userCachePath])
macosx.buildingFontCache = 0; NSFileManager *fileManager = [NSFileManager defaultManager];
else if (![fileManager fileExistsAtPath:globalCachePath] && ![fileManager fileExistsAtPath:userCachePath])
macosx.buildingFontCache = 1; {
/* Build Fontconfig cache */
displayMessage( MSG_FONT_CACHE );
FcBool initSuccess = FcInit();
hideMessage();
}
} }
/* /*
@ -634,6 +640,7 @@ static void CustomApplicationMain (argc, argv)
- (void) applicationDidFinishLaunching: (NSNotification *) note - (void) applicationDidFinishLaunching: (NSNotification *) note
{ {
int status; int status;
sdlMain = self;
/* Allow Cocoa events to be processed */ /* Allow Cocoa events to be processed */
setenv ("SDL_ENABLEAPPEVENTS", "1", 1); setenv ("SDL_ENABLEAPPEVENTS", "1", 1);
@ -641,8 +648,8 @@ static void CustomApplicationMain (argc, argv)
/* Set up Cocoa to SDL bridge */ /* Set up Cocoa to SDL bridge */
[self setupBridge]; [self setupBridge];
/* Install any files required by fontconfig */ /* Set up Fontconfig */
[self installFontconfig]; [self setupFontconfig];
/* Set the working directory to the .app's parent directory */ /* Set the working directory to the .app's parent directory */
[self setupWorkingDirectory:gFinderLaunch]; [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" */ /* Set the main menu to contain the real app name instead of "SDL App" */
[self fixMenu:[NSApp mainMenu] withAppName:getApplicationName()]; [self fixMenu:[NSApp mainMenu] withAppName:getApplicationName()];
#endif #endif
sdlMain = self;
/* Hand off to main application code */ /* Hand off to main application code */
gCalledAppMainline = TRUE; gCalledAppMainline = TRUE;

View file

@ -18,7 +18,6 @@ struct WrapperDataStruct
char preferencesPath[2048]; // path to the user's Tux Paint preferences folder char preferencesPath[2048]; // path to the user's Tux Paint preferences folder
char globalPreferencesPath[2048]; // path to all users' 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 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; // was SDL.framework found?
int foundSDL_image; // was SDL_image.framework found? int foundSDL_image; // was SDL_image.framework found?
int foundSDL_mixer; // was SDL_mixer.framework found? int foundSDL_mixer; // was SDL_mixer.framework found?