changeset 94933:75fb6b489ec6

Throughout the file, delete all USE_FONT_BACKEND conditionals. Don't check enable_font_backend. Delete all codes used only when USE_FONT_BACKEND is not defined. (x_set_font): Call x_new_font, not x_new_fontset2. (x_set_font_backend): Use FRAME_FONT macro to check if a font is already set for the frame.
author Kenichi Handa <handa@m17n.org>
date Wed, 14 May 2008 01:34:57 +0000
parents 4ac20761f264
children 669d4161a058
files src/frame.c
diffstat 1 files changed, 52 insertions(+), 95 deletions(-) [+]
line wrap: on
line diff
--- a/src/frame.c	Wed May 14 01:34:02 2008 +0000
+++ b/src/frame.c	Wed May 14 01:34:57 2008 +0000
@@ -38,14 +38,15 @@
 #include "commands.h"
 #include "keyboard.h"
 #include "frame.h"
-#ifdef HAVE_WINDOW_SYSTEM
-#include "fontset.h"
-#endif
 #include "blockinput.h"
 #include "termchar.h"
 #include "termhooks.h"
 #include "dispextern.h"
 #include "window.h"
+#ifdef HAVE_WINDOW_SYSTEM
+#include "font.h"
+#include "fontset.h"
+#endif
 #ifdef MSDOS
 #include "msdos.h"
 #include "dosfns.h"
@@ -54,10 +55,6 @@
 
 #ifdef HAVE_WINDOW_SYSTEM
 
-#ifdef USE_FONT_BACKEND
-#include "font.h"
-#endif	/* USE_FONT_BACKEND */
-
 /* The name we're using in resource queries.  Most often "emacs".  */
 
 Lisp_Object Vx_resource_name;
@@ -117,9 +114,7 @@
 Lisp_Object Qtty, Qtty_type;
 
 Lisp_Object Qfullscreen, Qfullwidth, Qfullheight, Qfullboth;
-#ifdef USE_FONT_BACKEND
 Lisp_Object Qfont_backend;
-#endif	/* USE_FONT_BACKEND */
 
 Lisp_Object Qinhibit_face_set_after_frame_default;
 Lisp_Object Qface_set_after_frame_default;
@@ -334,10 +329,8 @@
 #endif
   f->size_hint_flags = 0;
   f->win_gravity = 0;
-#ifdef USE_FONT_BACKEND
   f->font_driver_list = NULL;
   f->font_data_list = NULL;
-#endif	/* USE_FONT_BACKEND */
 
   root_window = make_window ();
   if (mini_p)
@@ -1468,10 +1461,8 @@
      memory. */
   free_glyphs (f);
 
-#ifdef USE_FONT_BACKEND
   /* Give chance to each font driver to free a frame specific data.  */
   font_update_drivers (f, Qnil);
-#endif	/* USE_FONT_BACKEND */
 
   /* Mark all the windows that used to be on FRAME as deleted, and then
      remove the reference to them.  */
@@ -2835,9 +2826,7 @@
   {"right-fringe",		&Qright_fringe},
   {"wait-for-wm",		&Qwait_for_wm},
   {"fullscreen",                &Qfullscreen},
-#ifdef USE_FONT_BACKEND
   {"font-backend",		&Qfont_backend}
-#endif	/* USE_FONT_BACKEND */
 };
 
 #ifdef HAVE_WINDOW_SYSTEM
@@ -3347,89 +3336,59 @@
      struct frame *f;
      Lisp_Object arg, oldval;
 {
-  Lisp_Object result;
-  Lisp_Object fontset_name;
   Lisp_Object frame;
-  int old_fontset = FRAME_FONTSET(f);
-
-#ifdef USE_FONT_BACKEND
-  if (enable_font_backend)
+  int fontset = -1;
+  Lisp_Object font_object;
+
+  /* Set the frame parameter back to the old value because we mail
+     fail to use ARG as the new parameter value.  */
+  store_frame_param (f, Qfont, oldval);
+
+  /* ARG is a fontset name, a font name, or a font object.
+     In the last case, this function never fail.  */
+  if (STRINGP (arg))
     {
-      int fontset = -1;
-      Lisp_Object font_object;
-
-      /* ARG is a fontset name, a font name, or a font object.
-	 In the last case, this function never fail.  */
-      if (STRINGP (arg))
+      fontset = fs_query_fontset (arg, 0);
+      if (fontset < 0)
 	{
-	  fontset = fs_query_fontset (arg, 0);
-	  if (fontset < 0)
-	    font_object = font_open_by_name (f, SDATA (arg));
-	  else if (fontset > 0)
-	    {
-	      Lisp_Object ascii_font = fontset_ascii (fontset);
-
-	      font_object = font_open_by_name (f, SDATA (ascii_font));
-	    }
+	  font_object = font_open_by_name (f, SDATA (arg));
+	  if (NILP (font_object))
+	    error ("Font `%s' is not defined", SDATA (arg));
+	  arg = AREF (font_object, FONT_NAME_INDEX);
+	}
+      else if (fontset > 0)
+	{
+	  Lisp_Object ascii_font = fontset_ascii (fontset);
+
+	  font_object = font_open_by_name (f, SDATA (ascii_font));
+	  if (NILP (font_object))
+	    error ("Font `%s' is not defined", SDATA (arg));
+	  arg = fontset_name (fontset);
 	}
       else
-	font_object = arg;
-
-      if (fontset < 0 && ! NILP (font_object))
-	fontset = new_fontset_from_font (font_object);
-
-      if (fontset == 0)
-	/* Refuse the default fontset.  */
-	result = Qt;
-      else if (NILP (font_object))
-	result = Qnil;
-      else
-	result = x_new_fontset2 (f, fontset, font_object);
+	error ("The default fontset can't be used for a frame font");
+    }
+  else if (FONT_OBJECT_P (arg))
+    {
+      font_object = arg;
+      /* This is store the XLFD font name in the frame parameter for
+	 backward compatiblity.  We should store the font-object
+	 itself in the future.  */
+      arg = AREF (font_object, FONT_NAME_INDEX);
     }
   else
-    {
-#endif	/* USE_FONT_BACKEND */
-  CHECK_STRING (arg);
-
-  fontset_name = Fquery_fontset (arg, Qnil);
-
-  BLOCK_INPUT;
-  result = (STRINGP (fontset_name)
-            ? x_new_fontset (f, fontset_name)
-            : x_new_fontset (f, arg));
-  UNBLOCK_INPUT;
-#ifdef USE_FONT_BACKEND
-    }
-#endif
-
-  if (EQ (result, Qnil))
-    error ("Font `%s' is not defined", SDATA (arg));
-  else if (EQ (result, Qt))
-    error ("The default fontset can't be used for a frame font");
-  else if (STRINGP (result))
-    {
-      set_default_ascii_font (result);
-      if (STRINGP (fontset_name))
-	{
-	  /* Fontset names are built from ASCII font names, so the
-	     names may be equal despite there was a change.  */
-	  if (old_fontset == FRAME_FONTSET (f))
-	    return;
-	}
-      store_frame_param (f, Qfont, result);
-
-      if (!NILP (Fequal (result, oldval)))
-        return;
-
-      /* Recalculate toolbar height.  */
-      f->n_tool_bar_rows = 0;
-      /* Ensure we redraw it.  */
-      clear_current_matrices (f);
-
-      recompute_basic_faces (f);
-    }
-  else
-    abort ();
+    signal_error ("Invalid font", arg);
+
+  if (! NILP (Fequal (font_object, oldval)))
+    return;
+  x_new_font (f, font_object, fontset);
+  store_frame_param (f, Qfont, arg);
+  /* Recalculate toolbar height.  */
+  f->n_tool_bar_rows = 0;
+  /* Ensure we redraw it.  */
+  clear_current_matrices (f);
+
+  recompute_basic_faces (f);
 
   do_pending_window_change (0);
 
@@ -3446,7 +3405,6 @@
 }
 
 
-#ifdef USE_FONT_BACKEND
 void
 x_set_font_backend (f, new_value, old_value)
      struct frame *f;
@@ -3476,7 +3434,7 @@
   if (! NILP (old_value) && ! NILP (Fequal (old_value, new_value)))
     return;
 
-  if (FRAME_FONT_OBJECT (f))
+  if (FRAME_FONT (f))
     free_all_realized_faces (Qnil);
 
   new_value = font_update_drivers (f, NILP (new_value) ? Qt : new_value);
@@ -3489,7 +3447,7 @@
     }
   store_frame_param (f, Qfont_backend, new_value);
 
-  if (FRAME_FONT_OBJECT (f))
+  if (FRAME_FONT (f))
     {
       Lisp_Object frame;
 
@@ -3499,7 +3457,6 @@
       ++windows_or_buffers_changed;
     }
 }
-#endif	/* USE_FONT_BACKEND */
 
 
 void