mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-30 23:27:22 +00:00
Move the fonts out of the Backend trait (#1438)
and remove the `'static`
This commit is contained in:
parent
793974ce9f
commit
8c70cd7f57
17 changed files with 167 additions and 251 deletions
|
@ -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(),
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue