diff options
author | okan | 2012-11-28 14:14:44 +0000 |
---|---|---|
committer | okan | 2012-11-28 14:14:44 +0000 |
commit | d16264bf90da79427118a7a1cea97aea40e3214e (patch) | |
tree | 5833630167ed00d20838f6de68a60cc33d3402a7 /font.c | |
parent | 94322ab4b003d971f561881fc600cffaa102a345 (diff) | |
download | cwm-d16264bf90da79427118a7a1cea97aea40e3214e.tar.gz |
replace hand rolled font_make() with XftFontOpenName() and merge into
font_init().
Diffstat (limited to '')
-rw-r--r-- | font.c | 26 |
1 files changed, 6 insertions, 20 deletions
@@ -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); -} |