aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2017-12-10 14:00:18 +0100
committerJoe Wilm <jwilm@users.noreply.github.com>2017-12-24 09:46:54 -0800
commit44251d9dbb411b5e915d28a8c10c3b34cb42abfd (patch)
treeab6bbe0becfcc1203fe219ef1ebc7366d8320cac
parentfe29b8c6873c82517a218067abbf56b64cae413b (diff)
downloadalacritty-44251d9dbb411b5e915d28a8c10c3b34cb42abfd.tar.gz
alacritty-44251d9dbb411b5e915d28a8c10c3b34cb42abfd.zip
Refactor darwin code
The ascent calculation on darwin was more complicated than it needed to be. By running a `.ceil()` instead of adding one, checking if it's 0, substracting if it is, and then flooring it, a few instructions could be shaved off.
-rw-r--r--font/src/darwin/mod.rs8
1 files changed, 3 insertions, 5 deletions
diff --git a/font/src/darwin/mod.rs b/font/src/darwin/mod.rs
index 56685dd5..7dde899a 100644
--- a/font/src/darwin/mod.rs
+++ b/font/src/darwin/mod.rs
@@ -475,13 +475,11 @@ impl Font {
// Get the top of the bounding box
let metrics = self.metrics();
let height = metrics.line_height;
- let mut ascent = height - self.ct_font.descent() + 1.;
- if ascent.floor() == ascent {
- // Fix off-by-one with an exact X.0 ascent
- ascent -= 1.;
- }
+ let ascent = (height - self.ct_font.descent()).ceil();
+
// Get the width of the cell
let width = self.glyph_advance('0') as i32;
+
// Return the new custom glyph
if character == super::BEAM_CURSOR_CHAR {
return super::get_beam_cursor_glyph(ascent as i32, height as i32, width);