From 428b5ef27c49a9202788921e349d7df9a23b7003 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Thu, 7 Jan 2021 11:16:29 +0100 Subject: foot.ini: add new options: line-height, letter-spacing and *-letter-offset --- foot.ini | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'foot.ini') diff --git a/foot.ini b/foot.ini index 76491372..ed9e5a72 100644 --- a/foot.ini +++ b/foot.ini @@ -1,22 +1,29 @@ # -*- conf -*- +# shell=$SHELL (if set, otherwise user's default shell from /etc/passwd) +# term=foot +# login-shell=no + # font=monospace:size=8 # font-bold= # font-italic= # font-bold-italic= +# line-height= +# letter-spacing= +# horizontal-letter-offset=0 +# vertical-letter-offset=0 # dpi-aware=yes + # initial-window-size-pixels=700x500 # Or, # initial-window-size-chars= # initial-window-mode=windowed # pad=2x2 # optionally append 'center' -# shell=$SHELL (if set, otherwise user's default shell from /etc/passwd) -# term=foot -# login-shell=no -# workers= + # bold-text-in-bright=no # bell=none # word-delimiters=,│`|:"'()[]{}<> # notify=notify-send -a foot -i foot ${title} ${body} +# workers= [scrollback] # lines=1000 -- cgit v1.3 From 70cfcf11fb26a1e3954e72550e4c24e0fa43a8b2 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Thu, 7 Jan 2021 11:46:18 +0100 Subject: config: letter-spacing: make this a relative value 0, the default, means no additional spacing; the cell width is defined by the font metrics. A positive value *adds* to the width from the font metrics, while a negative value *subtracts*. --- config.c | 17 +++++++++++++++-- foot.ini | 2 +- terminal.c | 9 +++++---- 3 files changed, 21 insertions(+), 7 deletions(-) (limited to 'foot.ini') diff --git a/config.c b/config.c index 6af8803b..8f0b334f 100644 --- a/config.c +++ b/config.c @@ -360,6 +360,19 @@ str_to_bool(const char *s) strtoul(s, NULL, 0) > 0; } +static bool +str_to_long(const char *s, int base, long *res) +{ + if (s == NULL) + return false; + + errno = 0; + char *end = NULL; + + *res = strtol(s, &end, base); + return errno == 0 && *end == '\0'; +} + static bool str_to_ulong(const char *s, int base, unsigned long *res) { @@ -567,8 +580,8 @@ parse_section_main(const char *key, const char *value, struct config *conf, } else if (strcmp(key, "letter-spacing") == 0) { - unsigned long spacing; - if (!str_to_ulong(value, 10, &spacing)) { + long spacing; + if (!str_to_long(value, 10, &spacing)) { LOG_AND_NOTIFY_ERR( "%s:%d: [default]: letter-spacing: expected an integer, got '%s'", path, lineno, value); diff --git a/foot.ini b/foot.ini index ed9e5a72..f13d8e63 100644 --- a/foot.ini +++ b/foot.ini @@ -9,7 +9,7 @@ # font-italic= # font-bold-italic= # line-height= -# letter-spacing= +# letter-spacing=0 # horizontal-letter-offset=0 # vertical-letter-offset=0 # dpi-aware=yes diff --git a/terminal.c b/terminal.c index c7383ae2..c23450fb 100644 --- a/terminal.c +++ b/terminal.c @@ -629,10 +629,11 @@ term_set_fonts(struct terminal *term, struct fcft_font *fonts[static 4]) const int old_cell_width = term->cell_width; const int old_cell_height = term->cell_height; - term->cell_width = term->conf->letter_spacing >= 0 - ? term->conf->letter_spacing - : (term->fonts[0]->space_advance.x > 0 - ? term->fonts[0]->space_advance.x : term->fonts[0]->max_advance.x); + term->cell_width = (term->fonts[0]->space_advance.x > 0 + ? term->fonts[0]->space_advance.x + : term->fonts[0]->max_advance.x) + + term->conf->letter_spacing; + term->cell_height = term->conf->line_height >= 0 ? term->conf->line_height : max(term->fonts[0]->height, -- cgit v1.3