fix(icons): Material icons at Lucide size, native window buttons
- icons that replace Lucide are served with a view box cropped to the glyph area (1.2x), matching the old sizes - window minimize, maximize, restore and close keep the native Windows glyphs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -211,7 +211,7 @@ const SYMBOLS: [(&str, &[u8]); 200] = symbols![
211
211
"zoom_out",
212
212
];
213
213
214
const LUCIDE_AS_MATERIAL: [(&str, &str); 163] = [
214
const LUCIDE_AS_MATERIAL: [(&str, &str); 159] = [
215
215
("icons/alarm-clock.svg", "symbols/alarm.svg"),
216
216
("icons/app-window.svg", "symbols/web_asset.svg"),
217
217
("icons/arrow-down.svg", "symbols/arrow_downward.svg"),
@@ -368,23 +368,32 @@ const LUCIDE_AS_MATERIAL: [(&str, &str); 163] = [
368
368
("icons/video-off.svg", "symbols/videocam_off.svg"),
369
369
("icons/volume-2.svg", "symbols/volume_up.svg"),
370
370
("icons/volume-off.svg", "symbols/volume_off.svg"),
371
("icons/window-close.svg", "symbols/close.svg"),
372
("icons/window-maximize.svg", "symbols/crop_square.svg"),
373
("icons/window-minimize.svg", "symbols/minimize.svg"),
374
("icons/window-restore.svg", "symbols/filter_none.svg"),
375
371
("icons/wrench.svg", "symbols/build.svg"),
376
372
("icons/x.svg", "symbols/close.svg"),
377
373
("icons/zap.svg", "symbols/bolt.svg"),
378
374
];
379
375
376
const MATERIAL_VIEW_BOX: &[u8] = b"viewBox=\"0 -960 960 960\"";
377
const LUCIDE_SIZED_VIEW_BOX: &[u8] = b"viewBox=\"80 -880 800 800\"";
378
379
fn symbol_bytes(path: &str) -> Option<&'static [u8]> {
380
SYMBOLS.iter().find(|(name, _)| *name == path).map(|(_, bytes)| *bytes)
381
}
382
383
fn at_lucide_size(svg: &[u8]) -> Vec<u8> {
384
match svg.windows(MATERIAL_VIEW_BOX.len()).position(|window| window == MATERIAL_VIEW_BOX) {
385
Some(start) => [&svg[..start], LUCIDE_SIZED_VIEW_BOX, &svg[start + MATERIAL_VIEW_BOX.len()..]].concat(),
386
None => svg.to_vec(),
387
}
388
}
389
380
390
pub struct AppAssets;
381
391
382
392
impl AssetSource for AppAssets {
383
393
fn load(&self, path: &str) -> Result<Option<Cow<'static, [u8]>>> {
384
let path = LUCIDE_AS_MATERIAL
385
.iter()
386
.find(|(lucide, _)| *lucide == path)
387
.map_or(path, |(_, material)| *material);
394
if let Some((_, material)) = LUCIDE_AS_MATERIAL.iter().find(|(lucide, _)| *lucide == path) {
395
return Ok(symbol_bytes(material).map(|bytes| Cow::Owned(at_lucide_size(bytes))));
396
}
388
397
if let Some((_, bytes)) = SYMBOLS.iter().find(|(name, _)| *name == path) {
389
398
return Ok(Some(Cow::Borrowed(bytes)));
390
399
}
@@ -413,6 +422,7 @@ mod tests {
413
422
assert!(SYMBOLS.iter().any(|(name, _)| *name == material), "{lucide} -> {material}");
414
423
let bytes = AppAssets.load(lucide).unwrap().unwrap();
415
424
assert!(bytes.starts_with(b"<svg"), "{lucide}");
425
assert!(bytes.windows(LUCIDE_SIZED_VIEW_BOX.len()).any(|window| window == LUCIDE_SIZED_VIEW_BOX), "{lucide}");
416
426
}
417
427
}
418
428
}
@@ -211,7 +211,7 @@ const SYMBOLS: [(&str, &[u8]); 200] = symbols![211
"zoom_out",211
"zoom_out",212
];212
];213
213
214
const LUCIDE_AS_MATERIAL: [(&str, &str); 163] = [214
const LUCIDE_AS_MATERIAL: [(&str, &str); 159] = [215
("icons/alarm-clock.svg", "symbols/alarm.svg"),215
("icons/alarm-clock.svg", "symbols/alarm.svg"),216
("icons/app-window.svg", "symbols/web_asset.svg"),216
("icons/app-window.svg", "symbols/web_asset.svg"),217
("icons/arrow-down.svg", "symbols/arrow_downward.svg"),217
("icons/arrow-down.svg", "symbols/arrow_downward.svg"),@@ -368,23 +368,32 @@ const LUCIDE_AS_MATERIAL: [(&str, &str); 163] = [368
("icons/video-off.svg", "symbols/videocam_off.svg"),368
("icons/video-off.svg", "symbols/videocam_off.svg"),369
("icons/volume-2.svg", "symbols/volume_up.svg"),369
("icons/volume-2.svg", "symbols/volume_up.svg"),370
("icons/volume-off.svg", "symbols/volume_off.svg"),370
("icons/volume-off.svg", "symbols/volume_off.svg"),371
("icons/window-close.svg", "symbols/close.svg"),372
("icons/window-maximize.svg", "symbols/crop_square.svg"),373
("icons/window-minimize.svg", "symbols/minimize.svg"),374
("icons/window-restore.svg", "symbols/filter_none.svg"),375
("icons/wrench.svg", "symbols/build.svg"),371
("icons/wrench.svg", "symbols/build.svg"),376
("icons/x.svg", "symbols/close.svg"),372
("icons/x.svg", "symbols/close.svg"),377
("icons/zap.svg", "symbols/bolt.svg"),373
("icons/zap.svg", "symbols/bolt.svg"),378
];374
];379
375
376
const MATERIAL_VIEW_BOX: &[u8] = b"viewBox=\"0 -960 960 960\"";377
const LUCIDE_SIZED_VIEW_BOX: &[u8] = b"viewBox=\"80 -880 800 800\"";378
379
fn symbol_bytes(path: &str) -> Option<&'static [u8]> {380
SYMBOLS.iter().find(|(name, _)| *name == path).map(|(_, bytes)| *bytes)381
}382
383
fn at_lucide_size(svg: &[u8]) -> Vec<u8> {384
match svg.windows(MATERIAL_VIEW_BOX.len()).position(|window| window == MATERIAL_VIEW_BOX) {385
Some(start) => [&svg[..start], LUCIDE_SIZED_VIEW_BOX, &svg[start + MATERIAL_VIEW_BOX.len()..]].concat(),386
None => svg.to_vec(),387
}388
}389
380
pub struct AppAssets;390
pub struct AppAssets;381
391
382
impl AssetSource for AppAssets {392
impl AssetSource for AppAssets {383
fn load(&self, path: &str) -> Result<Option<Cow<'static, [u8]>>> {393
fn load(&self, path: &str) -> Result<Option<Cow<'static, [u8]>>> {384
let path = LUCIDE_AS_MATERIAL394
if let Some((_, material)) = LUCIDE_AS_MATERIAL.iter().find(|(lucide, _)| *lucide == path) {385
.iter()395
return Ok(symbol_bytes(material).map(|bytes| Cow::Owned(at_lucide_size(bytes))));386
.find(|(lucide, _)| *lucide == path)396
}387
.map_or(path, |(_, material)| *material);388
if let Some((_, bytes)) = SYMBOLS.iter().find(|(name, _)| *name == path) {397
if let Some((_, bytes)) = SYMBOLS.iter().find(|(name, _)| *name == path) {389
return Ok(Some(Cow::Borrowed(bytes)));398
return Ok(Some(Cow::Borrowed(bytes)));390
}399
}@@ -413,6 +422,7 @@ mod tests {413
assert!(SYMBOLS.iter().any(|(name, _)| *name == material), "{lucide} -> {material}");422
assert!(SYMBOLS.iter().any(|(name, _)| *name == material), "{lucide} -> {material}");414
let bytes = AppAssets.load(lucide).unwrap().unwrap();423
let bytes = AppAssets.load(lucide).unwrap().unwrap();415
assert!(bytes.starts_with(b"<svg"), "{lucide}");424
assert!(bytes.starts_with(b"<svg"), "{lucide}");425
assert!(bytes.windows(LUCIDE_SIZED_VIEW_BOX.len()).any(|window| window == LUCIDE_SIZED_VIEW_BOX), "{lucide}");416
}426
}417
}427
}418
}428
}