From 54500e61ed0ff2309f06dd5b441f9f5b627e05c9 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 21 Jul 2024 13:01:27 +0200 Subject: Simplify font attributes in `Paragraph::with_spans` --- graphics/src/text/paragraph.rs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'graphics') diff --git a/graphics/src/text/paragraph.rs b/graphics/src/text/paragraph.rs index b69110b2..da703ceb 100644 --- a/graphics/src/text/paragraph.rs +++ b/graphics/src/text/paragraph.rs @@ -123,15 +123,7 @@ impl core::text::Paragraph for Paragraph { buffer.set_rich_text( font_system.raw(), text.content.iter().enumerate().map(|(i, span)| { - let attrs = if let Some(font) = span.font { - cosmic_text::Attrs::new() - .family(text::to_family(font.family)) - .weight(text::to_weight(font.weight)) - .stretch(text::to_stretch(font.stretch)) - .style(text::to_style(font.style)) - } else { - text::to_attributes(text.font) - }; + let attrs = text::to_attributes(span.font.unwrap_or(text.font)); let attrs = match (span.size, span.line_height) { (None, None) => attrs, -- cgit