Standardize cache name to handle new Mac OS X display names

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@26530 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fedor 2008-05-16 17:14:30 +00:00
parent 5f24b337b5
commit 9bbb15310f
5 changed files with 33 additions and 10 deletions

View file

@ -1,3 +1,10 @@
2008-05-16 Adam Fedor <fedor@gnu.org>
* Source/XGCommonFont.m (XGFontCacheName): New function to standardize
display name (and handle new Mac OS X display names).
* Tools/font_cacher.m ([XFontCacher -getPathFor:display]): Use it.
* Source/xlib/XGFontManager.m (cache_name): Use it.
2008-04-11 Fred Kiefer <FredKiefer@gmx.de>
* Source/xlib/GSXftFontInfo.m (Ones): Correct the parameter name.

View file

@ -42,6 +42,7 @@
extern NSString *XGXFontName(NSString *fontName, float size);
/* Font functions (defined in XGCommonFont) */
extern NSString *XGFontCacheName(Display *dpy);
extern NSString *XGFontName(Display *dpy, XFontStruct *font_struct);
extern NSString *XGFontFamily(Display *dpy, XFontStruct *font_struct);
extern float XGFontPointSize(Display *dpy, XFontStruct *font_struct);

View file

@ -93,6 +93,26 @@ static BOOL XGInitAtoms(Display *dpy)
return YES;
}
/*
* Return the name of the font cache file (used by font_cacher to write
* the file and the backend to read the file
*/
extern NSString *XGFontCacheName(Display *dpy)
{
NSString *dname;
dname = [NSString stringWithCString: XDisplayName(NULL)];
if ([dname hasPrefix: @"/tmp"])
{
/* This is the new Mac OS X display server information, not a real
host name. Use a more file-friendly name for the display */
NSString *str = [dname lastPathComponent];
dname = [dname stringByDeletingLastPathComponent];
dname = [NSString stringWithFormat: @"%@%@",
[dname lastPathComponent], str];
}
return dname;
}
/*
* Read an X Font property of type unsigned long
*/

View file

@ -76,12 +76,11 @@ cache_name()
NSFileManager *mgr;
BOOL flag;
Display *dpy = [XGServer currentXDisplay];
char *display_name = DisplayString(dpy);
NSString *file_name;
NSArray *paths;
NSString *path = nil;
file_name = [NSString stringWithCString: XDisplayName(display_name)];
file_name = XGFontCacheName(dpy);
paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,
NSUserDomainMask, YES);

View file

@ -163,23 +163,19 @@
NSArray *paths;
NSFileManager *mgr;
NSString *path;
const char *display_name;
BOOL flag;
if (display != nil)
display_name = [display cString];
dpy = XOpenDisplay([display cString]);
else
{
display = [NSString stringWithCString: XDisplayName(0)];
display_name = NULL;
}
dpy = XOpenDisplay(display_name);
dpy = XOpenDisplay(NULL);
if (dpy == 0)
{
NSLog(@"Unable to open X display - no font information available");
return nil;
}
/* Standardize the name */
display = XGFontCacheName(dpy);
paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,
NSUserDomainMask, YES);