Subject: bug#37786: 26.3; Emacs crashes when calling function to decode string

From: Allen Li <[email-masked]>
Date: Sat, 26 Oct 2019 02:44:52 -0700

Robert Pluim <[email-masked]> writes:

>>>>>> On Tue, 22 Oct 2019 20:25:40 -0700, Allen Li <[email-masked]> said:
>
>     Allen> I haven't touched xft-ignore-color-fonts (and it reproduces from emacs -Q)
>     >> 
>     Allen> #define FC_MAJOR	2
>     Allen> #define FC_MINOR	13
>     Allen> #define FC_REVISION	91
>     >> 
>
> Thatʼs a very recent (and maybe even unreleased) version of
> fontconfig.
>
>     Allen> Arch Linux
>
> Hmm. Could you try the following against emacs-26 and see if it fixes
> your crash? (the character will almost certainly end up displayed
> wrong). This looks more like a fontconfig bug than anything else: the
> pattern we've supplied to FcFontList explicitly says "donʼt give me
> color fonts".

Yep, this fixes the crash and I get the box with unicode codepoint
inside.  I don't know anything about fontconfig, so I can't comment on
whether this is a fontconfig bug.

>
> diff --git i/lisp/international/fontset.el w/lisp/international/fontset.el
> index c90d4f53bd..e80a1a87b9 100644
> --- i/lisp/international/fontset.el
> +++ w/lisp/international/fontset.el
> @@ -804,7 +804,6 @@ setup-default-fontset
>               #x2664
>               (#x2667 . #x2669)
>               (#x266C . #x26FF)
> -             (#x2700 . #x27bF) ;; Dingbats
>               (#x27C0 . #x27EF) ;; Misc Mathematical Symbols-A
>               (#x27F0 . #x27FF) ;; Supplemental Arrows-A
>               (#x2900 . #x297F) ;; Supplemental Arrows-B
> diff --git i/src/ftfont.c w/src/ftfont.c
> index 823fb2095c..017b349318 100644
> --- i/src/ftfont.c
> +++ w/src/ftfont.c
> @@ -861,6 +861,9 @@ ftfont_list (struct frame *f, Lisp_Object spec)
>  #endif /* FC_CAPABILITY */
>  #ifdef FC_FONTFORMAT
>                              FC_FONTFORMAT,
> +#endif
> +#ifdef FC_COLOR
> +                             FC_COLOR,
>  #endif
>                              NULL);
>    if (! objset)
> @@ -902,6 +905,15 @@ ftfont_list (struct frame *f, Lisp_Object spec)
>      {
>        Lisp_Object entity;
>
> +      {
> +        FcBool b;
> +        if (FcPatternGetBool (fontset->fonts[i], FC_COLOR, 0, &b)
> +            == FcResultMatch && b)
> +          {
> +            fprintf (stderr, "Skipping Color font\n");
> +            continue;
> +          }
> +      }
>        if (spacing >= 0)
>         {
>           int this;