/* xfaces.c -- "Face" primitives.
Copyright (C) 1993, 1994, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
- 2005, 2006 Free Software Foundation, Inc.
+ 2005, 2006, 2007 Free Software Foundation, Inc.
This file is part of GNU Emacs.
GNU Emacs is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
+the Free Software Foundation; either version 3, or (at your option)
any later version.
GNU Emacs is distributed in the hope that it will be useful,
#include <ctype.h>
+#undef abs
#define abs(X) ((X) < 0 ? -(X) : (X))
/* Number of pt per inch (from the TeXbook). */
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 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 void load_face_font P_ ((struct frame *, struct face *, int));
static void load_face_colors P_ ((struct frame *, struct face *, Lisp_Object *));
}
-/* Signal `error' with message S, and additional argument ARG. */
-
-static void
-signal_error (s, arg)
- char *s;
- Lisp_Object arg;
-{
- Fsignal (Qerror, Fcons (build_string (s), Fcons (arg, Qnil)));
-}
-
-
/* If FRAME is nil, return a pointer to the selected frame.
Otherwise, check that FRAME is a live frame, and return a pointer
to it. NPARAM is the parameter number of FRAME, for
if (bitmap_id < 0)
{
- add_to_log ("Invalid or undefined bitmap %s", name, Qnil);
+ add_to_log ("Invalid or undefined bitmap `%s'", name, Qnil);
bitmap_id = 0;
if (w_ptr)
if (EQ (hare, tortoise))
{
if (signal_p)
- Fsignal (Qcircular_list, Fcons (orig_face, Qnil));
+ xsignal1 (Qcircular_list, orig_face);
return Qdefault;
}
}
CHECK_LIVE_FRAME (frame);
f = XFRAME (frame);
- if ((CONSP (color1) && !parse_rgb_list (color1, &cdef1))
- || !STRINGP (color1)
- || !defined_color (f, SDATA (color1), &cdef1, 0))
+ if (!(CONSP (color1) && parse_rgb_list (color1, &cdef1))
+ && !(STRINGP (color1) && defined_color (f, SDATA (color1), &cdef1, 0)))
signal_error ("Invalid color", color1);
- if ((CONSP (color2) && !parse_rgb_list (color2, &cdef2))
- || !STRINGP (color2)
- || !defined_color (f, SDATA (color2), &cdef2, 0))
+ if (!(CONSP (color2) && parse_rgb_list (color2, &cdef2))
+ && !(STRINGP (color2) && defined_color (f, SDATA (color2), &cdef2, 0)))
signal_error ("Invalid color", color2);
return make_number (color_distance (&cdef1, &cdef2));
if (!realize_basic_faces (f))
return -1;
default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
+ if (default_face == NULL)
+ abort (); /* realize_basic_faces must have set it up */
}
if (!get_lface_attributes (f, symbol, symbol_attrs, signal_p))
val = attrs[LFACE_INVERSE_INDEX];
if (!UNSPECIFIEDP (val))
{
- if (face_attr_equal_p (val, def_attrs[LFACE_UNDERLINE_INDEX]))
+ if (face_attr_equal_p (val, def_attrs[LFACE_INVERSE_INDEX]))
return 0; /* same as default */
else
test_caps |= TTY_CAP_INVERSE;
bg = attrs[LFACE_BACKGROUND_INDEX];
if (STRINGP (bg))
{
- Lisp_Object def_bg = def_attrs[LFACE_FOREGROUND_INDEX];
+ Lisp_Object def_bg = def_attrs[LFACE_BACKGROUND_INDEX];
if (face_attr_equal_p (bg, def_bg))
return 0; /* same as default */
(attributes, display)
Lisp_Object attributes, display;
{
- int supports, i;
+ int supports = 0, i;
Lisp_Object frame;
struct frame *f;
struct face *def_face;
if (! realize_basic_faces (f))
error ("Cannot realize default face");
def_face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
+ if (def_face == NULL)
+ abort (); /* realize_basic_faces must have set it up */
}
/* Dispatch to the appropriate handler. */
{
/* We want a bold font, but didn't get one; try to use
overstriking instead to simulate bold-face. However,
- don't overstrike an already-bold fontn unless the
+ don't overstrike an already-bold font unless the
desired weight grossly exceeds the available weight. */
if (got_weight > XLFD_WEIGHT_MEDIUM)
- *needs_overstrike = (got_weight - want_weight) > 2;
+ *needs_overstrike = (want_weight - got_weight) > 2;
else
*needs_overstrike = 1;
}
#ifdef HAVE_WINDOW_SYSTEM
#ifdef HAVE_X_WINDOWS
if (face->font != FRAME_FONT (f))
- /* As the font specified for the frame was not acceptable as a
- font for the default face (perhaps because auto-scaled fonts
- are rejected), we must adjust the frame font. */
- x_set_font (f, build_string (face->font_name), Qnil);
+ {
+ /* This can happen when making a frame on a display that does
+ not support the default font. */
+ if (!face->font)
+ return 0;
+
+ /* Otherwise, the font specified for the frame was not
+ acceptable as a font for the default face (perhaps because
+ auto-scaled fonts are rejected), so we must adjust the frame
+ font. */
+ x_set_font (f, build_string (face->font_name), Qnil);
+ }
#endif /* HAVE_X_WINDOWS */
#endif /* HAVE_WINDOW_SYSTEM */
return 1;
staticpro (&QCforeground);
QCbackground = intern (":background");
staticpro (&QCbackground);
- QCstipple = intern (":stipple");;
+ QCstipple = intern (":stipple");
staticpro (&QCstipple);
QCwidth = intern (":width");
staticpro (&QCwidth);