mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-24 01:40:12 -05:00
term: font size adjust: re-load fonts in parallel
This commit is contained in:
parent
1d67f37045
commit
589e984b91
1 changed files with 30 additions and 9 deletions
39
terminal.c
39
terminal.c
|
|
@ -1309,25 +1309,46 @@ term_reset(struct terminal *term, bool hard)
|
||||||
term_damage_all(term);
|
term_damage_all(term);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct font_adjust_data {
|
||||||
|
struct fcft_font *font_in;
|
||||||
|
double amount;
|
||||||
|
struct fcft_font *font_out;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
font_size_adjust_thread(void *_data)
|
||||||
|
{
|
||||||
|
struct font_adjust_data *data = _data;
|
||||||
|
data->font_out = fcft_size_adjust(data->font_in, data->amount);
|
||||||
|
return data->font_out != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
term_font_size_adjust(struct terminal *term, double amount)
|
term_font_size_adjust(struct terminal *term, double amount)
|
||||||
{
|
{
|
||||||
struct fcft_font *fonts[4] = {
|
struct font_adjust_data data[4] = {
|
||||||
fcft_size_adjust(term->fonts[0], amount),
|
{term->fonts[0], amount},
|
||||||
fcft_size_adjust(term->fonts[1], amount),
|
{term->fonts[1], amount},
|
||||||
fcft_size_adjust(term->fonts[2], amount),
|
{term->fonts[2], amount},
|
||||||
fcft_size_adjust(term->fonts[3], amount),
|
{term->fonts[3], amount},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (fonts[0] == NULL || fonts[1] == NULL ||
|
thrd_t tids[4];
|
||||||
fonts[2] == NULL || fonts[3] == NULL)
|
for (size_t i = 0; i < 4; i++)
|
||||||
|
thrd_create(&tids[i], &font_size_adjust_thread, &data[i]);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < 4; i++)
|
||||||
|
thrd_join(tids[i], NULL);
|
||||||
|
|
||||||
|
if (data[0].font_out == NULL || data[1].font_out == NULL ||
|
||||||
|
data[2].font_out == NULL || data[3].font_out == NULL)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < 4; i++)
|
for (size_t i = 0; i < 4; i++)
|
||||||
fcft_destroy(fonts[i]);
|
fcft_destroy(data[i].font_out);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
term_set_fonts(term, fonts);
|
term_set_fonts(term, (struct fcft_font *[]){data[0].font_out, data[1].font_out, data[2].font_out, data[3].font_out});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue