diff options
author | okan <okan> | 2012-11-28 14:14:44 +0000 |
---|---|---|
committer | okan <okan> | 2012-11-28 14:14:44 +0000 |
commit | fad4798e5be4fb560c70c6f0e68aa576c28b85a4 (patch) | |
tree | 1d4c734eb259026f49d65a6fed9004b31f412ee2 /font.c | |
parent | 93f64ffc55d29947614f234a5c6deddcbc2d4e81 (diff) | |
download | cwm-fad4798e5be4fb560c70c6f0e68aa576c28b85a4.tar.gz cwm-fad4798e5be4fb560c70c6f0e68aa576c28b85a4.tar.xz cwm-fad4798e5be4fb560c70c6f0e68aa576c28b85a4.zip |
replace hand rolled font_make() with XftFontOpenName() and merge into
font_init().
Diffstat (limited to 'font.c')
-rw-r--r-- | font.c | 24 |
1 files changed, 5 insertions, 19 deletions
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); -} |