| Crates.io | findfont |
| lib.rs | findfont |
| version | 0.2.0 |
| created_at | 2025-02-24 03:57:04.523639+00 |
| updated_at | 2025-06-25 05:58:33.027439+00 |
| description | find font by file name |
| homepage | https://github.com/AllenDang/findfont-rs |
| repository | https://github.com/AllenDang/findfont-rs |
| max_upload_size | |
| id | 1566925 |
| size | 27,392 |
A cross-platform Rust library to find font files in system font directories.
Add to your Cargo.toml:
[dependencies]
findfont = "0.1"
Basic usage:
use findfont::find;
fn main() {
if let Some(path) = find("Arial") {
println!("Found font at: {}", path.display());
} else {
println!("Font not found");
}
}
With error handling:
use findfont::find;
fn load_font(font_name: &str) -> std::io::Result<Vec<u8>> {
find(font_name)
.map(std::fs::read)
.unwrap_or_else(|| Err(std::io::Error::new(
std::io::ErrorKind::NotFound,
"Font not found"
)))
}
~/.fonts/~/.local/share/fonts//usr/local/share/fonts//usr/share/fonts/~/Library/Fonts//Library/Fonts//System/Library/Fonts/%windir%\Fonts%LOCALAPPDATA%\Microsoft\Windows\Fonts.ttf.ttc.otf{font_name} Light.{ext}{font_name} Medium.{ext}Note: Search is case-sensitive and uses platform-specific path separators
Contributions are welcome! Please open an issue or PR for:
MIT/Apache