Skip to main content

Crate system_fonts

Crate system_fonts 

Source
Expand description

System font discovery and locale-based preset selection.

Detects the current system locale, maps it to a FontRegion, and resolves a prioritized list of installed fonts. On wasm, font discovery is not supported and the find_* functions return empty results.

use system_fonts::{find_for_system_locale, FontStyle};

let (_locale, region, fonts) = find_for_system_locale(FontStyle::Sans);
println!("region={region:?}, fonts={}", fonts.len());

Structs§

FoundFont
A resolved system font entry usable by UI code.

Enums§

FontPreset
A preset represents a prioritized group of candidate font families.
FontRegion
Writing system/locale region used to decide fallback priority.
FontStyle
Font preference used when selecting system fonts.
FoundFontSource
Font bytes source resolved from the system font database.

Functions§

find_for_locale
Resolves fonts for the given locale string. On wasm, returns an empty font list.
find_for_system_locale
Resolves fonts for the current system locale. On wasm, returns an empty font list.
find_from_presets
Resolves installed system fonts from presets, ordered by priority.
presets_for_region
Returns the default preset priority list for a region (highest priority first).
region_from_locale
Maps a locale string (BCP-47 or POSIX style) to a FontRegion.
system_locale
Returns the current system locale string (e.g. "ko-KR", "en-US"), or None on wasm.