diff --git a/config.c b/config.c index 2ed84daa1..fd54ed8a4 100644 --- a/config.c +++ b/config.c @@ -520,6 +520,7 @@ config_parse(const char *confpatharg) CFG_STR((char *) "text", (char *) NULL, CFGF_NONE), CFG_STR((char *) "fg", (char *) NULL, CFGF_NONE), CFG_STR((char *) "bg", (char *) NULL, CFGF_NONE), + CFG_STR((char *) "font", (char *) NULL, CFGF_NONE), CFG_END() }; static cfg_opt_t widget_progressbar_opts[] = diff --git a/config.h b/config.h index b17a5dff4..f86a2302c 100644 --- a/config.h +++ b/config.h @@ -235,6 +235,7 @@ struct Widget int location; int width; Button *buttons; + XftFont *font; Widget *next; }; diff --git a/statusbar.c b/statusbar.c index 098bcbedf..d5b459597 100644 --- a/statusbar.c +++ b/statusbar.c @@ -108,6 +108,7 @@ statusbar_draw(int screen) void statusbar_init(int screen) { + Widget *widget; XSetWindowAttributes wa; int phys_screen = get_phys_screen(screen); Area area = get_screen_area(screen, @@ -117,6 +118,10 @@ statusbar_init(int screen) statusbar->height = globalconf.screens[screen].font->height * 1.5; + for(widget = statusbar->widgets; widget; widget = widget->next) + if(widget->font) + statusbar->height = MAX(statusbar->height, widget->font->height); + if(statusbar->position == BarRight || statusbar->position == BarLeft) statusbar->width = area.height; else diff --git a/widgets/textbox.c b/widgets/textbox.c index 0d1869522..bea6f784e 100644 --- a/widgets/textbox.c +++ b/widgets/textbox.c @@ -46,17 +46,16 @@ static int textbox_draw(Widget *widget, DrawCtx *ctx, int offset, int used __attribute__ ((unused))) { - VirtScreen vscreen = globalconf.screens[widget->statusbar->screen]; Data *d = widget->data; - widget->width = textwidth(vscreen.font, d->text); + widget->width = textwidth(widget->font, d->text); widget->location = widget_calculate_offset(widget->statusbar->width, widget->width, offset, widget->alignment); draw_text(ctx, widget->location, 0, widget->width, widget->statusbar->height, - vscreen.font, d->text, d->fg, d->bg); + widget->font, d->text, d->fg, d->bg); return widget->width; } @@ -72,7 +71,7 @@ textbox_new(Statusbar *statusbar, cfg_t *config) { Widget *w; Data *d; - char *color; + char *buf; w = p_new(Widget, 1); widget_common_new(w, statusbar, config); @@ -81,16 +80,22 @@ textbox_new(Statusbar *statusbar, cfg_t *config) w->data = d = p_new(Data, 1); - if ((color = cfg_getstr(config, "fg"))) - d->fg = initxcolor(statusbar->screen, color); + if((buf = cfg_getstr(config, "fg"))) + d->fg = initxcolor(statusbar->screen, buf); else d->fg = globalconf.screens[statusbar->screen].colors_normal[ColFG]; - if ((color = cfg_getstr(config, "bg"))) - d->bg = initxcolor(statusbar->screen, color); + if((buf = cfg_getstr(config, "bg"))) + d->bg = initxcolor(statusbar->screen, buf); else d->bg = globalconf.screens[statusbar->screen].colors_normal[ColBG]; + if((buf = cfg_getstr(config, "font"))) + w->font = XftFontOpenName(globalconf.display, get_phys_screen(statusbar->screen), buf); + + if(!w->font) + w->font = globalconf.screens[statusbar->screen].font; + update(w, cfg_getstr(config, "text")); return w; }