]> git.mdlowis.com Git - proto/labwc.git/commitdiff
common/font: Add scale argument
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Sun, 12 Jun 2022 19:16:44 +0000 (21:16 +0200)
committerJohan Malm <johanmalm@users.noreply.github.com>
Tue, 14 Jun 2022 21:03:08 +0000 (22:03 +0100)
include/common/font.h
src/common/font.c
src/menu/menu.c
src/ssd/ssd_titlebar.c

index bcf5acd23642df9b7a6b5b88a3a0fa7f76b1b3d0..5095bdf0b611fa649de71bb5b4ea3edf55bd68a0 100644 (file)
@@ -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
index 47117fae73bb8cc63eeaa082127e417d399af2ed..75d98a0118fc02004c2b00a0f03dbffec6fd4b4e 100644 (file)
@@ -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);
index 22757c552b1819e79322b26edf00b0cd8c2ad2a9..67fac9755e9f7f27301372edc00938fe11cb81d7 100644 (file)
@@ -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) {
index e741bf0652dbe817981236f64ab6914663ddf382..f8f3c9c4912e3d5d580c4b56cf2922cb2a9aec78 100644 (file)
@@ -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");