From 9220e05e1b1696218227c46cad084e12d00d69f5 Mon Sep 17 00:00:00 2001 From: wsxarcher Date: Sat, 31 Aug 2024 17:19:36 +0200 Subject: [PATCH] clippy fix --- core/src/library.rs | 4 ++-- web/src/builder.rs | 25 +++++++++++++++---------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/core/src/library.rs b/core/src/library.rs index cbb5b94190b69..8cadb246e1f6d 100644 --- a/core/src/library.rs +++ b/core/src/library.rs @@ -597,7 +597,7 @@ impl<'gc> Library<'gc> { let name = font.descriptor().name().to_owned(); let is_bold = font.descriptor().bold(); let is_italic = font.descriptor().italic(); - info!("Loaded new device font \"{name}\" bold:{is_bold} italic:{is_italic} from swf tag"); + info!("Loaded new device font \"{name}\" (bold: {is_bold}, italic: {is_italic}) from swf tag"); self.device_fonts.register(font); } FontDefinition::FontFile { @@ -616,7 +616,7 @@ impl<'gc> Library<'gc> { FontType::Device, ) { let name = font.descriptor().name().to_owned(); - info!("Loaded new device font \"{name}\" bold:{is_bold} italic:{is_italic} from file"); + info!("Loaded new device font \"{name}\" (bold: {is_bold}, italic: {is_italic}) from file"); self.device_fonts.register(font); } else { warn!("Failed to load device font from file"); diff --git a/web/src/builder.rs b/web/src/builder.rs index 6ccfcd05b770d..4554dade31db9 100644 --- a/web/src/builder.rs +++ b/web/src/builder.rs @@ -345,16 +345,23 @@ impl RuffleInstanceBuilder { if let Ok(face) = ttf_parser::Face::parse(bytes_slice, 0) { tracing::debug!("Loading font {font_name} as TTF/OTF/TTC/OTC font"); - Self::register_ttf_face_by_name(font_name, bytes, face, number_of_fonts, 0, player); - // Check if font collection let number_of_fonts = ttf_parser::fonts_in_collection(bytes_slice).unwrap_or(1u32); + Self::register_ttf_face_by_name( + font_name, + bytes.clone(), + face, + number_of_fonts, + 0, + player, + ); + // Register all remaining fonts in the collection if it is a collection for i in 1u32..number_of_fonts { Self::register_ttf_face_by_name( font_name, - bytes, + bytes.clone(), ttf_parser::Face::parse(bytes_slice, i) .expect("Failed to parse font collection"), number_of_fonts, @@ -418,7 +425,7 @@ impl RuffleInstanceBuilder { #[inline] fn register_ttf_face_by_name( url: &String, - bytes: &Vec, + bytes: Vec, face: ttf_parser::Face<'_>, number_of_fonts: u32, index: u32, @@ -432,19 +439,17 @@ impl RuffleInstanceBuilder { let name = if let Some(full_name) = full_name { full_name + } else if number_of_fonts > 1 { + format!("{} {}", url, index + 1) } else { - if number_of_fonts > 1 { - format!("{} {}", url, index + 1) - } else { - url.to_string() - } + url.to_string() }; player.register_device_font(FontDefinition::FontFile { name: name.to_string(), is_bold: face.is_bold(), is_italic: face.is_italic(), - data: bytes.clone(), + data: bytes, index, }); }