From b874ba0d5c652639abd5e96c204a1877da462d5c Mon Sep 17 00:00:00 2001 From: bi4k8 Date: Mon, 10 Apr 2023 17:43:46 +0000 Subject: [PATCH] display-wayland: avoid crash when font has no family specified (#1498) Co-authored-by: bi4k8 --- src/display-wayland.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/display-wayland.cc b/src/display-wayland.cc index 9090922f..f1d8261a 100644 --- a/src/display-wayland.cc +++ b/src/display-wayland.cc @@ -866,6 +866,12 @@ void display_output_wayland::load_fonts(bool utf8) { auto &pango_font_entry = pango_fonts[i]; FcPattern *fc_pattern = FcNameParse(reinterpret_cast(font.name.c_str())); + // pango_fc_font_description_from_pattern requires a FAMILY to be set, + // so set an empty one if none is present. + FcValue dummy; + if (FcPatternGet (fc_pattern, FC_FAMILY, 0, &dummy) != FcResultMatch) { + FcPatternAddString (fc_pattern, FC_FAMILY, (FcChar8 *) ""); + } pango_font_entry.desc = pango_fc_font_description_from_pattern(fc_pattern, true);