From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: Bold by moving pixels problem Date: 18 Dec 2002 13:26:46 +0100 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <5xfzsvqzqx.fsf@kfs2.cua.dk> References: <20021120220834.GC29543@gnu.org> <200211210133.gAL1XiP23941@rum.cs.yale.edu> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1040210871 26081 80.91.224.249 (18 Dec 2002 11:27:51 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 18 Dec 2002 11:27:51 +0000 (UTC) Cc: emacs-devel@gnu.org Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18OcMf-0006mX-00 for ; Wed, 18 Dec 2002 12:27:49 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 18OcNG-0001ha-00 for ; Wed, 18 Dec 2002 12:28:27 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18OcN1-0004Lf-00 for emacs-devel@quimby.gnus.org; Wed, 18 Dec 2002 06:28:11 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18OcM7-0003xz-00 for emacs-devel@gnu.org; Wed, 18 Dec 2002 06:27:15 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18OcM2-0003rL-00 for emacs-devel@gnu.org; Wed, 18 Dec 2002 06:27:13 -0500 Original-Received: from mail.filanet.dk ([195.215.206.179]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18OcM1-0003q5-00; Wed, 18 Dec 2002 06:27:09 -0500 Original-Received: from kfs2.cua.dk.cua.dk (kfs2.local.filanet.dk [192.168.1.182]) by mail.filanet.dk (Postfix) with SMTP id 58A3E7C012; Wed, 18 Dec 2002 11:27:08 +0000 (GMT) Original-To: Miles Bader In-Reply-To: Original-Lines: 74 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 Original-cc: bob@rattlesnake.com X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Emacs development discussions. List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:10253 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:10253 Miles Bader writes: > Here's an updated version of my patch, that uses a list of functions: > > > > 2002-12-17 Miles Bader > > * 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. Example: 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"))) (t ;; intensify the color (setq lface (plist-put lface :foreground (highlight-color fg 2 5000)))))))) lface) -- Kim F. Storm http://www.cua.dk