unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Miles Bader <miles@lsi.nec.co.jp>
Cc: emacs-devel@gnu.org
Subject: Re: Bold by moving pixels problem
Date: 18 Dec 2002 19:01:01 +0900	[thread overview]
Message-ID: <buo1y4f3aua.fsf@mcspd15.ucom.lsi.nec.co.jp> (raw)
In-Reply-To: <buoisxtazqu.fsf@mcspd15.ucom.lsi.nec.co.jp>

[-- Attachment #1: Type: text/plain, Size: 72 bytes --]

Here's an updated version of my patch, that uses a list of functions:



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: realize-face-filter-20021218-0.patch --]
[-- Type: text/x-patch, Size: 9543 bytes --]

2002-12-17  Miles Bader  <miles@gnu.org>

	* xfaces.c (Vrealize_face_filter_functions): New variable.
	(realize_face): If Vrealize_face_filter_functions has a non-nil
	value, use it to filter the face attributes before realization.
	Use new calling conventions for realize_x_face, realize_tty_face,
	and load_face_font.
	(realize_x_face, realize_tty_face): Add new argument FACE, and
	change return type to void.  Use FACE instead of creating our own.
	(load_face_font): Add a new argument ATTRS, and use it instead of
	FACE->lface.
	(syms_of_xfaces): Initialize Vrealize_face_filter_functions.

Index: src/xfaces.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/xfaces.c,v
retrieving revision 1.266
diff -u -r1.266 xfaces.c
--- src/xfaces.c	17 Nov 2002 23:51:19 -0000	1.266
+++ src/xfaces.c	18 Dec 2002 05:26:34 -0000
@@ -422,6 +422,13 @@
 
 Lisp_Object Vtty_defined_color_alist;
 
+/* A list of functions to perturb faces before final realization.
+   They are passed a lisp-vector containing all the attributes of the
+   fully-specified face, and can change any that they wish. */
+
+Lisp_Object Vrealize_face_filter_functions;
+
+
 /* Counter for calls to clear_face_cache.  If this counter reaches
    CLEAR_FONT_TABLE_COUNT, and a frame has more than
    CLEAR_FONT_TABLE_NFONTS load, unused fonts are freed.  */
@@ -481,7 +488,7 @@
 static unsigned char *xstrlwr P_ ((unsigned char *));
 static void signal_error P_ ((char *, Lisp_Object));
 static struct frame *frame_or_selected_frame P_ ((Lisp_Object, int));
-static void load_face_font P_ ((struct frame *, struct face *, int));
+static void load_face_font P_ ((struct frame *, struct face *, Lisp_Object *, int));
 static void load_face_colors P_ ((struct frame *, struct face *, Lisp_Object *));
 static void free_face_colors P_ ((struct frame *, struct face *));
 static int face_color_gray_p P_ ((struct frame *, char *));
@@ -502,10 +509,10 @@
 static int cmp_font_names P_ ((const void *, const void *));
 static struct face *realize_face P_ ((struct face_cache *, Lisp_Object *, int,
 				      struct face *, int));
-static struct face *realize_x_face P_ ((struct face_cache *,
-					Lisp_Object *, int, struct face *));
-static struct face *realize_tty_face P_ ((struct face_cache *,
-					  Lisp_Object *, int));
+static void realize_x_face P_ ((struct face *, struct face_cache *,
+				Lisp_Object *, int, struct face *));
+static void realize_tty_face P_ ((struct face *, struct face_cache *,
+				  Lisp_Object *, int));
 static int realize_basic_faces P_ ((struct frame *));
 static int realize_default_face P_ ((struct frame *));
 static void realize_named_face P_ ((struct frame *, Lisp_Object, int));
@@ -1245,14 +1252,15 @@
 
 #ifdef HAVE_WINDOW_SYSTEM
 
-/* Load font of face FACE which is used on frame F to display
-   character C.  The name of the font to load is determined by lface
-   and fontset of FACE.  */
+/* Load font of face FACE with attributes ATTRS which is used on frame F to
+   display character C.  The name of the font to load is determined by
+   lface and fontset of FACE.  */
 
 static void
