Always suggest system font because .emacs may not have been read yet.
authorJan Djärv <jan.h.d@swipnet.se>
Fri, 20 Nov 2009 09:44:42 +0000 (09:44 +0000)
committerJan Djärv <jan.h.d@swipnet.se>
Fri, 20 Nov 2009 09:44:42 +0000 (09:44 +0000)
* xfns.c (x_default_font_parameter): Call xsettings_get_system_font.

* xsettings.h: Declare xsettings_get_system_font.

* xsettings.c (xsettings_get_system_font): New function.
(init_gconf): No use initiating gconf unless we have Xft also.
(syms_of_xsettings): Only provide system-font-setting if HAVE_XFT and
HAVE_GCONF.

src/ChangeLog
src/xfns.c
src/xsettings.c
src/xsettings.h

index e1cce91..cefcd61 100644 (file)
@@ -1,5 +1,14 @@
 2009-11-20  Jan Djärv  <jan.h.d@swipnet.se>
 
+       * xfns.c (x_default_font_parameter): Call xsettings_get_system_font.
+
+       * xsettings.h: Declare xsettings_get_system_font.
+
+       * xsettings.c (xsettings_get_system_font): New function.
+       (init_gconf): No use initiating gconf unless we have Xft also.
+       (syms_of_xsettings): Only provide system-font-setting if HAVE_XFT and
+       HAVE_GCONF.
+
        * gtkutil.c (xg_modify_menubar_widgets): If menubar is totally empty
        add a blank entry so it doesn't collapse into nothing.
 
index 3d7e89c..0ae6f95 100644 (file)
@@ -3031,14 +3031,21 @@ x_default_font_parameter (f, parms)
   Lisp_Object font;
   int got_from_gconf = 0;
   if (EQ (font_param, Qunbound))
+    font_param = Qnil;
+
+  if (NILP (font_param))
     {
-      font_param = Ffont_get_system_font();
-      got_from_gconf = !NILP (font_param);
+      /* System font takes precedendce over X resources.  We must suggest this
+         regardless of font-use-system-font because .emacs may not have been
+         read yet.  */
+      const char *system_font = xsettings_get_system_font ();
+      if (system_font) font_param = make_string (system_font,
+                                                 strlen (system_font));
     }
-
+  
   font = !NILP (font_param) ? font_param
     : x_get_arg (dpyinfo, parms, Qfont, "font", "Font", RES_TYPE_STRING);
-  
+
   if (! STRINGP (font))
     {
       char *names[]
index 71a7eaa..8ce2474 100644 (file)
@@ -498,7 +498,7 @@ xft_settings_event (dpyinfo, event)
 static void
 init_gconf ()
 {
-#ifdef HAVE_GCONF
+#if defined (HAVE_GCONF) && defined (HAVE_XFT)
   int i;
   char *s;
   /* Should be enough, this is called at startup */
@@ -556,7 +556,7 @@ init_gconf ()
           init_sigio (i);
 #endif /* ! defined (SIGIO) */
       }
-#endif /* HAVE_GCONF */
+#endif /* HAVE_GCONF && HAVE_XFT */
 }
 
 static void
@@ -605,6 +605,11 @@ xsettings_initialize (dpyinfo)
   init_xfd_settings (dpyinfo);
 }
 
+const char *
+xsettings_get_system_font ()
+{
+  return current_mono_font;
+}
 
 DEFUN ("font-get-system-font", Ffont_get_system_font, Sfont_get_system_font,
        0, 0, 0,
@@ -635,10 +640,10 @@ syms_of_xsettings ()
     doc: /* *Non-nil means to use the system defined font.  */);
   use_system_font = 0;
 
+#ifdef HAVE_XFT
+  Fprovide (intern_c_string ("font-render-setting"), Qnil);
 #ifdef HAVE_GCONF
   Fprovide (intern_c_string ("system-font-setting"), Qnil);
 #endif
-#ifdef HAVE_XFT
-  Fprovide (intern_c_string ("font-render-setting"), Qnil);
 #endif
 }
index 503116b..d1b3992 100644 (file)
@@ -24,6 +24,7 @@ EXFUN (Ffont_get_system_font, 0);
 extern void xsettings_initialize P_ ((struct x_display_info *dpyinfo));
 extern void xft_settings_event P_ ((struct x_display_info *dpyinfo,
                                     XEvent *));
+extern const char *xsettings_get_system_font P_ ((void));
 
 
 #endif /* XSETTINGS_H */