1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-18 19:41:01 -05:00

Support SGR 9 for strikethrough effect on text.

This is mostly easy: it's just like drawing an underline, except that
you put it at a different height in the character cell. The only
question is _where_ in the character cell.

Pango, and Windows GetOutlineTextMetrics, will tell you exactly where
the font wants to have it. Following xterm, I fall back to 3/8 of the
font's ascent (above the baseline) if either of those is unavailable.
This commit is contained in:
Simon Tatham
2020-08-13 21:08:53 +01:00
parent 334d87251e
commit 06a8d11964
6 changed files with 52 additions and 15 deletions

View File

@ -511,6 +511,7 @@ static unifont *x11font_create(GtkWidget *widget, const char *name,
xfont->u.height = xfont->u.ascent + xfont->u.descent;
xfont->u.public_charset = pubcs;
xfont->u.want_fallback = true;
xfont->u.strikethrough_y = xfont->u.ascent - (xfont->u.ascent * 3 / 8);
#ifdef DRAW_TEXT_GDK
xfont->u.preferred_drawtype = DRAWTYPE_GDK;
#elif defined DRAW_TEXT_CAIRO
@ -1463,6 +1464,9 @@ static unifont *pangofont_create_internal(GtkWidget *widget,
pfont->u.descent =
PANGO_PIXELS_CEIL(pango_font_metrics_get_descent(metrics));
pfont->u.height = pfont->u.ascent + pfont->u.descent;
pfont->u.strikethrough_y =
PANGO_PIXELS(pango_font_metrics_get_ascent(metrics) -
pango_font_metrics_get_strikethrough_position(metrics));
pfont->u.want_fallback = false;
#ifdef DRAW_TEXT_CAIRO
pfont->u.preferred_drawtype = DRAWTYPE_CAIRO;
@ -2242,6 +2246,7 @@ unifont *multifont_create(GtkWidget *widget, const char *name,
mfont->u.ascent = font->ascent;
mfont->u.descent = font->descent;
mfont->u.height = font->height;
mfont->u.strikethrough_y = font->strikethrough_y;
mfont->u.public_charset = font->public_charset;
mfont->u.want_fallback = false; /* shouldn't be needed, but just in case */
mfont->u.preferred_drawtype = font->preferred_drawtype;