From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Miles Bader Newsgroups: gmane.emacs.devel Subject: Re: Bold by moving pixels problem Date: 19 Dec 2002 19:18:56 +0900 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: References: <20021120220834.GC29543@gnu.org> <200211210133.gAL1XiP23941@rum.cs.yale.edu> <5xfzsvqzqx.fsf@kfs2.cua.dk> Reply-To: Miles Bader NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: main.gmane.org 1040293199 22101 80.91.224.249 (19 Dec 2002 10:19:59 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Thu, 19 Dec 2002 10:19:59 +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 18OxmX-0005kC-00 for ; Thu, 19 Dec 2002 11:19:57 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 18Oxnb-0006XG-00 for ; Thu, 19 Dec 2002 11:21:03 +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 18Oxmf-0006BR-01 for emacs-devel@quimby.gnus.org; Thu, 19 Dec 2002 05:20:05 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18OxmB-0006A7-00 for emacs-devel@gnu.org; Thu, 19 Dec 2002 05:19:35 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18Oxm9-00068u-00 for emacs-devel@gnu.org; Thu, 19 Dec 2002 05:19:34 -0500 Original-Received: from tyo202.gate.nec.co.jp ([202.32.8.202]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18Oxm9-00067i-00; Thu, 19 Dec 2002 05:19:33 -0500 Original-Received: from mailgate4.nec.co.jp ([10.7.69.195])gBJAIwU25181; Thu, 19 Dec 2002 19:18:58 +0900 (JST) Original-Received: from mailsv4.nec.co.jp (mailgate51.nec.co.jp [10.7.69.190]) by mailgate4.nec.co.jp (8.11.6/3.7W-MAILGATE-NEC) with ESMTP id gBJAIw619169; Thu, 19 Dec 2002 19:18:58 +0900 (JST) Original-Received: from mcsss2.ucom.lsi.nec.co.jp ([10.30.114.133]) by mailsv4.nec.co.jp (8.11.6/3.7W-MAILSV4-NEC) with ESMTP id gBJAIvq11487; Thu, 19 Dec 2002 19:18:57 +0900 (JST) Original-Received: from mcspd15.ucom.lsi.nec.co.jp (mcspd15 [10.30.114.174]) id gBJAIvB08593; Thu, 19 Dec 2002 19:18:57 +0900 (JST) Original-Received: by mcspd15.ucom.lsi.nec.co.jp (Postfix, from userid 31295) id EDC543702; Thu, 19 Dec 2002 19:18:56 +0900 (JST) Original-To: storm@cua.dk (Kim F. Storm) System-Type: i686-pc-linux-gnu Blat: Foop In-Reply-To: Original-Lines: 16 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:10274 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:10274 --=-=-= BTW, here's a version of the face-filter lisp example code I sent before, rewritten to use some macros instead; it's quite a bit more readable! I used the term `facevec' instead of `lface', since it's a bit more obvious, but that's just a suggestion... -Miles --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=relfilt.el Content-Description: Example realize-face-filter-functions filters (defmacro facevec-weight (facevec) `(aref ,facevec 4)) (defmacro facevec-slant (facevec) `(aref ,facevec 5)) (defmacro facevec-underline (facevec) `(aref ,facevec 6)) (defmacro facevec-foreground (facevec) `(aref ,facevec 8)) (defmacro set-facevec-weight (facevec val) `(aset ,facevec 4 ,val)) (defmacro set-facevec-slant (facevec val) `(aset ,facevec 5 ,val)) (defmacro set-facevec-underline (facevec val) `(aset ,facevec 6 ,val)) (defmacro set-facevec-foreground (facevec val) `(aset ,facevec 8 ,val)) (defun facevec-emulate-bold-with-color (facevec) (if (memq (facevec-weight facevec) '(bold heavy extra-bold semi-bold ultra-bold)) (let ((fg-vals (color-values (facevec-foreground facevec)))) ;; unboldify (set-facevec-weight facevec 'normal) ;; Tweak the fg color to indicate `bold' (cond ((equal fg-vals '(65535 65535 65535)) (set-facevec-foreground facevec "khaki")) ((equal fg-vals '(0 0 0)) (set-facevec-foreground facevec "orange4")) (t ;; intensify the color (set-facevec-foreground facevec (highlight-color fg-vals 2 5000))))))) (defun facevec-emulate-italic-with-color (facevec) (if (not (eq (facevec-slant facevec) 'normal)) (let ((fg-vals (color-values (facevec-foreground facevec)))) ;; unitalic (set-facevec-slant facevec 'normal) ;; Tweak the fg color to indicate `italic' (cond ((equal fg-vals '(65535 65535 65535)) (set-facevec-foreground facevec "cyan")) ((equal fg-vals '(0 0 0)) (set-facevec-foreground facevec "navy")) (t ;; intensify the color (set-facevec-foreground facevec (highlight-color fg-vals 2 5000))))))) (defun facevec-replace-italic-with-underline (facevec) (if (not (eq (facevec-slant facevec) 'normal)) (progn ;; remove italics (set-facevec-slant facevec 'normal) ;; underline (we preserve an existing value, in case it's colored) (if (null (facevec-underline facevec)) (set-facevec-underline facevec t))))) (push 'facevec-emulate-bold-with-color realize-face-filter-functions) ;(push 'facevec-replace-italic-with-underline realize-face-filter-functions) (push 'facevec-emulate-italic-with-color realize-face-filter-functions) (clear-face-cache) ;;; highlight-color function (defconst highlight-color-dark-boost-limit 48000) (defun highlight-color (color factor &optional delta) "Return a color which is lighter or darker than COLOR by FACTOR and DELTA." (let* ((old-rgb (if (stringp color) (color-values color) color)) (red (car old-rgb)) (green (cadr old-rgb)) (blue (nth 2 old-rgb)) (bright (/ (+ (* red 2) (* green 3) blue) 6))) (setq red (min 65535 (* red factor))) (setq green (min 65535 (* green factor))) (setq blue (min 65535 (* blue factor))) (when (and (< bright highlight-color-dark-boost-limit) delta) ;; Make an additive adjustment to NEW, because it's dark enough so ;; that scaling by FACTOR alone isn't enough. (let* ((dimness ;; How far below the limit this color is (0 - 1, 1 being darker). (- 1 (/ (float bright) highlight-color-dark-boost-limit))) (min-delta ;; The additive adjustment. (* delta dimness factor 0.5))) (cond ((< factor 1) (setq red (max 0 (- red min-delta))) (setq green (max 0 (- green min-delta))) (setq blue (max 0 (- blue min-delta)))) (t (setq red (min 65535 (+ red min-delta))) (setq green (min 65535 (+ green min-delta))) (setq blue (min 65535 (+ blue min-delta))))))) (format "#%04X%04X%04X" red green blue))) --=-=-= -- `Cars give people wonderful freedom and increase their opportunities. But they also destroy the environment, to an extent so drastic that they kill all social life' (from _A Pattern Language_) --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://mail.gnu.org/mailman/listinfo/emacs-devel --=-=-=--