Expand description
System font discovery and locale-based preset selection.
This crate provides a small API for:
- Detecting the current system locale
- Mapping a locale to a
FontRegion - Resolving a prioritized list of installed system fonts using
fontdb
The output (FoundFont) is designed to be consumed by UI toolkits (e.g. egui_system_fonts),
where the caller loads the font bytes and registers them into the UI font system.
§Quick start
Resolve fonts from the current system locale:
use system_fonts::{find_for_system_locale, FontStyle};
let (_locale, region, fonts) = find_for_system_locale(FontStyle::Sans);
println!("region={region:?}, fonts={}", fonts.len());Force a locale or region policy manually:
use system_fonts::{find_for_locale, FontStyle};
let (region, fonts) = find_for_locale("ko-KR", FontStyle::Sans);
println!("region={region:?}, fonts={}", fonts.len());§Notes
- Font resolution is best-effort: unknown families are skipped.
- The internal font database is cached (loaded once per process).
FoundFont::keyis unique within a single run; do not persist it across runs.
Structs§
- Found
Font - A resolved system font entry usable by UI code.
Enums§
- Font
Preset - A preset represents a prioritized group of candidate font families.
- Font
Region - Writing system/locale region used to decide fallback priority.
- Font
Style - Font preference used when selecting system fonts.
- Found
Font Source - Font bytes source resolved from the system font database.
Functions§
- find_
for_ locale - Detects a region from the given locale string, then resolves fonts using that region’s presets.
- find_
for_ system_ locale - Resolves fonts based on the current system locale.
- find_
from_ presets - Resolves system fonts from presets and style.
- presets_
for_ region - Returns the default preset priority list for a given region.
- region_
from_ locale - Converts a locale string into a
FontRegion. - system_
locale - Returns the current system locale string (e.g. “ko-KR”, “en-US”) if available.