]> git.eshelyaron.com Git - emacs.git/commitdiff
Circumvent bug#70989
authorPo Lu <luangruo@yahoo.com>
Mon, 20 May 2024 12:59:32 +0000 (20:59 +0800)
committerEshel Yaron <me@eshelyaron.com>
Thu, 23 May 2024 08:28:11 +0000 (10:28 +0200)
* src/ftfont.c (get_adstyle_property): Substitute a space for
unrepresentable adstyle characters.  (bug#70989)

(cherry picked from commit 5957e570800d495522fff688b6d68f34ce557e14)

src/ftfont.c

index 2e37b62ea35bbb7e0466947c43299f6e4346af40..214d7532d6fee15c6dded6a70cebf6069f40fd5a 100644 (file)
@@ -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;