X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=OSX%2Fjwxyz.m;h=e96e03b183603db11761344de4a113852fea8dbd;hp=604caf50dafb066ea1689f4172250918790aed2d;hb=5f9c47ca98dd43d8f59b7c27d3fde6edfde4fe21;hpb=50be9bb40dc60130c99ffa568e6677779904ff70 diff --git a/OSX/jwxyz.m b/OSX/jwxyz.m index 604caf50..e96e03b1 100644 --- a/OSX/jwxyz.m +++ b/OSX/jwxyz.m @@ -2418,8 +2418,21 @@ XLoadFont (Display *dpy, const char *name) Font fid = (Font) calloc (1, sizeof(*fid)); fid->nsfont = try_native_font (name, &fid->ps_name, &fid->size); + + if (!fid->nsfont && name && + strchr (name, ' ') && + !strchr (name, '*')) { + // If name contains a space but no stars, it is a native font spec -- + // return NULL so that we know it really didn't exist. Else, it is an + // XLFD font, so keep trying. + XUnloadFont (dpy, fid); + return 0; + } + if (! fid->nsfont) fid->nsfont = try_xlfd_font (name, &fid->ps_name, &fid->size); + + // We should never return NULL for XLFD fonts. if (!fid->nsfont) { NSLog(@"no NSFont for \"%s\"", name); abort(); @@ -2438,14 +2451,17 @@ XFontStruct * XLoadQueryFont (Display *dpy, const char *name) { Font fid = XLoadFont (dpy, name); + if (!fid) return 0; return XQueryFont (dpy, fid); } int XUnloadFont (Display *dpy, Font fid) { - free (fid->ps_name); - free (fid->metrics.per_char); + if (fid->ps_name) + free (fid->ps_name); + if (fid->metrics.per_char) + free (fid->metrics.per_char); // #### DAMMIT! I can't tell what's going wrong here, but I keep getting // crashes in [NSFont ascender] <- query_font, and it seems to go away