1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-29 12:50:04 -04:00

Added support for thin space

https://en.wikipedia.org/wiki/Thin_space
This commit is contained in:
Emil Ernerfeldt
2022-11-21 17:33:23 +01:00
parent 1c8cf9e3d5
commit 8671aa26e1
3 changed files with 20 additions and 1 deletions

View File

@@ -156,6 +156,23 @@ impl FontImpl {
}
}
if c == '\u{2009}' {
// Thin space, often used as thousands deliminator: 1234567890
// https://www.compart.com/en/unicode/U+2009
// https://en.wikipedia.org/wiki/Thin_space
if let Some(space) = self.glyph_info(' ') {
let em = self.height_in_points; // TODO(emilk): is this right?
let advance_width = f32::min(em / 6.0, space.advance_width * 0.5);
let glyph_info = GlyphInfo {
advance_width,
..GlyphInfo::default()
};
self.glyph_info_cache.write().insert(c, glyph_info);
return Some(glyph_info);
}
}
// Add new character:
use ab_glyph::Font as _;
let glyph_id = self.ab_glyph_font.glyph_id(c);