slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
17.54k stars 600 forks source link

How to input Chinese into the edit box of slint ui #4698

Open zhuisu930 opened 8 months ago

zhuisu930 commented 8 months ago

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

lifeRobot commented 8 months ago

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

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

lifeRobot commented 8 months ago

这个问题和#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

tronical commented 8 months ago

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

zhuisu930 commented 8 months ago

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

tronical commented 1 month ago

I tried installing this input method, but when attempting to download the arm64 .deb from https://shurufa.sogou.com/linux I get a HTTP access denied (403).

Do you know if this issue can be reproduce with another input method?