Crate gpui_symbols

Crate gpui_symbols 

Source
Expand description

§gpui-symbols

SF Symbols rendering for GPUI applications on macOS.

This crate provides two levels of API:

  1. SfSymbol - Low-level builder for rendering SF Symbols to raw RGBA pixels or GPUI RenderImage.

  2. Icon (requires component feature) - High-level GPUI component that can be used directly in views, similar to GPUI Components.

§Features

  • gpui - Enable GPUI integration (converts to RenderImage)
  • component - Enable high-level Icon component (implies gpui)

§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§

RenderingMode
Rendering mode for SF Symbols.
SymbolScale
Symbol scale for SF Symbols.
SymbolWeight
Symbol weight for SF Symbols.

Traits§

IconName
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.