aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2017-12-17 22:20:22 +0100
committerJoe Wilm <jwilm@users.noreply.github.com>2017-12-24 09:46:54 -0800
commit645100cf5f62448d43a43bf3799911461c2bdd9e (patch)
tree84ba275c206c560b296326cba01e0d89e27190ed
parent7895e320836900ff1cea14c17ae9e9aa4eeac6e5 (diff)
downloadalacritty-645100cf5f62448d43a43bf3799911461c2bdd9e.tar.gz
alacritty-645100cf5f62448d43a43bf3799911461c2bdd9e.zip
Fix linux symbol size
With linux every box, line or underline should now have the pixel-perfect size with any font at any size. This uses the default font to get the size of the monospace box. It assumes that the face 0 is always the primary font, if this is not the case, this will probably break.
-rw-r--r--font/src/ft/mod.rs20
1 files changed, 12 insertions, 8 deletions
diff --git a/font/src/ft/mod.rs b/font/src/ft/mod.rs
index 44dc0be3..a4a118b9 100644
--- a/font/src/ft/mod.rs
+++ b/font/src/ft/mod.rs
@@ -297,33 +297,37 @@ impl FreeTypeRasterizer {
// Render a custom symbol for the underline and beam cursor
match glyph_key.c {
super::UNDERLINE_CURSOR_CHAR => {
- // Get the bottom of the bounding box
+ // Get the primary face metrics
+ let face = self.faces.get(&FontKey { token: 0 }).unwrap();
let size_metrics = face.ft_face
.size_metrics()
.ok_or(Error::MissingSizeMetrics)?;
+
+ // Get the bottom of the bounding box
let descent = (size_metrics.descender / 64) as i32;
// Get the width of the cell
- let metrics = glyph.metrics();
- let width = (metrics.vertAdvance as f32 / 128.).round() as i32;
+ let width = (size_metrics.max_advance / 64) as i32;
// Return the new custom glyph
super::get_underline_cursor_glyph(descent, width)
}
super::BEAM_CURSOR_CHAR | super::BOX_CURSOR_CHAR => {
- // Get the top of the bounding box
+ // Get the primary face metrics
+ let face = self.faces.get(&FontKey { token: 0 }).unwrap();
let size_metrics = face.ft_face
.size_metrics()
.ok_or(Error::MissingSizeMetrics)?;
- let ascent = (size_metrics.ascender / 64) as i32 - 1;
// Get the height of the cell
+ let height = (size_metrics.height / 64) as i32;
+
+ // Get the top of the bounding box
let descent = (size_metrics.descender / 64) as i32;
- let height = ascent - descent;
+ let ascent = height + descent;
// Get the width of the cell
- let metrics = glyph.metrics();
- let width = (metrics.vertAdvance as f32 / 128.).round() as i32;
+ let width = (size_metrics.max_advance / 64) as i32;
// Return the new custom glyph
if glyph_key.c == super::BEAM_CURSOR_CHAR {