diff --git a/crates/epaint/src/text/font.rs b/crates/epaint/src/text/font.rs index 045f42aa702..50500de8482 100644 --- a/crates/epaint/src/text/font.rs +++ b/crates/epaint/src/text/font.rs @@ -139,6 +139,12 @@ impl FontImpl { /// /// See also [`invisible_char`]. fn ignore_character(&self, chr: char) -> bool { + use crate::text::FontDefinitions; + + if !FontDefinitions::builtin_font_names().contains(&self.name.as_str()) { + return false; + } + if self.name == "emoji-icon-font" { // HACK: https://github.com/emilk/egui/issues/1284 https://github.com/jslegers/emoji-icon-font/issues/18 // Don't show the wrong fullwidth capital letters: diff --git a/crates/epaint/src/text/fonts.rs b/crates/epaint/src/text/fonts.rs index 177c7327819..1f54a5f6489 100644 --- a/crates/epaint/src/text/fonts.rs +++ b/crates/epaint/src/text/fonts.rs @@ -335,6 +335,23 @@ impl FontDefinitions { families, } } + + /// List of all the builtin font names used by `epaint`. + #[cfg(feature = "default_fonts")] + pub fn builtin_font_names() -> &'static [&'static str] { + &[ + "Ubuntu-Light", + "NotoEmoji-Regular", + "emoji-icon-font", + "Hack", + ] + } + + /// List of all the builtin font names used by `epaint`. + #[cfg(not(feature = "default_fonts"))] + pub fn builtin_font_names() -> &'static [&'static str] { + &[] + } } // ----------------------------------------------------------------------------