slint icon indicating copy to clipboard operation
slint copied to clipboard

How to input Chinese into the edit box of slint ui

Open zhuisu930 opened this issue 11 months ago • 4 comments

Using LineEdit can't input Chinese, How to solve this problem?

zhuisu930 avatar Feb 27 '24 06:02 zhuisu930

slint默认会直接加载系统字体,只要系统字体支持中文就行了,如果不支持,好像slint还提供了加载外部ttf的方法的,我忘记是哪个api了

Windows下是C:\Windows下的Fonts,只要将字体文件丢到Fonts这里面去就会支持的,如果你要编译成wasm那可能需要找到加载外部ttf的api了

lifeRobot avatar Feb 27 '24 10:02 lifeRobot

这个问题和#3631 应该是同一个问题来的 1、我这边生成的是exe程序,目前输入中文是没有问题的: image 2、我在slint 1.4.1源码里面找到了focus_item这个属性,但是没有暴露给外部,是WindowInner的pub属性,但是WindowInner是内部pub的Window内置属性,而Window也没有提供操作focus_item的方法,所以暂时无解,看看官方是否会更新暴露修改focus_item的api吧: image image

3、如果你实在是非常想让wasm支持中文,那你可以将slint下载到本地,并更改pub struct Window(pub(crate) WindowInner);pub struct Window(pub WindowInner);,然后加载字体,最后引用本地的slint

lifeRobot avatar Feb 27 '24 11:02 lifeRobot

I'm sorry. Could you elaborate a little on your environment and choice of input methods?

tronical avatar Feb 27 '24 12:02 tronical

I'm sorry. Could you elaborate a little on your environment and choice of input methods?

My system is ubuntu 22.04, using Sogou input method

zhuisu930 avatar Feb 28 '24 09:02 zhuisu930