diff options
author | Zac Pullar-Strecker <zacps@users.noreply.github.com> | 2018-10-21 09:16:26 +1300 |
---|---|---|
committer | Christian Duerr <chrisduerr@users.noreply.github.com> | 2018-10-20 20:16:26 +0000 |
commit | 34ada9295d0d3801f305a9818de38ebaeb784f63 (patch) | |
tree | 03034911bc99f14d8dc16744daa05b5bdd9f8d02 /font | |
parent | a7e59d393d5ca93383b84d8ff7f2b912ba10c5b2 (diff) | |
download | alacritty-34ada9295d0d3801f305a9818de38ebaeb784f63.tar.gz alacritty-34ada9295d0d3801f305a9818de38ebaeb784f63.zip |
Add support for rendering cursors to rusttype
Diffstat (limited to 'font')
-rw-r--r-- | font/src/rusttype/mod.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/font/src/rusttype/mod.rs b/font/src/rusttype/mod.rs index dc64bc78..62d17de8 100644 --- a/font/src/rusttype/mod.rs +++ b/font/src/rusttype/mod.rs @@ -72,6 +72,32 @@ impl ::Rasterize for RustTypeRasterizer { } fn get_glyph(&mut self, glyph_key: GlyphKey) -> Result<RasterizedGlyph, Error> { + match glyph_key.c { + super::UNDERLINE_CURSOR_CHAR => { + let metrics = self.metrics(glyph_key.font_key, glyph_key.size)?; + return super::get_underline_cursor_glyph(metrics.descent as i32, metrics.average_advance as i32); + } + super::BEAM_CURSOR_CHAR => { + let metrics = self.metrics(glyph_key.font_key, glyph_key.size)?; + + return super::get_beam_cursor_glyph( + (metrics.line_height + f64::from(metrics.descent)).round() as i32, + metrics.line_height.round() as i32, + metrics.average_advance.round() as i32 + ); + } + super::BOX_CURSOR_CHAR => { + let metrics = self.metrics(glyph_key.font_key, glyph_key.size)?; + + return super::get_box_cursor_glyph( + (metrics.line_height + f64::from(metrics.descent)).round() as i32, + metrics.line_height.round() as i32, + metrics.average_advance.round() as i32 + ); + } + _ => () + } + let scaled_glyph = self.fonts[glyph_key.font_key.token as usize] .glyph(glyph_key.c) .ok_or(Error::MissingGlyph)? |