mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 12:50:04 -04:00
Switch the default egui font to Albert Sans
Follows the same approach as #8261: replaces Ubuntu-Light with a variable font hinted via ttfautohint, updates fallback references, loosens a couple of tests that hard-coded font-specific pixel values, and regenerates all visual snapshots. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -362,7 +362,7 @@ impl core::fmt::Debug for ColorImage {
|
||||
/// (which would require more atlas space, but would allow for more accurate rendering of colored text and emojis),
|
||||
/// or do the color compensation in the shader, based on the active text color.
|
||||
///
|
||||
/// When experimenting, use <https://fonts.google.com/specimen/Ubuntu> to compare to a ground truth.
|
||||
/// When experimenting, use <https://fonts.google.com/specimen/Albert+Sans> to compare to a ground truth.
|
||||
///
|
||||
/// See <https://hikogui.org/2022/10/24/the-trouble-with-anti-aliasing.html> for related analysis.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
||||
|
||||
@@ -452,10 +452,7 @@ impl FontFace {
|
||||
matches!(
|
||||
chr,
|
||||
// Strip out a religious symbol with secondary nefarious interpretation:
|
||||
'\u{534d}' | '\u{5350}' |
|
||||
|
||||
// Ignore ubuntu-specific stuff in `Ubuntu-Light.ttf`:
|
||||
'\u{E0FF}' | '\u{EFFD}' | '\u{F0FF}' | '\u{F200}'
|
||||
'\u{534d}' | '\u{5350}'
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ use crate::{
|
||||
use emath::{NumExt as _, OrderedFloat, Rangef};
|
||||
|
||||
#[cfg(feature = "default_fonts")]
|
||||
use epaint_default_fonts::{EMOJI_ICON, HACK_REGULAR, NOTO_EMOJI_REGULAR, UBUNTU_LIGHT};
|
||||
use epaint_default_fonts::{ALBERT_SANS, EMOJI_ICON, HACK_REGULAR, NOTO_EMOJI_REGULAR};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@@ -411,7 +411,7 @@ fn blob_from_font_data(data: &FontData) -> Blob {
|
||||
/// fonts.font_data.insert("my_font".to_owned(),
|
||||
/// std::sync::Arc::new(
|
||||
/// // .ttf and .otf supported
|
||||
/// FontData::from_static(include_bytes!("../../../epaint_default_fonts/fonts/Ubuntu-Light.ttf"))
|
||||
/// FontData::from_static(include_bytes!("../../../epaint_default_fonts/fonts/AlbertSans-VariableFont_wght.ttf"))
|
||||
/// )
|
||||
/// );
|
||||
///
|
||||
@@ -518,8 +518,13 @@ impl Default for FontDefinitions {
|
||||
);
|
||||
|
||||
font_data.insert(
|
||||
"Ubuntu-Light".to_owned(),
|
||||
Arc::new(FontData::from_static(UBUNTU_LIGHT)),
|
||||
"Albert Sans".to_owned(),
|
||||
// Albert Sans is a variable font; a slightly-lighter-than-regular weight
|
||||
// looks best for UI text.
|
||||
Arc::new(FontData::from_static(ALBERT_SANS).tweak(FontTweak {
|
||||
coords: VariationCoords::new([(b"wght", 350.0)]),
|
||||
..Default::default()
|
||||
})),
|
||||
);
|
||||
|
||||
// Bigger emojis, and more. <http://jslegers.github.io/emoji-icon-font/>:
|
||||
@@ -535,7 +540,7 @@ impl Default for FontDefinitions {
|
||||
FontFamily::Monospace,
|
||||
vec![
|
||||
"Hack".to_owned(),
|
||||
"Ubuntu-Light".to_owned(), // fallback for √ etc
|
||||
"Albert Sans".to_owned(), // fallback for √ etc
|
||||
"NotoEmoji-Regular".to_owned(),
|
||||
"emoji-icon-font".to_owned(),
|
||||
],
|
||||
@@ -543,7 +548,7 @@ impl Default for FontDefinitions {
|
||||
families.insert(
|
||||
FontFamily::Proportional,
|
||||
vec![
|
||||
"Ubuntu-Light".to_owned(),
|
||||
"Albert Sans".to_owned(),
|
||||
"NotoEmoji-Regular".to_owned(),
|
||||
"emoji-icon-font".to_owned(),
|
||||
],
|
||||
@@ -573,7 +578,7 @@ impl FontDefinitions {
|
||||
#[cfg(feature = "default_fonts")]
|
||||
pub fn builtin_font_names() -> &'static [&'static str] {
|
||||
&[
|
||||
"Ubuntu-Light",
|
||||
"Albert Sans",
|
||||
"NotoEmoji-Regular",
|
||||
"emoji-icon-font",
|
||||
"Hack",
|
||||
|
||||
@@ -1905,10 +1905,15 @@ mod tests {
|
||||
);
|
||||
|
||||
// Round-trip: position → cursor → position should be stable.
|
||||
//
|
||||
// A continuation glyph mid-cluster is placed at the pixel-rounded
|
||||
// cursor position, which can differ from the analytic (unrounded)
|
||||
// position by up to one physical pixel depending on the font's
|
||||
// glyph advance widths, so allow a one-pixel slack here.
|
||||
let cursor2 = galley.cursor_from_pos(Vec2::new(rect.center().x, rect.center().y));
|
||||
let rect2 = galley.pos_from_cursor(cursor2);
|
||||
assert!(
|
||||
(rect.min.x - rect2.min.x).abs() < 1.0,
|
||||
(rect.min.x - rect2.min.x).abs() <= 1.0,
|
||||
"Cursor round-trip unstable at index {i}: \
|
||||
first={}, second={}, cursor2.index={}",
|
||||
rect.min.x,
|
||||
|
||||
Reference in New Issue
Block a user