1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-25 14:05:41 -05:00

Add support for rendering cursors to rusttype

This commit is contained in:
Zac Pullar-Strecker 2018-10-21 09:16:26 +13:00 committed by Christian Duerr
parent a7e59d393d
commit 34ada9295d
3 changed files with 33 additions and 1 deletions

View file

@ -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

View file

@ -240,6 +240,11 @@ selection:
hide_cursor_when_typing: false
# Cursor style
#
# Values for 'cursor_style':
# - Block
# - Underline
# - Beam
cursor_style: Block

View file

@ -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)?