Fix: '\t' always take up the width of four spaces
This commit is contained in:
parent
96b642a7f5
commit
4ace85b780
1 changed files with 13 additions and 7 deletions
|
@ -137,6 +137,18 @@ impl FontImpl {
|
|||
// Add new character:
|
||||
use ab_glyph::Font as _;
|
||||
let glyph_id = self.ab_glyph_font.glyph_id(c);
|
||||
|
||||
if c == '\t' {
|
||||
if let Some(space) = self.glyph_info(' ') {
|
||||
let glyph_info = GlyphInfo {
|
||||
advance_width: crate::text::TAB_SIZE as f32 * space.advance_width,
|
||||
..GlyphInfo::default()
|
||||
};
|
||||
self.glyph_info_cache.write().insert(c, glyph_info);
|
||||
return Some(glyph_info);
|
||||
}
|
||||
}
|
||||
|
||||
if glyph_id.0 == 0 {
|
||||
if invisible_char(c) {
|
||||
// hack
|
||||
|
@ -147,7 +159,7 @@ impl FontImpl {
|
|||
None
|
||||
}
|
||||
} else {
|
||||
let mut glyph_info = allocate_glyph(
|
||||
let glyph_info = allocate_glyph(
|
||||
&mut self.atlas.lock(),
|
||||
&self.ab_glyph_font,
|
||||
glyph_id,
|
||||
|
@ -156,12 +168,6 @@ impl FontImpl {
|
|||
self.pixels_per_point,
|
||||
);
|
||||
|
||||
if c == '\t' {
|
||||
if let Some(space) = self.glyph_info(' ') {
|
||||
glyph_info.advance_width = crate::text::TAB_SIZE as f32 * space.advance_width;
|
||||
}
|
||||
}
|
||||
|
||||
self.glyph_info_cache.write().insert(c, glyph_info);
|
||||
Some(glyph_info)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue