aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-12-04 21:02:02 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-12-04 21:02:02 +0000
commitad56afe2f4823043bf2adcf7815d1addb52ef48f (patch)
tree9c3654cb175bcfbee8994c63fbe6cd44bfe267ee
parentmain: stop initializing a default set of fonts (diff)
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...
-rw-r--r--terminal.c21
1 files 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 *