* src/fns.c (Feql): Use `scm_eqv_p'.
[bpt/emacs.git] / src / fontset.c
index a6277b0..e34719e 100644 (file)
@@ -1,6 +1,6 @@
 /* Fontset handler.
 
-Copyright (C) 2001-2013 Free Software Foundation, Inc.
+Copyright (C) 2001-2014 Free Software Foundation, Inc.
 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
   2005, 2006, 2007, 2008, 2009, 2010, 2011
   National Institute of Advanced Industrial Science and Technology (AIST)
@@ -39,17 +39,10 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "intervals.h"
 #include "fontset.h"
 #include "window.h"
-#ifdef HAVE_X_WINDOWS
-#include "xterm.h"
-#endif
-#ifdef HAVE_NTGUI
-#include "w32term.h"
-#endif
-#ifdef HAVE_NS
-#include "nsterm.h"
-#endif
+#ifdef HAVE_WINDOW_SYSTEM
+#include TERM_HEADER
+#endif /* HAVE_WINDOW_SYSTEM */
 #include "termhooks.h"
-
 #include "font.h"
 
 /* FONTSET
@@ -216,27 +209,27 @@ set_fontset_name (Lisp_Object fontset, Lisp_Object name)
   set_char_table_extras (fontset, 1, name);
 }
 
-#define FONTSET_ASCII(fontset) XCHAR_TABLE (fontset)->extras[4]
+#define FONTSET_ASCII(fontset) XCHAR_TABLE (fontset)->extras[2]
 static void
 set_fontset_ascii (Lisp_Object fontset, Lisp_Object ascii)
 {
-  set_char_table_extras (fontset, 4, ascii);
+  set_char_table_extras (fontset, 2, ascii);
 }
 
 /* Access special values of (realized) FONTSET.  */
 
-#define FONTSET_BASE(fontset) XCHAR_TABLE (fontset)->extras[2]
+#define FONTSET_BASE(fontset) XCHAR_TABLE (fontset)->extras[3]
 static void
 set_fontset_base (Lisp_Object fontset, Lisp_Object base)
 {
-  set_char_table_extras (fontset, 2, base);
+  set_char_table_extras (fontset, 3, base);
 }
 
-#define FONTSET_FRAME(fontset) XCHAR_TABLE (fontset)->extras[3]
+#define FONTSET_FRAME(fontset) XCHAR_TABLE (fontset)->extras[4]
 static void
 set_fontset_frame (Lisp_Object fontset, Lisp_Object frame)
 {
-  set_char_table_extras (fontset, 3, frame);
+  set_char_table_extras (fontset, 4, frame);
 }
 
 #define FONTSET_NOFONT_FACE(fontset) XCHAR_TABLE (fontset)->extras[5]
@@ -246,20 +239,20 @@ set_fontset_nofont_face (Lisp_Object fontset, Lisp_Object face)
   set_char_table_extras (fontset, 5, face);
 }
 
-#define FONTSET_DEFAULT(fontset) XCHAR_TABLE (fontset)->extras[7]
+#define FONTSET_DEFAULT(fontset) XCHAR_TABLE (fontset)->extras[6]
 static void
 set_fontset_default (Lisp_Object fontset, Lisp_Object def)
 {
-  set_char_table_extras (fontset, 7, def);
+  set_char_table_extras (fontset, 6, def);
 }
 
 /* For both base and realized fontset.  */
 
-#define FONTSET_FALLBACK(fontset) XCHAR_TABLE (fontset)->extras[8]
+#define FONTSET_FALLBACK(fontset) XCHAR_TABLE (fontset)->extras[7]
 static void
 set_fontset_fallback (Lisp_Object fontset, Lisp_Object fallback)
 {
-  set_char_table_extras (fontset, 8, fallback);
+  set_char_table_extras (fontset, 7, fallback);
 }
 
 #define BASE_FONTSET_P(fontset) (NILP (FONTSET_BASE (fontset)))
@@ -859,21 +852,6 @@ fontset_ascii (int id)
   return elt;
 }
 
-static void
-free_realized_fontset (struct frame *f, Lisp_Object fontset)
-{
-#if 0
-  Lisp_Object tail;
-
-  if (0)
-    for (tail = FONTSET_OBJLIST (fontset); CONSP (tail); tail = XCDR (tail))
-      {
-       eassert (FONT_OBJECT_P (XCAR (tail)));
-       font_close_object (f, XCAR (tail));
-      }
-#endif
-}
-
 /* Free fontset of FACE defined on frame F.  Called from
    free_realized_face.  */
 
@@ -887,7 +865,6 @@ free_face_fontset (struct frame *f, struct face *face)
     return;
   eassert (! BASE_FONTSET_P (fontset));
   eassert (f == XFRAME (FONTSET_FRAME (fontset)));
-  free_realized_fontset (f, fontset);
   ASET (Vfontset_table, face->fontset, Qnil);
   if (face->fontset < next_fontset_id)
     next_fontset_id = face->fontset;
@@ -898,7 +875,6 @@ free_face_fontset (struct frame *f, struct face *face)
       fontset = AREF (Vfontset_table, id);
       eassert (!NILP (fontset) && ! BASE_FONTSET_P (fontset));
       eassert (f == XFRAME (FONTSET_FRAME (fontset)));
-      free_realized_fontset (f, fontset);
       ASET (Vfontset_table, id, Qnil);
       if (id < next_fontset_id)
        next_fontset_id = face->fontset;
@@ -906,42 +882,21 @@ free_face_fontset (struct frame *f, struct face *face)
   face->fontset = -1;
 }
 
-
-#if 0
-/* Return true if FACE is suitable for displaying character C.
-   Called from the macro FACE_SUITABLE_FOR_CHAR_P
-   when C is not an ASCII character.  */
-
-bool
-face_suitable_for_char_p (struct face *face, int c)
-{
-  Lisp_Object fontset, rfont_def;
-
-  fontset = FONTSET_FROM_ID (face->fontset);
-  rfont_def = fontset_font (fontset, c, NULL, -1);
-  return (VECTORP (rfont_def)
-         && INTEGERP (RFONT_DEF_FACE (rfont_def))
-         && face->id == XINT (RFONT_DEF_FACE (rfont_def)));
-}
-#endif
-
-
-/* Return ID of face suitable for displaying character C on frame F.
-   FACE must be realized for ASCII characters in advance.  Called from
-   the macro FACE_FOR_CHAR.  */
+/* Return ID of face suitable for displaying character C at buffer position
+   POS on frame F.  FACE must be realized for ASCII characters in advance.
+   Called from the macro FACE_FOR_CHAR.  */
 
 int
-face_for_char (struct frame *f, struct face *face, int c, int pos, Lisp_Object object)
+face_for_char (struct frame *f, struct face *face, int c,
+              ptrdiff_t pos, Lisp_Object object)
 {
   Lisp_Object fontset, rfont_def, charset;
   int face_id;
   int id;
 
-  /* If face->fontset is negative (that happens when no font is found
-     for face), just return face->ascii_face because we can't do
-     anything.  Perhaps, we should fix the callers to assure
-     that face->fontset is always valid.  */
-  if (ASCII_CHAR_P (c) || face->fontset < 0)
+  eassert (fontset_id_valid_p (face->fontset));
+
+  if (ASCII_CHAR_P (c) || CHAR_BYTE8_P (c))
     return face->ascii_face->id;
 
 #ifdef HAVE_NS
@@ -957,7 +912,6 @@ face_for_char (struct frame *f, struct face *face, int c, int pos, Lisp_Object o
     }
 #endif
 
-  eassert (fontset_id_valid_p (face->fontset));
   fontset = FONTSET_FROM_ID (face->fontset);
   eassert (!BASE_FONTSET_P (fontset));
 
@@ -1012,7 +966,7 @@ face_for_char (struct frame *f, struct face *face, int c, int pos, Lisp_Object o
 
 
 Lisp_Object
-font_for_char (struct face *face, int c, int pos, Lisp_Object object)
+font_for_char (struct face *face, int c, ptrdiff_t pos, Lisp_Object object)
 {
   Lisp_Object fontset, rfont_def, charset;
   int id;
@@ -1882,7 +1836,7 @@ DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 2, 0,
        return Qnil;
       w = XWINDOW (window);
       f = XFRAME (w->frame);
-      face_id = face_at_buffer_position (w, pos, -1, -1, &dummy,
+      face_id = face_at_buffer_position (w, pos, &dummy,
                                         pos + 100, 0, -1);
     }
   if (! CHAR_VALID_P (c))
@@ -2188,7 +2142,7 @@ void
 syms_of_fontset (void)
 {
   DEFSYM (Qfontset, "fontset");
-  Fput (Qfontset, Qchar_table_extra_slots, make_number (9));
+  Fput (Qfontset, Qchar_table_extra_slots, make_number (8));
   DEFSYM (Qfontset_info, "fontset-info");
   Fput (Qfontset_info, Qchar_table_extra_slots, make_number (1));