xcb_change_gc(conn, pixmap_gc, XCB_GC_FOREGROUND, (uint32_t[]){ get_colorpixel("#000000") });
xcb_poly_fill_rectangle(conn, pixmap, pixmap_gc, 1, &border);
- xcb_change_gc(conn, pixmap_gc, XCB_GC_FONT, (uint32_t[]){ font.id });
+ set_font(&font);
-#define txt(x, row, text) xcb_image_text_8(conn, strlen(text), pixmap, pixmap_gc, x, (row * font.height) + 2, text)
+#define txt(x, row, text) \
+ draw_text(text, strlen(text), false, pixmap, pixmap_gc, x, (row - 1) * font.height + 4)
if (current_step == STEP_WELCOME) {
/* restore font color */
else txt(31, 4, "<Win>");
/* the selected modifier */
+ set_font(&bold_font);
xcb_change_gc(conn, pixmap_gc, XCB_GC_FONT, (uint32_t[]){ bold_font.id });
if (modifier == MOD_Mod4)
txt(31, 4, "<Win>");
else txt(31, 5, "<Alt>");
/* green */
+ set_font(&font);
xcb_change_gc(conn, pixmap_gc, XCB_GC_FOREGROUND | XCB_GC_FONT,
(uint32_t[]) { get_colorpixel("#00FF00"), font.id });
xcb_numlock_mask = get_mod_mask_for(XCB_NUM_LOCK, symbols, modmap_reply);
font = load_font(pattern, true);
+ set_font(&font);
bold_font = load_font(patternbold, true);
/* Open an input window */
memcpy(full_text, prompt, prompt_len * 2);
memcpy(full_text + (prompt_len * 2), con, input_position * 2);
}
- xcb_image_text_16(conn, input_position + prompt_len, pixmap, pixmap_gc, 4 /* X */,
- font.height + 2 /* Y = baseline of font */, (xcb_char2b_t*)full_text);
+ if (input_position + prompt_len != 0)
+ draw_text(full_text, input_position + prompt_len, true, pixmap, pixmap_gc, 4, 4);
/* Copy the contents of the pixmap to the real window */
xcb_copy_area(conn, pixmap, win, pixmap_gc, 0, 0, 0, 0, /* */ 500, font.height + 8);
symbols = xcb_key_symbols_alloc(conn);
font = load_font(pattern, true);
+ set_font(&font);
/* Open an input window */
win = xcb_generate_id(conn);
values[0] = color_text;
values[1] = color_background;
xcb_change_gc(conn, pixmap_gc, XCB_GC_FOREGROUND | XCB_GC_BACKGROUND, values);
- xcb_image_text_8(conn, strlen(prompt), pixmap, pixmap_gc, 4 + 4/* X */,
- font.height + 2 + 4 /* Y = baseline of font */, prompt);
+ draw_text(prompt, strlen(prompt), false, pixmap, pixmap_gc, 4 + 4, 4 + 4);
/* render close button */
int line_width = 4;
values[1] = color_button_background;
values[2] = 1;
xcb_change_gc(conn, pixmap_gc, XCB_GC_FOREGROUND | XCB_GC_BACKGROUND | XCB_GC_LINE_WIDTH, values);
- xcb_image_text_8(conn, strlen("x"), pixmap, pixmap_gc, y - w - line_width + (w / 2) - 4/* X */,
- font.height + 2 + 4 - 1/* Y = baseline of font */, "X");
+ draw_text("X", 1, false, pixmap, pixmap_gc, y - w - line_width + w / 2 - 4, 4 + 4 - 1);
y -= w;
y -= 20;
values[0] = color_text;
values[1] = color_button_background;
xcb_change_gc(conn, pixmap_gc, XCB_GC_FOREGROUND | XCB_GC_BACKGROUND, values);
- xcb_image_text_8(conn, strlen(buttons[c].label), pixmap, pixmap_gc, y - w - line_width + 6/* X */,
- font.height + 2 + 3/* Y = baseline of font */, buttons[c].label);
+ draw_text(buttons[c].label, strlen(buttons[c].label), false, pixmap, pixmap_gc,
+ y - w - line_width + 6, 4 + 3);
y -= w;
}
}
font = load_font(pattern, true);
+ set_font(&font);
/* Open an input window */
win = xcb_generate_id(conn);
}
/* find the height for the decorations */
- int deco_height = config.font.height + 5;
+ int deco_height = config.font.height + 4;
+ if (config.font.height & 0x01)
+ ++deco_height;
/* precalculate the sizes to be able to correct rounding errors */
int sizes[children];
xcb_change_gc(conn, pixmap_gc, XCB_GC_FOREGROUND, (uint32_t[]){ get_colorpixel("#FFFFFF") });
for (int i = 0; i < sizeof(crash_text) / sizeof(char*); i++) {
- int text_len = strlen(crash_text[i]);
- xcb_char2b_t *full_text = convert_utf8_to_ucs2(crash_text[i], &text_len);
- xcb_image_text_16(conn, text_len, pixmap, pixmap_gc, 8 /* X */,
- 3 + (i + 1) * font_height /* Y = baseline of font */,
- (xcb_char2b_t*)full_text);
- free(full_text);
+ draw_text(crash_text[i], strlen(crash_text[i]), false,
+ pixmap, pixmap_gc, 8, 3 + (i - 1) * font_height);
}
/* Copy the contents of the pixmap to the real window */
uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND | XCB_GC_FONT;
uint32_t values[] = { p->color->text, p->color->background, config.font.id };
xcb_change_gc(conn, parent->pm_gc, mask, values);
- int text_offset_y = config.font.height + (con->deco_rect.height - config.font.height) / 2 - 1;
+ int text_offset_y = (con->deco_rect.height - config.font.height) / 2;
struct Window *win = con->window;
if (win == NULL || win->name_x == NULL) {
/* this is a non-leaf container, we need to make up a good description */
// TODO: use a good description instead of just "another container"
- xcb_image_text_8(
- conn,
- strlen("another container"),
- parent->pixmap,
- parent->pm_gc,
- con->deco_rect.x + 2,
- con->deco_rect.y + text_offset_y,
- "another container"
- );
-
+ draw_text("another container", strlen("another container"), false,
+ parent->pixmap, parent->pm_gc,
+ con->deco_rect.x + 2, con->deco_rect.y + text_offset_y);
goto copy_pixmaps;
}
//DLOG("indent_level = %d, indent_mult = %d\n", indent_level, indent_mult);
int indent_px = (indent_level * 5) * indent_mult;
- if (win->uses_net_wm_name)
- xcb_image_text_16(
- conn,
- win->name_len,
- parent->pixmap,
- parent->pm_gc,
- con->deco_rect.x + 2 + indent_px,
- con->deco_rect.y + text_offset_y,
- (xcb_char2b_t*)win->name_x
- );
- else
- xcb_image_text_8(
- conn,
- win->name_len,
- parent->pixmap,
- parent->pm_gc,
- con->deco_rect.x + 2 + indent_px,
- con->deco_rect.y + text_offset_y,
- win->name_x
- );
+ draw_text(win->name_x, win->name_len, win->uses_net_wm_name,
+ parent->pixmap, parent->pm_gc,
+ con->deco_rect.x + 2 + indent_px, con->deco_rect.y + text_offset_y);
copy_pixmaps:
xcb_copy_area(conn, con->pixmap, con->frame, con->pm_gc, 0, 0, 0, 0, con->rect.width, con->rect.height);