Subject: Re: bug#36284: 27.0.50; [Cairo] Setting default face :family attribute in the init script is broken

From: YAMAMOTO Mitsuharu <[email-masked]>
Date: Wed, 19 Jun 2019 12:37:05 +0900

On Wed, 19 Jun 2019 10:32:24 +0900,
Dmitry Gutov wrote:
> 
> When using a build with Cairo, putting
> 
> (set-face-attribute 'default nil :height 113 :family "Inconsolata LGC")
> 
> into the init script doesn't have any effect.
> 
> Evaluating (face-attribute 'default :family) in the new session after
> that still returns "Ubuntu Mono".
> 
> However, if I evaluate the set-face-attribute call form later in the new
> frame, the font changes successfully.

It seems that some changes I made to xsetting.c in order to remove
dependency on libXft was too naive.  For this particular problem, the
patch below would work.  For stricter consistency with the behavior of
the Xft version, one would need to implement replacements for
XftDefaultSubstitute and XftDefaultSet.

				     YAMAMOTO Mitsuharu
				[email-masked]

diff --git a/src/xsettings.c b/src/xsettings.c
index 3e9012e3ab1..06c47c6c6ce 100644
--- a/src/xsettings.c
+++ b/src/xsettings.c
@@ -608,18 +608,16 @@ static void
 apply_xft_settings (struct x_display_info *dpyinfo,
                     struct xsettings *settings)
 {
-#if defined USE_CAIRO || defined HAVE_XFT
+#ifdef HAVE_XFT
   FcPattern *pat;
   struct xsettings oldsettings;
   bool changed = false;
 
   memset (&oldsettings, 0, sizeof (oldsettings));
   pat = FcPatternCreate ();
-#ifdef HAVE_XFT
   XftDefaultSubstitute (dpyinfo->display,
                         XScreenNumberOfScreen (dpyinfo->screen),
                         pat);
-#endif
   FcPatternGetBool (pat, FC_ANTIALIAS, 0, &oldsettings.aa);
   FcPatternGetBool (pat, FC_HINTING, 0, &oldsettings.hinting);
 #ifdef FC_HINT_STYLE
@@ -719,9 +717,7 @@ apply_xft_settings (struct x_display_info *dpyinfo,
       };
       char buf[sizeof format + d_formats * d_growth + lf_formats * lf_growth];
 
-#ifdef HAVE_XFT
       XftDefaultSet (dpyinfo->display, pat);
-#endif
       store_config_changed_event (Qfont_render,
 				  XCAR (dpyinfo->name_list_element));
       Vxft_settings
@@ -733,7 +729,7 @@ apply_xft_settings (struct x_display_info *dpyinfo,
     }
   else
     FcPatternDestroy (pat);
-#endif /* USE_CAIRO || HAVE_XFT */
+#endif /* HAVE_XFT */
 }
 
 /* Read XSettings from the display for DPYINFO.