-
Notifications
You must be signed in to change notification settings - Fork 0
FontManager
The FontManager struct manages font loading and provides access to the underlying cosmic_text::FontSystem. It lives in the aurora_text::font_manager module.
FontManager is part of the aurora_text crate and is available when the text feature is enabled on the main aurora crate.
pub struct FontManager {
font_system: cosmic_text::FontSystem,
}Creates a new font manager with an empty font database. Equivalent to FontManager::default().
let mut font_manager = FontManager::new();Creates a new font manager with a BCP 47 locale tag (e.g. "en-US", "ar-SA", "ja-JP"). The locale is passed to cosmic_text::FontSystem for locale-aware font fallback — for example, choosing Japanese vs Chinese variants of shared Han characters.
let mut fm = FontManager::new_with_locale("ja-JP");Same as new_with_locale but also loads system fonts. Combines locale support with system font discovery.
let mut fm = FontManager::new_with_locale_and_system_db("ar-SA");When using App::locale("ja-JP"), the platform automatically calls new_with_locale or new_with_locale_and_system_db based on the use_system_font setting.
Loads a font from a file path on disk. The path can be anything that implements AsRef<Path>.
font_manager.load("fonts/Roboto-Regular.ttf")?;Loads a font from a byte slice. Returns the font family name on success, or None if the font could not be parsed.
This is the preferred method when embedding fonts with include_bytes!:
let family = font_manager.load_from_bytes(include_bytes!("Roboto-Regular.ttf"));
assert_eq!(family, Some("Roboto".to_string()));Returns a mutable reference to the underlying cosmic_text::FontSystem. Needed by TextLayout for shaping and rasterisation.
Fonts can be registered on the App builder using the font() method, which calls load_from_bytes internally:
App::new()
.font(include_bytes!("Roboto-Regular.ttf"))
.run(|window, _| { /* ... */ })
.unwrap();Errors returned by FontManager::load.
pub enum FontError {
FailedToLoadFont(io::Error),
}| Variant | Cause |
|---|---|
FailedToLoadFont |
The file could not be read from disk |
FontError implements Display and converts from io::Error.
AuroraUI is a cross-platform desktop UI framework that treats performance as a first-class constraint — not an afterthought.
- App - Application builder, windowing, and event loop
- MultiWindow - Window spawning, modals, messaging
-
Native Menu - OS menu bars (
menufeature) -
System Tray - System tray icons (
trayfeature) - Threading - Background tasks, thread-safe state
- Color - Color utilities and color schemes
- Undo / Redo - UndoStack and text input undo
- Rect - Rectangle geometry
- Point - Point geometry
- Size - Size geometry
- Edges - Edge insets (padding, margins, borders)
- Corners - Corner radii for rounded rectangles
- GpuContext - GPU surface abstraction and backends
- Canvas - 2D drawing API
- FontManager - Font loading and management
- TextLayout - Text shaping, measurement, and rendering
- Text - Text widget
- Layout - Column, Row, Stack, Positioned
- ScrollView - Scrollable viewport with scrollbar
- VirtualList - Virtualized list for large datasets
- Button - Styled button with any child content
- BoxWidget - Colored rectangle container
- TextInput - Single-line text input
- TouchArea - Invisible hit-testing region
- Drag & Drop - Draggable sources and drop zones
- ContentSwitch - Conditional child display
- Image - Raster image display (PNG, JPEG)
-
Composite - Stateful composites &
#[composite_widget] - TreeView - Hierarchical data with expand/collapse
- Display - Badge, Card, Alert, Progress, Spinner, Kbd, and more
- Stepper - Step-by-step progress indicator
- Forms - Checkbox, Switch, Slider, RadioGroup, Tabs, Accordion, and more
- SegmentedControl - iOS-style segmented toggle bar
- NumberInput - Numeric input with +/- buttons
- RichTextEditor - Rich text editing with bold/italic/underline
- Form Validation - Validators, error states, form-level validation
- Overlays - Tooltip, Popover, Dialog, DropdownMenu, Select, Toast
- Sheet - Slide-in panel from screen edge
- TagInput - Multi-value input with removable tags
- SplitPane - Resizable split view with drag handle
- ColorPicker - Color selection with hex/RGB
- TimePicker - Time selection with hour/minute spinners
- DateRangePicker - Dual-calendar date range selection
- DateTimePicker - Combined date and time selection
- Data & Advanced - Table, Calendar, Combobox, Command, and more
- Theme - Color profiles, slots, and runtime switching
- Animation - Tweens, easing, keyframes, timelines, and presets
- Syntax - Syntax highlighting for 16+ languages
- Accessibility - Screen reader support via AccessKit
- i18n - Locale detection, message formatting, RTL layout