Subject: bug#44664: 28.0.50; troubles with some chars in term

From: Eli Zaretskii <[email-masked]>
Date: Thu, 19 Nov 2020 16:26:58 +0200

> Date: Wed, 18 Nov 2020 23:06:30 +0300
> From: Jean Louis <[email-masked]>
> Cc: [email-masked], [email-masked], [email-masked]
> 
> I have been searching to find references:
> 
> https://github.com/jquast/wcwidth
> 
> https://github.com/streamlink/streamlink/pull/2032

This is not relevant, Emacs has this data as well.  But since you are
running a GUI session, the width of characters is not what's
important; what's important is the width of the font glyphs that Emacs
uses to display the non-ASCII characters in the term buffer.

> But I can also see many problems without any wide characters. 
> 
> I am also observing various switches of fonts. I have tried setting
> Terminus font and then I see that when I run mutt that the font
> changes to something else. After $ reset, it seem to have half
> Terminus and prompts to be DejaVu Sans, then after several killing of
> terminal buffer and restarts it started appearing everything to be
> using Terminus font.

First, start by trying this in "emacs -Q", to make sure it isn't due
to some customizations of yours.  Then, to see what fonts are used for
the "unusual" characters, use

  M-: (font-at POS) RET

where POS is the buffer position of the offending character.
Alternatively, go to the character and type "C-u C-x =", it will pop
up a buffer with a lot of information including the font.

My guess is that Emacs uses a font other than the default for those
problematic characters.

> There are 2 screenshots attached:
> 
> 1. One is Emacs M-x term there is line, above the line (53) and one
>    can see it being pulled to the left side
> 
> 2. XTerm version shows it is displayed aligned to the column.

There's no magic here.  Xterm uses the same -misc-fixed-medium font
that Emacs does, at least by default.  It is possible that you or
someone else (the distribution managers?) provided X resources for
xterm that configure it in some optimal way by specifying fixed-pitch
fonts for some non-ASCII scripts, so I would suggest to look at
.Xdefaults and other sources of X resources and customizations; you
could then use that information in Emacs, because Emacs supports
similar font customization features.

You could also try running term.el in a -nw session inside the same
xterm, to see if there is a difference -- in that case, Emacs doesn't
control the fonts at all.

> I have:
> 
> alias ls='ls --color=auto'
> 
> and each time I invoke ls I can see that font also changed for the
> rest of work. If I invoke $ reset and then /bin/ls then I remain in
> the same font.

Again, what are the two fonts used in this screenshot?  Use the
above-mentioned techniques to tell, and use "emacs -Q" to eliminate
the possibility that it's due to your customizations.

Also, do you have the LS_COLORS environment variable set, and if so,
what is its value?