changeset 90423:654ff3b48a81

Include "font.h". (x_default_font_parameter) [USE_FONT_BACKEND]: New function. (Fx_create_frame) [USE_FONT_BACKEND]: If enable_font_backend is nonzero, register all available font drivers. Call x_default_font_parameter for deciding a font. (x_create_tip_frame) [USE_FONT_BACKEND]: Likewise.
author Kenichi Handa <handa@m17n.org>
date Tue, 06 Jun 2006 03:56:46 +0000
parents 7190e43d6fde
children 4c7d4b278599
files src/xfns.c
diffstat 1 files changed, 91 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/xfns.c	Tue Jun 06 03:56:32 2006 +0000
+++ b/src/xfns.c	Tue Jun 06 03:56:46 2006 +0000
@@ -49,6 +49,10 @@
 #include "termhooks.h"
 #include "atimer.h"
 
+#ifdef USE_FONT_BACKEND
+#include "font.h"
+#endif	/* USE_FONT_BACKEND */
+
 #ifdef HAVE_X_WINDOWS
 
 #include <ctype.h>
@@ -537,6 +541,8 @@
 
 
 
+static void x_default_font_parameter P_ ((struct frame *, Lisp_Object));
+
 static Lisp_Object unwind_create_frame P_ ((Lisp_Object));
 static Lisp_Object unwind_create_tip_frame P_ ((Lisp_Object));
 
@@ -2958,6 +2964,43 @@
   return Qnil;
 }
 
+#ifdef USE_FONT_BACKEND
+static void
+x_default_font_parameter (f, parms)
+     struct frame *f;
+     Lisp_Object parms;
+{
+  struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
+  Lisp_Object font = x_get_arg (dpyinfo, parms, Qfont, "font", "Font",
+				RES_TYPE_STRING);
+
+  if (! STRINGP (font))
+    {
+      char *names[]
+	= { "-adobe-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1",
+	    "-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-1",
+	    "-*-*-medium-r-normal-*-*-140-*-*-c-*-iso8859-1",
+	    /* This was formerly the first thing tried, but it finds
+	       too many fonts and takes too long.  */
+	    "-*-*-medium-r-*-*-*-*-*-*-c-*-iso8859-1",
+	    /* If those didn't work, look for something which will
+	       at least work.  */
+	    "-*-fixed-*-*-*-*-*-140-*-*-c-*-iso8859-1",
+	    NULL };
+      int i;
+
+      for (i = 0; names[i]; i++)
+	{
+	  font = font_open_by_name (f, names[i]);
+	  if (! NILP (font))
+	    break;
+	}
+      if (NILP (font))
+	font = build_string ("fixed");
+    }
+  x_default_parameter (f, parms, Qfont, font, "font", "Font", RES_TYPE_STRING);
+}
+#endif	/* USE_FONT_BACKEND */
 
 DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
        1, 1, 0,
@@ -3133,8 +3176,32 @@
       specbind (Qx_resource_name, name);
     }
 
+  f->resx = dpyinfo->resx;
+  f->resy = dpyinfo->resy;
+
+#ifdef USE_FONT_BACKEND
+  if (enable_font_backend)
+    {
+      /* Perhaps, we must allow frame parameter, say `font-backend',
+	 to specify which font backends to use.  */
+#ifdef HAVE_FREETYPE
+#ifdef HAVE_XFT
+      register_font_driver (&xftfont_driver, f);
+#else	/* not HAVE_XFT */
+      register_font_driver (&ftxfont_driver, f);
+#endif	/* not HAVE_XFT */
+#endif	/* HAVE_FREETYPE */
+      register_font_driver (&xfont_driver, f);
+    }
+#endif	/* USE_FONT_BACKEND */
+
   /* Extract the window parameters from the supplied values
      that are needed to determine window geometry.  */
+#ifdef USE_FONT_BACKEND
+  if (enable_font_backend)
+    x_default_font_parameter (f, parms);
+else
+#endif	/* USE_FONT_BACKEND */
   {
     Lisp_Object font;
 
@@ -4719,8 +4786,32 @@
       specbind (Qx_resource_name, name);
     }
 
+  f->resx = dpyinfo->resx;
+  f->resy = dpyinfo->resy;
+
+#ifdef USE_FONT_BACKEND
+  if (enable_font_backend)
+    {
+      /* Perhaps, we must allow frame parameter, say `font-backend',
+	 to specify which font backends to use.  */
+#ifdef HAVE_FREETYPE
+#ifdef HAVE_XFT
+      register_font_driver (&xftfont_driver, f);
+#else	/* not HAVE_XFT */
+      register_font_driver (&ftxfont_driver, f);
+#endif	/* not HAVE_XFT */
+#endif	/* HAVE_FREETYPE */
+      register_font_driver (&xfont_driver, f);
+    }
+#endif	/* USE_FONT_BACKEND */
+
   /* Extract the window parameters from the supplied values that are
      needed to determine window geometry.  */
+#ifdef USE_FONT_BACKEND
+  if (enable_font_backend)
+    x_default_font_parameter (f, parms);
+else
+#endif	/* USE_FONT_BACKEND */
   {
     Lisp_Object font;