diff --git a/kitty/boss.py b/kitty/boss.py index d6637cb8c..fda25acf5 100644 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -265,12 +265,12 @@ class Boss: def restore_font_size(self): self.change_font_size(self.opts.font_size) - def _change_font_size(self, new_size=None): + def _change_font_size(self, new_size=None, on_dpi_change=False): if new_size is not None: self.current_font_size = new_size old_cell_width, old_cell_height = viewport_for_window()[-2:] windows = tuple(filter(None, self.window_id_map.values())) - resize_fonts(self.current_font_size) + resize_fonts(self.current_font_size, on_dpi_change=on_dpi_change) layout_sprite_map() prerender() for window in windows: diff --git a/kitty/fonts.c b/kitty/fonts.c index 74d5eb75c..8314b8cf1 100644 --- a/kitty/fonts.c +++ b/kitty/fonts.c @@ -283,7 +283,7 @@ python_send_to_gpu(unsigned int x, unsigned int y, unsigned int z, pixel* buf) { static inline PyObject* -update_cell_metrics() { +update_cell_metrics(bool on_dpi_change UNUSED) { #define CALL(idx, desired_height, force) { if (idx >= 0) { Font *f = fonts.fonts + idx; if ((f)->face) { if(!set_size_for_face((f)->face, desired_height, force)) return NULL; } clear_sprite_map((f)); }} CALL(BOX_FONT, 0, false); CALL(fonts.medium_font_idx, 0, false); CALL(fonts.bold_font_idx, 0, false); CALL(fonts.italic_font_idx, 0, false); CALL(fonts.bi_font_idx, 0, false); @@ -320,8 +320,9 @@ update_cell_metrics() { static PyObject* set_font_size(PyObject UNUSED *m, PyObject *args) { - if (!PyArg_ParseTuple(args, "f", &global_state.font_sz_in_pts)) return NULL; - return update_cell_metrics(); + int on_dpi_change = 0; + if (!PyArg_ParseTuple(args, "f|p", &global_state.font_sz_in_pts, &on_dpi_change)) return NULL; + return update_cell_metrics(on_dpi_change != 0); } static inline bool @@ -896,7 +897,7 @@ set_font(PyObject UNUSED *m, PyObject *args) { } fonts.first_fallback_font_idx = fonts.fonts_count; fonts.fallback_fonts_count = 0; - return update_cell_metrics(); + return update_cell_metrics(false); } static void diff --git a/kitty/fonts/render.py b/kitty/fonts/render.py index 829d35841..ba51da9ac 100644 --- a/kitty/fonts/render.py +++ b/kitty/fonts/render.py @@ -61,9 +61,9 @@ def set_font_family(opts=None, override_font_size=None): return cell_width, cell_height -def resize_fonts(new_sz): +def resize_fonts(new_sz, on_dpi_change=False): s = set_font_family.state - cell_width, cell_height, baseline, underline_position, underline_thickness = set_font_size(new_sz) + cell_width, cell_height, baseline, underline_position, underline_thickness = set_font_size(new_sz, on_dpi_change) set_font_family.state = FontState( s.family, new_sz, cell_width, cell_height, baseline, underline_position, underline_thickness