mirror of
https://github.com/labwc/labwc.git
synced 2026-05-06 06:47:33 -04:00
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:
parent
0caefa6a9e
commit
07a0a4e59b
4 changed files with 46 additions and 9 deletions
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include <cairo.h>
|
||||
#include <pango/pango-font.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
struct lab_data_buffer;
|
||||
|
||||
|
|
@ -43,10 +44,11 @@ void font_get_buffer_size(int max_width, const char *text, struct font *font,
|
|||
* @font: font description
|
||||
* @color: foreground color in rgba format
|
||||
* @bg_pattern: background pattern
|
||||
* @use_markup: flag to render pango markup
|
||||
*/
|
||||
void font_buffer_create(struct lab_data_buffer **buffer, int max_width,
|
||||
int height, const char *text, struct font *font, const float *color,
|
||||
cairo_pattern_t *bg_pattern, double scale);
|
||||
cairo_pattern_t *bg_pattern, double scale, bool use_markup);
|
||||
|
||||
/**
|
||||
* font_finish - free some font related resources
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ struct scaled_font_buffer {
|
|||
|
||||
/* Private */
|
||||
char *text;
|
||||
bool use_markup;
|
||||
int max_width;
|
||||
float color[4];
|
||||
float bg_color[4];
|
||||
|
|
@ -69,8 +70,18 @@ scaled_font_buffer_create_for_titlebar(struct wlr_scene_tree *parent,
|
|||
* bg_color is ignored for font buffers created with
|
||||
* scaled_font_buffer_create_for_titlebar().
|
||||
*/
|
||||
void scaled_font_buffer_update(struct scaled_font_buffer *self, const char *text,
|
||||
int max_width, struct font *font, const float *color,
|
||||
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);
|
||||
|
||||
/**
|
||||
* Update an existing auto scaling font buffer allowing the use of pango markup.
|
||||
*
|
||||
* Behaves identically to scaled_font_buffer_update(), but allows customization
|
||||
* of the `use_markup` field of the @self struct via @use_markup.
|
||||
*/
|
||||
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);
|
||||
|
||||
#endif /* LABWC_SCALED_FONT_BUFFER_H */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue