diff --git a/sugarloaf/examples/text_with_doubled_line_height.rs b/sugarloaf/examples/line_height.rs similarity index 95% rename from sugarloaf/examples/text_with_doubled_line_height.rs rename to sugarloaf/examples/line_height.rs index 1538ff7214..ed20f60575 100644 --- a/sugarloaf/examples/text_with_doubled_line_height.rs +++ b/sugarloaf/examples/line_height.rs @@ -9,7 +9,7 @@ use rio_window::{ use std::error::Error; use sugarloaf::{ layout::RootStyle, FragmentStyle, FragmentStyleDecoration, Object, RichText, - Sugarloaf, SugarloafWindow, SugarloafWindowSize, UnderlineInfo, UnderlineShape, + Sugarloaf, SugarCursor, SugarloafWindow, SugarloafWindowSize, UnderlineInfo, UnderlineShape, }; fn main() { @@ -267,6 +267,15 @@ impl ApplicationHandler for Application { ..FragmentStyle::default() }, ) + .add_text( + "?", + FragmentStyle { + color: [0.5, 0.5, 1.0, 1.0], + background_color: Some([1.0, 1.0, 1.0, 1.0]), + cursor: Some(SugarCursor::Block([1.0, 1.0, 1.0, 1.0])), + ..FragmentStyle::default() + }, + ) .build(); sugarloaf.set_objects(vec![Object::RichText(RichText { diff --git a/sugarloaf/src/components/rich_text/mod.rs b/sugarloaf/src/components/rich_text/mod.rs index 6a4aeb3ee4..8c15baa97c 100644 --- a/sugarloaf/src/components/rich_text/mod.rs +++ b/sugarloaf/src/components/rich_text/mod.rs @@ -447,7 +447,7 @@ fn draw_layout( } let first_run = &line.render_data.runs[0]; - // let ascent = first_run.ascent.round(); + let ascent = first_run.ascent.round(); // let descent = first_run.descent.round(); // let leading = (first_run.leading).round() * 2.; let mut px = x + 0.0; @@ -480,7 +480,7 @@ fn draw_layout( cursor: run.span.cursor, background_color: run.span.background_color, baseline: py, - topline: py - rect.height, + topline: py - ascent, line_height, advance: px - run_x, decoration: run.span.decoration, diff --git a/sugarloaf/src/layout/content.rs b/sugarloaf/src/layout/content.rs index e6fb582ad7..c34474f8bc 100644 --- a/sugarloaf/src/layout/content.rs +++ b/sugarloaf/src/layout/content.rs @@ -328,7 +328,7 @@ impl Content { let render_data = content.get_state(&id).unwrap().lines[0].clone(); if let Some(dimension) = advance_brush.dimensions(&self.fonts, &render_data) { - rte.layout.dimensions.height = dimension.height; + rte.layout.dimensions.height = dimension.height * rte.layout.line_height; rte.layout.dimensions.width = dimension.width; } }