slint-ui / slint

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

If the text does not start with Chinese, the characters will be unrecognized and garbled. #1199

Closed Misaka299 closed 2 years ago

Misaka299 commented 2 years ago
slint::slint! {
    MainWindow := Window {
        Text { text: " 当开头不是中文就会不识别"; }
    }
}
fn main() {
    MainWindow::new().run();
}

If the text does not start with Chinese, the characters will be unrecognized and garbled. image image image

Although I haven't tested it, I think this problem occurs in other languages as well.

ogoffart commented 2 years ago

Thanks for your bug report!

I believe this is a duplicate of #1139 which already has been fixed in the master branch. You can try using the git version of slint, or wait for the next release

Misaka299 commented 2 years ago

ok.

Misaka299 commented 2 years ago

image

May I ask why the code I wrote can't find the checkbox, and now I use the git version.

By the way, how to set the line height of text.

ogoffart commented 2 years ago

did you do

import { CheckBox } from "std-widgets.slint";
Misaka299 commented 2 years ago

How to read the checked field of the checkBox in the code.

Slint's design is very creative. but Slint's documentation feels inadequate. Although I make simple things, I can't always find the content I need. (I can't find what I need, or it may have something to do with my poor English.

ogoffart commented 2 years ago

I'll close this particular issue as the original issue is a duplicate of #1139

You are welcome to continue with more questions on the discussions => https://github.com/slint-ui/slint/discussions

Regarding your last question:

How to read the checked field of the checkBox in the code.

One way is to export the checkbox's checked property as a root property:

MainWindow := Window {
     property foo_checked <=> foo.checked;
     // ...
     foo := CheckBox { ... } 
     //...
}

Then you can use get_foo_checked() from the code.

Instead of a property in the root, that can also be a property in a global, see https://docs.rs/slint/latest/slint/trait.Global.html

export global MyGlobal := {
  property <bool> foo_checked;
}
MainWindow := Window {
     // ...
     foo := CheckBox { checked <=> MyGlobal.foo_checked; } 
     //...
}

Or you can also pass the result in a callback (or global callback)

MainWindow := Window {
     callbak foo_toggled(bool);
     // ...
     foo := CheckBox {  toggled => { root.foo_toggled(foo.checked); } } 
     //...
}
Misaka299 commented 2 years ago

thank you