changeset 59431:2f2c5349bc03

(merge_into_realized_face): New function. Used to merge escape-glyph face or face from display table into current face.
author Kim F. Storm <storm@cua.dk>
date Sun, 09 Jan 2005 02:05:20 +0000
parents 6aee7f43ad59
children b6b9daefbc42
files src/xfaces.c
diffstat 1 files changed, 47 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/xfaces.c	Sun Jan 09 02:05:04 2005 +0000
+++ b/src/xfaces.c	Sun Jan 09 02:05:20 2005 +0000
@@ -7687,6 +7687,53 @@
 }
 
 
+/* Merge a face into a realized face.
+
+   F is frame where faces are (to be) realized.
+
+   FACE_NAME is named face to merge, or if nil,
+   FACE_ID is face_id of realized face to merge.
+
+   BASE_FACE_ID is realized face to merge into.
+
+   Return new face.
+*/
+
+int
+merge_into_realized_face (f, face_name, face_id, base_face_id)
+     struct frame *f;
+     Lisp_Object face_name;
+     int face_id, base_face_id;
+{
+  Lisp_Object attrs[LFACE_VECTOR_SIZE];
+  struct face *base_face;
+
+  base_face = FACE_FROM_ID (f, base_face_id);
+  if (!base_face)
+    return base_face_id;
+
+  /* Begin with attributes from the base face.  */
+  bcopy (base_face->lface, attrs, sizeof attrs);
+
+  if (!NILP (face_name))
+    {
+      if (!merge_named_face (f, face_name, attrs, 0))
+	return base_face_id;
+    }
+  else
+    {
+      struct face *face;
+      face = FACE_FROM_ID (f, face_id);
+      if (!face)
+	return base_face_id;
+      merge_face_vectors (f, face->lface, attrs, 0);
+    }
+
+  /* Look up a realized face with the given face attributes,
+     or realize a new one for ASCII characters.  */
+  return lookup_face (f, attrs, 0, NULL);
+}
+
 
 /***********************************************************************
 				Tests