diff options
author | Hugo Osvaldo Barrera <hugo@barrera.io> | 2022-06-29 21:38:24 +0200 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2022-07-01 13:05:58 +0200 |
commit | 75605491a54f8647740fdba75dd2ad7bae9e0ca7 (patch) | |
tree | f1d7476fbc893517ea01ed0f92841219f8b4808a /sway/config.c | |
parent | Avoid unecessary string copy (diff) | |
download | sway-75605491a54f8647740fdba75dd2ad7bae9e0ca7.tar.gz sway-75605491a54f8647740fdba75dd2ad7bae9e0ca7.tar.zst sway-75605491a54f8647740fdba75dd2ad7bae9e0ca7.zip |
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 'sway/config.c')
-rw-r--r-- | sway/config.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/sway/config.c b/sway/config.c index 8220ece0..b41dd871 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -243,6 +243,7 @@ static void config_defaults(struct sway_config *config) { | |||
243 | config->default_layout = L_NONE; | 243 | config->default_layout = L_NONE; |
244 | config->default_orientation = L_NONE; | 244 | config->default_orientation = L_NONE; |
245 | if (!(config->font = strdup("monospace 10"))) goto cleanup; | 245 | if (!(config->font = strdup("monospace 10"))) goto cleanup; |
246 | config->font_description = pango_font_description_from_string(config->font); | ||
246 | config->urgent_timeout = 500; | 247 | config->urgent_timeout = 500; |
247 | config->focus_on_window_activation = FOWA_URGENT; | 248 | config->focus_on_window_activation = FOWA_URGENT; |
248 | config->popup_during_fullscreen = POPUP_SMART; | 249 | config->popup_during_fullscreen = POPUP_SMART; |
@@ -1006,7 +1007,7 @@ int workspace_output_cmp_workspace(const void *a, const void *b) { | |||
1006 | void config_update_font_height(void) { | 1007 | void config_update_font_height(void) { |
1007 | int prev_max_height = config->font_height; | 1008 | int prev_max_height = config->font_height; |
1008 | 1009 | ||
1009 | get_text_metrics(config->font, &config->font_height, &config->font_baseline); | 1010 | get_text_metrics(config->font_description, &config->font_height, &config->font_baseline); |
1010 | 1011 | ||
1011 | if (config->font_height != prev_max_height) { | 1012 | if (config->font_height != prev_max_height) { |
1012 | arrange_root(); | 1013 | arrange_root(); |