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"?>
<!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">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>Tux Paint</string>
<key>CFBundleGetInfoString</key>
<string>0.9.19, Copyright 2008, Tux Paint Development Team</string>
<key>CFBundleIconFile</key>
<string>tuxpaint.icns</string>
<key>CFBundleIdentifier</key>
<string>com.newbreedsoftware.tuxpaint</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<key>CFBundleName</key>
<string>Tux Paint</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<key>CFBundleShortVersionString</key>
<string>0.9.19</string>
<key>CFBundleGetInfoString</key>
<string>0.9.19, Copyright 2008, Tux Paint Development Team</string>
<key>CFBundleSignature</key>
<string>TXPT</string>
<key>CFBundleVersion</key>
<string>2008-02-05</string>
<string>2008-02-21</string>
<key>NSMainNibFile</key>
<string>SDLMain</string>
<key>NSPrincipalClass</key>

View file

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

View file

@ -12,6 +12,7 @@
#include <Security/Authorization.h>
#include <Security/AuthorizationTags.h>
#include <fontconfig/fontconfig.h>
#include <stdlib.h>
#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;

View file

@ -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?