Don't draw bidi control characters
Closes https://github.com/emilk/egui/issues/336
This commit is contained in:
parent
7da9928548
commit
bf8ce774cc
1 changed files with 16 additions and 1 deletions
|
@ -108,7 +108,14 @@ impl FontImpl {
|
|||
// Add new character:
|
||||
let glyph = self.rusttype_font.glyph(c);
|
||||
if glyph.id().0 == 0 {
|
||||
None
|
||||
if invisible_char(c) {
|
||||
// hack
|
||||
let glyph_info = GlyphInfo::default();
|
||||
self.glyph_info_cache.write().insert(c, glyph_info);
|
||||
Some(glyph_info)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} else {
|
||||
let mut glyph_info = allocate_glyph(
|
||||
&mut self.atlas.lock(),
|
||||
|
@ -588,6 +595,14 @@ fn is_chinese(c: char) -> bool {
|
|||
|| ('\u{2B740}' <= c && c <= '\u{2B81F}')
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn invisible_char(c: char) -> bool {
|
||||
// See https://github.com/emilk/egui/issues/336
|
||||
|
||||
// From https://www.fileformat.info/info/unicode/category/Cf/list.htm
|
||||
('\u{200B}'..='\u{206F}').contains(&c) // TODO: heed bidi characters
|
||||
}
|
||||
|
||||
fn allocate_glyph(
|
||||
atlas: &mut TextureAtlas,
|
||||
glyph: rusttype::Glyph<'static>,
|
||||
|
|
Loading…
Reference in a new issue