aboutsummaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2022-12-15 10:10:32 +0000
committerDaniel Eklöf <daniel@ekloef.se>2022-12-17 09:59:17 +0000
commitf6ca8c90e11d9b1ecdfe8a5bf69b1b793376a91c (patch)
treec8a6e83c143f6d973b9cdc4c3498901089ba263b /config.c
parentmain: Graceful fallback if user has configured an invalid locale (diff)
config: add ‘font-size-adjustment=N[px|%]’ option
This patch adds a new config option, font-size-adjustment. It lets you configure how much the font size should be incremented/decremented when zooming in or out (ctrl-+, ctrl+-). Values can be specified in points, pixels or percent. Closes #1188
Diffstat (limited to 'config.c')
-rw-r--r--config.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/config.c b/config.c
index 68641647..b10f42b2 100644
--- a/config.c
+++ b/config.c
@@ -925,6 +925,31 @@ parse_section_main(struct context *ctx)
return true;
}
+ else if (strcmp(key, "font-size-adjustment") == 0) {
+ const size_t len = strlen(ctx->value);
+ if (len >= 1 && ctx->value[len - 1] == '%') {
+ errno = 0;
+ char *end = NULL;
+
+ float percent = strtof(ctx->value, &end);
+ if (!(errno == 0 && end == ctx->value + len - 1)) {
+ LOG_CONTEXTUAL_ERR(
+ "invalid percent value (must be in the form 10.5%%)");
+ return false;
+ }
+
+ conf->font_size_adjustment.percent = percent / 100.;
+ conf->font_size_adjustment.pt_or_px.pt = 0;
+ conf->font_size_adjustment.pt_or_px.px = 0;
+ return true;
+ } else {
+ bool ret = value_to_pt_or_px(ctx, &conf->font_size_adjustment.pt_or_px);
+ if (ret)
+ conf->font_size_adjustment.percent = 0.;
+ return ret;
+ }
+ }
+
else if (strcmp(key, "line-height") == 0)
return value_to_pt_or_px(ctx, &conf->line_height);
@@ -2886,6 +2911,7 @@ config_load(struct config *conf, const char *conf_path,
},
.startup_mode = STARTUP_WINDOWED,
.fonts = {{0}},
+ .font_size_adjustment = {.percent = 0., .pt_or_px = {.pt = 0.5, .px = 0}},
.line_height = {.pt = 0, .px = -1},
.letter_spacing = {.pt = 0, .px = 0},
.horizontal_letter_offset = {.pt = 0, .px = 0},