+}
+
+void
+xft_init(struct swm_region *r)
+{
+ char *font, *d, *search;
+ XRenderColor color;
+
+ if (bar_font == NULL) {
+ if ((d = strdup(bar_fonts)) == NULL)
+ errx(1, "insufficient memory.");
+ search = d;
+ while ((font = strsep(&search, ",")) != NULL) {
+ if (*font == '\0')
+ continue;
+
+ DNPRINTF(SWM_D_INIT, "xft_init: try font %s\n", font);
+
+ if (isxlfd(font)) {
+ bar_font = XftFontOpenXlfd(display, r->s->idx,
+ font);
+ } else {
+ bar_font = XftFontOpenName(display, r->s->idx,
+ font);
+ }
+
+ if (!bar_font) {
+ warnx("unable to load font %s", font);
+ continue;
+ } else {
+ DNPRINTF(SWM_D_INIT, "successfully opened "
+ "font %s\n", font);
+ break;
+ }
+ }
+ free(d);
+ }
+
+ if (bar_font == NULL)
+ errx(1, "unable to open a font");
+
+ PIXEL_TO_XRENDERCOLOR(r->s->c[SWM_S_COLOR_BAR_FONT].pixel, color);
+
+ if (!XftColorAllocValue(display, DefaultVisual(display, r->s->idx),
+ DefaultColormap(display, r->s->idx), &color, &bar_font_color))
+ warn("unable to allocate Xft color");
+
+ bar_height = bar_font->height + 2 * bar_border_width;
+
+ if (bar_height < 1)
+ bar_height = 1;
+}
+
+void
+bar_setup(struct swm_region *r)
+{
+ xcb_screen_t *screen;
+ uint32_t wa[3];
+
+ DNPRINTF(SWM_D_BAR, "bar_setup: screen %d.\n",
+ r->s->idx);
+
+ if ((screen = get_screen(r->s->idx)) == NULL)
+ errx(1, "ERROR: can't get screen %d.", r->s->idx);
+
+ if (r->bar != NULL)
+ return;
+
+ if ((r->bar = calloc(1, sizeof(struct swm_bar))) == NULL)
+ err(1, "bar_setup: calloc: failed to allocate memory.");
+
+ if (bar_font_legacy)
+ fontset_init();
+ else
+ xft_init(r);
+