Skip to content

Commit

Permalink
Merge pull request #635 from woelper/link_speedup_opt
Browse files Browse the repository at this point in the history
Link speedup opt
  • Loading branch information
woelper authored Feb 1, 2025
2 parents f7ba18c + 6596eb5 commit f7aab68
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
7 changes: 3 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,15 @@ criterion = { version = "0.5.1", features = ["html_reports", "stable"] }

[profile.release]
codegen-units = 1
# incremental = false
lto = true
strip = true
# opt-level = 3
# panic = "abort"

[profile.dev]
debug = false
incremental = true
opt-level = 3
opt-level = 2
lto = false
codegen-units = 64


[[bench]]
Expand Down
9 changes: 5 additions & 4 deletions src/ui/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use epaint::FontFamily;
use font_kit::{
family_name::FamilyName, handle::Handle, properties::Properties, source::SystemSource,
};
use log::warn;
use std::{collections::HashMap, fs::read};

pub fn apply_theme(state: &mut OculanteState, ctx: &Context) {
Expand Down Expand Up @@ -109,14 +110,13 @@ pub fn apply_theme(state: &mut OculanteState, ctx: &Context) {
/// Attempt to load a system font by any of the given `family_names`, returning the first match.
fn load_font_family(family_names: &[&str]) -> Option<Vec<u8>> {
let system_source = SystemSource::new();

for &name in family_names {
let font_handle = system_source
.select_best_match(&[FamilyName::Title(name.to_string())], &Properties::new());
match font_handle {
Ok(h) => match &h {
Handle::Memory { bytes, .. } => {
debug!("Loaded {name} from memory.");
info!("Loaded {name} from memory.");
return Some(bytes.to_vec());
}
Handle::Path { path, .. } => {
Expand All @@ -126,10 +126,9 @@ fn load_font_family(family_names: &[&str]) -> Option<Vec<u8>> {
}
}
},
Err(e) => error!("Could not load {}: {:?}", name, e),
Err(e) => debug!("Could not load {}: {:?}", name, e),
}
}

None
}

Expand Down Expand Up @@ -191,6 +190,8 @@ pub fn load_system_fonts(mut fonts: FontDefinitions) -> FontDefinitions {
.get_mut(&FontFamily::Proportional)
.unwrap()
.push(region.to_owned());
} else {
warn!("Could not load a font for region {region}. If you experience incorrect file names, try installing one of these fonts: [{}]", font_names.join(", "))
}
}
fonts
Expand Down

0 comments on commit f7aab68

Please sign in to comment.