@@ -229,17 +229,68 @@ - (BOOL) installFontError: (NSError **)error
229229 return YES ;
230230}
231231
232- - (NSString *) systemFontsDirectory
232+ - (NSString *) userFontsDirectory
233233{
234- return @" /usr/local/share/fonts" ;
234+ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults ];
235+ NSString *fontsPath = [defaults stringForKey: @" GSUserFontsDirectory" ];
236+ NSString *homeDir = NSHomeDirectory ();
237+
238+ // If the default isn't set, discover it...
239+ if (fontsPath == nil )
240+ {
241+ NSProcessInfo *procInfo = [NSProcessInfo processInfo ];
242+ NSString *osName = [procInfo operatingSystemName ];
243+
244+ if ([osName isEqualToString: @" NSWindowsNTOperatingSystem" ]
245+ || [osName isEqualToString: @" NSWindows95OperatingSystem" ])
246+ {
247+ NSString *winDir = [NSString stringWithUTF8String: getenv (" USERPROFILE" )];
248+ fontsPath = [winDir stringByAppendingPathComponent: @" Fonts" ];
249+ }
250+ else if ([osName isEqualToString: @" NSMACHOperatingSystem" ])
251+ {
252+ fontsPath = [homeDir stringByAppendingPathComponent: @" Library" ];
253+ fontsPath = [fontsPath stringByAppendingPathComponent: @" Fonts" ];
254+ }
255+ else // Assume linux/unix
256+ {
257+ fontsPath = [homeDir stringByAppendingPathComponent: @" .fonts" ];
258+ }
259+ }
260+
261+ return fontsPath;
262+
235263}
236264
237- - (NSString *) userFontsDirectory
265+ - (NSString *) systemFontsDirectory
238266{
239- NSString *homeDir = NSHomeDirectory ();
267+ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults ];
268+ NSString *fontsPath = [defaults stringForKey: @" GSSystemFontsDirectory" ];
269+
270+ // If the default isn't set, discover it...
271+ if (fontsPath == nil )
272+ {
273+ NSProcessInfo *procInfo = [NSProcessInfo processInfo ];
274+ NSString *osName = [procInfo operatingSystemName ];
275+
276+ if ([osName isEqualToString: @" NSWindowsNTOperatingSystem" ]
277+ || [osName isEqualToString: @" NSWindows95OperatingSystem" ])
278+ {
279+ NSString *winDir = [NSString stringWithUTF8String: getenv (" WINDIR" )];
280+ fontsPath = [winDir stringByAppendingPathComponent: @" Fonts" ];
281+ }
282+ else if ([osName isEqualToString: @" NSMACHOperatingSystem" ])
283+ {
284+ fontsPath = @" /Library/Fonts" ;
285+ }
286+ else // Assume linux/unix
287+ {
288+ fontsPath = @" /usr/local/share/fonts" ;
289+ }
290+ }
291+
292+ return fontsPath;
240293
241- // Generic Unix/other systems
242- return [homeDir stringByAppendingPathComponent: @" .fonts" ];
243294}
244295
245296@end
0 commit comments