summaryrefslogtreecommitdiff
path: root/app/cwm
diff options
context:
space:
mode:
authorOkan Demirmen <okan@cvs.openbsd.org>2012-11-28 14:14:45 +0000
committerOkan Demirmen <okan@cvs.openbsd.org>2012-11-28 14:14:45 +0000
commit51edd01edf65db81ed337284b6fdde1982cee6be (patch)
treedb793f24466269c687b15dcba2634419dbf7bef3 /app/cwm
parent03bc691388de46519fdb710695bdae11ddfdcf61 (diff)
replace hand rolled font_make() with XftFontOpenName() and merge into
font_init().
Diffstat (limited to 'app/cwm')
-rw-r--r--app/cwm/calmwm.h6
-rw-r--r--app/cwm/conf.c5
-rw-r--r--app/cwm/font.c26
3 files changed, 11 insertions, 26 deletions
diff --git a/app/cwm/calmwm.h b/app/cwm/calmwm.h
index 64d816896..a8f1d9f74 100644
--- a/app/cwm/calmwm.h
+++ b/app/cwm/calmwm.h
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: calmwm.h,v 1.159 2012/11/08 20:18:19 okan Exp $
+ * $OpenBSD: calmwm.h,v 1.160 2012/11/28 14:14:44 okan Exp $
*/
#ifndef _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/app/cwm/conf.c b/app/cwm/conf.c
index 95e048457..9d9fc775c 100644
--- a/app/cwm/conf.c
+++ b/app/cwm/conf.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: conf.c,v 1.109 2012/11/14 21:31:53 okan Exp $
+ * $OpenBSD: conf.c,v 1.110 2012/11/28 14:14:44 okan Exp $
*/
#include <sys/param.h>
@@ -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/app/cwm/font.c b/app/cwm/font.c
index 83e4b6c5b..abec848f1 100644
--- a/app/cwm/font.c
+++ b/app/cwm/font.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: font.c,v 1.19 2012/11/09 03:52:02 okan Exp $
+ * $OpenBSD: font.c,v 1.20 2012/11/28 14:14:44 okan Exp $
*/
#include <sys/param.h>
@@ -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);
-}