int face_change_count;
+/* Non-zero means don't display bold text if a face's foreground
+ and background colors are the inverse of the default colors of the
+ display. This is a kluge to suppress `bold black' foreground text
+ which is hard to read on an LCD monitor. */
+
+int tty_suppress_bold_inverse_default_colors_p;
+
/* The total number of colors currently allocated. */
#if GLYPH_DEBUG
static int font_scalable_p P_ ((struct font_name *));
static int get_lface_attributes P_ ((struct frame *, Lisp_Object, Lisp_Object *, int));
static int load_pixmap P_ ((struct frame *, Lisp_Object, unsigned *, unsigned *));
-static char *xstrdup P_ ((char *));
static unsigned char *xstrlwr P_ ((unsigned char *));
static void signal_error P_ ((char *, Lisp_Object));
static struct frame *frame_or_selected_frame P_ ((Lisp_Object, int));
static int xlfd_numeric_value P_ ((struct table_entry *, int, struct font_name *,
int, int));
static Lisp_Object xlfd_symbolic_value P_ ((struct table_entry *, int,
- struct font_name *, int, int));
+ struct font_name *, int,
+ Lisp_Object));
static struct table_entry *xlfd_lookup_field_contents P_ ((struct table_entry *, int,
struct font_name *, int));
#ifdef HAVE_X_WINDOWS
+#ifdef DEBUG_X_COLORS
+
+/* The following is a poor mans infrastructure for debugging X color
+ allocation problems on displays with PseudoColor-8. Some X servers
+ like 3.3.5 XF86_SVGA with Matrox cards apparently don't implement
+ color reference counts completely so that they don't signal an
+ error when a color is freed whose reference count is already 0.
+ Other X servers do. To help me debug this, the following code
+ implements a simple reference counting schema of its own, for a
+ single display/screen. --gerd. */
+
+/* Reference counts for pixel colors. */
+
+int color_count[256];
+
+/* Register color PIXEL as allocated. */
+
+void
+register_color (pixel)
+ unsigned long pixel;
+{
+ xassert (pixel < 256);
+ ++color_count[pixel];
+}
+
+
+/* Register color PIXEL as deallocated. */
+
+void
+unregister_color (pixel)
+ unsigned long pixel;
+{
+ xassert (pixel < 256);
+ if (color_count[pixel] > 0)
+ --color_count[pixel];
+ else
+ abort ();
+}
+
+
+/* Register N colors from PIXELS as deallocated. */
+
+void
+unregister_colors (pixels, n)
+ unsigned long *pixels;
+ int n;
+{
+ int i;
+ for (i = 0; i < n; ++i)
+ unregister_color (pixels[i]);
+}
+
+#endif /* DEBUG_X_COLORS */
+
/* Free colors used on frame F. PIXELS is an array of NPIXELS pixel
color values. Interrupt input must be blocked when this function
is called. */
px[j++] = pixels[i];
if (j)
- XFreeColors (dpy, cmap, px, j, 0);
+ {
+ XFreeColors (dpy, cmap, px, j, 0);
+#ifdef DEBUG_X_COLORS
+ unregister_colors (px, j);
+#endif
+ }
}
else
- XFreeColors (dpy, cmap, pixels, npixels, 0);
+ {
+ XFreeColors (dpy, cmap, pixels, npixels, 0);
+#ifdef DEBUG_X_COLORS
+ unregister_colors (pixels, npixels);
+#endif
+ }
}
}
#endif /* WINDOWSNT */
-/* Like strdup, but uses xmalloc. */
-
-static char *
-xstrdup (s)
- char *s;
-{
- int len = strlen (s) + 1;
- char *p = (char *) xmalloc (len);
- bcopy (s, p, len);
- return p;
-}
-
-
/* Like stricmp. Used to compare parts of font names which are in
ISO8859-1. */
{
int bytes_per_row = ((XFASTINT (width) + BITS_PER_CHAR - 1)
/ BITS_PER_CHAR);
- if (STRING_BYTES (XSTRING (data)) >= bytes_per_row * height)
+ if (STRING_BYTES (XSTRING (data)) >= bytes_per_row * XINT (height))
pixmap_p = 1;
}
}
int dim;
struct font_name *font;
int field_index;
- int dflt;
+ Lisp_Object dflt;
{
struct table_entry *p;
p = xlfd_lookup_field_contents (table, dim, font, field_index);
return (hash_string_case_insensitive (v[LFACE_FAMILY_INDEX])
^ hash_string_case_insensitive (v[LFACE_FOREGROUND_INDEX])
^ hash_string_case_insensitive (v[LFACE_BACKGROUND_INDEX])
- ^ (unsigned) v[LFACE_WEIGHT_INDEX]
- ^ (unsigned) v[LFACE_SLANT_INDEX]
- ^ (unsigned) v[LFACE_SWIDTH_INDEX]
+ ^ XFASTINT (v[LFACE_WEIGHT_INDEX])
+ ^ XFASTINT (v[LFACE_SLANT_INDEX])
+ ^ XFASTINT (v[LFACE_SWIDTH_INDEX])
^ XFASTINT (v[LFACE_HEIGHT_INDEX]));
}
&& EQ (lface1[LFACE_SLANT_INDEX], lface2[LFACE_SLANT_INDEX])
&& (EQ (lface1[LFACE_FONT_INDEX], lface2[LFACE_FONT_INDEX])
|| (STRINGP (lface1[LFACE_FONT_INDEX])
+ && STRINGP (lface2[LFACE_FONT_INDEX])
&& xstricmp (XSTRING (lface1[LFACE_FONT_INDEX])->data,
XSTRING (lface2[LFACE_FONT_INDEX])->data))));
}
#if GLYPH_DEBUG
xassert (face == FACE_FROM_ID (f, face->id));
+
+/* When this function is called from face_for_char (in this case, C is
+ a multibyte character), a fontset of a face returned by
+ realize_face is not yet set, i.e. FACE_SUITABLE_FOR_CHAR_P (FACE,
+ C) is not sutisfied. The fontset is set for this face by
+ face_for_char later. */
+#if 0
if (FRAME_WINDOW_P (f))
xassert (FACE_SUITABLE_FOR_CHAR_P (face, c));
+#endif
#endif /* GLYPH_DEBUG */
return face->id;
struct frame *f;
{
int success_p = 0;
+
+ /* Block input there so that we won't be surprised by an X expose
+ event, for instance without having the faces set up. */
+ BLOCK_INPUT;
if (realize_default_face (f))
{
success_p = 1;
}
+ UNBLOCK_INPUT;
return success_p;
}
/* Insert the new face. */
cache_face (cache, face, lface_hash (attrs));
#ifdef HAVE_WINDOW_SYSTEM
- if (FRAME_X_P (cache->f) && face->font == NULL)
+ if (FRAME_WINDOW_P (cache->f) && face->font == NULL)
load_face_font (cache->f, face, c);
#endif /* HAVE_WINDOW_SYSTEM */
return face;
struct face *face;
int weight, slant;
Lisp_Object color;
- Lisp_Object tty_defined_color_alist =
- Fsymbol_value (intern ("tty-defined-color-alist"));
+ Lisp_Object tty_defined_color_alist
+ = find_symbol_value (intern ("tty-defined-color-alist"));
Lisp_Object tty_color_alist = intern ("tty-color-alist");
Lisp_Object frame;
int face_colors_defaulted = 0;
color = attrs[LFACE_FOREGROUND_INDEX];
if (STRINGP (color)
&& XSTRING (color)->size
- && !NILP (tty_defined_color_alist)
+ && CONSP (tty_defined_color_alist)
&& (color = Fassoc (color, call1 (tty_color_alist, frame)),
CONSP (color)))
/* Associations in tty-defined-color-alist are of the form
color = attrs[LFACE_BACKGROUND_INDEX];
if (STRINGP (color)
&& XSTRING (color)->size
- && !NILP (tty_defined_color_alist)
+ && CONSP (tty_defined_color_alist)
&& (color = Fassoc (color, call1 (tty_color_alist, frame)),
CONSP (color)))
/* Associations in tty-defined-color-alist are of the form
face->background = tem;
}
+ if (tty_suppress_bold_inverse_default_colors_p
+ && face->tty_bold_p
+ && face->background == FACE_TTY_DEFAULT_FG_COLOR
+ && face->foreground == FACE_TTY_DEFAULT_BG_COLOR)
+ face->tty_bold_p = 0;
+
return face;
}
+DEFUN ("tty-suppress-bold-inverse-default-colors",
+ Ftty_suppress_bold_inverse_default_colors,
+ Stty_suppress_bold_inverse_default_colors, 1, 1, 0,
+ "Suppress/allow boldness of faces with inverse default colors.\n\
+SUPPRESS non-nil means suppress it.\n\
+This affects bold faces on TTYs whose foreground is the default background\n\
+color of the display and whose background is the default foreground color.\n\
+For such faces, no bold text will be displayed.")
+ (suppress)
+ Lisp_Object suppress;
+{
+ tty_suppress_bold_inverse_default_colors_p = !NILP (suppress);
+ ++face_change_count;
+ return suppress;
+}
+
+
\f
/***********************************************************************
Computing Faces
defsubr (&Sshow_face_resources);
#endif /* GLYPH_DEBUG */
defsubr (&Sclear_face_cache);
+ defsubr (&Stty_suppress_bold_inverse_default_colors);
DEFVAR_LISP ("font-list-limit", &Vfont_list_limit,
"*Limit for font matching.\n\