From 59c78c6eff8562396d2a8eca496c03c47fd80b6c Mon Sep 17 00:00:00 2001 From: Po Lu Date: Mon, 20 May 2024 20:59:32 +0800 Subject: [PATCH] Circumvent bug#70989 * src/ftfont.c (get_adstyle_property): Substitute a space for unrepresentable adstyle characters. (bug#70989) (cherry picked from commit 5957e570800d495522fff688b6d68f34ce557e14) --- src/ftfont.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/ftfont.c b/src/ftfont.c index 2e37b62ea35..214d7532d6f 100644 --- a/src/ftfont.c +++ b/src/ftfont.c @@ -149,7 +149,8 @@ static Lisp_Object get_adstyle_property (FcPattern *p) { FcChar8 *fcstr; - char *str, *end; + char *str, *end, *tmp; + size_t i; Lisp_Object adstyle; #ifdef FC_FONTFORMAT @@ -168,7 +169,18 @@ get_adstyle_property (FcPattern *p) || matching_prefix (str, end - str, "Oblique") || matching_prefix (str, end - str, "Italic")) return Qnil; - adstyle = font_intern_prop (str, end - str, 1); + /* The characters `-', `?', `*', and `"' are not representable in XLFDs + and therefore must be replaced by substitutes. (bug#70989) */ + USE_SAFE_ALLOCA; + tmp = SAFE_ALLOCA (end - str); + for (i = 0; i < end - str; ++i) + tmp[i] = ((end[i] != '?' + && end[i] != '*' + && end[i] != '"' + && end[i] != '-') + ? end[i] : ' '); + adstyle = font_intern_prop (tmp, end - str, 1); + SAFE_FREE (); if (font_style_to_value (FONT_WIDTH_INDEX, adstyle, 0) >= 0) return Qnil; return adstyle; -- 2.39.5