bug#68339: [patch] Set the IME window font to an appropriate size

Eason Huang <[email protected]> Wed, 05 Aug 2026 10:25:16 +0800
Newsgroups gmane.emacs.bugs
Message-ID <[email protected]>
dANiuu zHaO <[email protected]> writes:

> [patch 3] Set the IME window font to an appropriate size
>
> Changed to use FACE_FROM_ID_OR_NULL and added a fallback check: if face i=
s NULL, use FRAME_FONT
> instead.
>
> dANiuu zHaO <[email protected]> =E4=BA=8E2026=E5=B9=B48=E6=9C=883=E6=
=97=A5=E5=91=A8=E4=B8=80 00:10=E5=86=99=E9=81=93=EF=BC=9A
>
>  Yes, more testing is a good idea. I will share and distribute these patc=
hes in the Emacs communities
>  I know, and I hope more people can help test them.
>
>  As for the code suggestions, I will send an improved patch shortly.
>
>  Finally, I have signed the form and am waiting for a response.
>  Thanks.
>
>  Eli Zaretskii <[email protected]> =E4=BA=8E2026=E5=B9=B48=E6=9C=882=E6=97=A5=
=E5=91=A8=E6=97=A5 23:52=E5=86=99=E9=81=93=EF=BC=9A
>
>  > From: dANiuu zHaO <[email protected]>
>  > Date: Sun, 2 Aug 2026 23:27:31 +0800
>  > Cc: [email protected]
>  >=20
>  > You were right. I only needed to build it once locally and it worked p=
erfectly =E2=80=94 exactly as
>  you described, with no
>  > errors at all. There's a new patch and a GIF attached to demonstrate m=
y current work.
>  > Everything works fine on my local machine, but it will likely need mor=
e testing from others.
>  Lastly, thank you for
>  > your guidance =E2=80=94 without it, it would have taken me much longer=
 to figure out the root cause.
>
>  Yes, more testing is a good idea.  Would people who have IME installed
>  on their Windows systems please apply the patch, try using IME, and
>  report back?
>
>  > Finally, I agree to sign the copyright-assignment agreement.
>
>  Thanks, form sent off-list.
>
>  > +       face =3D FACE_FROM_ID (f, lookup_basic_face (w, f, DEFAULT_FAC=
E_ID));
>  > +       GetObjectW (FONT_HANDLE (face->font), sizeof (lf), &lf);
>
>  Please add the fallback here, in case something goes wrong.
>  Specifically, if either 'face' or face->font is NULL, we should use
>  FRAME_FONT as fallback.
>
>  Also, please use FACE_FROM_ID_OR_NULL instead of FACE_FROM_ID, because
>  the latter will hit assert violation if the result is NULL, whereas we
>  want to handle that ourselves here.
>
>
Hello Eli and dANiuu,

Thanks for implemented this nice feature.
I tested the latest patch, It works. But it will crash my Emacs when
variable-pitch-mode and global-display-line-numbers-mode is enabled.

The version I build is emacs-31 branch
commit:d828a19fdc064b4fa324779143d78fbff9a9a7b2

steps to reproduce:

1. start emacs with emacs -Q=20
2. Past more example text into the * scratch * buffer
3. Enable variable-pitch-mode and global-display-line-numbers-mode by M-x
4. Use C-n or C-p navigate the text on buffer * scratch * will trigger crash

I recorded an video for this, you can get it by below link:

Video link: https://pan.baidu.com/s/1RhIAY6HIxYpFXDSWeOfTaA
password: uxcg

Hope that it can be helpful.


--=20
Eason Huang