aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2018-02-04 21:01:02 +0100
committerChristian Duerr <contact@christianduerr.com>2018-02-16 22:41:56 +0100
commitfd984f36b748137be4f5bd639b42d691fbb94b3d (patch)
tree510af23074c78d344a0379c302b1bc8bc91c65f8
parent0b90772efca8cb728c8f9ebb8a6d78f9e8350869 (diff)
downloadalacritty-fd984f36b748137be4f5bd639b42d691fbb94b3d.tar.gz
alacritty-fd984f36b748137be4f5bd639b42d691fbb94b3d.zip
Rework line position
Line position has been reworked to be more accurate to freetype specification. However, the strikethrough position is not documented in freetype so a weird hack has been chosen for now, further improving this depends on getting an accurate underline first. Underlines seem messed up because freetype is reporting a fixed underline position no matter how big the font size. This can lead to the underline leaving the glyph box with small fonts and a proportionally tiny underline with big fonts.
-rw-r--r--src/display.rs14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/display.rs b/src/display.rs
index e0b6b1a6..f6d0e7cd 100644
--- a/src/display.rs
+++ b/src/display.rs
@@ -539,10 +539,20 @@ fn cell_line_rect(
let y = match flag {
cell::Flags::UNDERLINE => {
- ((start.line.0 as f32 + 1.) * metrics.line_height as f32 + metrics.descent - metrics.underline_position) as u32
+ // Get the baseline positon and offset it down by (-) underline position
+ // then move it up by half the underline thickness
+ ((start.line.0 as f32 + 1.) * metrics.line_height as f32 + metrics.descent
+ - metrics.underline_position - metrics.underline_thickness / 2.).round() as u32
},
cell::Flags::STRIKE_THROUGH => {
- ((start.line.0 as f32 + 0.5) * metrics.line_height as f32) as u32
+ // Get half-way point between cell top and baseline
+ // Then offset it down by (-) underline position and
+ // move it up by half the underline thickness
+ // TODO: Moving the strikethrough down by underline thickness is a hack
+ ((start.line.0 as f32) * metrics.line_height as f32
+ + (metrics.line_height as f32 + metrics.descent) / 2.
+ - metrics.underline_thickness / 2.
+ - metrics.underline_position).round() as u32
},
_ => panic!("Invalid flag for cell line drawing specified"),
};