Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link speedup opt #635

Merged
merged 2 commits into from
Feb 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading