mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-25 01:40:19 -05:00
commit
4d03b6c611
2 changed files with 39 additions and 12 deletions
|
|
@ -98,11 +98,16 @@
|
|||
cursor. Only applies to block cursor using inversed fg/bg
|
||||
colors. ([#1205][1205]).
|
||||
* Crash when monitor’s physical size is "too small" ([#1209][1209]).
|
||||
* Line-height adjustment when incrementing/decrementing the font size
|
||||
with a user-set line-height ([#1218][1218]).
|
||||
* Scaling factor not being correctly applied when converting pt-or-px
|
||||
config values (e.g. letter offsets, line height etc).
|
||||
|
||||
[1173]: https://codeberg.org/dnkl/foot/issues/1173
|
||||
[1190]: https://codeberg.org/dnkl/foot/issues/1190
|
||||
[1205]: https://codeberg.org/dnkl/foot/issues/1205
|
||||
[1209]: https://codeberg.org/dnkl/foot/issues/1209
|
||||
[1218]: https://codeberg.org/dnkl/foot/issues/1218
|
||||
|
||||
|
||||
### Security
|
||||
|
|
|
|||
46
terminal.c
46
terminal.c
|
|
@ -704,6 +704,37 @@ free_custom_glyphs(struct fcft_glyph ***glyphs, size_t count)
|
|||
*glyphs = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
term_line_height_update(struct terminal *term)
|
||||
{
|
||||
const struct config *conf = term->conf;
|
||||
|
||||
if (term->conf->line_height.px < 0) {
|
||||
term->font_line_height.pt = 0;
|
||||
term->font_line_height.px = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
const float dpi = term->font_is_sized_by_dpi ? term->font_dpi : 96.;
|
||||
|
||||
const float font_original_pt_size =
|
||||
conf->fonts[0].arr[0].px_size > 0
|
||||
? conf->fonts[0].arr[0].px_size * 72. / dpi
|
||||
: conf->fonts[0].arr[0].pt_size;
|
||||
const float font_current_pt_size =
|
||||
term->font_sizes[0][0].px_size > 0
|
||||
? term->font_sizes[0][0].px_size * 72. / dpi
|
||||
: term->font_sizes[0][0].pt_size;
|
||||
|
||||
const float change = font_current_pt_size / font_original_pt_size;
|
||||
const float line_original_pt_size = conf->line_height.px > 0
|
||||
? conf->line_height.px * 72. / dpi
|
||||
: conf->line_height.pt;
|
||||
|
||||
term->font_line_height.px = 0;
|
||||
term->font_line_height.pt = fmaxf(line_original_pt_size * change, 0.);
|
||||
}
|
||||
|
||||
static bool
|
||||
term_set_fonts(struct terminal *term, struct fcft_font *fonts[static 4])
|
||||
{
|
||||
|
|
@ -730,6 +761,8 @@ term_set_fonts(struct terminal *term, struct fcft_font *fonts[static 4])
|
|||
fonts[0], U'M', term->font_subpixel);
|
||||
int advance = M != NULL ? M->advance.x : term->fonts[0]->max_advance.x;
|
||||
|
||||
term_line_height_update(term);
|
||||
|
||||
term->cell_width = advance +
|
||||
term_pt_or_px_as_pixels(term, &conf->letter_spacing);
|
||||
|
||||
|
|
@ -913,7 +946,7 @@ term_pt_or_px_as_pixels(const struct terminal *term,
|
|||
|
||||
return pt_or_px->px == 0
|
||||
? round(pt_or_px->pt * scale * dpi / 72)
|
||||
: pt_or_px->px;
|
||||
: pt_or_px->px * scale;
|
||||
}
|
||||
|
||||
struct font_load_data {
|
||||
|
|
@ -1078,7 +1111,6 @@ load_fonts_from_conf(struct terminal *term)
|
|||
}
|
||||
}
|
||||
|
||||
term->font_line_height = term->conf->line_height;
|
||||
return reload_fonts(term);
|
||||
}
|
||||
|
||||
|
|
@ -1298,7 +1330,6 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
|
|||
.pt_size = font->pt_size, .px_size = font->px_size};
|
||||
}
|
||||
}
|
||||
term->font_line_height = conf->line_height;
|
||||
|
||||
add_utmp_record(conf, reaper, ptmx);
|
||||
|
||||
|
|
@ -2030,15 +2061,6 @@ term_font_size_adjust(struct terminal *term, double amount)
|
|||
}
|
||||
}
|
||||
|
||||
if (term->font_line_height.px >= 0) {
|
||||
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 = fmaxf(old_pt_size + amount, 0.);
|
||||
}
|
||||
|
||||
return reload_fonts(term);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue