Simplify font attributes in Paragraph::with_spans

This commit is contained in:
Héctor Ramón Jiménez 2024-07-21 13:01:27 +02:00
parent 9bfaf2840c
commit 54500e61ed
No known key found for this signature in database
GPG key ID: 7CC46565708259A7

View file

@ -123,15 +123,7 @@ impl core::text::Paragraph for Paragraph {
buffer.set_rich_text( buffer.set_rich_text(
font_system.raw(), font_system.raw(),
text.content.iter().enumerate().map(|(i, span)| { text.content.iter().enumerate().map(|(i, span)| {
let attrs = if let Some(font) = span.font { let attrs = text::to_attributes(span.font.unwrap_or(text.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 = match (span.size, span.line_height) { let attrs = match (span.size, span.line_height) {
(None, None) => attrs, (None, None) => attrs,