aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorFurkan Sahin <furkan-dev@proton.me>2022-06-29 21:38:24 +0200
committerFurkan Sahin <furkan-dev@proton.me>2022-06-29 21:38:24 +0200
commit48cc4482a4b11aec6af4bb1ba52f88d1c809e7a9 (patch)
treef1d7476fbc893517ea01ed0f92841219f8b4808a /include
parentad0c2ed8b307746d0c0959a71cdb30382a03663d (diff)
Reject font values that are invalid for pango
Use pango to parse font configuration early, and reject the command as invalid if the value is invalid for pango. Since we're already parsing the font into a `PangoFontDescription`, keep that instance around and avoid re-parsing the font each time we render text. Fixes: https://github.com/swaywm/sway/issues/6805
Diffstat (limited to 'include')
-rw-r--r--include/pango.h2
-rw-r--r--include/sway/config.h4
2 files changed, 4 insertions, 2 deletions
diff --git a/include/pango.h b/include/pango.h
index 93affc23..2f14d2bb 100644
--- a/include/pango.h
+++ b/include/pango.h
@@ -17,7 +17,7 @@ PangoLayout *get_pango_layout(cairo_t *cairo, const char *font,
const char *text, double scale, bool markup);
void get_text_size(cairo_t *cairo, const char *font, int *width, int *height,
int *baseline, double scale, bool markup, const char *fmt, ...);
-void get_text_metrics(const char *font, int *height, int *baseline);
+void get_text_metrics(const PangoFontDescription *font, int *height, int *baseline);
void render_text(cairo_t *cairo, const char *font,
double scale, bool markup, const char *fmt, ...);
diff --git a/include/sway/config.h b/include/sway/config.h
index 05678c33..8939af00 100644
--- a/include/sway/config.h
+++ b/include/sway/config.h
@@ -17,6 +17,7 @@
#include "sway/input/tablet.h"
#include "sway/tree/root.h"
#include "wlr-layer-shell-unstable-v1-protocol.h"
+#include <pango/pangocairo.h>
// TODO: Refactor this shit
@@ -504,7 +505,8 @@ struct sway_config {
char *floating_scroll_right_cmd;
enum sway_container_layout default_orientation;
enum sway_container_layout default_layout;
- char *font;
+ char *font; // Use mostly for IPC.
+ PangoFontDescription *font_description; // Used internally for rendering and validating.
int font_height;
int font_baseline;
bool pango_markup;