Initial impl
This commit is contained in:
commit
4b729c5d32
133 files changed
+20475
No files matched your search
@@ -0,0 +1,36 @@
|
||||
//! Every non-ASCII character in the UI code must be drawable with the
|
||||
//! bundled fonts (a missing glyph panics in debug builds).
|
||||
|
||||
#[test]
|
||||
fn ui_symbols_exist_in_the_bundled_fonts() {
|
||||
let mut harness = egui_kittest::Harness::new_ui(|_ui| {});
|
||||
harness.step();
|
||||
let ctx = harness.ctx.clone();
|
||||
let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("src/ui");
|
||||
let mut missing = Vec::new();
|
||||
for entry in std::fs::read_dir(dir).unwrap() {
|
||||
let path = entry.unwrap().path();
|
||||
let src = std::fs::read_to_string(&path).unwrap();
|
||||
for (n, line) in src.lines().enumerate() {
|
||||
// Only string literals in code matter, not comments.
|
||||
if line.trim_start().starts_with("//") {
|
||||
continue;
|
||||
}
|
||||
for c in line.chars().filter(|c| !c.is_ascii()) {
|
||||
for family in [egui::FontFamily::Proportional, egui::FontFamily::Monospace] {
|
||||
let ok = ctx.fonts_mut(|f| f.has_glyph(&egui::FontId::new(14.0, family.clone()), c));
|
||||
if !ok {
|
||||
missing.push(format!(
|
||||
"{c:?} (U+{:04X}) {family:?} at {}:{}",
|
||||
c as u32,
|
||||
path.display(),
|
||||
n + 1
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
missing.dedup();
|
||||
assert!(missing.is_empty(), "missing glyphs:\n{}", missing.join("\n"));
|
||||
}
|
||||
Reference in new issue
Block a user