From 2796a6bc974d847580ab23c6a5f58db994883ec5 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 28 Jul 2024 13:56:39 +0200 Subject: Add `padding` to `text::Span` --- widget/src/text/rich.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'widget/src/text/rich.rs') diff --git a/widget/src/text/rich.rs b/widget/src/text/rich.rs index f636b219..67db31db 100644 --- a/widget/src/text/rich.rs +++ b/widget/src/text/rich.rs @@ -10,7 +10,7 @@ use crate::core::widget::text::{ use crate::core::widget::tree::{self, Tree}; use crate::core::{ self, Clipboard, Color, Element, Event, Layout, Length, Pixels, Point, - Rectangle, Shell, Size, Widget, + Rectangle, Shell, Size, Vector, Widget, }; use std::borrow::Cow; @@ -252,6 +252,16 @@ where let translation = layout.position() - Point::ORIGIN; for bounds in state.paragraph.span_bounds(index) { + let bounds = Rectangle::new( + bounds.position() + - Vector::new(span.padding.left, span.padding.top), + bounds.size() + + Size::new( + span.padding.horizontal(), + span.padding.vertical(), + ), + ); + renderer.fill_quad( renderer::Quad { bounds: bounds + translation, -- cgit