mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
render: ensure an underline cursor is not positioned too low
The underline cursor is positioned just below regular underlines. A bug in the positioning logic related to this, sometimes resulted in the cursor being thinner than what it should be, or even invisible. Fixes #1005
This commit is contained in:
parent
49ba16da25
commit
5ce1589c60
2 changed files with 24 additions and 19 deletions
|
|
@ -93,6 +93,9 @@
|
|||
(https://codeberg.org/dnkl/foot/issues/963).
|
||||
* Key presses with e.g. `AltGr` triggering key combinations with the
|
||||
base symbol (https://codeberg.org/dnkl/foot/issues/983).
|
||||
* Underline cursor sometimes being positioned too low, either making
|
||||
it look thinner than what it should be, or being completely
|
||||
invisible (https://codeberg.org/dnkl/foot/issues/1005).
|
||||
|
||||
|
||||
### Security
|
||||
|
|
|
|||
40
render.c
40
render.c
|
|
@ -345,24 +345,13 @@ draw_beam_cursor(const struct terminal *term, pixman_image_t *pix,
|
|||
term->fonts[0]->ascent + term->fonts[0]->descent});
|
||||
}
|
||||
|
||||
static void
|
||||
draw_underline_with_thickness(
|
||||
const struct terminal *term, pixman_image_t *pix,
|
||||
const struct fcft_font *font,
|
||||
const pixman_color_t *color, int x, int y, int cols, int thickness)
|
||||
static int
|
||||
underline_offset(const struct terminal *term, const struct fcft_font *font)
|
||||
{
|
||||
/* Make sure the line isn't positioned below the cell */
|
||||
int y_ofs = font_baseline(term) -
|
||||
return font_baseline(term) -
|
||||
(term->conf->use_custom_underline_offset
|
||||
? -term_pt_or_px_as_pixels(term, &term->conf->underline_offset)
|
||||
: font->underline.position);
|
||||
|
||||
y_ofs = min(y_ofs, term->cell_height - thickness);
|
||||
|
||||
pixman_image_fill_rectangles(
|
||||
PIXMAN_OP_SRC, pix, color,
|
||||
1, &(pixman_rectangle16_t){
|
||||
x, y + y_ofs, cols * term->cell_width, thickness});
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -375,9 +364,14 @@ draw_underline_cursor(const struct terminal *term, pixman_image_t *pix,
|
|||
term, &term->conf->cursor.underline_thickness)
|
||||
: font->underline.thickness;
|
||||
|
||||
draw_underline_with_thickness(
|
||||
term, pix, font, color, x, y + font->underline.thickness, cols,
|
||||
thickness);
|
||||
/* Make sure the line isn't positioned below the cell */
|
||||
const int y_ofs = min(underline_offset(term, font) + thickness,
|
||||
term->cell_height - thickness);
|
||||
|
||||
pixman_image_fill_rectangles(
|
||||
PIXMAN_OP_SRC, pix, color,
|
||||
1, &(pixman_rectangle16_t){
|
||||
x, y + y_ofs, cols * term->cell_width, thickness});
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -385,8 +379,16 @@ draw_underline(const struct terminal *term, pixman_image_t *pix,
|
|||
const struct fcft_font *font,
|
||||
const pixman_color_t *color, int x, int y, int cols)
|
||||
{
|
||||
draw_underline_with_thickness(
|
||||
term, pix, font, color, x, y, cols, font->underline.thickness);
|
||||
const int thickness = font->underline.thickness;
|
||||
|
||||
/* Make sure the line isn't positioned below the cell */
|
||||
const int y_ofs = min(underline_offset(term, font),
|
||||
term->cell_height - thickness);
|
||||
|
||||
pixman_image_fill_rectangles(
|
||||
PIXMAN_OP_SRC, pix, color,
|
||||
1, &(pixman_rectangle16_t){
|
||||
x, y + y_ofs, cols * term->cell_width, thickness});
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue