gpui_symbols/
lib.rs

1//! # gpui-symbols
2//!
3//! SF Symbols rendering for GPUI applications on macOS.
4//!
5//! This crate provides two levels of API:
6//!
7//! 1. **`SfSymbol`** - Low-level builder for rendering SF Symbols to raw RGBA pixels
8//!    or GPUI `RenderImage`.
9//!
10//! 2. **`Icon`** (requires `component` feature) - High-level GPUI component that can
11//!    be used directly in views, similar to GPUI Components.
12//!
13//! ## Features
14//!
15//! - `gpui` - Enable GPUI integration (converts to `RenderImage`)
16//! - `component` - Enable high-level `Icon` component (implies `gpui`)
17//!
18//! ## Example: Using SfSymbol
19//!
20//! ```rust,ignore
21//! use gpui_symbols::SfSymbol;
22//!
23//! // Render to raw RGBA pixels
24//! let (width, height, data) = SfSymbol::new("star.fill")
25//!     .size(32.0)
26//!     .color(0x000000)
27//!     .render_rgba()
28//!     .unwrap();
29//!
30//! // With GPUI feature enabled:
31//! let image = SfSymbol::new("star.fill").render().unwrap();
32//! ```
33//!
34//! ## Example: Using Icon Component
35//!
36//! ```rust,ignore
37//! use gpui_symbols::{Icon, define_icons};
38//! use gpui::px;
39//!
40//! // Define your own icon enum
41//! define_icons! {
42//!     pub enum AppIcon {
43//!         Star => "star.fill",
44//!         Heart => "heart.fill",
45//!         Settings => "gearshape.fill",
46//!     }
47//! }
48//!
49//! // Use in a view
50//! fn view(window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
51//!     div()
52//!         .child(Icon::new("star.fill"))
53//!         .child(Icon::from_name(AppIcon::Heart).text_color(0xFF0000))
54//! }
55//! ```
56
57mod platform;
58mod symbol;
59
60#[cfg(feature = "component")]
61mod icon;
62
63// Re-export main types
64pub use symbol::{RenderingMode, SfSymbol, SymbolScale, SymbolWeight};
65
66// Re-export cache functions
67#[cfg(feature = "cache")]
68pub use symbol::{cache_size, clear_cache};
69
70#[cfg(feature = "component")]
71pub use icon::{Icon, IconName};
72
73// Re-export sfsymbols presets
74#[cfg(feature = "presets")]
75pub use sfsymbols;