add windows theme source and platform icon resolvers

This commit is contained in:
2026-10-31 08:56:57 +07:00
parent c45f939211
commit d53f4e290d
13 changed files with 895 additions and 36 deletions
+43
View File
@@ -0,0 +1,43 @@
//! 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 codepoint for the role.
pub(crate) fn glyph(role: IconRole) -> Option<char> {
let codepoint = match role {
IconRole::Check => 0xE73E, // CheckMark
IconRole::Close => 0xE8BB, // ChromeClose
IconRole::ChevronDown => 0xE70D, // ChevronDown
IconRole::ChevronLeft => 0xE76B, // ChevronLeft
IconRole::ChevronRight => 0xE76C, // ChevronRight
IconRole::ChevronUp => 0xE70E, // ChevronUp
IconRole::Plus => 0xE710, // Add
IconRole::Minus => 0xE738, // Remove
IconRole::Search => 0xE721, // Search
IconRole::Folder => 0xE8B7, // Folder
IconRole::Warning => 0xE7BA, // Warning
IconRole::Info => 0xE946, // Info
};
char::from_u32(codepoint)
}
/// 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_to_a_codepoint() {
for role in crate::IconRole::all() {
assert!(glyph(*role).is_some(), "missing codepoint for {role:?}");
}
}
#[test]
fn the_close_role_uses_the_chrome_close_glyph() {
assert_eq!(glyph(IconRole::Close), Some('\u{E8BB}'));
}
}