From fad4798e5be4fb560c70c6f0e68aa576c28b85a4 Mon Sep 17 00:00:00 2001 From: okan Date: Wed, 28 Nov 2012 14:14:44 +0000 Subject: [PATCH 1/3] replace hand rolled font_make() with XftFontOpenName() and merge into font_init(). --- calmwm.h | 4 ++-- conf.c | 3 +-- font.c | 24 +++++------------------- 3 files changed, 8 insertions(+), 23 deletions(-) diff --git a/calmwm.h b/calmwm.h index 8c06db4..5085807 100644 --- a/calmwm.h +++ b/calmwm.h @@ -446,9 +446,9 @@ int font_descent(struct screen_ctx *); void font_draw(struct screen_ctx *, const char *, int, Drawable, int, int); u_int font_height(struct screen_ctx *); -void font_init(struct screen_ctx *, const char *); +void font_init(struct screen_ctx *, const char *, + const char *); int font_width(struct screen_ctx *, const char *, int); -XftFont *font_make(struct screen_ctx *, const char *); void xev_loop(void); diff --git a/conf.c b/conf.c index b4967e4..2fe7363 100644 --- a/conf.c +++ b/conf.c @@ -62,8 +62,7 @@ conf_gap(struct conf *c, struct screen_ctx *sc) void conf_font(struct conf *c, struct screen_ctx *sc) { - font_init(sc, c->color[CWM_COLOR_FONT].name); - sc->font = font_make(sc, c->font); + font_init(sc, c->font, c->color[CWM_COLOR_FONT].name); } static struct color color_binds[] = { diff --git a/font.c b/font.c index 3793e55..0e1c144 100644 --- a/font.c +++ b/font.c @@ -49,7 +49,7 @@ font_height(struct screen_ctx *sc) } void -font_init(struct screen_ctx *sc, const char *color) +font_init(struct screen_ctx *sc, const char *name, const char *color) { sc->xftdraw = XftDrawCreate(X_Dpy, sc->rootwin, DefaultVisual(X_Dpy, sc->which), DefaultColormap(X_Dpy, sc->which)); @@ -59,6 +59,10 @@ font_init(struct screen_ctx *sc, const char *color) if (!XftColorAllocName(X_Dpy, DefaultVisual(X_Dpy, sc->which), DefaultColormap(X_Dpy, sc->which), color, &sc->xftcolor)) errx(1, "XftColorAllocName"); + + sc->font = XftFontOpenName(X_Dpy, sc->which, name); + if (sc->font == NULL) + errx(1, "XftFontOpenName"); } int @@ -80,21 +84,3 @@ font_draw(struct screen_ctx *sc, const char *text, int len, XftDrawStringUtf8(sc->xftdraw, &sc->xftcolor, sc->font, x, y, (const FcChar8*)text, len); } - -XftFont * -font_make(struct screen_ctx *sc, const char *name) -{ - XftFont *fn = NULL; - FcPattern *pat, *patx; - XftResult res; - - if ((pat = FcNameParse((const FcChar8*)name)) == NULL) - return (NULL); - - if ((patx = XftFontMatch(X_Dpy, sc->which, pat, &res)) != NULL) - fn = XftFontOpenPattern(X_Dpy, patx); - - FcPatternDestroy(pat); - - return (fn); -} From 2b9d921edaa665f896cf29bf6ba332c6ac11dd21 Mon Sep 17 00:00:00 2001 From: okan Date: Wed, 28 Nov 2012 14:25:05 +0000 Subject: [PATCH 2/3] ever since the 9wm code bits were removed or replaced, this file has been a no-op, for each source file has a complete license marker (ISC). no objections from oga, who did the 9wm rewrite/remove work in 2008. --- LICENSE | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 LICENSE diff --git a/LICENSE b/LICENSE deleted file mode 100644 index de3b872..0000000 --- a/LICENSE +++ /dev/null @@ -1,14 +0,0 @@ - Copyright (c) 2004,2005 Marius Aamodt Eriksen - Copyright (c) 2004 Andy Adamson - - Permission to use, copy, modify, and distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. From 3e151f8c764a5f1116fae3bea87f3d4474dc686a Mon Sep 17 00:00:00 2001 From: okan Date: Wed, 28 Nov 2012 14:32:44 +0000 Subject: [PATCH 3/3] add xasprintf() for upcoming changes. --- calmwm.h | 3 +++ xmalloc.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/calmwm.h b/calmwm.h index 5085807..1abcbef 100644 --- a/calmwm.h +++ b/calmwm.h @@ -492,6 +492,9 @@ void u_spawn(char *); void *xcalloc(size_t, size_t); void *xmalloc(size_t); char *xstrdup(const char *); +int xasprintf(char **, const char *, ...) + __attribute__((__format__ (printf, 2, 3))) + __attribute__((__nonnull__ (2))); /* Externs */ extern Display *X_Dpy; diff --git a/xmalloc.c b/xmalloc.c index d0697fa..0480c73 100644 --- a/xmalloc.c +++ b/xmalloc.c @@ -69,3 +69,19 @@ xstrdup(const char *str) return (p); } + +int +xasprintf(char **ret, const char *fmt, ...) +{ + va_list ap; + int i; + + va_start(ap, fmt); + i = vasprintf(ret, fmt, ap); + va_end(ap); + + if (i < 0 || *ret == NULL) + err(1, "asprintf"); + + return (i); +}