From: Consolatis <35009135+Consolatis@users.noreply.github.com> Date: Sun, 12 Jun 2022 19:16:44 +0000 (+0200) Subject: common/font: Add scale argument X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=f3a685155ddcae71233c4154f0e2ae0b50ca4d97;p=proto%2Flabwc.git common/font: Add scale argument --- diff --git a/include/common/font.h b/include/common/font.h index bcf5acd2..5095bdf0 100644 --- a/include/common/font.h +++ b/include/common/font.h @@ -24,7 +24,7 @@ int font_height(struct font *font); * @color: foreground color in rgba format */ void font_buffer_create(struct lab_data_buffer **buffer, int max_width, - const char *text, struct font *font, float *color); + const char *text, struct font *font, float *color, double scale); /** * font_buffer_update - Wrapper around font_buffer_create @@ -32,7 +32,7 @@ void font_buffer_create(struct lab_data_buffer **buffer, int max_width, * wlr_buffer_drop() will be called on the buffer. */ void font_buffer_update(struct lab_data_buffer **buffer, int max_width, - const char *text, struct font *font, float *color); + const char *text, struct font *font, float *color, double scale); /** * font_finish - free some font related resources diff --git a/src/common/font.c b/src/common/font.c index 47117fae..75d98a01 100644 --- a/src/common/font.c +++ b/src/common/font.c @@ -51,18 +51,18 @@ font_height(struct font *font) void font_buffer_update(struct lab_data_buffer **buffer, int max_width, - const char *text, struct font *font, float *color) + const char *text, struct font *font, float *color, double scale) { if (*buffer) { wlr_buffer_drop(&(*buffer)->base); *buffer = NULL; } - font_buffer_create(buffer, max_width, text, font, color); + font_buffer_create(buffer, max_width, text, font, color, scale); } void font_buffer_create(struct lab_data_buffer **buffer, int max_width, - const char *text, struct font *font, float *color) + const char *text, struct font *font, float *color, double scale) { if (!text || !*text) { return; @@ -72,8 +72,7 @@ font_buffer_create(struct lab_data_buffer **buffer, int max_width, if (max_width && rect.width > max_width) { rect.width = max_width; } - /* TODO: scale */ - *buffer = buffer_create_cairo(rect.width, rect.height, 1, true); + *buffer = buffer_create_cairo(rect.width, rect.height, scale, true); if (!*buffer) { wlr_log(WLR_ERROR, "Failed to create font buffer of size %dx%d", rect.width, rect.height); diff --git a/src/menu/menu.c b/src/menu/menu.c index 22757c55..67fac975 100644 --- a/src/menu/menu.c +++ b/src/menu/menu.c @@ -99,9 +99,9 @@ item_create(struct menu *menu, const char *text) /* Font buffer */ font_buffer_create(&menuitem->normal.buffer, item_max_width, - text, &font, theme->menu_items_text_color); + text, &font, theme->menu_items_text_color, 1); font_buffer_create(&menuitem->selected.buffer, item_max_width, - text, &font, theme->menu_items_active_text_color); + text, &font, theme->menu_items_active_text_color, 1); if (!menuitem->normal.buffer || !menuitem->selected.buffer) { wlr_log(WLR_ERROR, "Failed to create menu item '%s'", text); if (menuitem->normal.buffer) { diff --git a/src/ssd/ssd_titlebar.c b/src/ssd/ssd_titlebar.c index e741bf06..f8f3c9c4 100644 --- a/src/ssd/ssd_titlebar.c +++ b/src/ssd/ssd_titlebar.c @@ -247,7 +247,8 @@ ssd_update_title(struct view *view) } /* Generate and update the lab_data_buffer, drops the old buffer */ - font_buffer_update(&part->buffer, title_bg_width, title, &font, text_color); + font_buffer_update(&part->buffer, title_bg_width, title, &font, + text_color, 1); if (!part->buffer) { /* This can happen for example by defining a font size of 0 */ wlr_log(WLR_ERROR, "Failed to create title buffer");