aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-12-14 16:45:12 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-12-14 16:45:12 +0000
commita098fad004f70a52c2b3163e185d95e8abcf2704 (patch)
tree7738cf3592db8e8be178938d052102d6855c478f
parentMerge branch 'wl-output-name-description' (diff)
term: font_size_adjust: use DPI=96 when font is *not* scaled by DPI
Closes #842
-rw-r--r--CHANGELOG.md6
-rw-r--r--terminal.c16
2 files changed, 14 insertions, 8 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2ebf3f98..ca3ca225 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -48,6 +48,12 @@
### Deprecated
### Removed
### Fixed
+
+* Font size adjustment (“zooming”) when font is configured with a
+ **pixelsize**, and `dpi-aware=no`
+ (https://codeberg.org/dnkl/foot/issues/842).
+
+
### Security
### Contributors
diff --git a/terminal.c b/terminal.c
index d5728a53..73f003d6 100644
--- a/terminal.c
+++ b/terminal.c
@@ -1917,11 +1917,13 @@ term_font_size_adjust(struct terminal *term, double amount)
{
const struct config *conf = term->conf;
+ const float dpi = term->font_is_sized_by_dpi ? term->font_dpi : 96.;
+
for (size_t i = 0; i < 4; i++) {
const struct config_font_list *font_list = &conf->fonts[i];
for (size_t j = 0; j < font_list->count; j++) {
- double old_pt_size = term->font_sizes[i][j].pt_size;
+ float old_pt_size = term->font_sizes[i][j].pt_size;
/*
* To ensure primary and user-configured fallback fonts are
@@ -1929,23 +1931,21 @@ term_font_size_adjust(struct terminal *term, double amount)
* sizes, and to the adjustment on point sizes only.
*/
- if (term->font_sizes[i][j].px_size > 0) {
- double dpi = term->font_dpi;
+ if (term->font_sizes[i][j].px_size > 0)
old_pt_size = term->font_sizes[i][j].px_size * 72. / dpi;
- }
- term->font_sizes[i][j].pt_size = fmax(old_pt_size + amount, 0);
+ term->font_sizes[i][j].pt_size = fmaxf(old_pt_size + amount, 0.);
term->font_sizes[i][j].px_size = -1;
}
}
if (term->font_line_height.px >= 0) {
- double old_pt_size = term->font_line_height.px > 0
- ? term->font_line_height.px * 72. / term->font_dpi
+ float old_pt_size = term->font_line_height.px > 0
+ ? term->font_line_height.px * 72. / dpi
: term->font_line_height.pt;
term->font_line_height.px = 0;
- term->font_line_height.pt = fmax(old_pt_size + amount, 0);
+ term->font_line_height.pt = fmaxf(old_pt_size + amount, 0.);
}
return reload_fonts(term);