From 3c1d27d8859cc4eda5802c1502ee5ae7430a9c8f Mon Sep 17 00:00:00 2001 From: Ivan Oleynikov Date: Tue, 27 Jul 2021 00:19:42 +0600 Subject: Scale fonts when Wayland updates scaling factor Before this commit, the code in src/wl_window.c seemed to handle the Wayland scaling [1] correctly, it was sending resize events to imv to update the buffer size accordingly. One thing it didn't update is the scaling of fonts that Pango renders on Cairo. This commit simply forwards the scaling factor (computed as [1] requests) together with updated buffer dimentions in resize event, and when the resize event is handled it calls cairo_surface_set_device_scale to notify Pango/Cairo of the scaling. For X11, I simply assume the scaline factor is always 1. This seems to be what the old code did: `grep scale src/x11_window.c` gives no matches. AFAIK, X11 does not have an established way of telling clients what scaling factor to use (and never updates it at runtime). [1]: https://wayland-book.com/surfaces-in-depth/hidpi.html --- src/imv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/imv.c') diff --git a/src/imv.c b/src/imv.c index b83980f..7842800 100644 --- a/src/imv.c +++ b/src/imv.c @@ -447,8 +447,9 @@ static void event_handler(void *data, const struct imv_event *e) const int wh = e->data.resize.height; const int bw = e->data.resize.buffer_width; const int bh = e->data.resize.buffer_height; + const double scale = e->data.resize.scale; imv_viewport_update(imv->view, ww, wh, bw, bh, imv->current_image, imv->scaling_mode); - imv_canvas_resize(imv->canvas, bw, bh); + imv_canvas_resize(imv->canvas, bw, bh, scale); break; } case IMV_EVENT_KEYBOARD: -- cgit v1.2.3