Skip to content

Commit

Permalink
clippy fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wsxarcher committed Aug 31, 2024
1 parent 964e821 commit 9220e05
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
4 changes: 2 additions & 2 deletions core/src/library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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");
Expand Down
25 changes: 15 additions & 10 deletions web/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -418,7 +425,7 @@ impl RuffleInstanceBuilder {
#[inline]
fn register_ttf_face_by_name(
url: &String,
bytes: &Vec<u8>,
bytes: Vec<u8>,
face: ttf_parser::Face<'_>,
number_of_fonts: u32,
index: u32,
Expand All @@ -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,
});
}
Expand Down

0 comments on commit 9220e05

Please sign in to comment.