unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Kangas <stefan@marxist.se>
To: Robert Samal <samal@iuuk.mff.cuni.cz>
Cc: 33648@debbugs.gnu.org
Subject: bug#33648: 25.2; feature request: configurable position of strike-through line
Date: Mon, 31 Aug 2020 11:21:09 +0000	[thread overview]
Message-ID: <CADwFkmk6+O0yxeGoo5AJmT5FJ6=F3EtuZz_rngxn0ZkTpKmrKw@mail.gmail.com> (raw)
In-Reply-To: <2738781e-9dc8-01d1-1b88-13e9a684b53e@iuuk.mff.cuni.cz> (Robert Samal's message of "Thu, 6 Dec 2018 09:20:21 +0100")

[-- Attachment #1: Type: text/plain, Size: 1155 bytes --]

tags 33648 + confirmed
thanks

Robert Samal <samal@iuuk.mff.cuni.cz> writes:

> When I use set-face-attribute to give some text a strike-through
> attribute, I see that emacs behaves differently from other pieces of
> software: Apparently, the line is drawn at the level of half the glyph's
> height -- which causes the line to be just touching letters like "a",
> "c", "e", ... and it isn't perceived as striking the text out (at least
> not by me).
>
> In comparison, web browsers interpreting html strike tag make the
> line at the level of half of the "small lowercase letters" -- basically
> at the level of the line in lowercase "e". The same is done by Libre
> Office ... and others.
>
> My suggestion is to make this configurable in some way. I'm not sure,
> if it would be better to have a global option for all files, or
> if "(set-face-attribute ... :strike-through" should accept more choices
> to make each line configurable. (I personally would change all of my
> striking lines, if possible.)
>
> Thanks in advance for considering this, for some uses (in particular
> org-mode) this would help a lot.

This is what I see on current master:

[-- Attachment #2: Type: text/plain, Size: 49 bytes --]


This is the same text rendered in LibreOffice:


[-- Attachment #3: bug-33648-emacs-orig.png --]
[-- Type: image/png, Size: 3871 bytes --]

[-- Attachment #4: bug-33648-libreoffice.png --]
[-- Type: image/png, Size: 4903 bytes --]

[-- Attachment #5: Type: text/plain, Size: 637 bytes --]


I see two problems here:

1. The strike-through in our case is placed at half the height of an
   upper-case glyph.  LibreOffice seems to have a smarter positioning.

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'm have no idea how to fix it; the font code is pretty opaque to me.

I mucked around a bit and came up with the below diff.  It is probably
not the correct fix, but does make it slightly better for me.  Someone
who understands this better would need to investigate this properly.

FWIW, here is what it looks like with the below patch:


[-- Attachment #6: bug-33648-with-patch.png --]
[-- Type: image/png, Size: 2288 bytes --]

[-- Attachment #7: Type: text/plain, Size: 513 bytes --]


diff --git a/src/xterm.c b/src/xterm.c
index 2e0407aff4..5792574e05 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -3932,7 +3932,7 @@ x_draw_glyph_string (struct glyph_string *s)
 	  /* Strike-through width and offset from the glyph string's
 	     top edge.  */
           unsigned long h = 1;
-          unsigned long dy = (glyph_height - h) / 2;
+          unsigned long dy = (glyph_height - h) / 3;
 
 	  if (s->face->strike_through_color_defaulted_p)
 	    x_fill_rectangle (s->f, s->gc, s->x, glyph_y + dy,

  reply	other threads:[~2020-08-31 11:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-06  8:20 bug#33648: 25.2; feature request: configurable position of strike-through line Robert Samal
2020-08-31 11:21 ` Stefan Kangas [this message]
2020-08-31 11:35   ` Stefan Kangas
2020-08-31 14:39     ` Eli Zaretskii
2020-08-31 14:40     ` Eli Zaretskii
2020-08-31 14:37   ` Eli Zaretskii
2020-08-31 17:42   ` Stefan Kangas
2020-08-31 18:43     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADwFkmk6+O0yxeGoo5AJmT5FJ6=F3EtuZz_rngxn0ZkTpKmrKw@mail.gmail.com' \
    --to=stefan@marxist.se \
    --cc=33648@debbugs.gnu.org \
    --cc=samal@iuuk.mff.cuni.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).