From 56a4d88ad6c71c74cc8d9283f20f821d64163de8 Mon Sep 17 00:00:00 2001 From: Raphael Amorim Date: Sat, 21 Dec 2024 23:30:04 -0300 Subject: [PATCH] let's render on center --- docs/docs/releases.md | 4 +++- sugarloaf/src/components/rich_text/mod.rs | 4 ++-- sugarloaf/src/layout/content.rs | 2 +- sugarloaf/src/layout/mod.rs | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/docs/releases.md b/docs/docs/releases.md index 4c987df6f7..eaddb4531f 100644 --- a/docs/docs/releases.md +++ b/docs/docs/releases.md @@ -10,7 +10,9 @@ language: 'en' ## 0.2.3 (unreleased) -- Fixed Nix build [#853](https://github.com/raphamorim/rio/pull/853). +- Fixed: Nix build [#853](https://github.com/raphamorim/rio/pull/853). +- Support to line height. +- Fixed: Unremovable bottom padding when using line-height [#449](https://github.com/raphamorim/rio/issues/449). - On macOS, fixed undocumented cursors (e.g. zoom, resize, help) always appearing to be invalid and falling back to the default cursor. - On X11, Wayland, Windows and macOS, improved scancode conversions for more obscure key codes. - On macOS, fixed the scancode conversion for audio volume keys. diff --git a/sugarloaf/src/components/rich_text/mod.rs b/sugarloaf/src/components/rich_text/mod.rs index 8c15baa97c..c294a290fd 100644 --- a/sugarloaf/src/components/rich_text/mod.rs +++ b/sugarloaf/src/components/rich_text/mod.rs @@ -453,10 +453,10 @@ fn draw_layout( let mut px = x + 0.0; // let baseline = line_y + ascent; // line_y = baseline + descent; - line_y = line_y + rect.height; + line_y = line_y + rect.height * 2.0; let py = line_y; // let line_height = ascent + descent + leading; - let line_height = rect.height; + let line_height = rect.height * 2.0; for run in &line.render_data.runs { glyphs.clear(); let font = run.span.font_id; diff --git a/sugarloaf/src/layout/content.rs b/sugarloaf/src/layout/content.rs index c34474f8bc..e6fb582ad7 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.line_height; + rte.layout.dimensions.height = dimension.height; rte.layout.dimensions.width = dimension.width; } } diff --git a/sugarloaf/src/layout/mod.rs b/sugarloaf/src/layout/mod.rs index 6b0d3c440b..421e30ef1f 100644 --- a/sugarloaf/src/layout/mod.rs +++ b/sugarloaf/src/layout/mod.rs @@ -105,8 +105,8 @@ impl Default for RootStyle { impl RootStyle { pub fn new(scale_factor: f32, font_size: f32, line_height: f32) -> RootStyle { - // Line height can never be zero - // let line_height = if line_height == 0.0 { 1.0 } else { line_height }; + // Line height cannot be under 1 + let line_height = if line_height <= 1.0 { 1.0 } else { line_height }; RootStyle { scale_factor,