emacs-31 d31d3245ba4: Fix display of ambiguous-width CJK characters in GUI sessions

Eli Zaretskii <[email protected]> Sat, 1 Aug 2026 06:02:35 -0400 (EDT)
Newsgroups gmane.emacs.diffs
Message-ID <[email protected]>
branch: emacs-31
commit d31d3245ba44c852356cb28e4dcc395df5ab0e3e
Author: Eli Zaretskii <[email protected]>
Commit: Eli Zaretskii <[email protected]>

    Fix display of ambiguous-width CJK characters in GUI sessions
    
    * lisp/international/characters.el (use-cjk-char-width-table): Fix
    to work correctly in GUI sessions on Windows.  (Bug#81489)
---
 lisp/international/characters.el | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lisp/international/characters.el b/lisp/international/characters.el
index b29b0f8d094..a880577064b 100644
--- a/lisp/international/characters.el
+++ b/lisp/international/characters.el
@@ -1715,8 +1715,15 @@ the value of the variable with `setq'."
               (ambiguous-is-wide
                (and cjk-ambiguous-chars-are-wide
                     ;; MS-Windows Terminal forces all ambiguous
-                    ;; characters to be narrow, even in CJK locales.
-                    (not (and (boundp 'w32--terminal-is-conhost)
+                    ;; characters to be narrow, even in CJK locales,
+                    ;; assuming the fonts it uses were left at their
+                    ;; defaults.
+                    (not (and (eq system-type 'windows-nt)
+                              ;; 'window-system' might be nil when this
+                              ;; code is called from startup.el, as part
+                              ;; of 'set-locale-environment', so we must
+                              ;; test 'initial-window-system' instead.
+                              (null initial-window-system)
                               (null w32--terminal-is-conhost))))))
           (map-char-table
            (lambda (range _val)