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
This commit is contained in:
Hugo Osvaldo Barrera 2022-06-29 21:38:24 +02:00 committed by Simon Ser
parent 9e8866ae20
commit 75605491a5
5 changed files with 30 additions and 6 deletions

View file

@ -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;