From 7275ecc282d29d1c67f700c01a399582ba052853 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Mon, 31 Dec 2018 17:01:06 +0000 Subject: Fix line metrics Since bitmap fonts do not provide their own underline metrics, the self-calculated metrics which have been used for rusttype are now also used for bitmap fonts with freetype. The rusttype and bitmap fallback metrics have incorrectly offset the underline by the underline height. Since the position is already defined as the center point, that is not necessary. All rounding and clamping has also been removed from the font library, so that the raw values are reported now. The clamping and rounding is now done in the line renderer. --- src/renderer/lines.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/renderer/lines.rs b/src/renderer/lines.rs index 99d1f28f..3c250caf 100644 --- a/src/renderer/lines.rs +++ b/src/renderer/lines.rs @@ -122,12 +122,15 @@ fn create_rect( let end_x = (end.column.0 + 1) as f32 * size.cell_width; let width = end_x - start_x; - let (position, height) = match flag { + let (position, mut height) = match flag { Flags::UNDERLINE => (metrics.underline_position, metrics.underline_thickness), Flags::STRIKEOUT => (metrics.strikeout_position, metrics.strikeout_thickness), _ => unimplemented!("Invalid flag for cell line drawing specified"), }; + // Make sure lines are always visible + height = height.max(1.); + let cell_bottom = (start.line.0 as f32 + 1.) * size.cell_height; let baseline = cell_bottom + metrics.descent; @@ -139,9 +142,9 @@ fn create_rect( let rect = Rect::new( start_x + size.padding_x, - y + size.padding_y, + y.round() + size.padding_y, width, - height, + height.round(), ); (rect, start.fg) -- cgit