render: csd_title(): use a custom font, sized based on the title bar’s height

We still use the primary font, but use a custom size, based on the
title bar’s height.

This fixes an issue where the window title could be way too small, or
way too big. And changed size when the terminal font size was changed.
This commit is contained in:
Daniel Eklöf 2021-07-22 21:23:59 +02:00
parent 4a41575cb5
commit 0cf7a19616
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
3 changed files with 43 additions and 3 deletions

View file

@ -1675,9 +1675,14 @@ render_csd_title(struct terminal *term, const struct csd_data *info,
title_text = _title_text;
}
const int margin = 10 * term->scale;
render_osd(term, surf->surf, surf->sub, buf, title_text, fg, bg,
margin, (buf->height - term->fonts[0]->height) / 2);
struct wl_window *win = term->window;
const int margin = win->csd.font->space_advance.x > 0
? win->csd.font->space_advance.x
: win->csd.font->max_advance.x;
render_osd(term, surf->surf, surf->sub, win->csd.font,
buf, title_text, fg, bg, margin,
(buf->height - win->csd.font->height) / 2);
csd_commit(term, surf->surf, buf);
free(_title_text);