aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorHugo Osvaldo Barrera <hugo@barrera.io>2022-07-01 12:23:04 +0200
committerSimon Ser <contact@emersion.fr>2022-07-01 13:05:58 +0200
commit80e386fd97c0da00970f0acc007574151048cfbf (patch)
treedf11d53184b20e3f1afe86b8272420349fd9b552 /include
parent75605491a54f8647740fdba75dd2ad7bae9e0ca7 (diff)
Reuse parsed PangoFontDescription
Avoids parsing the configured font each time text is rendered.
Diffstat (limited to 'include')
-rw-r--r--include/pango.h8
-rw-r--r--include/sway/config.h2
-rw-r--r--include/swaybar/config.h3
-rw-r--r--include/swaynag/types.h3
4 files changed, 9 insertions, 7 deletions
diff --git a/include/pango.h b/include/pango.h
index 2f14d2bb..1db113c2 100644
--- a/include/pango.h
+++ b/include/pango.h
@@ -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
diff --git a/include/sway/config.h b/include/sway/config.h
index 8939af00..2b4aa972 100644
--- a/include/sway/config.h
+++ b/include/sway/config.h
@@ -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;
diff --git a/include/swaybar/config.h b/include/swaybar/config.h
index 4cacd21a..361acd99 100644
--- a/include/swaybar/config.h
+++ b/include/swaybar/config.h
@@ -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;
diff --git a/include/swaynag/types.h b/include/swaynag/types.h
index 3c3b2754..18f218e0 100644
--- a/include/swaynag/types.h
+++ b/include/swaynag/types.h
@@ -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