iris: add replaceable glyph atlas buckets

This commit is contained in:
iris committed 2026-09-12 18:10:55 -04:00
1 parent c97df72015
commit 90dffce514
12 files changed
+401 -91

No files matched your search

+37
View File
@@ -550,6 +550,43 @@ mod apply_tests {
assert!(!rsc.widgets().has_updates());
}
#[test]
fn replacing_a_font_only_clears_its_glyph_bucket() {
let mut rsc = TestRsc {
ui: Ui::default(),
events: EventManager::default(),
};
rsc.ui.resize((800.0, 600.0));
rsc.ui
.register_font_in("first-icons", "first", ICON_FONT)
.unwrap();
rsc.ui
.register_font_in("second-icons", "second", ICON_FONT)
.unwrap();
let first = wtext(icon::OPEN)
.family("first-icons")
.add_strong(&mut rsc)
.any();
let second = wtext(icon::OPEN)
.family("second-icons")
.add_strong(&mut rsc)
.any();
rsc.draw(&first);
rsc.draw(&second);
let glyphs_before = rsc.ui.text.borrow().atlas.glyph_count();
let pages_before = rsc.ui.text.borrow().atlas.page_count();
assert_eq!((glyphs_before, pages_before), (2, 2));
rsc.ui.replace_font("first-icons", ICON_FONT).unwrap();
assert_eq!(rsc.ui.text.borrow().atlas.glyph_count(), 1);
assert_eq!(rsc.ui.text.borrow().atlas.page_count(), 1);
rsc.draw(&first);
assert_eq!(rsc.ui.text.borrow().atlas.glyph_count(), 2);
assert_eq!(rsc.ui.text.borrow().atlas.page_count(), 2);
}
fn cost_of_one_delta(paragraphs: usize) -> (u64, u64) {
let mut rsc = TestRsc {
ui: Ui::default(),