|
From: | Dmitry Gutov |
Subject: | bug#64420: string-width of … is 2 in CJK environments |
Date: | Tue, 11 Jul 2023 05:23:03 +0300 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 |
On 02/07/2023 16:43, Eli Zaretskii wrote:
Since the overlay-based popup is used on both GUI and Terminal frames, are you suggesting I define my own string-width like this? (defun company--string-width (str) (if (display-graphic-p) (ceiling (/ (string-pixel-width str) (float (default-font-width)))) (string-width str)))Yes, definitely. (Actually, display-multi-font-p is better than display-graphic-p, but in practice they will return the same value.)
Regarding this approach, though: it seems to fail in my terminal Emacs.Meaning, when I'm testing the feature using 'emacs -nw' (inside e.g. gnome-terminal), both (string-pixel-width "…") and (string-width "…") return 2. Whereas the character on display looks 1-character wide even there.
More than that, moving the cursor close to that character with C-f or C-b creates odd effects like the cursor jumping one position to the left, or a char being rendered twice at a certain position on the same line to the right of it (after I move the cursor there past the … char), in my case it's an opening paren. Nothing like that happens on the lines without this char, or after I switch the language env back to "English".
That happens in Emacs 29.
[Prev in Thread] | Current Thread | [Next in Thread] |