summaryrefslogtreecommitdiffstats
path: root/utils/font-retry.c
diff options
context:
space:
mode:
authorSimon Rettberg2019-02-18 11:55:41 +0100
committerSimon Rettberg2019-02-18 11:55:41 +0100
commitae69a754244c4e475c8d2591772ca8e005071d83 (patch)
tree58b3fa7abc2dcfe3c23e1c0ce108950c720826ab /utils/font-retry.c
parentUpdate gitignore (diff)
downloadxscreensaver-ae69a754244c4e475c8d2591772ca8e005071d83.tar.gz
xscreensaver-ae69a754244c4e475c8d2591772ca8e005071d83.tar.xz
xscreensaver-ae69a754244c4e475c8d2591772ca8e005071d83.zip
Update to 5.42
Diffstat (limited to 'utils/font-retry.c')
-rw-r--r--utils/font-retry.c43
1 files changed, 30 insertions, 13 deletions
diff --git a/utils/font-retry.c b/utils/font-retry.c
index c3e91a0..ab999e2 100644
--- a/utils/font-retry.c
+++ b/utils/font-retry.c
@@ -25,19 +25,21 @@ extern const char *progname;
#undef countof
#define countof(x) (sizeof((x))/sizeof((*x)))
+#undef DEBUG
+
static void *
load_font_retry_1 (Display *dpy, int screen, const char *xlfd, Bool xft_p)
{
# ifdef USE_XFT
-# define LOADFONT() (xft_p \
- ? (void *) XftFontOpenXlfd (dpy, screen, xlfd) \
- : (void *) XLoadQueryFont (dpy, xlfd))
+# define LOADFONT(F) (xft_p \
+ ? (void *) XftFontOpenXlfd (dpy, screen, (F)) \
+ : (void *) XLoadQueryFont (dpy, (F)))
# else
-# define LOADFONT() ((void *) XLoadQueryFont (dpy, xlfd))
+# define LOADFONT(F) ((void *) XLoadQueryFont (dpy, (F)))
# endif
- void *f = LOADFONT();
+ void *f = xlfd ? LOADFONT(xlfd) : 0;
# ifndef USE_XFT
if (xft_p) abort();
@@ -46,11 +48,18 @@ load_font_retry_1 (Display *dpy, int screen, const char *xlfd, Bool xft_p)
# ifdef HAVE_JWXYZ
return f;
# else /* !HAVE_JWXYZ */
+ if (! xlfd) xlfd = "<null>";
if (f)
- return f;
+ {
+# ifdef DEBUG
+ fprintf (stderr, "%s: loaded %s\n", progname, xlfd);
+# endif
+ return f;
+ }
else
{
- Bool bold_p = (!!strcasestr (xlfd, "-bold-"));
+ Bool bold_p = (!!strcasestr (xlfd, "-bold-") ||
+ !!strcasestr (xlfd, "-ocr"));
Bool italic_p = (!!strcasestr (xlfd, "-i-") ||
!!strcasestr (xlfd, "-o-"));
Bool fixed_p = (!!strcasestr (xlfd, "courier") ||
@@ -59,6 +68,10 @@ load_font_retry_1 (Display *dpy, int screen, const char *xlfd, Bool xft_p)
!!strcasestr (xlfd, "-c-"));
int size = 0;
+# ifdef DEBUG
+ fprintf (stderr, "%s: failed %s\n", progname, xlfd);
+# endif
+
if (!strcmp (xlfd, "vga")) /* BSOD uses this: it has no XLFD name. */
fixed_p = True, size = 120;
@@ -90,7 +103,7 @@ load_font_retry_1 (Display *dpy, int screen, const char *xlfd, Bool xft_p)
fprintf (stderr, "%s: unloadable, unparsable font: \"%s\"\n",
progname, xlfd);
xlfd = "fixed";
- return LOADFONT();
+ return LOADFONT(xlfd);
}
else
{
@@ -145,13 +158,17 @@ load_font_retry_1 (Display *dpy, int screen, const char *xlfd, Bool xft_p)
spacings[e],
"*", /* average width */
charsets[a]);
- /* fprintf(stderr, "%s: trying %s\n", progname, buf);*/
- f = LOADFONT();
+# ifdef DEBUG
+ fprintf(stderr, "%s: trying %s\n", progname, buf);
+# endif
+ f = LOADFONT(buf);
if (f)
{
- /* fprintf (stderr,
+# ifdef DEBUG
+ fprintf (stderr,
"%s: substituted \"%s\" for \"%s\"\n",
- progname, buf, xlfd); */
+ progname, buf, xlfd);
+# endif
return f;
}
}
@@ -159,7 +176,7 @@ load_font_retry_1 (Display *dpy, int screen, const char *xlfd, Bool xft_p)
fprintf (stderr, "%s: unable to find any alternatives to \"%s\"\n",
progname, xlfd);
xlfd = "fixed";
- return LOADFONT();
+ return LOADFONT(xlfd);
}
}
# endif /* !HAVE_JWXYZ */