mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-16 05:34:00 -04:00
term: increase/decrease custom line-height with font size changes
When the user has set a custom line-height, we now adjust it when increasing/decreasing (“zooming”) the font size at run-time. Previously, the line-height was fixed at the size specified in foot.ini.
This commit is contained in:
parent
57a663a0c7
commit
7609fbba47
4 changed files with 22 additions and 8 deletions
|
|
@ -33,6 +33,8 @@
|
||||||
|
|
||||||
* Logic that repairs invalid key bindings ended up breaking valid key
|
* Logic that repairs invalid key bindings ended up breaking valid key
|
||||||
bindings instead (https://codeberg.org/dnkl/foot/issues/407).
|
bindings instead (https://codeberg.org/dnkl/foot/issues/407).
|
||||||
|
* Custom `line-height` settings now scale when increasing or
|
||||||
|
decreasing the font size at run-time.
|
||||||
|
|
||||||
|
|
||||||
### Security
|
### Security
|
||||||
|
|
|
||||||
6
config.h
6
config.h
|
|
@ -53,12 +53,6 @@ struct config_mouse_binding {
|
||||||
struct config_binding_pipe pipe;
|
struct config_binding_pipe pipe;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* If px != 0 then px is valid, otherwise pt is valid */
|
|
||||||
struct pt_or_px {
|
|
||||||
int16_t px;
|
|
||||||
float pt;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct config_spawn_template {
|
struct config_spawn_template {
|
||||||
char *raw_cmd;
|
char *raw_cmd;
|
||||||
char **argv;
|
char **argv;
|
||||||
|
|
|
||||||
15
terminal.c
15
terminal.c
|
|
@ -649,8 +649,8 @@ term_set_fonts(struct terminal *term, struct fcft_font *fonts[static 4])
|
||||||
: term->fonts[0]->max_advance.x)
|
: term->fonts[0]->max_advance.x)
|
||||||
+ pt_or_px_as_pixels(term, &conf->letter_spacing);
|
+ pt_or_px_as_pixels(term, &conf->letter_spacing);
|
||||||
|
|
||||||
term->cell_height = conf->line_height.px >= 0
|
term->cell_height = term->font_line_height.px >= 0
|
||||||
? pt_or_px_as_pixels(term, &conf->line_height)
|
? pt_or_px_as_pixels(term, &term->font_line_height)
|
||||||
: max(term->fonts[0]->height,
|
: max(term->fonts[0]->height,
|
||||||
term->fonts[0]->ascent + term->fonts[0]->descent);
|
term->fonts[0]->ascent + term->fonts[0]->descent);
|
||||||
|
|
||||||
|
|
@ -979,6 +979,7 @@ load_fonts_from_conf(struct terminal *term)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
term->font_line_height = term->conf->line_height;
|
||||||
return reload_fonts(term);
|
return reload_fonts(term);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1196,6 +1197,7 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
|
||||||
.pt_size = it->item.pt_size, .px_size = it->item.px_size};
|
.pt_size = it->item.pt_size, .px_size = it->item.px_size};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
term->font_line_height = conf->line_height;
|
||||||
|
|
||||||
/* Start the slave/client */
|
/* Start the slave/client */
|
||||||
if ((term->slave = slave_spawn(
|
if ((term->slave = slave_spawn(
|
||||||
|
|
@ -1780,6 +1782,15 @@ term_font_size_adjust(struct terminal *term, double amount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
: term->font_line_height.pt;
|
||||||
|
|
||||||
|
term->font_line_height.px = 0;
|
||||||
|
term->font_line_height.pt = fmax(old_pt_size + amount, 0);
|
||||||
|
}
|
||||||
|
|
||||||
return reload_fonts(term);
|
return reload_fonts(term);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -261,6 +261,12 @@ struct url {
|
||||||
};
|
};
|
||||||
typedef tll(struct url) url_list_t;
|
typedef tll(struct url) url_list_t;
|
||||||
|
|
||||||
|
/* If px != 0 then px is valid, otherwise pt is valid */
|
||||||
|
struct pt_or_px {
|
||||||
|
int16_t px;
|
||||||
|
float pt;
|
||||||
|
};
|
||||||
|
|
||||||
struct terminal {
|
struct terminal {
|
||||||
struct fdm *fdm;
|
struct fdm *fdm;
|
||||||
struct reaper *reaper;
|
struct reaper *reaper;
|
||||||
|
|
@ -312,6 +318,7 @@ struct terminal {
|
||||||
|
|
||||||
struct fcft_font *fonts[4];
|
struct fcft_font *fonts[4];
|
||||||
struct config_font *font_sizes[4];
|
struct config_font *font_sizes[4];
|
||||||
|
struct pt_or_px font_line_height;
|
||||||
float font_dpi;
|
float font_dpi;
|
||||||
int font_scale;
|
int font_scale;
|
||||||
int16_t font_x_ofs;
|
int16_t font_x_ofs;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue