[Top][All Lists]

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

[PATCH] Re: About the :distant-foreground face attribute

From: Daniel Colascione
Subject: [PATCH] Re: About the :distant-foreground face attribute
Date: Mon, 13 Jan 2014 05:13:45 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0

On 01/08/2014 09:43 AM, Eli Zaretskii wrote:
From: Chong Yidong <address@hidden>
Cc: address@hidden,  address@hidden
Date: Wed, 08 Jan 2014 13:24:17 +0800

Eli Zaretskii <address@hidden> writes:

The feature does not fit well with the design of the rest of the
face-handling code.  We already have a mechanism for checking to see
when to use a particular face: the DISPLAY element in a face spec.  The
:distant-foreground face attribute, by its very existence, is redundant
with what the DISPLAY element was meant to do.  This adds extra
complexity to the design, for no good reason.

The attached patch might be another solution to the problem. It replaces :distant-foreground with :contrast-function, which punts the actual contrast logic to lisp by calling the named function during face realization. (Performance isn't a problem in practice because we cache face realizations.) In lisp, we implement four low-contrast-mitigation policies: do not adjust for contrast, adjust automatically (by adjusting CIE L*A*B color space L values), adjust automatically (by adjusting the V values in HSV color space), or just set the foreground to a specific color if the contrast dips below a certain point (the current :distant-foreground behavior). Both the policy and the parameters (well, the override color) are customizable on a per-face basis; when merging faces, the one with the highest priority sets the whole behavior.

The patch uses the CIE L*A*B colorspace algorithm by default. It produces surprisingly good results, at least in my tests, adapting automatically to light and dark backgrounds while preserving the hues of theme foreground colors.

(Changing themes nukes the face property right now, so you'll have to reset it each time.)

Attachment: adaptive-face.patch
Description: Text Data

reply via email to

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