-load_face_font (f, face, c)
+load_face_font (f, face, attrs, c)
      struct frame *f;
      struct face *face;
+     Lisp_Object *attrs;
      int c;
 {
   struct font_info *font_info = NULL;
@@ -1262,7 +1270,7 @@
   face->font_info_id = -1;
   face->font = NULL;
 
-  font_name = choose_face_font (f, face->lface, face->fontset, c,
+  font_name = choose_face_font (f, attrs, face->fontset, c,
 				&needs_overstrike);
   if (!font_name)
     return;
@@ -6678,6 +6686,11 @@
      int former_face_id;
 {
   struct face *face;
+  /* The set of attributes this face is know by to the user, as opposed to
+     the set actually used to render the face.  They're usually the same
+     as, but may be different if some attribute is changed by
+     realize-face-filter.  */
+  Lisp_Object *orig_attrs = attrs;
 
   /* LFACE must be fully specified.  */
   xassert (cache != NULL);
@@ -6691,41 +6704,70 @@
       free_realized_face (cache->f, former_face);
     }
 
+  if (CONSP (Vrealize_face_filter_functions))
+    {
+      /* Call these user-defined functions to perturb the face attributes
+	 before realization.  */
+      Lisp_Object filters, cycle_check;
+      Lisp_Object lface = Fmake_vector (make_number (LFACE_VECTOR_SIZE),
+					Qunspecified);
+
+      bcopy (attrs, XVECTOR (lface)->contents,
+	     LFACE_VECTOR_SIZE * (sizeof *attrs));
+
+      cycle_check = Qnil;
+      for (filters = Vrealize_face_filter_functions;
+	   CONSP (filters);
+	   filters = XCDR (filters))
+	{
+	  safe_call1 (XCAR (filters), lface);
+	  cycle_check = CYCLE_CHECK (cycle_check, filters, 50);
+	  if (NILP (cycle_check))
+	    break;		/* cycle detected */
+	}
+
+      attrs = XVECTOR (lface)->contents;
+    }      
+
+  /* Allocate a new realized face.  */
+  face = make_realized_face (orig_attrs);
+
+  /* Fill it in.  */
   if (FRAME_WINDOW_P (cache->f))
-    face = realize_x_face (cache, attrs, c, base_face);
+    realize_x_face (face, cache, attrs, c, base_face);
   else if (FRAME_TERMCAP_P (cache->f) || FRAME_MSDOS_P (cache->f))
-    face = realize_tty_face (cache, attrs, c);
+    realize_tty_face (face, cache, attrs, c);
   else
     abort ();
 
   /* Insert the new face.  */
-  cache_face (cache, face, lface_hash (attrs));
+  cache_face (cache, face, lface_hash (orig_attrs));
 #ifdef HAVE_WINDOW_SYSTEM
   if (FRAME_WINDOW_P (cache->f) && face->font == NULL)
-    load_face_font (cache->f, face, c);
+    load_face_font (cache->f, face, attrs, c);
 #endif  /* HAVE_WINDOW_SYSTEM */
   return face;
 }
 
 
-/* Realize the fully-specified face with attributes ATTRS in face
-   cache CACHE for character C.  Do it for X frame CACHE->f.  If C is
-   a multibyte character, BASE_FACE is a face that has the same
-   attributes.  Otherwise, BASE_FACE is ignored.  If the new face
-   doesn't share font with the default face, a fontname is allocated
-   from the heap and set in `font_name' of the new face, but it is not
-   yet loaded here.  Value is a pointer to the newly created realized
-   face.  */
+/* Realize into FACE the fully-specified face with attributes ATTRS in face
+   cache CACHE for character C.  Do it for X frame CACHE->f.  If C is a
+   multibyte character, BASE_FACE is a face that has the same attributes.
+   Otherwise, BASE_FACE is ignored.  If the new face doesn't share font
+   with the default face, a fontname is allocated from the heap and set in
+   `font_name' of the new face, but it is not yet loaded here.  Value is a
+   pointer to the newly created realized face.  */
 
-static struct face *
-realize_x_face (cache, attrs, c, base_face)
+static void
+realize_x_face (face, cache, attrs, c, base_face)
+     struct face *face;
      struct face_cache *cache;
      Lisp_Object *attrs;
      int c;
      struct face *base_face;
 {
 #ifdef HAVE_WINDOW_SYSTEM
-  struct face *face, *default_face;
+  struct face *default_face;
   struct frame *f;
   Lisp_Object stipple, overline, strike_through, box;
 
@@ -6733,9 +6775,6 @@
   xassert (SINGLE_BYTE_CHAR_P (c)
 	   || base_face);
 
-  /* Allocate a new realized face.  */
-  face = make_realized_face (attrs);
-
   f = cache->f;
 
   /* If C is a multibyte character, we share all face attirbutes with
@@ -6751,7 +6790,7 @@
 
       /* to force realize_face to load font */
       face->font = NULL;
-      return face;
+      return;
     }
 
   /* Now we are realizing a face for ASCII (and unibyte) characters.  */
@@ -6921,7 +6960,6 @@
     face->stipple = load_pixmap (f, stipple, &face->pixmap_w, &face->pixmap_h);
 
   xassert (FACE_SUITABLE_FOR_CHAR_P (face, c));
-  return face;
 #endif /* HAVE_WINDOW_SYSTEM */
 }
 
