Let update_cell_emtrics() know if it is being called in response to a DPI change
This commit is contained in:
parent
22cf67b407
commit
328f22adab
@ -265,12 +265,12 @@ class Boss:
|
|||||||
def restore_font_size(self):
|
def restore_font_size(self):
|
||||||
self.change_font_size(self.opts.font_size)
|
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:
|
if new_size is not None:
|
||||||
self.current_font_size = new_size
|
self.current_font_size = new_size
|
||||||
old_cell_width, old_cell_height = viewport_for_window()[-2:]
|
old_cell_width, old_cell_height = viewport_for_window()[-2:]
|
||||||
windows = tuple(filter(None, self.window_id_map.values()))
|
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()
|
layout_sprite_map()
|
||||||
prerender()
|
prerender()
|
||||||
for window in windows:
|
for window in windows:
|
||||||
|
|||||||
@ -283,7 +283,7 @@ python_send_to_gpu(unsigned int x, unsigned int y, unsigned int z, pixel* buf) {
|
|||||||
|
|
||||||
|
|
||||||
static inline PyObject*
|
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)); }}
|
#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(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);
|
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*
|
static PyObject*
|
||||||
set_font_size(PyObject UNUSED *m, PyObject *args) {
|
set_font_size(PyObject UNUSED *m, PyObject *args) {
|
||||||
if (!PyArg_ParseTuple(args, "f", &global_state.font_sz_in_pts)) return NULL;
|
int on_dpi_change = 0;
|
||||||
return update_cell_metrics();
|
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
|
static inline bool
|
||||||
@ -896,7 +897,7 @@ set_font(PyObject UNUSED *m, PyObject *args) {
|
|||||||
}
|
}
|
||||||
fonts.first_fallback_font_idx = fonts.fonts_count;
|
fonts.first_fallback_font_idx = fonts.fonts_count;
|
||||||
fonts.fallback_fonts_count = 0;
|
fonts.fallback_fonts_count = 0;
|
||||||
return update_cell_metrics();
|
return update_cell_metrics(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@ -61,9 +61,9 @@ def set_font_family(opts=None, override_font_size=None):
|
|||||||
return cell_width, cell_height
|
return cell_width, cell_height
|
||||||
|
|
||||||
|
|
||||||
def resize_fonts(new_sz):
|
def resize_fonts(new_sz, on_dpi_change=False):
|
||||||
s = set_font_family.state
|
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(
|
set_font_family.state = FontState(
|
||||||
s.family, new_sz, cell_width, cell_height, baseline,
|
s.family, new_sz, cell_width, cell_height, baseline,
|
||||||
underline_position, underline_thickness
|
underline_position, underline_thickness
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user