Settings struct configures runtime behavior for iced applications, including fonts, text rendering, and graphics options.
Structure Definition
Fields
The identifier of the application. If provided, this identifier may be used to identify the application or communicate with it through the windowing system.
The fonts to load on boot. Add custom font files as byte arrays to make them available throughout your application.
The default
Font to be used. By default, it uses Family::SansSerif.The text size that will be used by default throughout the application.
If set to true, the renderer will try to perform antialiasing for some primitives. Enabling it can produce a smoother result in some widgets, like the
canvas widget, at a performance cost.Whether or not to attempt to synchronize rendering when possible. Disabling it can improve rendering performance on some platforms.
Default Settings
Configuration with Application Builder
TheApplication builder provides convenient methods to configure settings:
Using .settings() Method
Using Builder Methods
Examples
Custom Font Loading
Performance Optimization
Application Identifier
Larger Default Text Size
Builder Methods Reference
TheApplication struct provides these methods for settings configuration:
| Method | Description | Source Location |
|---|---|---|
.settings(settings) | Sets all settings at once | ~/workspace/source/src/application.rs:213 |
.antialiasing(bool) | Enables/disables antialiasing | ~/workspace/source/src/application.rs:218 |
.default_font(font) | Sets the default font | ~/workspace/source/src/application.rs:229 |
.font(bytes) | Adds a font to load at startup | ~/workspace/source/src/application.rs:240 |
Performance Considerations
Antialiasing
- Enabled (default): Smoother appearance, especially for canvas widgets and diagonal lines
- Disabled: Better performance, crisper edges for pixel-perfect designs
VSync
- Enabled (default): Prevents screen tearing, synchronizes with display refresh rate
- Disabled: Higher potential frame rates, may introduce tearing
Font Loading
Fonts are loaded at application startup. Loading many large fonts can increase startup time. Consider:- Only loading fonts you actually use
- Using font subsetting to reduce file size
- Lazy-loading fonts if possible
Location in Source
~/workspace/source/core/src/settings.rs:8
Related
- Application Builder - Main application configuration
- Window Settings - Window-specific configuration
- Styling - Styling and theming guide