@@ -7012,17 +7050,16 @@
 }
 
 
-/* Realize the fully-specified face with attributes ATTRS in face
-   cache CACHE for character C.  Do it for TTY frame CACHE->f.  Value is a
-   pointer to the newly created realized face.  */
+/* Realize into FACE the fully-specified face with attributes ATTRS in face
+   cache CACHE for character C.  Do it for TTY frame CACHE->f.  */
 
-static struct face *
-realize_tty_face (cache, attrs, c)
+static void
+realize_tty_face (face, cache, attrs, c)
+     struct face *face;
      struct face_cache *cache;
      Lisp_Object *attrs;
      int c;
 {
-  struct face *face;
   int weight, slant;
   int face_colors_defaulted = 0;
   struct frame *f = cache->f;
@@ -7030,8 +7067,6 @@
   /* Frame must be a termcap frame.  */
   xassert (FRAME_TERMCAP_P (cache->f) || FRAME_MSDOS_P (cache->f));
 
-  /* Allocate a new realized face.  */
-  face = make_realized_face (attrs);
   face->font_name = FRAME_MSDOS_P (cache->f) ? "ms-dos" : "tty";
 
   /* Map face attributes to TTY appearances.  We map slant to
@@ -7068,8 +7103,6 @@
       && face->background == FACE_TTY_DEFAULT_FG_COLOR
       && face->foreground == FACE_TTY_DEFAULT_BG_COLOR)
     face->tty_bold_p = 0;
-
-  return face;
 }
 
 
@@ -7670,6 +7703,14 @@
 Each element is a regular expression that matches names of fonts to
 ignore.  */);
   Vface_ignored_fonts = Qnil;
+
+  DEFVAR_LISP ("realize-face-filter-functions",
+	       &Vrealize_face_filter_functions,
+	       doc:/* A list of functions to perturb faces before final realization.
+They are passed a lisp-vector containing all the attributes of the
+fully-specified face, and can change any that they wish. */);
+  Vrealize_face_filter_functions = Qnil;
+
 
 #ifdef HAVE_WINDOW_SYSTEM
   defsubr (&Sbitmap_spec_p);

