X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Ffontglide.c;h=263393a282ea0fd6ab1c6ba681172a0e6d943808;hb=c85f503f5793839a6be4c818332aca4a96927bb2;hp=6a304171fa88e8ba142518e91d352e5c47efbd73;hpb=aa75c7476aeaa84cf3abc192b376a8b03c325213;p=xscreensaver diff --git a/hacks/fontglide.c b/hacks/fontglide.c index 6a304171..263393a2 100644 --- a/hacks/fontglide.c +++ b/hacks/fontglide.c @@ -1,4 +1,4 @@ -/* xscreensaver, Copyright (c) 2003-2016 Jamie Zawinski +/* xscreensaver, Copyright (c) 2003-2017 Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -164,6 +164,34 @@ pick_font_size (state *s) } +#ifdef HAVE_JWXYZ + +static char * +append_font_name(Display *dpy, char *dest, const XFontStruct *font) +{ + int i; + for (i = 0; i != font->n_properties; ++i) { + if (font->properties[i].name == XA_FONT) { + const char *suffix = XGetAtomName (dpy, font->properties[i].card32); + strcpy(dest, suffix); + return dest + strlen(suffix); + } + } + + dest[0] = '?'; + dest[1] = 0; + return dest + 1; + +/* + float s; + const char *n = jwxyz_nativeFontName (font->fid, &s); + return dest + sprintf (dest, "%s %.1f", n, s); + */ +} + +#endif + + /* Finds the set of scalable fonts on the system; picks one; and loads that font in a random pixel size. Returns False if something went wrong. @@ -367,9 +395,12 @@ pick_font_1 (state *s, sentence *se) strcpy (pattern2, pattern); # ifdef HAVE_JWXYZ { - float s; - const char *n = jwxyz_nativeFontName (se->xftfont->xfont->fid, &s); - sprintf (pattern2 + strlen(pattern2), " (%s %.1f)", n, s); + char *out = pattern2 + strlen(pattern2); + out[0] = ' '; + out[1] = '('; + out = append_font_name (s->dpy, out + 2, se->xftfont->xfont); + out[0] = ')'; + out[1] = 0; } # endif @@ -1622,11 +1653,7 @@ fontglide_draw_metrics (state *s) strcpy (fn2, fn); # ifdef HAVE_JWXYZ - { - float ss; - const char *n = jwxyz_nativeFontName (s->metrics_xftfont->xfont->fid, &ss); - sprintf (fn2, "%s %.1f", n, ss); - } + append_font_name (s->dpy, fn2, s->metrics_xftfont->xfont); # endif xftdraw = XftDrawCreate (s->dpy, dest, s->xgwa.visual, @@ -1658,8 +1685,8 @@ fontglide_draw_metrics (state *s) # ifdef HAVE_JWXYZ { - char *name = - jwxyz_unicode_character_name (s->metrics_font1->fid, s->debug_metrics_p); + char *name = jwxyz_unicode_character_name ( + s->dpy, s->metrics_font1->fid, s->debug_metrics_p); if (!name || !*name) name = strdup("unknown character name"); XDrawString (s->dpy, dest, gc, 10,