changeset 89047:3b6234eb229c

(QCfontset): New variable. (LFACE_FONTSET): New macro. (check_lface_attrs): Check also LFACE_FONTSET_INDEX. (set_lface_from_font_name): Setup LFACE_FONTSET (lface). (Finternal_set_lisp_face_attribute): Handle QCfontset. (Finternal_get_lisp_face_attribute): Likewise. (lface_same_font_attributes_p): Fix checking of LFACE_FONT_INDEX, check also LFACE_FONTSET_INDEX. (face_fontset): Check attrs[LFACE_FONTSET_INDEX], not attrs[LFACE_FONT_INDEX]. (syms_of_xfaces): Intern and staticpro QCfontset.
author Kenichi Handa <handa@m17n.org>
date Fri, 23 Aug 2002 02:26:44 +0000
parents 7a6ebd6b0c38
children 87c6cb535c03
files src/xfaces.c
diffstat 1 files changed, 46 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/xfaces.c	Thu Aug 22 01:18:39 2002 +0000
+++ b/src/xfaces.c	Fri Aug 23 02:26:44 2002 +0000
@@ -56,7 +56,7 @@
    13. Whether or not a box should be drawn around characters, the box
    type, and, for simple boxes, in what color.
 
-   14. Font or fontset pattern, or nil.  This is a special attribute.
+   14. Font pattern, or nil.  This is a special attribute.
    When this attribute is specified, the face uses a font opened by
    that pattern as is.  In addition, all the other font-related
    attributes (1st thru 5th) are generated from the opened font name.
@@ -72,6 +72,8 @@
    and is used to ensure that a font specified on the command line,
    for example, can be matched exactly.
 
+   17. A fontset name.
+
    Faces are frame-local by nature because Emacs allows to define the
    same named face (face names are symbols) differently for different
    frames.  Each frame has an alist of face definitions for all named
@@ -123,7 +125,7 @@
    is realized, it inherits (thus shares) a fontset of an ASCII face
    that has the same attributes other than font-related ones.
 
-   Thus, all realized face have a realized fontset.
+   Thus, all realized faces have a realized fontset.
 
 
    Unibyte text.
@@ -341,6 +343,7 @@
 Lisp_Object QCwidth, QCfont, QCbold, QCitalic;
 Lisp_Object QCreverse_video;
 Lisp_Object QCoverline, QCstrike_through, QCbox, QCinherit;
+Lisp_Object QCfontset;
 
 /* Symbols used for attribute values.  */
 
@@ -1252,8 +1255,7 @@
 #ifdef HAVE_WINDOW_SYSTEM
 
 /* Load font of face FACE which is used on frame F to display ASCII
-   characters.  The name of the font to load is determined by lface
-   and fontset of FACE.  */
+   characters.  The name of the font to load is determined by lface.  */
 
 static void
 load_face_font (f, face)
@@ -2985,6 +2987,7 @@
 #define LFACE_FONT(LFACE)	    AREF ((LFACE), LFACE_FONT_INDEX)
 #define LFACE_INHERIT(LFACE)	    AREF ((LFACE), LFACE_INHERIT_INDEX)
 #define LFACE_AVGWIDTH(LFACE)	    AREF ((LFACE), LFACE_AVGWIDTH_INDEX)
+#define LFACE_FONTSET(LFACE)	    AREF ((LFACE), LFACE_FONTSET_INDEX)
 
 /* Non-zero if LFACE is a Lisp face.  A Lisp face is a vector of size
    LFACE_VECTOR_SIZE which has the symbol `face' in slot 0.  */
@@ -3048,6 +3051,8 @@
   xassert (UNSPECIFIEDP (attrs[LFACE_FONT_INDEX])
 	   || NILP (attrs[LFACE_FONT_INDEX])
 	   || STRINGP (attrs[LFACE_FONT_INDEX]));
+  xassert (UNSPECIFIEDP (attrs[LFACE_FONTSET_INDEX])
+	   || STRINGP (attrs[LFACE_FONTSET_INDEX]));
 #endif
 }
 
@@ -3286,8 +3291,13 @@
     LFACE_SLANT (lface)
       = have_xlfd_p ? xlfd_symbolic_slant (&font) : Qnormal;
 
-  LFACE_FONT (lface) = fontname;
-
+  if (fontset)
+    {
+      LFACE_FONT (lface) = build_string (font_info->full_name);
+      LFACE_FONTSET (lface) = fontset_name (fontset);
+    }
+  else
+    LFACE_FONT (lface) = fontname;
   return 1;
 }
 
