Merge pull request #3286 from batistalucasv/fix/font-picker-warning-filled

font-manager: use filled warning triangle icon in FontPicker (storytold/wordcraft#7684)
This commit is contained in:
Martin Ball
2026-11-25 09:35:13 +00:00
committed by GitHub
5 changed files with 66 additions and 2 deletions
+1 -1
View File
@@ -529,7 +529,7 @@ const TEXT: PartKey = PartKey::new("text");
const CHEVRON: PartKey = PartKey::new("chevron");
/// The mark before the chevron of a shown font that is not installed; its tooltip is the note.
const WARNING: PartKey = PartKey::new("missing");
const WARNING_ICON: &str = "warning";
const WARNING_ICON: &str = "warning_filled";
/// The popup the chevron and Alt+Down toggle.
const POPUP: &str = "list";
/// The Show Similar part at the end of a family row, in the `Chips` layout.
+58
View File
@@ -806,6 +806,64 @@ fn the_missing_font_warning_icon_paints_in_status_warn_fg_and_dims_when_disabled
);
}
/// Texture ids of textured meshes whose centre falls inside `rect`.
fn mesh_textures(shapes: &[egui::Shape], rect: egui::Rect, out: &mut Vec<egui::TextureId>) {
for shape in shapes {
match shape {
egui::Shape::Vec(inner) => mesh_textures(inner, rect, out),
egui::Shape::Mesh(mesh) if rect.contains(mesh.calc_bounds().center()) => {
out.push(mesh.texture_id);
}
_ => {}
}
}
}
#[trial]
fn the_missing_font_warning_icon_is_a_filled_triangle() {
use std::cell::Cell;
let catalog = catalog_of(&[INTER_REGULAR]);
let seen = Rc::new(Cell::new(None));
let held = Rc::clone(&seen);
let mut family = "Gotham".to_owned();
let mut fx = Fixture::new(move |ui| {
let out = FontPicker::new("Font family", Bind::bound(&mut family), &catalog).kind(FontPickerKind::Plain).shown_as("Inter").show(ui);
held.set(Some(out.edit.response.id));
});
fx.pixels_per_point(2.0);
fx.record_paint();
fx.in_room(Room::Window);
fx.settle();
let picker = seen.get().expect("the picker");
let mark = fx.part_rect(picker, PartKey::new("missing")).expect("the field carries a mark while the family is not installed");
let mut paint = fx.take_paint().expect("recorded paint output");
let mut textures = Vec::new();
for clipped in &paint.shapes {
mesh_textures(std::slice::from_ref(&clipped.shape), mark, &mut textures);
}
let texture = *textures.first().expect("the missing-font warning icon paints a texture");
let image = paint
.textures_delta
.set
.get(&texture)
.and_then(|deltas| deltas.last())
.map(|delta| match &delta.image {
egui::ImageData::Color(color) => color,
})
.expect("the warning icon texture was uploaded");
let [w, h] = image.size;
let alpha = |fx: f32, fy: f32| {
let x = ((w as f32 * fx) as usize).min(w - 1);
let y = ((h as f32 * fy) as usize).min(h - 1);
image.pixels[y * w + x].a()
};
let (left, right, center) = (alpha(0.34, 0.69), alpha(0.66, 0.69), alpha(0.50, 0.48));
paint.textures_delta.clear();
assert!(left > 128 && right > 128, "the triangle interior is filled, not an outline (left={left}, right={right}, size={w}x{h})");
assert!(center < 128, "the exclamation stem stays knocked out inside the filled triangle (center={center})");
}
/// The library picker's family and settings, as the last pass left them.
struct Library {
family: String,
+1 -1
View File
@@ -11,7 +11,7 @@ Each folder holds only the files `icons.toml` lists, unchanged from the pinned s
Carbon's licence file is the repository's root `LICENSE` (the icons package has none of its own).
Every set folder's files come from the npm package of the version in the table (`@phosphor-icons/core` 2.0.8, `lucide-static` 1.63.0, `@carbon/icons` 11.91.0, `@tabler/icons` 3.50.0), the same releases as the tags above. Phosphor files are `regular` weight, except `star-filled.svg` and `circle-filled.svg`, which are Phosphor's `fill` weight (`star-fill.svg`, `circle-fill.svg`). `panel-left.svg` is Phosphor's `sidebar-simple` unchanged, and `panel-right.svg` is the same glyph mirrored.
Every set folder's files come from the npm package of the version in the table (`@phosphor-icons/core` 2.0.8, `lucide-static` 1.63.0, `@carbon/icons` 11.91.0, `@tabler/icons` 3.50.0), the same releases as the tags above. Phosphor files are `regular` weight, except `star-filled.svg`, `circle-filled.svg` and `warning-filled.svg`, which are Phosphor's `fill` weight (`star-fill.svg`, `circle-fill.svg`, `warning-fill.svg`). `panel-left.svg` is Phosphor's `sidebar-simple` unchanged, and `panel-right.svg` is the same glyph mirrored.
`phosphor/` also holds drawings made for the suite, for glyphs the pinned Phosphor release lacks. They follow Phosphor's regular style (256 view box, 16-unit round-capped strokes, some converted to filled outlines), take their shapes from PhotoCraft's glyphs, and carry the suite's own licence:
+5
View File
@@ -454,6 +454,11 @@ phosphor = "warning"
carbon = "warning--alt"
tabler = "alert-triangle"
[[icon]]
name = "warning_filled"
directional = false
phosphor = "warning-filled"
[[icon]]
name = "web_colors"
directional = false
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M236.8,188.09,149.35,36.22h0a24.76,24.76,0,0,0-42.7,0L19.2,188.09a23.51,23.51,0,0,0,0,23.72A24.35,24.35,0,0,0,40.55,224h174.9a24.35,24.35,0,0,0,21.33-12.19A23.51,23.51,0,0,0,236.8,188.09ZM120,104a8,8,0,0,1,16,0v40a8,8,0,0,1-16,0Zm8,88a12,12,0,1,1,12-12A12,12,0,0,1,128,192Z"/></svg>

After

Width:  |  Height:  |  Size: 373 B