+/* Loads the font named by the X resource "res" and returns
+ a texture-font object.
+*/
+texture_font_data *
+load_texture_font (Display *dpy, char *res)
+{
+ char *font = get_string_resource (dpy, res, "Font");
+ const char *def1 = "-*-helvetica-medium-r-normal-*-240-*";
+ const char *def2 = "-*-helvetica-medium-r-normal-*-180-*";
+ const char *def3 = "fixed";
+ XFontStruct *f;
+
+ if (!strcmp (res, "fpsFont"))
+ def1 = "-*-courier-bold-r-normal-*-180-*"; /* Kludge. Sue me. */
+
+ if (!res || !*res) abort();
+ if (!font) font = strdup(def1);
+
+ f = XLoadQueryFont(dpy, font);
+ if (!f && !!strcmp (font, def1))
+ {
+ fprintf (stderr, "%s: unable to load font \"%s\", using \"%s\"\n",
+ progname, font, def1);
+ free (font);
+ font = strdup (def1);
+ f = XLoadQueryFont(dpy, font);
+ }
+
+ if (!f && !!strcmp (font, def2))
+ {
+ fprintf (stderr, "%s: unable to load font \"%s\", using \"%s\"\n",
+ progname, font, def2);
+ free (font);
+ font = strdup (def2);
+ f = XLoadQueryFont(dpy, font);
+ }
+
+ if (!f && !!strcmp (font, def3))
+ {
+ fprintf (stderr, "%s: unable to load font \"%s\", using \"%s\"\n",
+ progname, font, def3);
+ free (font);
+ font = strdup (def3);
+ f = XLoadQueryFont(dpy, font);
+ }
+
+ if (!f)
+ {
+ fprintf (stderr, "%s: unable to load fallback font \"%s\" either!\n",
+ progname, font);
+ exit (1);
+ }
+
+ free (font);
+ font = 0;
+
+ return load_texture_xfont (dpy, f);
+}
+
+
+/* Bounding box of the multi-line string, in pixels.