Reuse parsed PangoFontDescription

Avoids parsing the configured font each time text is rendered.
This commit is contained in:
Hugo Osvaldo Barrera 2022-07-01 12:23:04 +02:00 committed by Simon Ser
parent 75605491a5
commit 80e386fd97
11 changed files with 52 additions and 49 deletions

View file

@ -13,12 +13,12 @@
* escaped string to dest if provided.
*/
size_t escape_markup_text(const char *src, char *dest);
PangoLayout *get_pango_layout(cairo_t *cairo, const char *font,
PangoLayout *get_pango_layout(cairo_t *cairo, const PangoFontDescription *desc,
const char *text, double scale, bool markup);
void get_text_size(cairo_t *cairo, const char *font, int *width, int *height,
void get_text_size(cairo_t *cairo, const PangoFontDescription *desc, int *width, int *height,
int *baseline, double scale, bool markup, const char *fmt, ...);
void get_text_metrics(const PangoFontDescription *font, int *height, int *baseline);
void render_text(cairo_t *cairo, const char *font,
void get_text_metrics(const PangoFontDescription *desc, int *height, int *baseline);
void render_text(cairo_t *cairo, PangoFontDescription *desc,
double scale, bool markup, const char *fmt, ...);
#endif

View file

@ -505,7 +505,7 @@ struct sway_config {
char *floating_scroll_right_cmd;
enum sway_container_layout default_orientation;
enum sway_container_layout default_layout;
char *font; // Use mostly for IPC.
char *font; // Used for IPC.
PangoFontDescription *font_description; // Used internally for rendering and validating.
int font_height;
int font_baseline;

View file

@ -6,6 +6,7 @@
#include "../include/config.h"
#include "list.h"
#include "util.h"
#include <pango/pangocairo.h>
struct box_colors {
uint32_t border;
@ -28,7 +29,7 @@ struct swaybar_config {
char *status_command;
bool pango_markup;
uint32_t position; // zwlr_layer_surface_v1_anchor
char *font;
PangoFontDescription *font_description;
char *sep_symbol;
char *mode;
char *hidden_state;

View file

@ -4,7 +4,8 @@
struct swaynag_type {
char *name;
char *font;
char *font; // Used for debugging.
PangoFontDescription *font_description;
char *output;
uint32_t anchors;
int32_t layer; // enum zwlr_layer_shell_v1_layer or -1 if unset