Subject: bug#65803: 29.1; Noto Sans Mono CJK JP has doubled-width on Windows

From: Eli Zaretskii <[email-masked]>
Date: Fri, 08 Sep 2023 15:18:32 +0300

> From: Shingo Tanaka <[email-masked]>
> Date: Fri, 8 Sep 2023 07:26:18 +0900
> Cc: [email-masked]
> 
> > Please also tell what does (frame-char-width) return with each of the
> > two fonts on Windows.
> 
> Here are the results including the one on Ubuntu.
> Obviously, the 2nd one (Noto on Windows) returns a doubled-width size
> which is unexpected.
> 
> ;; On Windows - No issue
> (progn
>   (set-face-attribute 'default nil :font "ＭＳ ゴシック")
>   (frame-char-width))
> 10
> (string-pixel-width "A")
> 10
> (string-pixel-width "あ")
> 20
> 
> ;; On Windows - Wrong frame-char-width
> (progn
>   (set-face-attribute 'default nil :font "Noto Sans Mono CJK JP")
>   (frame-char-width))
> 20
> (string-pixel-width "A")
> 10
> (string-pixel-width "あ")
> 20
> 
> ;; On Ubuntu (w/Cairo) - No issue
> (progn
>   (set-face-attribute 'default nil :font "Noto Sans Mono CJK JP")
>   (frame-char-width))
> 13
> (string-pixel-width "A")
> 13
> (string-pixel-width "あ")
> 26

This is strange.  AFAIU, frame-char-width returns the "average width"
attribute of the font, so why do we get different results on Windows
and on X?  Po Lu, can you help?  Do font backends on X perform some
trickery on the font's average_width attribute that we don't do on
Windows?

> > Is your Ubuntu build with Cairo, btw?
> 
> Yes, the Emacs on Ubuntu is the latest Snap version which is compiled
> with Cairo, as I can double check it by seeing colored Emoji.