aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLibravatar Hugo Osvaldo Barrera <hugo@barrera.io>2022-07-01 12:23:04 +0200
committerLibravatar Simon Ser <contact@emersion.fr>2022-07-01 13:05:58 +0200
commit80e386fd97c0da00970f0acc007574151048cfbf (patch)
treedf11d53184b20e3f1afe86b8272420349fd9b552 /include
parentReject font values that are invalid for pango (diff)
downloadsway-80e386fd97c0da00970f0acc007574151048cfbf.tar.gz
sway-80e386fd97c0da00970f0acc007574151048cfbf.tar.zst
sway-80e386fd97c0da00970f0acc007574151048cfbf.zip
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 @@
13 * escaped string to dest if provided. 13 * escaped string to dest if provided.
14 */ 14 */
15size_t escape_markup_text(const char *src, char *dest); 15size_t escape_markup_text(const char *src, char *dest);
16PangoLayout *get_pango_layout(cairo_t *cairo, const char *font, 16PangoLayout *get_pango_layout(cairo_t *cairo, const PangoFontDescription *desc,
17 const char *text, double scale, bool markup); 17 const char *text, double scale, bool markup);
18void get_text_size(cairo_t *cairo, const char *font, int *width, int *height, 18void get_text_size(cairo_t *cairo, const PangoFontDescription *desc, int *width, int *height,
19 int *baseline, double scale, bool markup, const char *fmt, ...); 19 int *baseline, double scale, bool markup, const char *fmt, ...);
20void get_text_metrics(const PangoFontDescription *font, int *height, int *baseline); 20void get_text_metrics(const PangoFontDescription *desc, int *height, int *baseline);
21void render_text(cairo_t *cairo, const char *font, 21void render_text(cairo_t *cairo, PangoFontDescription *desc,
22 double scale, bool markup, const char *fmt, ...); 22 double scale, bool markup, const char *fmt, ...);
23 23
24#endif 24#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 {
505 char *floating_scroll_right_cmd; 505 char *floating_scroll_right_cmd;
506 enum sway_container_layout default_orientation; 506 enum sway_container_layout default_orientation;
507 enum sway_container_layout default_layout; 507 enum sway_container_layout default_layout;
508 char *font; // Use mostly for IPC. 508 char *font; // Used for IPC.
509 PangoFontDescription *font_description; // Used internally for rendering and validating. 509 PangoFontDescription *font_description; // Used internally for rendering and validating.
510 int font_height; 510 int font_height;
511 int font_baseline; 511 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 @@
6#include "../include/config.h" 6#include "../include/config.h"
7#include "list.h" 7#include "list.h"
8#include "util.h" 8#include "util.h"
9#include <pango/pangocairo.h>
9 10
10struct box_colors { 11struct box_colors {
11 uint32_t border; 12 uint32_t border;
@@ -28,7 +29,7 @@ struct swaybar_config {
28 char *status_command; 29 char *status_command;
29 bool pango_markup; 30 bool pango_markup;
30 uint32_t position; // zwlr_layer_surface_v1_anchor 31 uint32_t position; // zwlr_layer_surface_v1_anchor
31 char *font; 32 PangoFontDescription *font_description;
32 char *sep_symbol; 33 char *sep_symbol;
33 char *mode; 34 char *mode;
34 char *hidden_state; 35 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 @@
4struct swaynag_type { 4struct swaynag_type {
5 char *name; 5 char *name;
6 6
7 char *font; 7 char *font; // Used for debugging.
8 PangoFontDescription *font_description;
8 char *output; 9 char *output;
9 uint32_t anchors; 10 uint32_t anchors;
10 int32_t layer; // enum zwlr_layer_shell_v1_layer or -1 if unset 11 int32_t layer; // enum zwlr_layer_shell_v1_layer or -1 if unset