X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=hacks%2Ffontglide.c;h=6a304171fa88e8ba142518e91d352e5c47efbd73;hp=e45591fca8b3934379ae1527d790eb55502d7928;hb=aa75c7476aeaa84cf3abc192b376a8b03c325213;hpb=88cfe534a698a0562e81345957a50714af1453bc diff --git a/hacks/fontglide.c b/hacks/fontglide.c index e45591fc..6a304171 100644 --- a/hacks/fontglide.c +++ b/hacks/fontglide.c @@ -1,4 +1,4 @@ -/* xscreensaver, Copyright (c) 2003-2015 Jamie Zawinski +/* xscreensaver, Copyright (c) 2003-2016 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 @@ -25,8 +25,9 @@ /* #define DEBUG */ #include +#include -#ifndef HAVE_COCOA +#ifndef HAVE_JWXYZ # include #endif @@ -174,7 +175,7 @@ pick_font_1 (state *s, sentence *se) char pattern[1024]; char pattern2[1024]; -# ifndef HAVE_COCOA /* real Xlib */ +#ifndef HAVE_JWXYZ /* real Xlib */ char **names = 0; char **names2 = 0; XFontStruct *info = 0; @@ -333,7 +334,7 @@ pick_font_1 (state *s, sentence *se) XFreeFontInfo (names2, info, count2); XFreeFontNames (names); -# else /* HAVE_COCOA */ +# else /* HAVE_JWXYZ */ if (s->font_override) sprintf (pattern, "%.200s", s->font_override); @@ -346,7 +347,7 @@ pick_font_1 (state *s, sentence *se) sprintf (pattern, "*-%s-%s-%s-*-*-*-%d-*", family, weight, slant, size); } ok = True; -# endif /* HAVE_COCOA */ +# endif /* HAVE_JWXYZ */ if (! ok) return False; @@ -364,7 +365,7 @@ pick_font_1 (state *s, sentence *se) } strcpy (pattern2, pattern); -# ifdef HAVE_COCOA +# ifdef HAVE_JWXYZ { float s; const char *n = jwxyz_nativeFontName (se->xftfont->xfont->fid, &s); @@ -493,7 +494,7 @@ static char *unread_word_text = 0; /* Returns a newly-allocated string with one word in it, or NULL if there is no complete word available. */ -static const char * +static char * get_word_text (state *s) { const char *start = s->buf; @@ -520,9 +521,9 @@ get_word_text (state *s) if (unread_word_text) { - start = unread_word_text; + result = unread_word_text; unread_word_text = 0; - return start; + return strdup (result); } /* Skip over whitespace at the beginning of the buffer, @@ -1121,7 +1122,7 @@ populate_sentence (state *s, sentence *se) while (!done) { - const char *txt = get_word_text (s); + char *txt = get_word_text (s); word *w; if (!txt) { @@ -1146,6 +1147,8 @@ populate_sentence (state *s, sentence *se) } w = new_word (s, se, txt, !se->move_chars_p); + free (txt); + txt = 0; /* If we have a few words, let punctuation terminate the sentence: stop gathering more words if the last word ends in a period, etc. */ @@ -1185,6 +1188,7 @@ populate_sentence (state *s, sentence *se) y + se->xftfont->ascent + se->xftfont->descent > s->xgwa.height) { unread_word (s, w); + free (w); /* done = True; */ break; } @@ -1592,7 +1596,7 @@ fontglide_draw_metrics (state *s) gc = XCreateGC (s->dpy, dest, 0, 0); XSetFont (s->dpy, gc, s->metrics_font1->fid); -# ifdef HAVE_COCOA +# if defined(HAVE_JWXYZ) jwxyz_XSetAntiAliasing (s->dpy, gc, False); # endif @@ -1617,7 +1621,7 @@ fontglide_draw_metrics (state *s) } strcpy (fn2, fn); -# ifdef HAVE_COCOA +# ifdef HAVE_JWXYZ { float ss; const char *n = jwxyz_nativeFontName (s->metrics_xftfont->xfont->fid, &ss); @@ -1652,7 +1656,7 @@ fontglide_draw_metrics (state *s) s->xgwa.height - 5, fn2, strlen(fn2)); -# ifdef HAVE_COCOA +# ifdef HAVE_JWXYZ { char *name = jwxyz_unicode_character_name (s->metrics_font1->fid, s->debug_metrics_p); @@ -1741,7 +1745,7 @@ fontglide_draw_metrics (state *s) { Pixmap p2; GC gc2 = XCreateGC (s->dpy, p, 0, 0); -# ifdef HAVE_COCOA +# ifdef HAVE_JWXYZ jwxyz_XSetAntiAliasing (s->dpy, gc2, False); # endif XSetFont (s->dpy, gc2, s->metrics_font1->fid); @@ -1749,7 +1753,7 @@ fontglide_draw_metrics (state *s) XFillRectangle (s->dpy, p, gc2, 0, 0, pixw, pixh); XSetForeground (s->dpy, gc, WhitePixelOfScreen (s->xgwa.screen)); XSetForeground (s->dpy, gc2, WhitePixelOfScreen (s->xgwa.screen)); -# ifdef HAVE_COCOA +# ifdef HAVE_JWXYZ jwxyz_XSetAntiAliasing (s->dpy, gc2, s->debug_metrics_antialiasing_p); # endif @@ -1890,7 +1894,7 @@ fontglide_draw_metrics (state *s) { XSetFont (s->dpy, gc, s->metrics_font1->fid); XSetForeground (s->dpy, gc, WhitePixelOfScreen (s->xgwa.screen)); -# ifdef HAVE_COCOA +# ifdef HAVE_JWXYZ jwxyz_XSetAntiAliasing (s->dpy, gc, s->debug_metrics_antialiasing_p); # endif sprintf (txt2, "%s [XX%sXX] [%s%s%s%s]", @@ -1913,7 +1917,7 @@ fontglide_draw_metrics (state *s) xoff + x/2 + (sc*cc.rbearing/2) - cc.rbearing/2, ascent + 10, txt2, strlen(txt2)); -# ifdef HAVE_COCOA +# ifdef HAVE_JWXYZ jwxyz_XSetAntiAliasing (s->dpy, gc, False); # endif XSetFont (s->dpy, gc, s->metrics_font2->fid); @@ -1949,7 +1953,7 @@ fontglide_draw_metrics (state *s) txt2, strlen(txt2)); } -# ifdef HAVE_COCOA +# ifdef HAVE_JWXYZ jwxyz_XSetAntiAliasing (s->dpy, gc, True); # endif @@ -2056,7 +2060,7 @@ fontglide_draw_metrics (state *s) xoff + x + sc*cc.rbearing, y - sc*ascent, xoff + x + sc*cc.rbearing, y + sc*descent + 40); - y += sc * (ascent + descent) * 2; + /* y += sc * (ascent + descent) * 2; */ } } @@ -2196,7 +2200,7 @@ fontglide_init (Display *dpy, Window window) ? 199 : 0); s->debug_scale = 6; -# ifdef HAVE_COCOA +# ifdef HAVE_JWXYZ if (s->debug_metrics_p && !s->font_override) s->font_override = "Helvetica Bold 16"; # endif @@ -2205,7 +2209,7 @@ fontglide_init (Display *dpy, Window window) s->dbuf = get_boolean_resource (dpy, "doubleBuffer", "Boolean"); -# ifdef HAVE_COCOA /* Don't second-guess Quartz's double-buffering */ +# ifdef HAVE_JWXYZ /* Don't second-guess Quartz's double-buffering */ s->dbuf = False; # endif