mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-07 04:06:07 -05:00
render: add font_baseline() - calculates the y-coordinate for the baseline
The old baseline calculation was copy-pasted to a couple of places, and also assumed that the font's height was equal to ascent+descent. While this is typically true, it isn't necessarily so. Now, we assume that height >= ascent+descent, and then position the baseline in "center" (but adjusted for the descent).
This commit is contained in:
parent
6d5f200429
commit
013cf61ffb
1 changed files with 19 additions and 0 deletions
19
render.c
19
render.c
|
|
@ -80,6 +80,25 @@ pixman_color_dim_for_search(pixman_color_t *color)
|
|||
color->blue /= 3;
|
||||
}
|
||||
|
||||
static inline int
|
||||
font_baseline(const struct terminal *term)
|
||||
{
|
||||
assert(term->fextents.ascent >= 0);
|
||||
assert(term->fextents.descent >= 0);
|
||||
|
||||
int diff = term->fextents.height - (term->fextents.ascent + term->fextents.descent);
|
||||
assert(diff >= 0);
|
||||
|
||||
#if 0
|
||||
LOG_INFO("height=%d, ascent=%d, descent=%d, diff=%d",
|
||||
term->fextents.height,
|
||||
term->fextents.ascent, term->fextents.descent,
|
||||
diff);
|
||||
#endif
|
||||
|
||||
return term->fextents.height - diff / 2 - term->fextents.descent;
|
||||
}
|
||||
|
||||
static void
|
||||
draw_bar(const struct terminal *term, pixman_image_t *pix,
|
||||
const pixman_color_t *color, int x, int y)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue