Re: [PATCH] emacs: fix author field width with double-width chars

Subject: Re: [PATCH] emacs: fix author field width with double-width chars

Date: Sun, 13 Jul 2025 15:33:34 +0800

To: David Bremner

Cc: notmuch@notmuchmail.org

From: 赵一开


Hi,

Sorry for the late reply

I see the root cause is that your chinese character's width is still
not exactly 2x of the ASCII char's. But I'm now not sure how to really
fix that, except maybe trying some other combinations. Maybe it
depends on the system settings or something. If we count the
characters, we can see that the result is correct.

Anyway, as I mentioned, the current implementation does require the
user to choose perfectly monospaced fonts in order to make the
alignment works. For those who do, the current patch should fix the
alignment; for those who don't, the alignment issue should be
everywhere anyway (e.g. markdown tables etc.). We need a different
approach to support the latter case.


On Thu, Jul 3, 2025 at 6:04 PM David Bremner <david@tethera.net> wrote:
>
> 赵一开 <yikai@z1k.dev> writes:
>
> >
> > You've come across the most common issue that every new CJK user
> > struggles with :)
> >
> > The issue in your screenshot is that the CJK font together with the
> > ASCII font is not monospaced.
> > You should try using Noto CJK Mono as the default font in emacs (apply
> > to both CJK characters and ASCII characters), with e.g.
> > (set-face-attribute 'default nil :family "Noto Sans Mono CJK KR").
> > Sorry I wasn't specific enough for this earlier.
> >
>
> Thanks for your patience. I tried this (in emacs -Q) and I agree it is
> better, but it still seems not quite right to me (screenshots at end).
>
> I attach a second screenshot in whitespace mode.
>
> > Since CJK characters are wider than ASCII characters and defined as
> > "double-width" in unicode, although CJK chars themselves are always
> > monospaced, they should be exactly 2x the width of the ASCII chars to
> > make the whole buffer properly aligned. However, sometimes CJK chars
> > and ASCII chars are provided by different fonts, so the user is
> > responsible to make sure of that. The easy way is to use one single
> > monospaced font for all chars (e.g. "Noto Sans Mono CJK" mentioned
> > above), or alternatively there are certain known compatible font
> > pairs, for example, IIRC "Fira Code" and "Source Code Pro" works well
> > with "Noto Sans CJK".
> >
>
> FWIW my initial screenshots used Fira Code.
>
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: