aboutsummaryrefslogtreecommitdiff
path: root/terminal.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-03-11 15:10:55 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-03-14 21:34:03 +0000
commit36ef0463b7157199aac1876ad4cc9725403fff4a (patch)
tree730169426fd99e91b60e0d19ef1787a86204f1e9 /terminal.c
parentquirks: weston_csd_{on,off}: don't do anything in fullscreen mode (diff)
term: use logical DPI+scale factor when scaling fonts
This fixes an issue where the fonts were rendered too small when the output had fractional scaling. For integral scaling, using the logical (scaled) DPI multiplied with the scaling factor results in the same final DPI value as if we had used the physical DPI. But for fractional scaling, this works around the fact that the compositor downscales the surface after we've rendered it. Closes #5
Diffstat (limited to 'terminal.c')
-rw-r--r--terminal.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/terminal.c b/terminal.c
index 3803e847..68dc9b58 100644
--- a/terminal.c
+++ b/terminal.c
@@ -532,18 +532,39 @@ term_set_fonts(struct terminal *term, struct font *fonts[static 4])
static unsigned
get_font_dpi(const struct terminal *term)
{
+ /*
+ * Use output's DPI to scale font. This is to ensure the font has
+ * the same physical height (if measured by a ruler) regardless of
+ * monitor.
+ *
+ * Conceptually, we use the physical monitor specs to calculate
+ * the DPI, and we ignore the output's scaling factor.
+ *
+ * However, to deal with fractional scaling, where we're told to
+ * render at e.g. 2x, but are then downscaled by the compositor to
+ * e.g. 1.25, we use the scaled DPI value multiplied by the scale
+ * factor instead.
+ *
+ * For integral scaling factors the resulting DPI is the same as
+ * if we had used the physical DPI.
+ *
+ * For fractional scaling factors we'll get a DPI *larger* than
+ * the physical DPI, that ends up being right when later
+ * downscaled by the compositor.
+ */
+
/* Use highest DPI from outputs we're mapped on */
unsigned dpi = 0;
assert(term->window != NULL);
tll_foreach(term->window->on_outputs, it) {
- if (it->item->y_ppi > dpi)
- dpi = it->item->y_ppi;
+ if (it->item->ppi.scaled.y > dpi)
+ dpi = it->item->ppi.scaled.y * term->scale;
}
/* If we're not mapped, use DPI from first monitor. Hopefully this is where we'll get mapped later... */
if (dpi == 0) {
tll_foreach(term->wl->monitors, it) {
- dpi = it->item.y_ppi;
+ dpi = it->item.ppi.scaled.y * term->scale;
break;
}
}