Expand description
§gpui-symbols
SF Symbols rendering for GPUI applications on macOS.
This crate provides two levels of API:
-
SfSymbol- Low-level builder for rendering SF Symbols to raw RGBA pixels or GPUIRenderImage. -
Icon(requirescomponentfeature) - High-level GPUI component that can be used directly in views, similar to GPUI Components.
§Features
gpui- Enable GPUI integration (converts toRenderImage)component- Enable high-levelIconcomponent (impliesgpui)
§Example: Using SfSymbol
ⓘ
use gpui_symbols::SfSymbol;
// Render to raw RGBA pixels
let (width, height, data) = SfSymbol::new("star.fill")
.size(32.0)
.color(0x000000)
.render_rgba()
.unwrap();
// With GPUI feature enabled:
let image = SfSymbol::new("star.fill").render().unwrap();§Example: Using Icon Component
ⓘ
use gpui_symbols::{Icon, define_icons};
use gpui::px;
// Define your own icon enum
define_icons! {
pub enum AppIcon {
Star => "star.fill",
Heart => "heart.fill",
Settings => "gearshape.fill",
}
}
// Use in a view
fn view(window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
div()
.child(Icon::new("star.fill"))
.child(Icon::from_name(AppIcon::Heart).text_color(0xFF0000))
}Re-exports§
pub use sfsymbols;
Macros§
- define_
icons - Convenience macro for creating Icon enums with SF Symbol mappings.
Structs§
- Icon
- A GPUI-compatible Icon component for rendering SF Symbols.
- SfSymbol
- SF Symbol builder for rendering system symbols.
Enums§
- Rendering
Mode - Rendering mode for SF Symbols.
- Symbol
Scale - Symbol scale for SF Symbols.
- Symbol
Weight - Symbol weight for SF Symbols.
Traits§
- Icon
Name - Trait for types that can provide an SF Symbol name.
Functions§
- cache_
size - Get the number of cached symbols.
- clear_
cache - Clear the global symbol cache.