@@ -4124,7 +4134,7 @@
       LFACE_SWIDTH (lface) = value;
       font_related_attr_p = 1;
     }
-  else if (EQ (attr, QCfont))
+  else if (EQ (attr, QCfont) || EQ (attr, QCfontset))
     {
 #ifdef HAVE_WINDOW_SYSTEM
       if (FRAME_WINDOW_P (XFRAME (frame)))
@@ -4145,9 +4155,16 @@
 	  tmp = Fquery_fontset (value, Qnil);
 	  if (!NILP (tmp))
 	    value = tmp;
-
-	  if (!set_lface_from_font_name (f, lface, value, 1, 1))
-	    signal_error ("Invalid font or fontset name", value);
+	  else if (EQ (attr, QCfontset))
+	    error ("Invalid fontset", XSTRING (value)->data);
+
+	  if (EQ (attr, QCfont))
+	    {
+	      if (!set_lface_from_font_name (f, lface, value, 1, 1))
+		signal_error ("Invalid font or fontset name", value);
+	    }
+	  else
+	    LFACE_FONTSET (lface) = value;
 
 	  font_attr_p = 1;
 	}
@@ -4197,6 +4214,7 @@
      init_iterator will then free realized faces.  */
   if (!EQ (frame, Qt)
       && (EQ (attr, QCfont)
+	  || EQ (attr, QCfontset)
 	  || NILP (Fequal (old_value, value))))
     {
       ++face_change_count;
@@ -4304,7 +4322,7 @@
 #ifdef HAVE_WINDOW_SYSTEM
 
 /* Set the `font' frame parameter of FRAME determined from `default'
-   face attributes LFACE.  If a face or fontset name is explicitely
+   face attributes LFACE.  If a font name is explicitely
    specfied in LFACE, use it as is.  Otherwise, determine a font name
    from the other font-related atrributes of LFACE.  In that case, if
    there's no matching font, signals an error.  */
@@ -4680,6 +4698,8 @@
     value = LFACE_INHERIT (lface);
   else if (EQ (keyword, QCfont))
     value = LFACE_FONT (lface);
+  else if (EQ (keyword, QCfontset))
+    value = LFACE_FONTSET (lface);
   else
     signal_error ("Invalid face attribute name", keyword);
 
@@ -4966,8 +4986,8 @@
 
 /* Return non-zero if LFACE1 and LFACE2 specify the same font (without
    considering charsets/registries).  They do if they specify the same
-   family, point size, weight, width, slant, and fontset.  Both LFACE1
-   and LFACE2 must be fully-specified.  */
+   family, point size, weight, width, slant, font, and fontset.  Both
+   LFACE1 and LFACE2 must be fully-specified.  */
 
 static INLINE int
 lface_same_font_attributes_p (lface1, lface2)
@@ -4985,8 +5005,14 @@
 	  && (EQ (lface1[LFACE_FONT_INDEX], lface2[LFACE_FONT_INDEX])
 	      || (STRINGP (lface1[LFACE_FONT_INDEX])
 		  && STRINGP (lface2[LFACE_FONT_INDEX])
-		  && xstricmp (XSTRING (lface1[LFACE_FONT_INDEX])->data,
-			       XSTRING (lface2[LFACE_FONT_INDEX])->data))));
+		  && ! xstricmp (XSTRING (lface1[LFACE_FONT_INDEX])->data,
+				 XSTRING (lface2[LFACE_FONT_INDEX])->data)))
+	  && (EQ (lface1[LFACE_FONTSET_INDEX], lface2[LFACE_FONTSET_INDEX])
+	      || (STRINGP (lface1[LFACE_FONTSET_INDEX])
+		  && STRINGP (lface2[LFACE_FONTSET_INDEX])
+		  && ! xstricmp (XSTRING (lface1[LFACE_FONTSET_INDEX])->data,
+				 XSTRING (lface2[LFACE_FONTSET_INDEX])->data)))
+	  );
 }
 
 
@@ -6167,8 +6193,9 @@
      Lisp_Object *attrs;
 {
   Lisp_Object name;
-
-  name = attrs[LFACE_FONT_INDEX];
+  int fontset;
+
+  name = attrs[LFACE_FONTSET_INDEX];
   if (!STRINGP (name))
     return -1;
   return fs_query_fontset (name, 0);
@@ -7288,6 +7315,8 @@
   staticpro (&QCwidth);
   QCfont = intern (":font");
   staticpro (&QCfont);
+  QCfontset = intern (":fontset");
+  staticpro (&QCfontset);
   QCbold = intern (":bold");
   staticpro (&QCbold);
   QCitalic = intern (":italic");