Open efancier-cn opened 1 year ago
It looks like your target platform is missing some basic fonts. When running fc-match sans-serif
on the target, the command should print the name of a .ttf file that's to be used as default font. Could it be that you're missing some font packages? (Noto?)
Marking this as bug in any case. If we continue to panic, then the panic message needs to be about the fact that we couldn't locate any fonts. Otherwise I guess... we should not render any text simply? (this happens during text rendering).
@ogoffart any preference here? (panic vs. no-rendering-and-stderr-message)
@ogoffart any preference here? (panic vs. no-rendering-and-stderr-message)
I'm going to say no-rendering-and-stderr-message. Panic is the absolute worst.
But stderr messages isn't great either.
Would be great to have a way to report non-fatal error messages from the API.
We could also chose to make it a fatal error and end up in a slint::PlatformError. No text is quite bad after all.
But my guts tell me that a "WARNING: Could not load default font. See https://github.com/slint-ui/slint/issues/xyz¹ for troubleshooting. {}"
error message in the console would be alright I think.
¹ or dicsussion?, or .md file in the docs folder? or something in our docs?
@tronical , The system is generated by buildroot, it is possible that the font is missing, I will check. is it possible to put a fallback font rather than panic or stderr
@tronical , The system is generated by buildroot, it is possible that the font is missing, I will check. is it possible to put a fallback font rather than panic or stderr
I think this panic occurs when there is no fallback font available on the system.
To clarify: The acceptance criteria here is to not panic when running on a (linux) system where we can't find fonts, but instead print a message to stderr and not render any text.
This issue still persists. Even if you include your own fonts in the binary, and set them as default in your main window, the application will panic because there is no default system font.
On a ARM Contex-A7 Linux platform, able to cross-compile the slint-test code, execute it, got following message:
thread 'main' panicked at 'removal index (is 0) should be < len (is 0)', /home/roli/.cargo/registry/src/github.com-1ecc6299db9ec823/i-slint-renderer-femtovg-1.0.0/fonts.rs:240:54 stack backtrace: 0: rust_begin_unwind at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/panicking.rs:575:5 1: core::panicking::panic_fmt at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/core/src/panicking.rs:64:14 2: alloc::vec::Vec<T,A>::remove::assert_failed at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/alloc/src/vec/mod.rs:1513:13 3:::default
4: std::thread::local::fast::Key::try_initialize
5: std::thread::local::LocalKey::with
6: i_slint_renderer_femtovg::fonts::text_size
7: ::text_size
8: ::text_size
9: ::layout_info::{{closure}}
10: ::layout_info
11: core::ops::function::FnOnce::call_once
12: i_slint_core::properties::alloc_binding_holder::evaluate
13: i_slint_core::properties::Property::get
14: core::ops::function::FnOnce::call_once
15: i_slint_core::properties::alloc_binding_holder::evaluate
16: i_slint_core::properties::Property::get
17: ::drop::VT::layout_info
18: i_slint_core::component::Component_vtable_mod::ComponentTO::layout_info
19: <i_slint_backend_winit::glwindow::GLWindow as i_slint_core::window::WindowAdapterSealed>::show
20: i_slint_core::window::WindowInner::show
21: i_slint_core::api::Window::show
22: ::run
23: slint_test::main