mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-10 04:27:45 -05:00
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*.
This commit is contained in:
parent
389570b274
commit
70cfcf11fb
3 changed files with 21 additions and 7 deletions
17
config.c
17
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);
|
||||
|
|
|
|||
2
foot.ini
2
foot.ini
|
|
@ -9,7 +9,7 @@
|
|||
# font-italic=<italic variant of regular font>
|
||||
# font-bold-italic=<bold+italic variant of regular font>
|
||||
# line-height=<font metrics>
|
||||
# letter-spacing=<font metrics>
|
||||
# letter-spacing=0
|
||||
# horizontal-letter-offset=0
|
||||
# vertical-letter-offset=0
|
||||
# dpi-aware=yes
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue