Subject: Re: bug#33648: 25.2; feature request: configurable position of strike-through line

From: Stefan Kangas <[email-masked]>
Date: Mon, 31 Aug 2020 17:42:43 +0000

Stefan Kangas <[email-masked]> writes:

> 2. The strike-through line is hard coded to 1 pixel in our case, whereas
>    LibreOffice scales it up as the font size increases.

I've attached a suggested patch to change the strike-through line
depending on the glyph size.  The constant factor was found by
experimentation and produces reasonable results here.

Best regards,
Stefan Kangas
From 74b5091161890bc145034c5f2fd0c7e615b21d65 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <[email-masked]>
Date: Mon, 31 Aug 2020 13:39:51 +0200
Subject: [PATCH] Make strike-through thicker for larger font sizes

* src/nsterm.m (ns_draw_text_decoration):
* src/w32term.c (w32_draw_glyph_string):
* src/xterm.c (x_draw_glyph_string): Make strike-through thicker
for larger font sizes.  (Bug#33648)
* src/dispextern.h (STRIKE_THROUGH_WIDTH_FACTOR): New constant.
---
 src/dispextern.h | 4 ++++
 src/nsterm.m     | 2 +-
 src/w32term.c    | 2 +-
 src/xterm.c      | 2 +-
 4 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/dispextern.h b/src/dispextern.h
index 956ca96eb6..461526a7f8 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -656,6 +656,10 @@ #define GLYPH_INVALID_P(GLYPH) (GLYPH_CHAR (GLYPH) < 0)
 
 #define CHAR_GLYPH_PADDING_P(GLYPH) (GLYPH).padding_p
 
+/* Calculate the width of the strike-through line.  */
+
+#define STRIKE_THROUGH_WIDTH(x) ceilf (x / 15.0)
+

 
diff --git a/src/nsterm.m b/src/nsterm.m
index 26059ab67c..16575c066b 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -3706,7 +3706,7 @@ larger if there are taller display elements (e.g., characters
       int glyph_height = s->first_glyph->ascent + s->first_glyph->descent;
       /* Strike-through width and offset from the glyph string's
 	 top edge.  */
-      unsigned long h = 1;
+      unsigned long h = STRIKE_THROUGH_WIDTH (glyph_height);
       unsigned long dy;
 
       dy = lrint ((glyph_height - h) / 2);
diff --git a/src/w32term.c b/src/w32term.c
index 1766b32514..1b8d9b811b 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -2636,7 +2636,7 @@ w32_draw_glyph_string (struct glyph_string *s)
 	  int glyph_height = s->first_glyph->ascent + s->first_glyph->descent;
 	  /* Strike-through width and offset from the glyph string's
 	     top edge.  */
-          unsigned long h = 1;
+	  unsigned long h = STRIKE_THROUGH_WIDTH (glyph_height);
           unsigned long dy = (glyph_height - h) / 2;
 
           if (s->face->strike_through_color_defaulted_p)
diff --git a/src/xterm.c b/src/xterm.c
index 2e0407aff4..b17afdf225 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -3931,7 +3931,7 @@ x_draw_glyph_string (struct glyph_string *s)
 	  int glyph_height = s->first_glyph->ascent + s->first_glyph->descent;
 	  /* Strike-through width and offset from the glyph string's
 	     top edge.  */
-          unsigned long h = 1;
+	  unsigned long h = STRIKE_THROUGH_WIDTH (glyph_height);
           unsigned long dy = (glyph_height - h) / 2;
 
 	  if (s->face->strike_through_color_defaulted_p)
-- 
2.28.0