Skip to content

Commit

Permalink
Fix: allow using the full Private Use Area for custom fonts (#3509)
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

<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to add commits to your PR.
* Remember to run `cargo fmt` and `cargo cranky`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review you PR, but my time is limited!
-->

Closes <https://github.com/emilk/egui/issues/THE_RELEVANT_ISSUE>.

---------

Co-authored-by: Emil Ernerfeldt <[email protected]>
  • Loading branch information
varphone and emilk authored Jan 6, 2024
1 parent 5a6d1cb commit 932fdae
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 932fdae

Please sign in to comment.