mirror of
https://github.com/wez/wezterm.git
synced 2024-12-25 14:22:37 +03:00
gui: vertically center cell within adjusted line height
When line_height is specified, rather than applying the offset to just the top of the cell, apply it in equal parts to the top and the bottom so that the cell is vertically centered. closes: https://github.com/wez/wezterm/issues/582
This commit is contained in:
parent
4112b74f8a
commit
b441be3ac9
@ -33,16 +33,21 @@ impl RenderMetrics {
|
|||||||
metrics.cell_width.get().ceil() as usize,
|
metrics.cell_width.get().ceil() as usize,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// When line_height != 1.0, we want to adjust the baseline position
|
||||||
|
// such that we are horizontally centered.
|
||||||
|
let line_height_y_adjust = (cell_height as f64 - metrics.cell_height.get()) / 2.;
|
||||||
|
|
||||||
let underline_height = metrics.underline_thickness.get().round().max(1.) as isize;
|
let underline_height = metrics.underline_thickness.get().round().max(1.) as isize;
|
||||||
|
|
||||||
let descender_row =
|
let descender_row = (cell_height as f64
|
||||||
(cell_height as f64 + (metrics.descender - metrics.underline_position).get()) as isize;
|
+ (metrics.descender - metrics.underline_position).get()
|
||||||
|
- line_height_y_adjust) as isize;
|
||||||
let descender_plus_two =
|
let descender_plus_two =
|
||||||
(2 * underline_height + descender_row).min(cell_height as isize - underline_height);
|
(2 * underline_height + descender_row).min(cell_height as isize - underline_height);
|
||||||
let strike_row = descender_row / 2;
|
let strike_row = descender_row / 2;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
descender: metrics.descender,
|
descender: metrics.descender - PixelLength::new(line_height_y_adjust),
|
||||||
descender_row,
|
descender_row,
|
||||||
descender_plus_two,
|
descender_plus_two,
|
||||||
strike_row,
|
strike_row,
|
||||||
|
Loading…
Reference in New Issue
Block a user