1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-11 16:08:13 +00:00

Recalculate default font when switching font backend

This is an updated version of the patch by Dmitry Antipov
<dmantipov@yandex.ru> in
<https://debbugs.gnu.org/cgi/bugreport.cgi?bug=23386#43>.

Fixes Bug#23386

* src/dispextern.h (struct redisplay_interface): New member
default_font_parameter.
* src/xterm.h: Add prototype for x_default_font_parameter.
* src/xterm.c (x_redisplay_interface): Initialize
default_font_parameter member.
* src/xfns.c (x_default_font_parameter): Make non-static.
* src/w32term.h: Add prototype for w32_default_font_parameter
* src/w32fns.c (w32_default_font_parameter): Make non-static.
* src/w32term.c (w32_redisplay_interface): Initialize
default_font_parameter member.
* src/nsterm.m (ns_redisplay_interface): Add dummy
ns_default_font_parameter (there is currently only one possible font
backend on macOS).  Initialize default_font_parameter member.
* src/frame.c (gui_set_font_backend): Recalculate default font using
RIF default_font_parameter to avoid crash when changing font backend.
This commit is contained in:
Robert Pluim 2020-03-16 17:21:02 +01:00
parent a2dd8c4234
commit 5747a59a88
9 changed files with 30 additions and 10 deletions

View File

@ -3003,6 +3003,9 @@ struct redisplay_interface
/* Cancel hourglass cursor on frame F. */
void (*hide_hourglass) (struct frame *f);
/* Called to (re)calculate the default face when changing the font
backend. */
void (*default_font_parameter) (struct frame *f, Lisp_Object parms);
#endif /* HAVE_WINDOW_SYSTEM */
};

View File

@ -4565,7 +4565,11 @@ gui_set_font_backend (struct frame *f, Lisp_Object new_value, Lisp_Object old_va
return;
if (FRAME_FONT (f))
free_all_realized_faces (Qnil);
{
Lisp_Object frame;
XSETFRAME (frame, f);
free_all_realized_faces (frame);
}
new_value = font_update_drivers (f, NILP (new_value) ? Qt : new_value);
if (NILP (new_value))
@ -4579,10 +4583,8 @@ gui_set_font_backend (struct frame *f, Lisp_Object new_value, Lisp_Object old_va
if (FRAME_FONT (f))
{
Lisp_Object frame;
XSETFRAME (frame, f);
gui_set_font (f, Fframe_parameter (frame, Qfont), Qnil);
/* Reconsider default font after backend(s) change (Bug#23386). */
FRAME_RIF(f)->default_font_parameter (f, Qnil);
face_change = true;
windows_or_buffers_changed = 18;
}

View File

@ -5132,6 +5132,13 @@ static Lisp_Object ns_string_to_lispmod (const char *s)
reset_mouse_highlight (&dpyinfo->mouse_highlight);
}
/* This currently does nothing, since it's only really needed when
changing the font-backend, but macOS currently only has one
possible backend. This may change if we add HarfBuzz support. */
static void
ns_default_font_parameter (struct frame *f, Lisp_Object parms)
{
}
/* This and next define (many of the) public functions in this file. */
/* gui_* are generic versions in xdisp.c that we, and other terms, get away
@ -5167,7 +5174,8 @@ static Lisp_Object ns_string_to_lispmod (const char *s)
ns_draw_window_divider,
ns_shift_glyphs_for_insert,
ns_show_hourglass,
ns_hide_hourglass
ns_hide_hourglass,
ns_default_font_parameter
};

View File

@ -5749,7 +5749,7 @@ do_unwind_create_frame (Lisp_Object frame)
unwind_create_frame (frame);
}
static void
void
w32_default_font_parameter (struct frame *f, Lisp_Object parms)
{
struct w32_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);

View File

@ -7249,7 +7249,8 @@ static struct redisplay_interface w32_redisplay_interface =
w32_draw_window_divider,
w32_shift_glyphs_for_insert,
w32_show_hourglass,
w32_hide_hourglass
w32_hide_hourglass,
w32_default_font_parameter
};
static void w32_delete_terminal (struct terminal *term);

View File

@ -267,6 +267,10 @@ extern void w32con_show_cursor (void);
extern const char *w32_get_string_resource (void *v_rdb,
const char *name,
const char *class);
/* w32fns.c */
extern void w32_default_font_parameter (struct frame* f, Lisp_Object parms);
#define PIX_TYPE COLORREF

View File

@ -3555,7 +3555,7 @@ do_unwind_create_frame (Lisp_Object frame)
unwind_create_frame (frame);
}
static void
void
x_default_font_parameter (struct frame *f, Lisp_Object parms)
{
struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);

View File

@ -13374,7 +13374,8 @@ static struct redisplay_interface x_redisplay_interface =
x_draw_window_divider,
x_shift_glyphs_for_insert, /* Never called; see comment in function. */
x_show_hourglass,
x_hide_hourglass
x_hide_hourglass,
x_default_font_parameter
};

View File

@ -1056,6 +1056,7 @@ extern void x_real_pos_and_offsets (struct frame *f,
int *xptr,
int *yptr,
int *outer_border);
extern void x_default_font_parameter (struct frame* f, Lisp_Object parms);
/* From xrdb.c. */