* bug#10867: 23.4 must export LC_CTYPE to zh_CN.UTF-8 or similar CJK locale to use X input method @ 2012-02-22 11:41 Weng Xuetian 2020-08-02 19:03 ` bug#10867: 26.3; XIM preedit/status font handling Yichao Yu 0 siblings, 1 reply; 9+ messages in thread From: Weng Xuetian @ 2012-02-22 11:41 UTC (permalink / raw) To: 10867 This bug has existing for a long time. Ever since serveral years ago. I'm not talking about built in input method, but XIM, which can be provided by fcitx, gcin, scim, or ibus. Since this bug existing for a long time, I think that'some of the reason that scim and ibus provides scim-el and ibus-el to make emacs works with input method under non-CJK locale. There is no limitation for XIM to work with non-CJK locale, since xterm, or something similar already can works well. Or emacs should change the input method support code to gtk input context. Reproduce step: 1. set locale to en_US.UTF-8, start emacs, X input method do not work. 2. set locale to zh_CN.UTF-8, start emacs, X input method now works. ^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#10867: 26.3; XIM preedit/status font handling 2012-02-22 11:41 bug#10867: 23.4 must export LC_CTYPE to zh_CN.UTF-8 or similar CJK locale to use X input method Weng Xuetian @ 2020-08-02 19:03 ` Yichao Yu 2020-08-02 20:07 ` Yichao Yu 0 siblings, 1 reply; 9+ messages in thread From: Yichao Yu @ 2020-08-02 19:03 UTC (permalink / raw) To: 10867; +Cc: Xuetian Weng This is a really old bug but it is finally clear recently what is causing it. ## Background and observed issues. 1. Since at least 8 years ago when this bug was first reported, it was observed that sometimes emacs cannot use XIM unless set to a CJK locale, e.g. zh_CN.UTF-8. This is not always necessary, and might not always work and it was also unclear what caused it since nothing seems to have hard coded anything locale dependent in either emacs or xlib and other programs using xim also seems fine... 2. It was also know (probably more recent) that it is necessary to install certain font to get XIM work with emacs since otherwise some XIM related font lookup fails and disables XIM. ## Root cause It turns out that the two issues are closely related. The full story is roughly like this, 1. Emacs calls `xic_create_xfontset` in `create_frame_xic`. This function try to figure out a list of fonts based on some conditions. If no font is found at this state, it causes the second issue that requires installation of some fonts. 2. The return value of this is then passed in as the `fontSet` (XNFontSet) attribute for preedit and status within `create_frame_xic`. However, if there are too many font matches, it'll fail in the `XimType_XFontSet` case within `_XimValueToAttribute` since it can overflow the 2048 byte buffer that xlib uses. (the buffer size available when it decodes the XFontSet measured locally is ~ 1k). This also causes the input method initialization to fail and this is the cause of the first issue. The effect of setting the locale is actually simply on the number of font matches. Most users seem to have more fonts matching an english locale than a CJK one which is why setting to a CJK locale avoids the overflow. For users that have fewer/different (english) fonts installed there could also be fewer matches allowing XIM to work. ## What other programs do * xterm seems to use "fixed" to lookup font * qt4 https://dreamswork.github.io/qt4/qximinputcontext__x11_8cpp_source.html AFAICT uses different fonts? * gtk I don't actually see where it set fonts... @Xuetian Weng dug deeper into this ## Fix I'm not sure what's the correct one. It seems that setting the fontSet is necessary although I'm not sure how/if gtk get away with it. According to @Xuetian Weng virtually no one use this setting anymore so setting a dummy value to comfort xlib might be good enough? It would avoid both issues at the same time. ------------------- In GNU Emacs 26.3 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.21) of 2020-07-29 built on yyc.yyc-arch.org Repository revision: d9eea1ad1bca16406a6d4c9bd0daa57a9d0a531f System Description: Arch Linux Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. Making completion list... Configured using: 'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib --localstatedir=/var --with-x-toolkit=gtk3 --with-xft --with-wide-int --with-modules 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -g -fvar-tracking-assignments -fdebug-prefix-map=/home/yuyichao/projects/arch-pkg/pkg/tmp/emacs/repos/extra-x86_64/src=/usr/src/debug -ggdb3 -O0 -DDEBUG_XIC_FONTSET=1' CPPFLAGS=-D_FORTIFY_SOURCE=2 LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now' Configured features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS GLIB NOTIFY ACL GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS LIBSYSTEMD LCMS2 Important settings: value of $LANG: zh_CN.UTF-8 value of $XMODIFIERS: @im=fcitx locale-coding-system: utf-8-unix Major mode: Fundamental Minor modes in effect: tooltip-mode: t global-eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t buffer-read-only: t line-number-mode: t transient-mark-mode: t Load-path shadows: /usr/share/emacs/site-lisp/org/ox hides /usr/share/emacs/26.3/lisp/org/ox /usr/share/emacs/site-lisp/org/ox-texinfo hides /usr/share/emacs/26.3/lisp/org/ox-texinfo /usr/share/emacs/site-lisp/org/ox-publish hides /usr/share/emacs/26.3/lisp/org/ox-publish /usr/share/emacs/site-lisp/org/ox-org hides /usr/share/emacs/26.3/lisp/org/ox-org /usr/share/emacs/site-lisp/org/ox-odt hides /usr/share/emacs/26.3/lisp/org/ox-odt /usr/share/emacs/site-lisp/org/ox-md hides /usr/share/emacs/26.3/lisp/org/ox-md /usr/share/emacs/site-lisp/org/ox-man hides /usr/share/emacs/26.3/lisp/org/ox-man /usr/share/emacs/site-lisp/org/ox-latex hides /usr/share/emacs/26.3/lisp/org/ox-latex /usr/share/emacs/site-lisp/org/ox-icalendar hides /usr/share/emacs/26.3/lisp/org/ox-icalendar /usr/share/emacs/site-lisp/org/ox-html hides /usr/share/emacs/26.3/lisp/org/ox-html /usr/share/emacs/site-lisp/org/ox-beamer hides /usr/share/emacs/26.3/lisp/org/ox-beamer /usr/share/emacs/site-lisp/org/ox-ascii hides /usr/share/emacs/26.3/lisp/org/ox-ascii /usr/share/emacs/site-lisp/org/org hides /usr/share/emacs/26.3/lisp/org/org /usr/share/emacs/site-lisp/org/org-version hides /usr/share/emacs/26.3/lisp/org/org-version /usr/share/emacs/site-lisp/org/org-timer hides /usr/share/emacs/26.3/lisp/org/org-timer /usr/share/emacs/site-lisp/org/org-table hides /usr/share/emacs/26.3/lisp/org/org-table /usr/share/emacs/site-lisp/org/org-src hides /usr/share/emacs/26.3/lisp/org/org-src /usr/share/emacs/site-lisp/org/org-protocol hides /usr/share/emacs/26.3/lisp/org/org-protocol /usr/share/emacs/site-lisp/org/org-plot hides /usr/share/emacs/26.3/lisp/org/org-plot /usr/share/emacs/site-lisp/org/org-pcomplete hides /usr/share/emacs/26.3/lisp/org/org-pcomplete /usr/share/emacs/site-lisp/org/org-mouse hides /usr/share/emacs/26.3/lisp/org/org-mouse /usr/share/emacs/site-lisp/org/org-mobile hides /usr/share/emacs/26.3/lisp/org/org-mobile /usr/share/emacs/site-lisp/org/org-macs hides /usr/share/emacs/26.3/lisp/org/org-macs /usr/share/emacs/site-lisp/org/org-macro hides /usr/share/emacs/26.3/lisp/org/org-macro /usr/share/emacs/site-lisp/org/org-loaddefs hides /usr/share/emacs/26.3/lisp/org/org-loaddefs /usr/share/emacs/site-lisp/org/org-list hides /usr/share/emacs/26.3/lisp/org/org-list /usr/share/emacs/site-lisp/org/org-lint hides /usr/share/emacs/26.3/lisp/org/org-lint /usr/share/emacs/site-lisp/org/org-install hides /usr/share/emacs/26.3/lisp/org/org-install /usr/share/emacs/site-lisp/org/org-inlinetask hides /usr/share/emacs/26.3/lisp/org/org-inlinetask /usr/share/emacs/site-lisp/org/org-indent hides /usr/share/emacs/26.3/lisp/org/org-indent /usr/share/emacs/site-lisp/org/org-id hides /usr/share/emacs/26.3/lisp/org/org-id /usr/share/emacs/site-lisp/org/org-habit hides /usr/share/emacs/26.3/lisp/org/org-habit /usr/share/emacs/site-lisp/org/org-footnote hides /usr/share/emacs/26.3/lisp/org/org-footnote /usr/share/emacs/site-lisp/org/org-feed hides /usr/share/emacs/26.3/lisp/org/org-feed /usr/share/emacs/site-lisp/org/org-faces hides /usr/share/emacs/26.3/lisp/org/org-faces /usr/share/emacs/site-lisp/org/org-entities hides /usr/share/emacs/26.3/lisp/org/org-entities /usr/share/emacs/site-lisp/org/org-element hides /usr/share/emacs/26.3/lisp/org/org-element /usr/share/emacs/site-lisp/org/org-duration hides /usr/share/emacs/26.3/lisp/org/org-duration /usr/share/emacs/site-lisp/org/org-datetree hides /usr/share/emacs/26.3/lisp/org/org-datetree /usr/share/emacs/site-lisp/org/org-ctags hides /usr/share/emacs/26.3/lisp/org/org-ctags /usr/share/emacs/site-lisp/org/org-crypt hides /usr/share/emacs/26.3/lisp/org/org-crypt /usr/share/emacs/site-lisp/org/org-compat hides /usr/share/emacs/26.3/lisp/org/org-compat /usr/share/emacs/site-lisp/org/org-colview hides /usr/share/emacs/26.3/lisp/org/org-colview /usr/share/emacs/site-lisp/org/org-clock hides /usr/share/emacs/26.3/lisp/org/org-clock /usr/share/emacs/site-lisp/org/org-capture hides /usr/share/emacs/26.3/lisp/org/org-capture /usr/share/emacs/site-lisp/org/org-attach hides /usr/share/emacs/26.3/lisp/org/org-attach /usr/share/emacs/site-lisp/org/org-archive hides /usr/share/emacs/26.3/lisp/org/org-archive /usr/share/emacs/site-lisp/org/org-agenda hides /usr/share/emacs/26.3/lisp/org/org-agenda /usr/share/emacs/site-lisp/org/ob hides /usr/share/emacs/26.3/lisp/org/ob /usr/share/emacs/site-lisp/org/ob-vala hides /usr/share/emacs/26.3/lisp/org/ob-vala /usr/share/emacs/site-lisp/org/ob-tangle hides /usr/share/emacs/26.3/lisp/org/ob-tangle /usr/share/emacs/site-lisp/org/ob-table hides /usr/share/emacs/26.3/lisp/org/ob-table /usr/share/emacs/site-lisp/org/ob-stan hides /usr/share/emacs/26.3/lisp/org/ob-stan /usr/share/emacs/site-lisp/org/ob-sqlite hides /usr/share/emacs/26.3/lisp/org/ob-sqlite /usr/share/emacs/site-lisp/org/ob-sql hides /usr/share/emacs/26.3/lisp/org/ob-sql /usr/share/emacs/site-lisp/org/ob-shen hides /usr/share/emacs/26.3/lisp/org/ob-shen /usr/share/emacs/site-lisp/org/ob-shell hides /usr/share/emacs/26.3/lisp/org/ob-shell /usr/share/emacs/site-lisp/org/ob-sed hides /usr/share/emacs/26.3/lisp/org/ob-sed /usr/share/emacs/site-lisp/org/ob-screen hides /usr/share/emacs/26.3/lisp/org/ob-screen /usr/share/emacs/site-lisp/org/ob-scheme hides /usr/share/emacs/26.3/lisp/org/ob-scheme /usr/share/emacs/site-lisp/org/ob-sass hides /usr/share/emacs/26.3/lisp/org/ob-sass /usr/share/emacs/site-lisp/org/ob-ruby hides /usr/share/emacs/26.3/lisp/org/ob-ruby /usr/share/emacs/site-lisp/org/ob-ref hides /usr/share/emacs/26.3/lisp/org/ob-ref /usr/share/emacs/site-lisp/org/ob-python hides /usr/share/emacs/26.3/lisp/org/ob-python /usr/share/emacs/site-lisp/org/ob-processing hides /usr/share/emacs/26.3/lisp/org/ob-processing /usr/share/emacs/site-lisp/org/ob-plantuml hides /usr/share/emacs/26.3/lisp/org/ob-plantuml /usr/share/emacs/site-lisp/org/ob-picolisp hides /usr/share/emacs/26.3/lisp/org/ob-picolisp /usr/share/emacs/site-lisp/org/ob-perl hides /usr/share/emacs/26.3/lisp/org/ob-perl /usr/share/emacs/site-lisp/org/ob-org hides /usr/share/emacs/26.3/lisp/org/ob-org /usr/share/emacs/site-lisp/org/ob-octave hides /usr/share/emacs/26.3/lisp/org/ob-octave /usr/share/emacs/site-lisp/org/ob-ocaml hides /usr/share/emacs/26.3/lisp/org/ob-ocaml /usr/share/emacs/site-lisp/org/ob-mscgen hides /usr/share/emacs/26.3/lisp/org/ob-mscgen /usr/share/emacs/site-lisp/org/ob-maxima hides /usr/share/emacs/26.3/lisp/org/ob-maxima /usr/share/emacs/site-lisp/org/ob-matlab hides /usr/share/emacs/26.3/lisp/org/ob-matlab /usr/share/emacs/site-lisp/org/ob-makefile hides /usr/share/emacs/26.3/lisp/org/ob-makefile /usr/share/emacs/site-lisp/org/ob-lua hides /usr/share/emacs/26.3/lisp/org/ob-lua /usr/share/emacs/site-lisp/org/ob-lob hides /usr/share/emacs/26.3/lisp/org/ob-lob /usr/share/emacs/site-lisp/org/ob-lisp hides /usr/share/emacs/26.3/lisp/org/ob-lisp /usr/share/emacs/site-lisp/org/ob-lilypond hides /usr/share/emacs/26.3/lisp/org/ob-lilypond /usr/share/emacs/site-lisp/org/ob-ledger hides /usr/share/emacs/26.3/lisp/org/ob-ledger /usr/share/emacs/site-lisp/org/ob-latex hides /usr/share/emacs/26.3/lisp/org/ob-latex /usr/share/emacs/site-lisp/org/ob-js hides /usr/share/emacs/26.3/lisp/org/ob-js /usr/share/emacs/site-lisp/org/ob-java hides /usr/share/emacs/26.3/lisp/org/ob-java /usr/share/emacs/site-lisp/org/ob-io hides /usr/share/emacs/26.3/lisp/org/ob-io /usr/share/emacs/site-lisp/org/ob-hledger hides /usr/share/emacs/26.3/lisp/org/ob-hledger /usr/share/emacs/site-lisp/org/ob-haskell hides /usr/share/emacs/26.3/lisp/org/ob-haskell /usr/share/emacs/site-lisp/org/ob-groovy hides /usr/share/emacs/26.3/lisp/org/ob-groovy /usr/share/emacs/site-lisp/org/ob-gnuplot hides /usr/share/emacs/26.3/lisp/org/ob-gnuplot /usr/share/emacs/site-lisp/org/ob-fortran hides /usr/share/emacs/26.3/lisp/org/ob-fortran /usr/share/emacs/site-lisp/org/ob-forth hides /usr/share/emacs/26.3/lisp/org/ob-forth /usr/share/emacs/site-lisp/org/ob-exp hides /usr/share/emacs/26.3/lisp/org/ob-exp /usr/share/emacs/site-lisp/org/ob-eval hides /usr/share/emacs/26.3/lisp/org/ob-eval /usr/share/emacs/site-lisp/org/ob-emacs-lisp hides /usr/share/emacs/26.3/lisp/org/ob-emacs-lisp /usr/share/emacs/site-lisp/org/ob-ebnf hides /usr/share/emacs/26.3/lisp/org/ob-ebnf /usr/share/emacs/site-lisp/org/ob-dot hides /usr/share/emacs/26.3/lisp/org/ob-dot /usr/share/emacs/site-lisp/org/ob-ditaa hides /usr/share/emacs/26.3/lisp/org/ob-ditaa /usr/share/emacs/site-lisp/org/ob-css hides /usr/share/emacs/26.3/lisp/org/ob-css /usr/share/emacs/site-lisp/org/ob-core hides /usr/share/emacs/26.3/lisp/org/ob-core /usr/share/emacs/site-lisp/org/ob-coq hides /usr/share/emacs/26.3/lisp/org/ob-coq /usr/share/emacs/site-lisp/org/ob-comint hides /usr/share/emacs/26.3/lisp/org/ob-comint /usr/share/emacs/site-lisp/org/ob-clojure hides /usr/share/emacs/26.3/lisp/org/ob-clojure /usr/share/emacs/site-lisp/org/ob-calc hides /usr/share/emacs/26.3/lisp/org/ob-calc /usr/share/emacs/site-lisp/org/ob-awk hides /usr/share/emacs/26.3/lisp/org/ob-awk /usr/share/emacs/site-lisp/org/ob-asymptote hides /usr/share/emacs/26.3/lisp/org/ob-asymptote /usr/share/emacs/site-lisp/org/ob-abc hides /usr/share/emacs/26.3/lisp/org/ob-abc /usr/share/emacs/site-lisp/org/ob-R hides /usr/share/emacs/26.3/lisp/org/ob-R /usr/share/emacs/site-lisp/org/ob-J hides /usr/share/emacs/26.3/lisp/org/ob-J /usr/share/emacs/site-lisp/org/ob-C hides /usr/share/emacs/26.3/lisp/org/ob-C Features: (shadow sort mail-extr emacsbug message rmc puny seq byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib dired dired-loaddefs format-spec rfc822 mml easymenu mml-sec password-cache epa derived epg epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils term/xterm xterm time-date elec-pair mule-util china-util tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote threads dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 100413 6755) (symbols 48 20515 1) (miscs 40 73 105) (strings 32 28736 1427) (string-bytes 1 750294) (vectors 16 13057) (vector-slots 8 514213 20152) (floats 8 54 437) (intervals 56 232 0) (buffers 992 13)) ^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#10867: 26.3; XIM preedit/status font handling 2020-08-02 19:03 ` bug#10867: 26.3; XIM preedit/status font handling Yichao Yu @ 2020-08-02 20:07 ` Yichao Yu 2020-08-08 8:00 ` Eli Zaretskii 0 siblings, 1 reply; 9+ messages in thread From: Yichao Yu @ 2020-08-02 20:07 UTC (permalink / raw) To: 10867; +Cc: Xuetian Weng > ## What other programs do > * xterm seems to use "fixed" to lookup font > * qt4 https://dreamswork.github.io/qt4/qximinputcontext__x11_8cpp_source.html > AFAICT uses different fonts? > * gtk I don't actually see where it set fonts... > @Xuetian Weng dug deeper into this > > ## Fix > I'm not sure what's the correct one. It seems that setting the fontSet > is necessary although I'm not sure how/if gtk get away with it. > According to @Xuetian Weng virtually no one use this setting anymore > so setting a dummy value to comfort xlib might be good enough? It > would avoid both issues at the same time. And since it's basically a useless setting at this point, this fix seems to work diff --git a/src/xfns.c b/src/xfns.c index 2ab5080d97..fbbc429fe1 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -2511,72 +2511,19 @@ xic_create_xfontset (struct frame *f) if (! xfs) { - char buf[256]; char **missing_list; int missing_count; char *def_string; - const char *xlfd_format = "-*-*-medium-r-normal--%d-*-*-*-*-*"; + const char *last_resort = "fixed"; - sprintf (buf, xlfd_format, pixel_size); missing_list = NULL; - xfs = XCreateFontSet (FRAME_X_DISPLAY (f), buf, + xfs = XCreateFontSet (FRAME_X_DISPLAY (f), last_resort, &missing_list, &missing_count, &def_string); #ifdef DEBUG_XIC_FONTSET - print_fontset_result (xfs, buf, missing_list, missing_count); + print_fontset_result (xfs, last_resort, missing_list, missing_count); #endif if (missing_list) - XFreeStringList (missing_list); - if (! xfs) - { - /* List of pixel sizes most likely available. Find one that - is closest to pixel_size. */ - int sizes[] = {0, 8, 10, 11, 12, 14, 17, 18, 20, 24, 26, 34, 0}; - int *smaller, *larger; - - for (smaller = sizes; smaller[1]; smaller++) - if (smaller[1] >= pixel_size) - break; - larger = smaller + 1; - if (*larger == pixel_size) - larger++; - while (*smaller || *larger) - { - int this_size; - - if (! *larger) - this_size = *smaller--; - else if (! *smaller) - this_size = *larger++; - else if (pixel_size - *smaller < *larger - pixel_size) - this_size = *smaller--; - else - this_size = *larger++; - sprintf (buf, xlfd_format, this_size); - missing_list = NULL; - xfs = XCreateFontSet (FRAME_X_DISPLAY (f), buf, - &missing_list, &missing_count, &def_string); -#ifdef DEBUG_XIC_FONTSET - print_fontset_result (xfs, buf, missing_list, missing_count); -#endif - if (missing_list) - XFreeStringList (missing_list); - if (xfs) - break; - } - } - if (! xfs) - { - const char *last_resort = "-*-*-*-r-normal--*-*-*-*-*-*"; - - missing_list = NULL; - xfs = XCreateFontSet (FRAME_X_DISPLAY (f), last_resort, - &missing_list, &missing_count, &def_string); -#ifdef DEBUG_XIC_FONTSET - print_fontset_result (xfs, last_resort, missing_list, missing_count); -#endif - if (missing_list) - XFreeStringList (missing_list); - } + XFreeStringList (missing_list); } ^ permalink raw reply related [flat|nested] 9+ messages in thread
* bug#10867: 26.3; XIM preedit/status font handling 2020-08-02 20:07 ` Yichao Yu @ 2020-08-08 8:00 ` Eli Zaretskii 2020-08-21 4:53 ` Yichao Yu 0 siblings, 1 reply; 9+ messages in thread From: Eli Zaretskii @ 2020-08-08 8:00 UTC (permalink / raw) To: Yichao Yu; +Cc: wengxt, 10867 > From: Yichao Yu <yyc1992@gmail.com> > Date: Sun, 2 Aug 2020 16:07:26 -0400 > Cc: Xuetian Weng <wengxt@gmail.com> > > > ## What other programs do > > * xterm seems to use "fixed" to lookup font > > * qt4 https://dreamswork.github.io/qt4/qximinputcontext__x11_8cpp_source.html > > AFAICT uses different fonts? > > * gtk I don't actually see where it set fonts... > > @Xuetian Weng dug deeper into this > > > > ## Fix > > I'm not sure what's the correct one. It seems that setting the fontSet > > is necessary although I'm not sure how/if gtk get away with it. > > According to @Xuetian Weng virtually no one use this setting anymore > > so setting a dummy value to comfort xlib might be good enough? It > > would avoid both issues at the same time. > > And since it's basically a useless setting at this point, this fix seems to work Thanks. Can someone with access to a system with this issue and sufficient knowledge of what's going on please review this patch? TIA ^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#10867: 26.3; XIM preedit/status font handling 2020-08-08 8:00 ` Eli Zaretskii @ 2020-08-21 4:53 ` Yichao Yu 2020-10-07 4:20 ` Lars Ingebrigtsen 0 siblings, 1 reply; 9+ messages in thread From: Yichao Yu @ 2020-08-21 4:53 UTC (permalink / raw) To: Eli Zaretskii; +Cc: Xuetian Weng, 10867 > Thanks. Can someone with access to a system with this issue and > sufficient knowledge of what's going on please review this patch? And some new findings and a more aggressive and robust fix. 1. It's fine to set status area and preedit position even without the corresponding xim style set. The input method will handle that just fine. In emacs, doing that for status area cause error due to uninitialized memory (`needed` is not initialized in `xic_set_statusarea` under such condition) so that one still needs to be done conditionally. 2. Without XIMPreeditPosition and XIMStatusArea, xlib will not require the fonts to be set and there's no issue with not finding font or finding too many fonts anymore. All in all, the following patch fixes all the issues cleanly. Note that this is exactly what gtk3 does (https://github.com/GNOME/gtk/blob/de04aaf82db8d694af7d42ab6bb2e26d3ef0c947/modules/input/gtkimcontextxim.c#L183), i.e. it does not accept either XIMPreeditPosition or XIMStatusArea. (It does accept callback but that is for "on-the-spot" style I believe and is not implemented in emacs anyway.) That's why I expect this to work with all modern input methods. The support for cursor following (xic_set_preeditarea) as well as the problematic approach involving the font was introduced in https://github.com/emacs-mirror/emacs/commit/5a7df7d75faa0f8921fd6a9591cdf6836d89941b 20.5 years ago. ``` diff --git a/src/xfns.c b/src/xfns.c index 78f977bf0a..ef4e2abfa5 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -2322,23 +2322,6 @@ hack_wm_protocols (struct frame *f, Widget widget) static XIMStyle best_xim_style (XIMStyles *); -/* Supported XIM styles, ordered by preference. */ - -static const XIMStyle supported_xim_styles[] = -{ - XIMPreeditPosition | XIMStatusArea, - XIMPreeditPosition | XIMStatusNothing, - XIMPreeditPosition | XIMStatusNone, - XIMPreeditNothing | XIMStatusArea, - XIMPreeditNothing | XIMStatusNothing, - XIMPreeditNothing | XIMStatusNone, - XIMPreeditNone | XIMStatusArea, - XIMPreeditNone | XIMStatusNothing, - XIMPreeditNone | XIMStatusNone, - 0, -}; - - #if defined HAVE_X_WINDOWS && defined USE_X_TOOLKIT /* Create an X fontset on frame F with base font name BASE_FONTNAME. */ @@ -2622,15 +2605,8 @@ xic_free_xfontset (struct frame *f) static XIMStyle best_xim_style (XIMStyles *xim) { - int i, j; - int nr_supported = ARRAYELTS (supported_xim_styles); - - for (i = 0; i < nr_supported; ++i) - for (j = 0; j < xim->count_styles; ++j) - if (supported_xim_styles[i] == xim->supported_styles[j]) - return supported_xim_styles[i]; - - /* Return the default style. */ + /* Return the default style. This is what GTK3 uses and + should work fine with all modern input methods. */ return XIMPreeditNothing | XIMStatusNothing; } diff --git a/src/xterm.c b/src/xterm.c index 2e0407aff4..0a242ad214 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -9704,7 +9704,7 @@ x_draw_window_cursor (struct window *w, struct glyph_row *glyph_row, int x, #ifdef HAVE_X_I18N if (w == XWINDOW (f->selected_window)) - if (FRAME_XIC (f) && (FRAME_XIC_STYLE (f) & XIMPreeditPosition)) + if (FRAME_XIC (f)) xic_set_preeditarea (w, x, y); #endif } @@ -10387,11 +10387,8 @@ xim_instantiate_callback (Display *display, XPointer client_data, XPointer call_ create_frame_xic (f); if (FRAME_XIC_STYLE (f) & XIMStatusArea) xic_set_statusarea (f); - if (FRAME_XIC_STYLE (f) & XIMPreeditPosition) - { - struct window *w = XWINDOW (f->selected_window); - xic_set_preeditarea (w, w->cursor.x, w->cursor.y); - } + struct window *w = XWINDOW (f->selected_window); + xic_set_preeditarea (w, w->cursor.x, w->cursor.y); } } ``` ^ permalink raw reply related [flat|nested] 9+ messages in thread
* bug#10867: 26.3; XIM preedit/status font handling 2020-08-21 4:53 ` Yichao Yu @ 2020-10-07 4:20 ` Lars Ingebrigtsen 2020-12-28 3:19 ` Lars Ingebrigtsen 0 siblings, 1 reply; 9+ messages in thread From: Lars Ingebrigtsen @ 2020-10-07 4:20 UTC (permalink / raw) To: Yichao Yu; +Cc: Xuetian Weng, 10867 Yichao Yu <yyc1992@gmail.com> writes: >> Thanks. Can someone with access to a system with this issue and >> sufficient knowledge of what's going on please review this patch? [...] > All in all, the following patch fixes all the issues cleanly. > Note that this is exactly what gtk3 does > (https://github.com/GNOME/gtk/blob/de04aaf82db8d694af7d42ab6bb2e26d3ef0c947/modules/input/gtkimcontextxim.c#L183), > i.e. it does not accept either XIMPreeditPosition or XIMStatusArea. The patch was mangled by the mailer, apparently, but I've respun it below. It doesn't seem to introduce any regressions, but I'm not using XIM, so that's no surprise. Like Eli said, it would be nice if somebody with more XIM knowledge could give this patch a look before we apply it to Emacs 28. diff --git a/src/xfns.c b/src/xfns.c index 46e4bd73a6..5eba34c710 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -2321,24 +2321,6 @@ hack_wm_protocols (struct frame *f, Widget widget) static XFontSet xic_create_xfontset (struct frame *); static XIMStyle best_xim_style (XIMStyles *); - -/* Supported XIM styles, ordered by preference. */ - -static const XIMStyle supported_xim_styles[] = -{ - XIMPreeditPosition | XIMStatusArea, - XIMPreeditPosition | XIMStatusNothing, - XIMPreeditPosition | XIMStatusNone, - XIMPreeditNothing | XIMStatusArea, - XIMPreeditNothing | XIMStatusNothing, - XIMPreeditNothing | XIMStatusNone, - XIMPreeditNone | XIMStatusArea, - XIMPreeditNone | XIMStatusNothing, - XIMPreeditNone | XIMStatusNone, - 0, -}; - - #if defined HAVE_X_WINDOWS && defined USE_X_TOOLKIT /* Create an X fontset on frame F with base font name BASE_FONTNAME. */ @@ -2622,15 +2604,8 @@ xic_free_xfontset (struct frame *f) static XIMStyle best_xim_style (XIMStyles *xim) { - int i, j; - int nr_supported = ARRAYELTS (supported_xim_styles); - - for (i = 0; i < nr_supported; ++i) - for (j = 0; j < xim->count_styles; ++j) - if (supported_xim_styles[i] == xim->supported_styles[j]) - return supported_xim_styles[i]; - - /* Return the default style. */ + /* Return the default style. This is what GTK3 uses and + should work fine with all modern input methods. */ return XIMPreeditNothing | XIMStatusNothing; } diff --git a/src/xterm.c b/src/xterm.c index 2e0407aff4..0a242ad214 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -9704,7 +9704,7 @@ x_draw_window_cursor (struct window *w, struct glyph_row *glyph_row, int x, #ifdef HAVE_X_I18N if (w == XWINDOW (f->selected_window)) - if (FRAME_XIC (f) && (FRAME_XIC_STYLE (f) & XIMPreeditPosition)) + if (FRAME_XIC (f)) xic_set_preeditarea (w, x, y); #endif } @@ -10387,11 +10387,8 @@ xim_instantiate_callback (Display *display, XPointer client_data, XPointer call_ create_frame_xic (f); if (FRAME_XIC_STYLE (f) & XIMStatusArea) xic_set_statusarea (f); - if (FRAME_XIC_STYLE (f) & XIMPreeditPosition) - { - struct window *w = XWINDOW (f->selected_window); - xic_set_preeditarea (w, w->cursor.x, w->cursor.y); - } + struct window *w = XWINDOW (f->selected_window); + xic_set_preeditarea (w, w->cursor.x, w->cursor.y); } } -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no ^ permalink raw reply related [flat|nested] 9+ messages in thread
* bug#10867: 26.3; XIM preedit/status font handling 2020-10-07 4:20 ` Lars Ingebrigtsen @ 2020-12-28 3:19 ` Lars Ingebrigtsen 2020-12-28 3:26 ` Yichao Yu 0 siblings, 1 reply; 9+ messages in thread From: Lars Ingebrigtsen @ 2020-12-28 3:19 UTC (permalink / raw) To: Yichao Yu; +Cc: Xuetian Weng, 10867 Lars Ingebrigtsen <larsi@gnus.org> writes: > Like Eli said, it would be nice if somebody with more XIM knowledge > could give this patch a look before we apply it to Emacs 28. That was three months ago, and nobody volunteered, so I've pushed the patch now to Emacs 28. If this regresses stuff for people, we'll have to revert. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no ^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#10867: 26.3; XIM preedit/status font handling 2020-12-28 3:19 ` Lars Ingebrigtsen @ 2020-12-28 3:26 ` Yichao Yu 2020-12-28 3:28 ` Lars Ingebrigtsen 0 siblings, 1 reply; 9+ messages in thread From: Yichao Yu @ 2020-12-28 3:26 UTC (permalink / raw) To: Lars Ingebrigtsen; +Cc: Xuetian Weng, 10867 On Sun, Dec 27, 2020 at 10:19 PM Lars Ingebrigtsen <larsi@gnus.org> wrote: > > Lars Ingebrigtsen <larsi@gnus.org> writes: > > > Like Eli said, it would be nice if somebody with more XIM knowledge > > could give this patch a look before we apply it to Emacs 28. > > That was three months ago, and nobody volunteered, so I've pushed the > patch now to Emacs 28. If this regresses stuff for people, we'll have > to revert. I also thought about it more and I think if people have objections or this really regresses for people, an alternative is to still try the old method but fallback to this one if any steps fail. OTOH, it'll make the code more complicated and IMHO the old one isn't particularly "better" just "different" so I wasn't in a hurry to implement that. Please do let me know if there's any report related to this and it shouldn't be **that** hard to add the new path only as a fallback. > > -- > (domestic pets only, the antidote for overdose, milk.) > bloggy blog: http://lars.ingebrigtsen.no ^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#10867: 26.3; XIM preedit/status font handling 2020-12-28 3:26 ` Yichao Yu @ 2020-12-28 3:28 ` Lars Ingebrigtsen 0 siblings, 0 replies; 9+ messages in thread From: Lars Ingebrigtsen @ 2020-12-28 3:28 UTC (permalink / raw) To: Yichao Yu; +Cc: Xuetian Weng, 10867 Yichao Yu <yyc1992@gmail.com> writes: > Please do let me know if there's any report related to this and it > shouldn't be **that** hard to add the new path only as a fallback. Will do. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2020-12-28 3:28 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-02-22 11:41 bug#10867: 23.4 must export LC_CTYPE to zh_CN.UTF-8 or similar CJK locale to use X input method Weng Xuetian 2020-08-02 19:03 ` bug#10867: 26.3; XIM preedit/status font handling Yichao Yu 2020-08-02 20:07 ` Yichao Yu 2020-08-08 8:00 ` Eli Zaretskii 2020-08-21 4:53 ` Yichao Yu 2020-10-07 4:20 ` Lars Ingebrigtsen 2020-12-28 3:19 ` Lars Ingebrigtsen 2020-12-28 3:26 ` Yichao Yu 2020-12-28 3:28 ` Lars Ingebrigtsen
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).