summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Pullar-Strecker <zacps@users.noreply.github.com>2018-10-21 09:16:26 +1300
committerChristian Duerr <chrisduerr@users.noreply.github.com>2018-10-20 20:16:26 +0000
commit34ada9295d0d3801f305a9818de38ebaeb784f63 (patch)
tree03034911bc99f14d8dc16744daa05b5bdd9f8d02
parenta7e59d393d5ca93383b84d8ff7f2b912ba10c5b2 (diff)
Add support for rendering cursors to rusttype
-rw-r--r--CHANGELOG.md1
-rw-r--r--alacritty_windows.yml7
-rw-r--r--font/src/rusttype/mod.rs26
3 files changed, 33 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 397d7c99..ac8c0c06 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Fixed erroneous results when using the `indexed_colors` config option
+- Fixed rendering cursors other than rectangular with the RustType backend
## Version 0.2.1
diff --git a/alacritty_windows.yml b/alacritty_windows.yml
index 1277d6dc..23210292 100644
--- a/alacritty_windows.yml
+++ b/alacritty_windows.yml
@@ -240,7 +240,12 @@ selection:
hide_cursor_when_typing: false
-# - Beam
+# Cursor style
+#
+# Values for 'cursor_style':
+# - Block
+# - Underline
+# - Beam
cursor_style: Block
# Whether the cursor should be a hollow block on window focus loss
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)?