;; Set the font on all current and future frames, as though
;; the `default' face had been "set for this session":
(set-frame-font new-font nil frame-list)
- ;; Just redraw the existing fonts on all frames, by clearing
- ;; the font and face caches. This will cause all fonts to be
- ;; recreated.
- (clear-font-cache)
- (clear-face-cache t)
- (redraw-display)))))
+ ;; Just reconsider the existing fonts on all frames on each
+ ;; display, by clearing the font and face caches. This will
+ ;; cause all fonts to be recreated.
+ (dolist (frame frame-list)
+ (reconsider-frame-fonts frame))))))
(defun dynamic-setting-handle-config-changed-event (event)
"Handle config-changed-event on the display in EVENT.
if (FRAME_FONT (f))
{
/* Reconsider default font after backend(s) change (Bug#23386). */
- FRAME_RIF(f)->default_font_parameter (f, Qnil);
+ FRAME_RIF (f)->default_font_parameter (f, Qnil);
face_change = true;
windows_or_buffers_changed = 18;
}
return f->was_invisible ? Qt : Qnil;
}
+
+#ifdef HAVE_WINDOW_SYSTEM
+
+DEFUN ("reconsider-frame-fonts", Freconsider_frame_fonts,
+ Sreconsider_frame_fonts, 1, 1, 0,
+ doc: /* Recreate FRAME's default font using updated font parameters.
+Signal an error if FRAME is not a window system frame. This should be
+called after a `config-changed' event is received, signalling that the
+parameters (such as pixel density) used by the system to open fonts
+have changed. */)
+ (Lisp_Object frame)
+{
+ struct frame *f;
+
+ f = decode_window_system_frame (frame);
+
+ if (FRAME_RIF (f)->default_font_parameter)
+ FRAME_RIF (f)->default_font_parameter (f, Qnil);
+
+ return Qnil;
+}
+
+#endif
+
\f
/***********************************************************************
Multimonitor data
#ifdef HAVE_WINDOW_SYSTEM
defsubr (&Sx_get_resource);
defsubr (&Sx_parse_geometry);
+ defsubr (&Sreconsider_frame_fonts);
#endif
-
}
}
if (NILP (font))
- font = !NILP (font_param) ? font_param
- : gui_display_get_arg (dpyinfo, parms, Qfont, "font", "Font",
- RES_TYPE_STRING);
+ font = (!NILP (font_param)
+ ? font_param
+ : gui_display_get_arg (dpyinfo, parms,
+ Qfont, "font", "Font",
+ RES_TYPE_STRING));
if (! FONTP (font) && ! STRINGP (font))
{