unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Adam Ibrahim <ibrahimadam193@gmail.com>
Cc: 63544@debbugs.gnu.org
Subject: bug#63544: 28.3; extra width not renderes correctly in TUI when making a character wider
Date: Wed, 17 May 2023 16:25:17 +0300	[thread overview]
Message-ID: <83ednfxf7m.fsf@gnu.org> (raw)
In-Reply-To: <CAHdC_i+USpAEQPF9LG63JiqWK9iWs0pW=XsW3aBZW76ZnbYNvA@mail.gmail.com> (message from Adam Ibrahim on Tue, 16 May 2023 15:34:38 -0400)

tags 63544 notabug
thanks

> From: Adam Ibrahim <ibrahimadam193@gmail.com>
> Date: Tue, 16 May 2023 15:34:38 -0400
> 
> When I make a character wider by changing the char width table, it isn't
> sometimes with shows and sometimes it doesn't.
> 
> 1. Start up emacs with this command.
> 
> emacs -Q --eval '(progn (set-char-table-range char-width-table #x221e 2) (set-char-table-range
> char-width-table #x2014 2))'
> 
> 2. Type "—a" into the scratch buffer. The em dash should be correctly rendered two cells wide, and the
> a shouldn't overlap with the em dash.
> 3. `M-x redraw-screen`. The em dash should now overlap the a.

(I guess you mean "M-x redraw-display".  There's no redraw-screen
command in Emacs.)

I'm guessing you did the above in order to cause the em-dash character
display as two character cells instead of just one.  But that will
only work if, when the em-dash character is written to the terminal,
its glyph indeed takes two character cells, and the terminal tells the
driver that the "virtual write cursor" was moved by two character
cells.  Emacs expects double-width characters to produce that effect,
and evidently in your case this character doesn't.

The upshot is that we cannot support artificially "widening"
characters which don't behave like double-width characters from the
POV of the terminal emulator.  Just using a font where the character's
glyph is wide is not enough; you need the terminal emulator to
understand that this is the case with these characters, and behave
accordingly.

The above "sometimes works" because Emacs doesn't always write the
entire screen line of the characters.  It tries very hard to minimize
the writes to the glass.  So when you type the initial '—' character,
Emacs writes only it, and then moves the display cursor to where it
thinks it should be -- which is column 2 (zero-based).  Then, when you
type 'a', Emacs inserts just the glyph for 'a', it doesn't redraw the
first '—' character.

By contrast, when you invoke redraw-display, Emacs redraws the entire
line, expecting the 'a' character to be written by the terminal
emulator starting at column 2, not column 1.  It expects the terminal
emulator to make sure this is what happens when Emacs writes the
string "—a" to the terminal.  But in your case, it doesn't: the 'a'
character starts at column 1, so it overlaps with '—'.

IOW, Emacs assumes that writing a single character '—' occupies 2
columns no matter whether there are or aren't characters after '—'.
And that requires the terminal emulator to play along, when you use
Iosevka (and other similar fonts).

This is not a bug.  I don't see how Emacs could do anything here to
fix the terminal emulator, without causing serious degradation in
redisplay performance.

Sorry.





  reply	other threads:[~2023-05-17 13:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-16 19:34 bug#63544: 28.3; extra width not renderes correctly in TUI when making a character wider Adam Ibrahim
2023-05-17 13:25 ` Eli Zaretskii [this message]
2023-09-03 10:35   ` Stefan Kangas

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=83ednfxf7m.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=63544@debbugs.gnu.org \
    --cc=ibrahimadam193@gmail.com \
    /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).