mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-18 13:55:23 -05:00
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.
This commit is contained in:
parent
0b90772efc
commit
fd984f36b7
1 changed files with 12 additions and 2 deletions
|
@ -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"),
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue