diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2019-07-16 13:08:02 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2019-07-16 13:08:02 +0000 |
| commit | 06f9495ae2371929f9ffdf962c491ec27486bdbc (patch) | |
| tree | 51ce36ed77fcb3e942434d63fc6876914d84f122 /render.c | |
| parent | render: implement 'underline' (diff) | |
render: implement strikeout
Diffstat (limited to 'render.c')
| -rw-r--r-- | render.c | 20 |
1 files changed, 17 insertions, 3 deletions
@@ -134,13 +134,27 @@ render_cell(struct terminal *term, struct buffer *buf, const struct cell *cell, /* Underline */ if (cell->attrs.underline) { const struct font *font = attrs_to_font(term, &cell->attrs); + double baseline = y + term->fextents.height - term->fextents.descent; double width = font->underline.thickness; - double y_under = y + term->cell_height + font->underline.position + width / 2.; + double y_under = baseline - font->underline.position - width / 2.; cairo_set_source_rgb(buf->cairo, foreground.r, foreground.g, foreground.b); cairo_set_line_width(buf->cairo, width); - cairo_move_to(buf->cairo, x, y_under); - cairo_line_to(buf->cairo, x + term->cell_width, y_under); + cairo_move_to(buf->cairo, x, round(y_under) + 0.5); + cairo_line_to(buf->cairo, x + term->cell_width, round(y_under) + 0.5); + cairo_stroke(buf->cairo); + } + + if (cell->attrs.strikethrough) { + const struct font *font = attrs_to_font(term, &cell->attrs); + double baseline = y + term->fextents.height - term->fextents.descent; + double width = font->strikeout.thickness; + double y_strike = baseline - font->strikeout.position - width / 2.; + + cairo_set_source_rgb(buf->cairo, foreground.r, foreground.g, foreground.b); + cairo_set_line_width(buf->cairo, width); + cairo_move_to(buf->cairo, x, round(y_strike) + 0.5); + cairo_line_to(buf->cairo, x + term->cell_width, round(y_strike) + 0.5); cairo_stroke(buf->cairo); } |
