Files
gpui-native-kit/crates/icons/src/segoe.rs
T
2026-11-10 20:14:26 +07:00

54 lines
2.2 KiB
Rust

//! Windows resolver: each role maps to a Segoe Fluent Icons codepoint,
//! rendered as text in the system font (never bundled).
use crate::IconRole;
/// The Segoe Fluent Icons glyph for the role.
pub(crate) fn glyph(role: IconRole) -> Option<&'static str> {
let glyph = match role {
IconRole::Check => "\u{E73E}", // CheckMark
IconRole::Close => "\u{E8BB}", // ChromeClose
IconRole::ChevronDown => "\u{E70D}", // ChevronDown
IconRole::ChevronLeft => "\u{E76B}", // ChevronLeft
IconRole::ChevronRight => "\u{E76C}", // ChevronRight
IconRole::ChevronUp => "\u{E70E}", // ChevronUp
IconRole::Plus => "\u{E710}", // Add
IconRole::Minus => "\u{E738}", // Remove
IconRole::Search => "\u{E721}", // Search
IconRole::Folder => "\u{E8B7}", // Folder
IconRole::Warning => "\u{E7BA}", // Warning
IconRole::Info => "\u{E946}", // Info
IconRole::Copy => "\u{E8C8}", // Copy
IconRole::Eye => "\u{E7B3}", // RedEye
IconRole::EyeOff => "\u{ED1A}", // Hide
IconRole::PanelLeft => "\u{E90C}", // DockLeft
IconRole::PanelRight => "\u{E90D}", // DockRight
IconRole::WindowMinimize => "\u{E921}", // ChromeMinimize
IconRole::WindowMaximize => "\u{E922}", // ChromeMaximize
IconRole::WindowRestore => "\u{E923}", // ChromeRestore
IconRole::Microphone => "\u{E720}", // Microphone
IconRole::Stop => "\u{E71A}", // Stop
// No Segoe spinner glyph, the icon falls back to the bundled SVG.
IconRole::Loader => return None,
};
Some(glyph)
}
/// The system font the codepoints resolve against (Windows 11+).
pub(crate) const FONT_FAMILY: &str = "Segoe Fluent Icons";
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn every_role_maps_a_codepoint_or_falls_back_to_the_bundled_svg() {
for role in crate::IconRole::all() {
assert!(
glyph(*role).is_some() || crate::asset_bytes(role.asset_path()).is_some(),
"no Segoe codepoint or bundled asset for {role:?}"
);
}
}
}