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

@ -2039,7 +2039,8 @@ fn compile_builtin_function_call(
}
BuiltinFunction::RegisterCustomFontByPath => {
if let [Expression::StringLiteral(path)] = arguments {
quote!(slint::register_font_from_path(&std::path::PathBuf::from(#path));)
let window_tokens = access_window_field(ctx);
quote!(#window_tokens.renderer().register_font_from_path(&std::path::PathBuf::from(#path));)
} else {
panic!("internal error: invalid args to RegisterCustomFontByPath {:?}", arguments)
}
@ -2048,7 +2049,8 @@ fn compile_builtin_function_call(
if let [Expression::NumberLiteral(resource_id)] = &arguments {
let resource_id: usize = *resource_id as _;
let symbol = format_ident!("SLINT_EMBEDDED_RESOURCE_{}", resource_id);
quote!(slint::register_font_from_memory(#symbol.into());)
let window_tokens = access_window_field(ctx);
quote!(#window_tokens.renderer().register_font_from_memory(#symbol.into());)
} else {
panic!("internal error: invalid args to RegisterCustomFontByMemory {:?}", arguments)
}
@ -2057,7 +2059,8 @@ fn compile_builtin_function_call(
if let [Expression::NumberLiteral(resource_id)] = &arguments {
let resource_id: usize = *resource_id as _;
let symbol = format_ident!("SLINT_EMBEDDED_RESOURCE_{}", resource_id);
quote!(slint::internal::register_bitmap_font(&#symbol);)
let window_tokens = access_window_field(ctx);
quote!(#window_tokens.renderer().register_bitmap_font(&#symbol);)
} else {
panic!("internal error: invalid args to RegisterBitmapFont must be a number")
}