From ad56afe2f4823043bf2adcf7815d1addb52ef48f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Wed, 4 Dec 2019 22:02:02 +0100 Subject: [PATCH] term: test: set font DPI to the highest DPI we find In most cases (i.e. when there's only a single output/monitor), this will be *the* DPI value. In other cases, well... The _right_ thing to do is track the outputs our window is actually mapped on, and re-instantiate fonts depending on the current output's DPI. But that's for the future... --- terminal.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/terminal.c b/terminal.c index 31046df9..922b28f8 100644 --- a/terminal.c +++ b/terminal.c @@ -375,11 +375,24 @@ initialize_fonts(struct terminal *term, const struct config *conf) tll_foreach(conf->fonts, it) names[i++] = it->item; + /* Use highest DPI available */ + unsigned dpi = 96; + tll_foreach(term->wl->monitors, it) { + if (it->item.y_ppi > dpi) + dpi = it->item.y_ppi; + } + + char attrs0[64], attrs1[64], attrs2[64], attrs3[64]; + snprintf(attrs0, sizeof(attrs0), "dpi=%u", dpi); + snprintf(attrs1, sizeof(attrs1), "dpi=%u:weight=bold", dpi); + snprintf(attrs2, sizeof(attrs2), "dpi=%u:slant=italic", dpi); + snprintf(attrs3, sizeof(attrs3), "dpi=%u:weight=bold:slant=italic", dpi); + return ( - (term->fonts[0] = font_from_name(names, count, "dpi=96")) != NULL && - (term->fonts[1] = font_from_name(names, count, "dpi=96:weight=bold")) != NULL && - (term->fonts[2] = font_from_name(names, count, "dpi=96:slant=italic")) != NULL && - (term->fonts[3] = font_from_name(names, count, "dpi=96:weight=bold:slant=italic")) != NULL); + (term->fonts[0] = font_from_name(names, count, attrs0)) != NULL && + (term->fonts[1] = font_from_name(names, count, attrs1)) != NULL && + (term->fonts[2] = font_from_name(names, count, attrs2)) != NULL && + (term->fonts[3] = font_from_name(names, count, attrs3)) != NULL); } struct terminal *