Move the fonts out of the Backend trait (#1438)

and remove the `'static`
This commit is contained in:
Olivier Goffart 2022-07-26 16:45:54 +02:00 committed by GitHub
parent 793974ce9f
commit 8c70cd7f57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 167 additions and 251 deletions

View file

@ -6,7 +6,7 @@
use core::ffi::c_void;
use i_slint_backend_selector::backend;
use i_slint_core::api::Window;
use i_slint_core::window::ffi::WindowRcOpaque;
use i_slint_core::window::{ffi::WindowRcOpaque, WindowRc};
#[doc(hidden)]
#[cold]
@ -63,12 +63,14 @@ pub unsafe extern "C" fn slint_quit_event_loop() {
#[no_mangle]
pub unsafe extern "C" fn slint_register_font_from_path(
win: *const WindowRcOpaque,
path: &i_slint_core::SharedString,
error_str: *mut i_slint_core::SharedString,
) {
let window = &*(win as *const WindowRc);
core::ptr::write(
error_str,
match crate::backend().register_font_from_path(std::path::Path::new(path.as_str())) {
match window.renderer().register_font_from_path(std::path::Path::new(path.as_str())) {
Ok(()) => Default::default(),
Err(err) => err.to_string().into(),
},
@ -77,12 +79,14 @@ pub unsafe extern "C" fn slint_register_font_from_path(
#[no_mangle]
pub unsafe extern "C" fn slint_register_font_from_data(
win: *const WindowRcOpaque,
data: i_slint_core::slice::Slice<'static, u8>,
error_str: *mut i_slint_core::SharedString,
) {
let window = &*(win as *const WindowRc);
core::ptr::write(
error_str,
match crate::backend().register_font_from_memory(data.as_slice()) {
match window.renderer().register_font_from_memory(data.as_slice()) {
Ok(()) => Default::default(),
Err(err) => err.to_string().into(),
},