[-- Attachment #3: Type: text/plain, Size: 59 bytes --]



Also, here's a lisp file that implements some filters:



[-- Attachment #4: Some filters for face-realization --]
[-- Type: application/emacs-lisp, Size: 2270 bytes --]

[-- Attachment #5: Type: text/plain, Size: 165 bytes --]



-Miles
-- 
I'm beginning to think that life is just one long Yoko Ono album; no rhyme
or reason, just a lot of incoherent shrieks and then it's over.  --Ian Wolff

[-- Attachment #6: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel

  reply	other threads:[~2002-12-18 10:01 UTC|newest]

Thread overview: 131+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-07 19:39 Gtk version getting closer Jan D.
2002-11-08  0:08 ` Kim F. Storm
2002-11-08  9:21   ` jasonr
2002-11-08  9:56     ` Juanma Barranquero
2002-11-08 11:25       ` Kim F. Storm
2002-11-08 10:36         ` Juanma Barranquero
2002-11-09 14:27         ` Jan D.
2002-11-09 21:29   ` Eli Zaretskii
2002-11-09 11:53 ` Richard Stallman
2002-11-09 14:16   ` Jan D.
2002-11-11 10:19     ` Richard Stallman
2002-11-09 15:05   ` Karl Eichwalder
2002-11-11 10:19     ` Richard Stallman
2002-11-11 18:36       ` Karl Eichwalder
2002-11-12  5:50         ` Eli Zaretskii
2002-11-12  7:24           ` Karl Eichwalder
2002-11-12 17:15             ` Eli Zaretskii
2002-11-13  4:40             ` Miles Bader
2002-11-13  5:42               ` Eli Zaretskii
2002-11-13 13:21                 ` Robert J. Chassell
2002-11-13 15:38                   ` Jan D.
2002-11-13 16:35                     ` Stefan Monnier
2002-11-13 17:58                       ` Jan D.
2002-11-14 18:57                     ` Eli Zaretskii
2002-11-14 20:07                       ` Jan D.
2002-11-14 20:28                         ` Eli Zaretskii
2002-11-14 23:03                       ` Jason Rumney
2002-11-15 15:59                         ` Eli Zaretskii
2002-11-13 15:55                   ` Kim F. Storm
2002-11-13 18:23                     ` Robert J. Chassell
2002-11-13 18:42                       ` Stefan Monnier
2002-11-13 21:15                         ` Jan D.
2002-11-13 18:58                       ` David Masterson
2002-11-13 16:52                   ` Francesco Potorti`
2002-11-14 12:16                   ` Richard Stallman
2002-11-14 16:46                     ` Robert J. Chassell
2002-11-15  2:20                       ` Miles Bader
2002-11-15 12:29                         ` Robert J. Chassell
     [not found]                         ` <m18EUbO-000IeAC@localhost>
2002-11-20 22:08                           ` Bold by moving pixels problem Miles Bader
2002-11-21  0:21                             ` Robert J. Chassell
2002-11-21  1:33                               ` Stefan Monnier
2002-11-21  1:44                                 ` Miles Bader
     [not found]                                   ` <m18HRR2-000IeBC@localhost>
2002-12-17  5:00                                     ` Miles Bader
2002-12-17  6:28                                       ` Miles Bader
2002-12-17  7:08                                         ` Miles Bader
2002-12-18 10:01                                           ` Miles Bader [this message]
2002-12-18 12:26                                             ` Kim F. Storm
2002-12-19  8:34                                               ` Miles Bader
2002-12-19 10:18                                                 ` Miles Bader
2002-12-19 12:18                                                 ` Kim F. Storm
2002-12-19 11:27                                                   ` Miles Bader
2002-12-19 12:25                                                     ` Miles Bader
2002-12-19 13:55                                                       ` Kim F. Storm
2003-01-07 11:02                                                       ` Kim F. Storm
2003-01-07 14:02                                                         ` Miles Bader
2003-01-09  7:28                                                         ` Richard Stallman
2003-01-09  7:52                                                           ` Miles Bader
2002-12-18 14:25                                             ` Robert J. Chassell
2002-12-19 10:15                                               ` signal handling bogosities Miles Bader
2002-12-20 17:12                                                 ` Richard Stallman
2002-12-20 17:46                                                   ` Eli Zaretskii
2002-12-20 18:35                                                   ` Alex Schroeder
2002-12-20 22:06                                                   ` Miles Bader
2002-12-21 20:26                                                     ` Richard Stallman
2002-12-21 23:42                                                       ` Alex Schroeder
2002-12-23 20:58                                                         ` Richard Stallman
2002-12-22  2:02                                                       ` Miles Bader
2002-12-22  2:27                                                   ` Miles Bader
2002-12-23 20:58                                                     ` Richard Stallman
2002-12-17 10:31                                       ` Bold by moving pixels problem Kim F. Storm
2002-12-17 16:38                                       ` Robert J. Chassell
2002-12-17 23:54                                         ` Miles Bader
2002-11-21  6:01                               ` Eli Zaretskii
2002-11-16  1:34                       ` Gtk version getting closer Richard Stallman
2002-11-14 12:16               ` Richard Stallman
2002-11-12 12:34           ` Jan D.
2002-11-12 17:21             ` Eli Zaretskii
2002-11-13 10:15               ` Jan D.
2002-11-14 12:16                 ` Richard Stallman
2002-11-14 18:53                 ` Eli Zaretskii
2002-11-14 20:13                   ` Jan D.
2002-11-13 16:55             ` Jason Rumney
2002-11-14 17:25               ` Jan D.
2002-11-14  4:09             ` Richard Stallman
2002-11-14 17:49               ` Jan D.
2002-11-14 20:29                 ` Eli Zaretskii
2002-11-14 21:47                   ` Jan D.
2002-11-14 21:30                 ` David Masterson
2002-11-16  1:34                 ` Richard Stallman
2002-11-16 16:11                   ` Jan D.
2002-11-13 11:32         ` Richard Stallman
2002-11-13 17:09         ` David Masterson
2002-11-14 17:31           ` Jan D.
2002-11-14 20:22             ` David Masterson
2002-11-16  1:34               ` Richard Stallman
2002-11-18  5:06                 ` David Masterson
2002-11-15  2:36           ` Richard Stallman
2002-11-15  4:04             ` Miles Bader
2002-11-15 16:36               ` David Masterson
2002-11-15 16:31                 ` Eli Zaretskii
2002-11-15 18:46                   ` David Masterson
2002-11-15 21:15                     ` Eli Zaretskii
2002-11-15 22:35                       ` David Masterson
2002-11-15 17:33                 ` Miles Bader
2002-11-15 18:55                   ` David Masterson
2002-11-15 23:18                     ` Jason Rumney
2002-11-16  0:44                       ` David Masterson
2002-11-15 19:03                   ` Stefan Monnier
2002-11-15 18:00                 ` Robert J. Chassell
2002-11-19 13:26                   ` Miles Bader
2002-11-20 21:13                   ` Richard Stallman
2002-11-20 21:56                     ` Jason Rumney
2002-11-21  0:47                       ` Robert J. Chassell
2002-11-22 21:00                         ` Richard Stallman
2002-11-21  0:38                     ` Robert J. Chassell
2002-11-21 13:09                       ` Kenichi Handa
2002-11-21 14:08                         ` Miles Bader
2002-11-21 21:47                           ` Jason Rumney
2002-11-15 18:13                 ` Jason Rumney
2002-11-15 19:03                   ` David Masterson
2002-11-09 21:31 ` Eli Zaretskii
2002-11-10  9:02   ` Jan D.
2002-11-11 10:20     ` Richard Stallman
  -- strict thread matches above, loose matches on Subject: below --
2003-06-04  8:54 Bold by moving pixels problem Richard Stallman
2003-06-04 14:35 ` Stefan Monnier
2003-06-05 10:58   ` Richard Stallman
2004-01-21  5:39     ` Stefan Monnier
2003-06-04 23:30 ` Kim F. Storm
     [not found]   ` <E19O2Z4-0002Rk-GY@fencepost.gnu.org>
2003-06-06  1:45     ` Kim F. Storm
2003-06-06  0:46       ` Miles Bader
2003-08-07  6:04 last-sexp-toggle-display Richard Stallman
2003-08-07 16:56 ` last-sexp-toggle-display Luc Teirlinck
2003-08-11 12:53   ` last-sexp-toggle-display Richard Stallman
2003-08-11 17:59     ` last-sexp-toggle-display Luc Teirlinck
2003-08-11 18:54       ` Bold by moving pixels problem Robert J. Chassell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=buo1y4f3aua.fsf@mcspd15.ucom.lsi.nec.co.jp \
    --to=miles@lsi.nec.co.jp \
    --cc=emacs-devel@gnu.org \
    --cc=miles@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).