From fd998c7f54a69da63e3b588c7c8faf2d27d6c83e Mon Sep 17 00:00:00 2001 From: "Kim F. Storm" Date: Sun, 9 Jan 2005 02:05:20 +0000 Subject: [PATCH] (merge_into_realized_face): New function. Used to merge escape-glyph face or face from display table into current face. --- src/xfaces.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/xfaces.c b/src/xfaces.c index b980467882c..c6dff0bae7f 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -7687,6 +7687,53 @@ face_at_string_position (w, string, pos, bufpos, region_beg, } +/* 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 -- 2.39.2