diff --git a/src/xfaces.c b/src/xfaces.c index cffa89e1f3..eeea165187 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -1157,8 +1157,6 @@ load_color (struct frame *f, struct face *face, Lisp_Object name, #ifdef HAVE_WINDOW_SYSTEM -#define NEAR_SAME_COLOR_THRESHOLD 30000 - /* Load colors for face FACE which is used on frame F. Colors are specified by slots LFACE_BACKGROUND_INDEX and LFACE_FOREGROUND_INDEX of ATTRS. If the background color specified is not supported on F, @@ -1198,8 +1196,9 @@ load_face_colors (struct frame *f, struct face *face, face->foreground = load_color2 (f, face, fg, LFACE_FOREGROUND_INDEX, &xfg); dfg = attrs[LFACE_DISTANT_FOREGROUND_INDEX]; + int distance = color_distance (&xbg, &xfg); if (!NILP (dfg) && !UNSPECIFIEDP (dfg) - && color_distance (&xbg, &xfg) < NEAR_SAME_COLOR_THRESHOLD) + && distance < face_near_same_color_threshold) { if (EQ (attrs[LFACE_INVERSE_INDEX], Qt)) face->background = load_color (f, face, dfg, LFACE_BACKGROUND_INDEX); @@ -6768,6 +6767,12 @@ RESCALE-RATIO is a floating point number to specify how much larger a font of 10 point, we actually use a font of 10 * RESCALE-RATIO point. */); Vface_font_rescale_alist = Qnil; + DEFVAR_INT ("face-near-same-color-threshold", face_near_same_color_threshold, + doc: /* Number representing the minimum tolerated distance +between face background and foreground colors before distant-foreground is +used instead (when present). */); + face_near_same_color_threshold = 30000; + #ifdef HAVE_WINDOW_SYSTEM defsubr (&Sbitmap_spec_p); defsubr (&Sx_list_fonts);