scaled-buffer: introduce scaled_font_buffer_update_markup()

This function behaves identically to `scaled_font_buffer_update()`
but allows setting the text as pango markup, supporting further
customization like underscores.
This commit is contained in:
Alex Chernika 2026-04-26 12:33:54 +02:00 committed by Johan Malm
parent 0caefa6a9e
commit 07a0a4e59b
4 changed files with 46 additions and 9 deletions

View file

@ -26,7 +26,7 @@ _create_buffer(struct scaled_buffer *scaled_buffer, double scale)
/* Buffer gets free'd automatically along the backing wlr_buffer */
font_buffer_create(&buffer, self->max_width, self->height, self->text,
&self->font, self->color, bg_pattern, scale);
&self->font, self->color, bg_pattern, scale, self->use_markup);
if (!buffer) {
wlr_log(WLR_ERROR, "font_buffer_create() failed");
@ -56,6 +56,7 @@ _equal(struct scaled_buffer *scaled_buffer_a,
struct scaled_font_buffer *b = scaled_buffer_b->data;
return str_equal(a->text, b->text)
&& a->use_markup == b->use_markup
&& a->max_width == b->max_width
&& str_equal(a->font.name, b->font.name)
&& a->font.size == b->font.size
@ -104,10 +105,10 @@ scaled_font_buffer_create_for_titlebar(struct wlr_scene_tree *parent,
return self;
}
void
scaled_font_buffer_update(struct scaled_font_buffer *self, const char *text,
static void
_scaled_font_buffer_update(struct scaled_font_buffer *self, const char *text,
int max_width, struct font *font, const float *color,
const float *bg_color)
const float *bg_color, bool use_markup)
{
assert(self);
assert(text);
@ -120,6 +121,7 @@ scaled_font_buffer_update(struct scaled_font_buffer *self, const char *text,
/* Update internal state */
self->text = xstrdup(text);
self->use_markup = use_markup;
self->max_width = max_width;
if (font->name) {
self->font.name = xstrdup(font->name);
@ -139,3 +141,19 @@ scaled_font_buffer_update(struct scaled_font_buffer *self, const char *text,
scaled_buffer_request_update(self->scaled_buffer,
self->width, self->height);
}
void
scaled_font_buffer_update(struct scaled_font_buffer *self, const char *text,
int max_width, struct font *font, const float *color,
const float *bg_color)
{
_scaled_font_buffer_update(self, text, max_width, font, color, bg_color, false);
}
void
scaled_font_buffer_update_markup(struct scaled_font_buffer *self, const char *text,
int max_width, struct font *font, const float *color,
const float *bg_color, bool use_markup)
{
_scaled_font_buffer_update(self, text, max_width, font, color, bg_color, use_markup);
}