Use default metrics for empty lines, fixes #258

This commit is contained in:
Jeremy Soller 2024-06-07 11:27:49 -06:00
parent 21e88ebc45
commit 6eb67bb524
No known key found for this signature in database
GPG key ID: D02FD439211AF56F

View file

@ -741,6 +741,7 @@ impl ShapeSpan {
pub struct ShapeLine { pub struct ShapeLine {
pub rtl: bool, pub rtl: bool,
pub spans: Vec<ShapeSpan>, pub spans: Vec<ShapeSpan>,
pub metrics_opt: Option<Metrics>,
} }
// Visual Line Ranges: (span_index, (first_word_index, first_glyph_index), (last_word_index, last_glyph_index)) // 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 // A modified version of first part of unicode_bidi::bidi_info::visual_run
@ -1484,7 +1489,7 @@ impl ShapeLine {
w: 0.0, w: 0.0,
max_ascent: 0.0, max_ascent: 0.0,
max_descent: 0.0, max_descent: 0.0,
line_height_opt: None, line_height_opt: self.metrics_opt.map(|x| x.line_height),
glyphs: Default::default(), glyphs: Default::default(),
}); });
} }