mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 13:20:05 -04:00
Move default fonts to new crate epaint_default_fonts (#4853)
This allows license checking tools to omit the OFL and UFL licenses when `default_fonts` are turned off. There was some discussion of versioning on the original issue; I have chosen to label this version as `0.28.1` to match the other crates. Happy to adjust the version as needed. <!-- 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. * The PR title is what ends up in the changelog, so make it descriptive! * 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 test and add commits to your PR. * Remember to run `cargo fmt` and `cargo clippy`. * 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 your PR, but my time is limited! --> * Closes <https://github.com/emilk/egui/issues/2321> * [X] I have followed the instructions in the PR template --------- Co-authored-by: Alex Pinkus <pinkus@amazon.com>
This commit is contained in:
@@ -10,6 +10,9 @@ use crate::{
|
||||
};
|
||||
use emath::{NumExt as _, OrderedFloat};
|
||||
|
||||
#[cfg(feature = "default_fonts")]
|
||||
use epaint_default_fonts::{EMOJI_ICON, HACK_REGULAR, NOTO_EMOJI_REGULAR, UBUNTU_LIGHT};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/// How to select a sized font.
|
||||
@@ -217,7 +220,7 @@ fn ab_glyph_font_from_font_data(name: &str, data: &FontData) -> ab_glyph::FontAr
|
||||
///
|
||||
/// // Install my own font (maybe supporting non-latin characters):
|
||||
/// fonts.font_data.insert("my_font".to_owned(),
|
||||
/// FontData::from_static(include_bytes!("../../fonts/Ubuntu-Light.ttf"))); // .ttf and .otf supported
|
||||
/// FontData::from_static(include_bytes!("../../../epaint_default_fonts/fonts/Ubuntu-Light.ttf"))); // .ttf and .otf supported
|
||||
///
|
||||
/// // Put my font first (highest priority):
|
||||
/// fonts.families.get_mut(&FontFamily::Proportional).unwrap()
|
||||
@@ -263,39 +266,32 @@ impl Default for FontDefinitions {
|
||||
|
||||
let mut families = BTreeMap::new();
|
||||
|
||||
font_data.insert(
|
||||
"Hack".to_owned(),
|
||||
FontData::from_static(include_bytes!("../../fonts/Hack-Regular.ttf")),
|
||||
);
|
||||
font_data.insert("Hack".to_owned(), FontData::from_static(HACK_REGULAR));
|
||||
font_data.insert(
|
||||
"Ubuntu-Light".to_owned(),
|
||||
FontData::from_static(include_bytes!("../../fonts/Ubuntu-Light.ttf")),
|
||||
FontData::from_static(UBUNTU_LIGHT),
|
||||
);
|
||||
|
||||
// Some good looking emojis. Use as first priority:
|
||||
font_data.insert(
|
||||
"NotoEmoji-Regular".to_owned(),
|
||||
FontData::from_static(include_bytes!("../../fonts/NotoEmoji-Regular.ttf")).tweak(
|
||||
FontTweak {
|
||||
scale: 0.81, // make it smaller
|
||||
..Default::default()
|
||||
},
|
||||
),
|
||||
FontData::from_static(NOTO_EMOJI_REGULAR).tweak(FontTweak {
|
||||
scale: 0.81, // make it smaller
|
||||
..Default::default()
|
||||
}),
|
||||
);
|
||||
|
||||
// Bigger emojis, and more. <http://jslegers.github.io/emoji-icon-font/>:
|
||||
font_data.insert(
|
||||
"emoji-icon-font".to_owned(),
|
||||
FontData::from_static(include_bytes!("../../fonts/emoji-icon-font.ttf")).tweak(
|
||||
FontTweak {
|
||||
scale: 0.88, // make it smaller
|
||||
FontData::from_static(EMOJI_ICON).tweak(FontTweak {
|
||||
scale: 0.88, // make it smaller
|
||||
|
||||
// probably not correct, but this does make texts look better (#2724 for details)
|
||||
y_offset_factor: 0.11, // move glyphs down to better align with common fonts
|
||||
baseline_offset_factor: -0.11, // ...now the entire row is a bit down so shift it back
|
||||
..Default::default()
|
||||
},
|
||||
),
|
||||
// probably not correct, but this does make texts look better (#2724 for details)
|
||||
y_offset_factor: 0.11, // move glyphs down to better align with common fonts
|
||||
baseline_offset_factor: -0.11, // ...now the entire row is a bit down so shift it back
|
||||
..Default::default()
|
||||
}),
|
||||
);
|
||||
|
||||
families.insert(
|
||||
|
||||
Reference in New Issue
Block a user