From 6eb67bb524482c8214ac209108a8fe621ce7e995 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Fri, 7 Jun 2024 11:27:49 -0600 Subject: [PATCH] Use default metrics for empty lines, fixes #258 --- src/shape.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/shape.rs b/src/shape.rs index ec74857c82..8d69800a9d 100644 --- a/src/shape.rs +++ b/src/shape.rs @@ -741,6 +741,7 @@ impl ShapeSpan { pub struct ShapeLine { pub rtl: bool, pub spans: Vec, + pub metrics_opt: Option, } // Visual Line Ranges: (span_index, (first_word_index, first_glyph_index), (last_word_index, last_glyph_index)) @@ -843,7 +844,11 @@ impl ShapeLine { )); } - Self { rtl, spans } + Self { + rtl, + spans, + metrics_opt: attrs_list.defaults().metrics_opt.map(|x| x.into()), + } } // A modified version of first part of unicode_bidi::bidi_info::visual_run @@ -1484,7 +1489,7 @@ impl ShapeLine { w: 0.0, max_ascent: 0.0, max_descent: 0.0, - line_height_opt: None, + line_height_opt: self.metrics_opt.map(|x| x.line_height), glyphs: Default::default(), }); }