Log when system_font feature is off (#8520)

This commit is contained in:
Lucas Meurer authored and GitHub committed 2026-09-07 08:54:37 +00:00
1 parent 83ca91e8d7
commit 7bda288fe6
1 file changed
+33 -2
+33 -2
View File
@@ -147,6 +147,35 @@ pub fn create_storage_with_file(_file: impl Into<PathBuf>) -> Option<Box<dyn epi
// ----------------------------------------------------------------------------
/// Stands in for the system font provider when the `system_fonts` feature is off.
///
/// It never finds a font, but tells you once why nothing was even looked for,
/// so missing CJK/Arabic/emoji glyphs don't look like an egui bug.
#[cfg(not(feature = "system_fonts"))]
#[derive(Default)]
struct MissingSystemFontsWarning {
warned: core::sync::atomic::AtomicBool,
}
#[cfg(not(feature = "system_fonts"))]
impl egui::FontProvider for MissingSystemFontsWarning {
fn font_for(&self, request: &egui::FallbackRequest<'_>) -> Option<egui::FontInsert> {
use core::sync::atomic::Ordering::Relaxed;
if !self.warned.swap(true, Relaxed) {
log::info!(
"No font has {:?}. \
Enable the `system_fonts` feature in `eframe`, \
add a font with `egui::Context::add_font`, \
or set `NativeOptions::system_font_fallback` to `false` to silence this.",
request.cluster
);
}
None
}
}
// ----------------------------------------------------------------------------
/// Everything needed to make a winit-based integration for [`epi`].
///
/// Only one instance per app (not one per viewport).
@@ -217,9 +246,11 @@ impl EpiIntegration {
Some(icon),
);
#[cfg(feature = "system_fonts")]
if native_options.system_font_fallback {
egui_ctx.add_font_provider(Arc::new(egui_system_fonts::SystemFontProvider::new()));
egui_ctx.add_font_provider(cfg_select! {
feature = "system_fonts" => Arc::new(egui_system_fonts::SystemFontProvider::new()),
_ => Arc::new(MissingSystemFontsWarning::default()),
});
}
Self {