From http://www.jwz.org/xscreensaver/xscreensaver-5.39.tar.gz
[xscreensaver] / driver / splash.c
index 38381e06a2ac0407c57428070a55f97d2dbd33f4..a4f17616e4b46ba0d271bdd7f9d9bbe67f597317 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1991-2017 Jamie Zawinski <jwz@netscape.com>
+/* xscreensaver, Copyright (c) 1991-2018 Jamie Zawinski <jwz@jwz.org>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -17,6 +17,7 @@
 
 #include "xscreensaver.h"
 #include "resources.h"
+#include "font-retry.h"
 
 #undef MAX
 #define MAX(a,b) ((a)>(b)?(a):(b))
@@ -103,6 +104,19 @@ static void do_prefs (saver_screen_info *ssi);
 static void do_help (saver_screen_info *ssi);
 
 
+XFontStruct *
+splash_load_font (Display *dpy, char *name, char *class)
+{
+  char *s = get_string_resource (dpy, name, class);
+  XFontStruct *f;
+  if (!s || !*s)
+    s = "-*-helvetica-bold-r-*-*-*-140-*-*-*-*-*-*";
+  f = load_font_retry (dpy, s);
+  if (!f) abort();
+  return f;
+}
+
+
 struct splash_dialog_data {
 
   saver_screen_info *prompt_screen;
@@ -165,11 +179,10 @@ make_splash_dialog (saver_info *si)
   splash_dialog_data *sp;
   saver_screen_info *ssi;
   Colormap cmap;
-  char *f;
 
-  Bool whine = decrepit_p ();
+  Bool whyne = senesculent_p ();
 
-  if (whine)
+  if (whyne)
     {
       /* If locking is not enabled, make sure they see the message. */
       if (!p->lock_p)
@@ -220,7 +233,7 @@ make_splash_dialog (saver_info *si)
 
 
 
-  if (whine)
+  if (whyne)
     {
       sp->body3_label = strdup("WARNING: This version is very old!");
       sp->body4_label = strdup("Please upgrade!");
@@ -246,20 +259,12 @@ make_splash_dialog (saver_info *si)
     sp->heading_label = s;
   }
 
-  f = get_string_resource (si->dpy, "splash.headingFont", "Dialog.Font");
-  sp->heading_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
-  if (!sp->heading_font) sp->heading_font = XLoadQueryFont (si->dpy, "fixed");
-  if (f) free (f);
-
-  f = get_string_resource(si->dpy, "splash.bodyFont", "Dialog.Font");
-  sp->body_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
-  if (!sp->body_font) sp->body_font = XLoadQueryFont (si->dpy, "fixed");
-  if (f) free (f);
-
-  f = get_string_resource(si->dpy, "splash.buttonFont", "Dialog.Font");
-  sp->button_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
-  if (!sp->button_font) sp->button_font = XLoadQueryFont (si->dpy, "fixed");
-  if (f) free (f);
+  sp->heading_font =
+    splash_load_font (si->dpy, "splash.headingFont", "Dialog.Font");
+  sp->body_font =
+    splash_load_font (si->dpy, "splash.bodyFont", "Dialog.Font");
+  sp->button_font =
+    splash_load_font (si->dpy, "splash.buttonFont", "Dialog.Font");
 
   sp->foreground = get_pixel_resource (si->dpy, cmap,
                                        "splash.foreground",