X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fmemscroller.c;h=e3940f8e54158d6932281d41e3ed72d76c8aa4f7;hb=5f9c47ca98dd43d8f59b7c27d3fde6edfde4fe21;hp=2435c2f5b94e58a15267908dab7898034d151498;hpb=6b1c86cf395f59389e4ece4ea8f4bea2c332745b;p=xscreensaver diff --git a/hacks/memscroller.c b/hacks/memscroller.c index 2435c2f5..e3940f8e 100644 --- a/hacks/memscroller.c +++ b/hacks/memscroller.c @@ -38,7 +38,7 @@ typedef struct { Window window; XWindowAttributes xgwa; GC draw_gc, erase_gc, text_gc; - XFontStruct *fonts[4]; + XFontStruct *fonts[6]; int border; enum { SEED_RAM, SEED_RANDOM, SEED_FILE } seed_mode; @@ -97,14 +97,31 @@ memscroller_init (Display *dpy, Window window) char res[20]; sprintf (res, "font%d", i+1); fontname = get_string_resource (dpy, res, "Font"); - st->fonts[i] = XLoadQueryFont (dpy, fontname); - if (!st->fonts[i] && i < nfonts-1) + /* Each resource can be a comma-separated list of font names. + We use the first one that exists. */ + if (fontname && *fontname) { - fprintf (stderr, "%s: unable to load font: \"%s\"\n", - progname, fontname); - st->fonts[i] = st->fonts[i+1]; + char *f2 = strdup(fontname); + char *f, *token = f2; + while ((f = strtok(token, ",")) && !st->fonts[i]) + { + token = 0; + while (*f == ' ' || *f == '\t') f++; + st->fonts[i] = XLoadQueryFont (dpy, f); + } + free (f2); + if (!st->fonts[i] && i < nfonts-1) + { + fprintf (stderr, "%s: unable to load font: \"%s\"\n", + progname, fontname); + st->fonts[i] = st->fonts[i+1]; + } } } + + if (!st->fonts[0]) + st->fonts[0] = XLoadQueryFont (dpy, "fixed"); + if (!st->fonts[0]) { fprintf (stderr, "%s: unable to load any fonts!", progname); @@ -483,7 +500,7 @@ draw_string (state *st) x = (st->xgwa.width - w) / 2; y = (bot - h) / 2; - if (y + h + 10 <= bot) + if (y + h + 10 <= bot && x > -10) { XSetFont (st->dpy, st->text_gc, st->fonts[i]->fid); XFillRectangle (st->dpy, st->window, st->erase_gc, @@ -580,14 +597,29 @@ memscroller_free (Display *dpy, Window window, void *closure) static const char *memscroller_defaults [] = { ".background: black", "*drawMode: color", + "*fpsSolid: true", + "*fpsTop: true", "*filename: (RAM)", ".textColor: #00FF00", ".foreground: #00FF00", "*borderSize: 2", - ".font1: -*-courier-bold-r-*-*-*-1400-*-*-m-*-*-*", - ".font2: -*-courier-bold-r-*-*-*-600-*-*-m-*-*-*", - ".font3: -*-courier-bold-r-*-*-*-180-*-*-m-*-*-*", - ".font4: fixed", + +#ifdef HAVE_COCOA + ".font1: OCR A Std 192, Lucida Console 192", + ".font2: OCR A Std 144, Lucida Console 144", + ".font3: OCR A Std 128, Lucida Console 128", + ".font4: OCR A Std 96, Lucida Console 96", + ".font5: OCR A Std 48, Lucida Console 48", + ".font6: OCR A Std 24, Lucida Console 24", +#else /* !HAVE_COCOA */ + ".font1: -*-courier-bold-r-*-*-*-1440-*-*-m-*-*-*", + ".font2: -*-courier-bold-r-*-*-*-960-*-*-m-*-*-*", + ".font3: -*-courier-bold-r-*-*-*-480-*-*-m-*-*-*", + ".font4: -*-courier-bold-r-*-*-*-320-*-*-m-*-*-*", + ".font5: -*-courier-bold-r-*-*-*-180-*-*-m-*-*-*", + ".font6: fixed", +#endif /* !HAVE_COCOA */ + "*delay: 10000", "*offset: 0", 0