bug#68339: [patch] Set the IME window font to an appropriate size
dANiuu zHaO <[email protected]> Wed, 5 Aug 2026 15:05:22 +0800
| Newsgroups | gmane.emacs.bugs |
|---|---|
| Message-ID | <CAEOE9jeRvqsuUB2jwZF5qvdYuGOO-CQ5x_Uz5=YEdsjjUoEdow@mail.gmail.com> |
--000000000000e8e2ed06584765b7 Content-Type: multipart/alternative; boundary="000000000000e8e2ec06584765b5" --000000000000e8e2ec06584765b5 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable [PATCH 4] Set the IME window font to an appropriate size Already fixed. During my local testing, I found that lookup_basic_face would trigger an emacs_abort assertion =E2=80=94 specifically, the function= that triggered it was make_uninit_string. So instead, I changed it to read the global w32_system_caret_height as the lfHeight value, which is quite clever= . Eason Huang <[email protected]> =E4=BA=8E2026=E5=B9=B48=E6=9C=885=E6=97= =A5=E5=91=A8=E4=B8=89 10:25=E5=86=99=E9=81=93=EF=BC=9A > 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 > is 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 > patches 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] > > > > > > You were right. I only needed to build it once locally and it worked > perfectly =E2=80=94 exactly as > > you described, with no > > > errors at all. There's a new patch and a GIF attached to demonstrate > my current work. > > > Everything works fine on my local machine, but it will likely need > more testing from others. > > Lastly, thank you for > > > your guidance =E2=80=94 without it, it would have taken me much long= er 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_FACE_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 > 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. > > > -- > Eason Huang > > --000000000000e8e2ec06584765b5 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div>[PATCH 4]=C2=A0Set the IME window font to an appropri= ate size</div><div><br></div>Already fixed. During my local testing, I foun= d that lookup_basic_face would trigger an emacs_abort assertion =E2=80=94 s= pecifically, the function that triggered it was make_uninit_string. So inst= ead, I changed it to read the global w32_system_caret_height as the lfHeigh= t value, which is quite clever.<br class=3D"gmail-Apple-interchange-newline= "></div><br><div class=3D"gmail_quote gmail_quote_container"><div dir=3D"lt= r" class=3D"gmail_attr">Eason Huang <<a href=3D"mailto:aqua0210@foxmail.= com">[email protected]</a>> =E4=BA=8E2026=E5=B9=B48=E6=9C=885=E6=97= =A5=E5=91=A8=E4=B8=89 10:25=E5=86=99=E9=81=93=EF=BC=9A<br></div><blockquote= class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px so= lid rgb(204,204,204);padding-left:1ex">dANiuu zHaO <<a href=3D"mailto:zh= [email protected]" target=3D"_blank">[email protected]</a>> writes:<= br> <br> > [patch 3] Set the IME window font to an appropriate size<br> ><br> > Changed to use FACE_FROM_ID_OR_NULL and added a fallback check: if fac= e is NULL, use FRAME_FONT<br> > instead.<br> ><br> > dANiuu zHaO <<a href=3D"mailto:[email protected]" target=3D"_bla= nk">[email protected]</a>> =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<br> ><br> >=C2=A0 Yes, more testing is a good idea. I will share and distribute th= ese patches in the Emacs communities<br> >=C2=A0 I know, and I hope more people can help test them.<br> ><br> >=C2=A0 As for the code suggestions, I will send an improved patch short= ly.<br> ><br> >=C2=A0 Finally, I have signed the form and am waiting for a response.<b= r> >=C2=A0 Thanks.<br> ><br> >=C2=A0 Eli Zaretskii <<a href=3D"mailto:[email protected]" target=3D"_bla= nk">[email protected]</a>> =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<br> ><br> >=C2=A0 > From: dANiuu zHaO <<a href=3D"mailto:[email protected]= m" target=3D"_blank">[email protected]</a>><br> >=C2=A0 > Date: Sun, 2 Aug 2026 23:27:31 +0800<br> >=C2=A0 > Cc: <a href=3D"mailto:[email protected]" target=3D"_bla= nk">[email protected]</a><br> >=C2=A0 > <br> >=C2=A0 > You were right. I only needed to build it once locally and = it worked perfectly =E2=80=94 exactly as<br> >=C2=A0 you described, with no<br> >=C2=A0 > errors at all. There's a new patch and a GIF attached t= o demonstrate my current work.<br> >=C2=A0 > Everything works fine on my local machine, but it will like= ly need more testing from others.<br> >=C2=A0 Lastly, thank you for<br> >=C2=A0 > your guidance =E2=80=94 without it, it would have taken me = much longer to figure out the root cause.<br> ><br> >=C2=A0 Yes, more testing is a good idea.=C2=A0 Would people who have IM= E installed<br> >=C2=A0 on their Windows systems please apply the patch, try using IME, = and<br> >=C2=A0 report back?<br> ><br> >=C2=A0 > Finally, I agree to sign the copyright-assignment agreement= .<br> ><br> >=C2=A0 Thanks, form sent off-list.<br> ><br> >=C2=A0 > +=C2=A0 =C2=A0 =C2=A0 =C2=A0face =3D FACE_FROM_ID (f, looku= p_basic_face (w, f, DEFAULT_FACE_ID));<br> >=C2=A0 > +=C2=A0 =C2=A0 =C2=A0 =C2=A0GetObjectW (FONT_HANDLE (face-&= gt;font), sizeof (lf), &lf);<br> ><br> >=C2=A0 Please add the fallback here, in case something goes wrong.<br> >=C2=A0 Specifically, if either 'face' or face->font is NULL,= we should use<br> >=C2=A0 FRAME_FONT as fallback.<br> ><br> >=C2=A0 Also, please use FACE_FROM_ID_OR_NULL instead of FACE_FROM_ID, b= ecause<br> >=C2=A0 the latter will hit assert violation if the result is NULL, wher= eas we<br> >=C2=A0 want to handle that ourselves here.<br> ><br> ><br> Hello Eli and dANiuu,<br> <br> Thanks for implemented this nice feature.<br> I tested the latest patch, It works. But it will crash my Emacs when<br> variable-pitch-mode and global-display-line-numbers-mode is enabled.<br> <br> The version I build is emacs-31 branch<br> commit:d828a19fdc064b4fa324779143d78fbff9a9a7b2<br> <br> steps to reproduce:<br> <br> 1. start emacs with emacs -Q <br> 2. Past more example text into the * scratch * buffer<br> 3. Enable variable-pitch-mode and global-display-line-numbers-mode by M-x<b= r> 4. Use C-n or C-p navigate the text on buffer * scratch * will trigger cras= h<br> <br> I recorded an video for this, you can get it by below link:<br> <br> Video link: <a href=3D"https://pan.baidu.com/s/1RhIAY6HIxYpFXDSWeOfTaA" rel= =3D"noreferrer" target=3D"_blank">https://pan.baidu.com/s/1RhIAY6HIxYpFXDSW= eOfTaA</a><br> password: uxcg<br> <br> Hope that it can be helpful.<br> <br> <br> -- <br> Eason Huang<br> <br> </blockquote></div> --000000000000e8e2ec06584765b5-- --000000000000e8e2ed06584765b7 Content-Type: application/octet-stream; name="0001-Set-the-IME-window-font-to-an-appropriate-size.patch" Content-Disposition: attachment; filename="0001-Set-the-IME-window-font-to-an-appropriate-size.patch" Content-Transfer-Encoding: base64 Content-ID: <f_msfqo9850> X-Attachment-Id: f_msfqo9850 RnJvbSAzZWVkY2U2ODMwMDM5Yzk3YjkwZWEwMGUzYWEzODdkZDYwN2ZlOTgwIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiB6ZG4gPHpoYW9kYW5pdTFAZ21haWwuY29tPgpEYXRlOiBTdW4s IDIgQXVnIDIwMjYgMTE6MDU6MDIgKzA4MDAKU3ViamVjdDogW1BBVENIXSBTZXQgdGhlIElNRSB3 aW5kb3cgZm9udCB0byBhbiBhcHByb3ByaWF0ZSBzaXplLgoKKiBzcmMvdzMyZm5zLmMgKHczMl93 bmRfcHJvYyk6IENvbnZlcnQgRlJBTUVfRk9OVCAoZikgdG8gSEZPTlQgdXNpbmcKRk9OVF9IQU5E TEUgbWFjcm8sIGFuZCBhcHBseSB3MzJfc3lzdGVtX2NhcmV0X2hlaWdodCB0byBzZXQgdGhlIGhl aWdodC4KLS0tCiBzcmMvdzMyZm5zLmMgfCAxNCArKysrKysrKysrKysrKwogMSBmaWxlIGNoYW5n ZWQsIDE0IGluc2VydGlvbnMoKykKCmRpZmYgLS1naXQgYS9zcmMvdzMyZm5zLmMgYi9zcmMvdzMy Zm5zLmMKaW5kZXggNzI2ZmU1Mi4uZDlkYzM2NSAxMDA2NDQKLS0tIGEvc3JjL3czMmZucy5jCisr KyBiL3NyYy93MzJmbnMuYwpAQCAtNDcsNiArNDcsNy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k9OVCAo Zik7CisJICBHZXRPYmplY3RXIChGT05UX0hBTkRMRSAoZm9udCksIHNpemVvZiAobGYpLCAmbGYp OworCSAgbGYubGZIZWlnaHQgPSAtdzMyX3N5c3RlbV9jYXJldF9oZWlnaHQ7CisJICBzZXRfaW1l X2NvbXBvc2l0aW9uX2ZvbnRfZm4gKGNvbnRleHQsICZsZik7CiAJICBzZXRfaW1lX2NvbXBvc2l0 aW9uX3dpbmRvd19mbiAoY29udGV4dCwgJmZvcm0pOwogCSAgcmVsZWFzZV9pbWVfY29udGV4dF9m biAoaHduZCwgY29udGV4dCk7CiAJfQpAQCAtMTIzMzIsNiArMTIzNDMsOSBAQCBnbG9iYWxzX29m X3czMmZucyAodm9pZCkKICAgICAgIGdldF9wcm9jX2FkZHIgKGltbTMyX2xpYiwgIkltbUdldE9w ZW5TdGF0dXMiKTsKICAgICBzZXRfaW1lX29wZW5fc3RhdHVzX2ZuID0gKEltbVNldE9wZW5TdGF0 dXNfUHJvYykKICAgICAgIGdldF9wcm9jX2FkZHIgKGltbTMyX2xpYiwgIkltbVNldE9wZW5TdGF0 dXMiKTsKKworICAgIHNldF9pbWVfY29tcG9zaXRpb25fZm9udF9mbiA9IChJbW1TZXRDb21wb3Np dGlvbkZvbnRfUHJvYykKKyAgICAgIGdldF9wcm9jX2FkZHIgKGltbTMyX2xpYiwgIkltbVNldENv bXBvc2l0aW9uRm9udFciKTsKICAgfQogCiAgIEhNT0RVTEUgaG1fa2VybmVsMzIgPSBHZXRNb2R1 bGVIYW5kbGUgKCJrZXJuZWwzMi5kbGwiKTsKLS0gCjIuNTQuMAoK --000000000000e8e2ed06584765b7--