/* xfaces.c -- "Face" primitives.
-Copyright (C) 1993-1994, 1998-2014 Free Software Foundation, Inc.
+Copyright (C) 1993-1994, 1998-2015 Free Software Foundation, Inc.
This file is part of GNU Emacs.
try to free unused fonts, too. */
void
-clear_face_cache (int clear_fonts_p)
+clear_face_cache (bool clear_fonts_p)
{
#ifdef HAVE_WINDOW_SYSTEM
Lisp_Object tail, frame;
f = XFRAME (selected_frame);
else
f = XFRAME (frame);
- if (! FONT_OBJECT_P (value))
- {
- Lisp_Object *attrs = XVECTOR (lface)->contents;
- Lisp_Object font_object;
- font_object = font_load_for_lface (f, attrs, value);
- if (NILP (font_object))
- signal_error ("Font not available", value);
- value = font_object;
- }
- set_lface_from_font (f, lface, value, 1);
+ /* FIXME:
+ If frame is t, and selected frame is a tty frame, the font
+ can't be realized. An improvement would be to loop over frames
+ for a non-tty frame and use that. See discussion in Bug#18573.
+ For a daemon, frame may be an initial frame (Bug#18869). */
+ if (FRAME_WINDOW_P (f))
+ {
+ if (! FONT_OBJECT_P (value))
+ {
+ Lisp_Object *attrs = XVECTOR (lface)->contents;
+ Lisp_Object font_object;
+
+ font_object = font_load_for_lface (f, attrs, value);
+ if (NILP (font_object))
+ signal_error ("Font not available", value);
+ value = font_object;
+ }
+ set_lface_from_font (f, lface, value, 1);
+ }
}
else
ASET (lface, LFACE_FONT_INDEX, value);
ASET (lface, LFACE_FONT_INDEX, font);
}
f->default_face_done_p = 0;
- Fmodify_frame_parameters (frame, list1 (Fcons (Qfont, font)));
+ AUTO_FRAME_ARG (arg, Qfont, font);
+ Fmodify_frame_parameters (frame, arg);
}
}
&& newface->font)
{
Lisp_Object name = newface->font->props[FONT_NAME_INDEX];
- Fmodify_frame_parameters (frame, list1 (Fcons (Qfont, name)));
+ AUTO_FRAME_ARG (arg, Qfont, name);
+ Fmodify_frame_parameters (frame, arg);
}
if (STRINGP (gvec[LFACE_FOREGROUND_INDEX]))
- Fmodify_frame_parameters (frame,
- list1 (Fcons (Qforeground_color,
- gvec[LFACE_FOREGROUND_INDEX])));
+ {
+ AUTO_FRAME_ARG (arg, Qforeground_color,
+ gvec[LFACE_FOREGROUND_INDEX]);
+ Fmodify_frame_parameters (frame, arg);
+ }
if (STRINGP (gvec[LFACE_BACKGROUND_INDEX]))
- Fmodify_frame_parameters (frame,
- list1 (Fcons (Qbackground_color,
- gvec[LFACE_BACKGROUND_INDEX])));
+ {
+ AUTO_FRAME_ARG (arg, Qbackground_color,
+ gvec[LFACE_BACKGROUND_INDEX]);
+ Fmodify_frame_parameters (frame, arg);
+ }
}
}
endpos = XINT (end);
/* Look at properties from overlays. */
+ USE_SAFE_ALLOCA;
{
ptrdiff_t next_overlay;
/* Optimize common cases where we can use the default face. */
if (noverlays == 0
&& NILP (prop))
- return default_face->id;
+ {
+ SAFE_FREE ();
+ return default_face->id;
+ }
/* Begin with attributes from the default face. */
memcpy (attrs, default_face->lface, sizeof attrs);
*endptr = endpos;
+ SAFE_FREE ();
+
/* Look up a realized face with the given face attributes,
or realize a new one for ASCII characters. */
return lookup_face (f, attrs);