aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChong Yidong2012-08-17 17:10:31 +0800
committerChong Yidong2012-08-17 17:10:31 +0800
commit383dcbf97748f1a4ef57f8af4f5780501ba78216 (patch)
treed21e24ab76f120c7f47cb6fc42b23f828a1fd902 /src
parent0df648f9869d11681df46502f7eef2bee1c7ae39 (diff)
downloademacs-383dcbf97748f1a4ef57f8af4f5780501ba78216.tar.gz
emacs-383dcbf97748f1a4ef57f8af4f5780501ba78216.zip
Allow face-remapping using :font, and use it in mouse-appearance-menu.
* mouse.el (mouse-appearance-menu): If x-select-font returns a font spec, set the font directly. * xfaces.c (merge_face_vectors): If the target font specfies a font spec, make the font's attributes take precedence over directly-specified attributes. (merge_face_ref): Recognize :font. Fixes: debbugs:3228
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog7
-rw-r--r--src/xfaces.c51
2 files changed, 40 insertions, 18 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 84d6920b3ea..72a11c177c4 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
12012-08-17 Chong Yidong <cyd@gnu.org>
2
3 * xfaces.c (merge_face_vectors): If the target font specfies a
4 font spec, make the font's attributes take precedence over
5 directly-specified attributes.
6 (merge_face_ref): Recognize :font.
7
12012-08-17 Dmitry Antipov <dmantipov@yandex.ru> 82012-08-17 Dmitry Antipov <dmantipov@yandex.ru>
2 9
3 Do not use memcpy for copying intervals. 10 Do not use memcpy for copying intervals.
diff --git a/src/xfaces.c b/src/xfaces.c
index 7491802466d..8c6542ee725 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -2281,6 +2281,7 @@ merge_face_vectors (struct frame *f, Lisp_Object *from, Lisp_Object *to,
2281 struct named_merge_point *named_merge_points) 2281 struct named_merge_point *named_merge_points)
2282{ 2282{
2283 int i; 2283 int i;
2284 Lisp_Object font = Qnil;
2284 2285
2285 /* If FROM inherits from some other faces, merge their attributes into 2286 /* If FROM inherits from some other faces, merge their attributes into
2286 TO before merging FROM's direct attributes. Note that an :inherit 2287 TO before merging FROM's direct attributes. Note that an :inherit
@@ -2291,24 +2292,13 @@ merge_face_vectors (struct frame *f, Lisp_Object *from, Lisp_Object *to,
2291 && !NILP (from[LFACE_INHERIT_INDEX])) 2292 && !NILP (from[LFACE_INHERIT_INDEX]))
2292 merge_face_ref (f, from[LFACE_INHERIT_INDEX], to, 0, named_merge_points); 2293 merge_face_ref (f, from[LFACE_INHERIT_INDEX], to, 0, named_merge_points);
2293 2294
2294 i = LFACE_FONT_INDEX; 2295 if (FONT_SPEC_P (from[LFACE_FONT_INDEX]))
2295 if (!UNSPECIFIEDP (from[i]))
2296 { 2296 {
2297 if (!UNSPECIFIEDP (to[i])) 2297 if (!UNSPECIFIEDP (to[LFACE_FONT_INDEX]))
2298 to[i] = merge_font_spec (from[i], to[i]); 2298 font = merge_font_spec (from[LFACE_FONT_INDEX], to[LFACE_FONT_INDEX]);
2299 else 2299 else
2300 to[i] = copy_font_spec (from[i]); 2300 font = copy_font_spec (from[LFACE_FONT_INDEX]);
2301 if (! NILP (AREF (to[i], FONT_FOUNDRY_INDEX))) 2301 to[LFACE_FONT_INDEX] = font;
2302 to[LFACE_FOUNDRY_INDEX] = SYMBOL_NAME (AREF (to[i], FONT_FOUNDRY_INDEX));
2303 if (! NILP (AREF (to[i], FONT_FAMILY_INDEX)))
2304 to[LFACE_FAMILY_INDEX] = SYMBOL_NAME (AREF (to[i], FONT_FAMILY_INDEX));
2305 if (! NILP (AREF (to[i], FONT_WEIGHT_INDEX)))
2306 to[LFACE_WEIGHT_INDEX] = FONT_WEIGHT_FOR_FACE (to[i]);
2307 if (! NILP (AREF (to[i], FONT_SLANT_INDEX)))
2308 to[LFACE_SLANT_INDEX] = FONT_SLANT_FOR_FACE (to[i]);
2309 if (! NILP (AREF (to[i], FONT_WIDTH_INDEX)))
2310 to[LFACE_SWIDTH_INDEX] = FONT_WIDTH_FOR_FACE (to[i]);
2311 ASET (to[i], FONT_SIZE_INDEX, Qnil);
2312 } 2302 }
2313 2303
2314 for (i = 1; i < LFACE_VECTOR_SIZE; ++i) 2304 for (i = 1; i < LFACE_VECTOR_SIZE; ++i)
@@ -2319,8 +2309,7 @@ merge_face_vectors (struct frame *f, Lisp_Object *from, Lisp_Object *to,
2319 to[i] = merge_face_heights (from[i], to[i], to[i]); 2309 to[i] = merge_face_heights (from[i], to[i], to[i]);
2320 font_clear_prop (to, FONT_SIZE_INDEX); 2310 font_clear_prop (to, FONT_SIZE_INDEX);
2321 } 2311 }
2322 else if (i != LFACE_FONT_INDEX 2312 else if (i != LFACE_FONT_INDEX && ! EQ (to[i], from[i]))
2323 && ! EQ (to[i], from[i]))
2324 { 2313 {
2325 to[i] = from[i]; 2314 to[i] = from[i];
2326 if (i >= LFACE_FAMILY_INDEX && i <=LFACE_SLANT_INDEX) 2315 if (i >= LFACE_FAMILY_INDEX && i <=LFACE_SLANT_INDEX)
@@ -2334,6 +2323,25 @@ merge_face_vectors (struct frame *f, Lisp_Object *from, Lisp_Object *to,
2334 } 2323 }
2335 } 2324 }
2336 2325
2326 /* If FROM specifies a font spec, make its contents take precedence
2327 over :family and other attributes. This is needed for face
2328 remapping using :font to work. */
2329
2330 if (!NILP (font))
2331 {
2332 if (! NILP (AREF (font, FONT_FOUNDRY_INDEX)))
2333 to[LFACE_FOUNDRY_INDEX] = SYMBOL_NAME (AREF (font, FONT_FOUNDRY_INDEX));
2334 if (! NILP (AREF (font, FONT_FAMILY_INDEX)))
2335 to[LFACE_FAMILY_INDEX] = SYMBOL_NAME (AREF (font, FONT_FAMILY_INDEX));
2336 if (! NILP (AREF (font, FONT_WEIGHT_INDEX)))
2337 to[LFACE_WEIGHT_INDEX] = FONT_WEIGHT_FOR_FACE (font);
2338 if (! NILP (AREF (font, FONT_SLANT_INDEX)))
2339 to[LFACE_SLANT_INDEX] = FONT_SLANT_FOR_FACE (font);
2340 if (! NILP (AREF (font, FONT_WIDTH_INDEX)))
2341 to[LFACE_SWIDTH_INDEX] = FONT_WIDTH_FOR_FACE (font);
2342 ASET (font, FONT_SIZE_INDEX, Qnil);
2343 }
2344
2337 /* TO is always an absolute face, which should inherit from nothing. 2345 /* TO is always an absolute face, which should inherit from nothing.
2338 We blindly copy the :inherit attribute above and fix it up here. */ 2346 We blindly copy the :inherit attribute above and fix it up here. */
2339 to[LFACE_INHERIT_INDEX] = Qnil; 2347 to[LFACE_INHERIT_INDEX] = Qnil;
@@ -2575,6 +2583,13 @@ merge_face_ref (struct frame *f, Lisp_Object face_ref, Lisp_Object *to,
2575 else 2583 else
2576 err = 1; 2584 err = 1;
2577 } 2585 }
2586 else if (EQ (keyword, QCfont))
2587 {
2588 if (FONTP (value))
2589 to[LFACE_FONT_INDEX] = value;
2590 else
2591 err = 1;
2592 }
2578 else if (EQ (keyword, QCinherit)) 2593 else if (EQ (keyword, QCinherit))
2579 { 2594 {
2580 /* This is not really very useful; it's just like a 2595 /* This is not really very useful; it's just like a