[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bold by moving pixels problem

From: Kim F. Storm
Subject: Re: Bold by moving pixels problem
Date: 18 Dec 2002 13:26:46 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

Miles Bader <address@hidden> writes:

> Here's an updated version of my patch, that uses a list of functions:
> 2002-12-17  Miles Bader  <address@hidden>
>       * 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.

I've looked at your patch, and it seems to be very low-level to give
the filter functions direct access to the actual lface vector elements.

I'd suggest a different approach using the internal-lisp-face attribute
names that are already defined in xfaces.c such as :family, :height, etc.

Instead of the raw lface vector, the filter function should receive
a plist with all of the current lface attributes (:family X :height Y ...),
and it should return a (possibly) modified plist ... which is then
passed on to the next filter function in the list.

When all filter functions have been called, the plist is used to
build the final lface vector.

It might be a little less efficient than using the raw vector, but
this doesn't get called very often anyway (according to your own
statistics).  And not at all if Vrealize_face_filter_functions is nil.

Your code:
> (defun lface-emulate-bold-with-color (lface)
>   (if (memq (aref lface 4)
>           '(bold heavy extra-bold semi-bold ultra-bold))
>       (let ((fg-vals (color-values (aref lface 8))))
>       ;; unboldify
>       (aset lface 4 'normal)
>       ;; Tweak the fg color to indicate bold.
>       (cond ((equal fg-vals '(65535 65535 65535))
>              (aset lface 8 "khaki"))
>             ((equal fg-vals '(0 0 0))
>              (aset lface 8 "orange4"))
>             (t
>              ;; intensify the color
>              (aset lface 8 (highlight-color (aref lface 8) 2 5000)))))))

becomes something like this: [not tested]

(defun lface-emulate-bold-with-color (lface)
  (let ((weight (plist-get lface :weight))
        (fg (plist-get lface :foreground)))
    (if (memq weight '(bold heavy extra-bold semi-bold ultra-bold))
        (let ((fg-vals (color-values fg)))
          ;; unboldify
          (setq lface (plist-put lface :weight 'normal))
          ;; Tweak the fg color to indicate bold.
          (cond ((equal fg-vals '(65535 65535 65535))
                 (setq lface (plist-put lface :foreground "khaki")))
                ((equal fg-vals '(0 0 0))
                 (setq lface (plist-put lface :foreground "orange4")))
                 ;; intensify the color
                 (setq lface (plist-put lface :foreground
                                        (highlight-color fg 2 5000))))))))

Kim F. Storm <address@hidden> http://www.cua.dk

reply via email to

[Prev in Thread] Current Thread [Next in Thread]