Skip to content

Commit

Permalink
Limit FontImpl::ignore_character to builtin fonts only
Browse files Browse the repository at this point in the history
The ignored characters are used in some custom fonts.

for example: the \u{F0FF} is used as `cleaning_services` in MaterialIcons-Regular.ttf
  • Loading branch information
varphone committed Oct 27, 2023
1 parent fd75adb commit 3e6cd74
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/epaint/src/text/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
17 changes: 17 additions & 0 deletions crates/epaint/src/text/fonts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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] {
&[]
}
}

// ----------------------------------------------------------------------------
Expand Down

0 comments on commit 3e6cd74

Please sign in to comment.