diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-03-31 16:31:21 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-03-31 16:33:33 +0200 |
| commit | 5f97e0a77348d4fb1c89a9adf671647f1fa86dc3 (patch) | |
| tree | 2800a61d06ac7cae8e57cb361804c530b1843bb8 /library/src/text | |
| parent | 00f11ae56d6d20b92a8c6ad6f2245c3ad3e94d86 (diff) | |
Make `Paint` not implement `Copy`
Diffstat (limited to 'library/src/text')
| -rw-r--r-- | library/src/text/deco.rs | 6 | ||||
| -rw-r--r-- | library/src/text/raw.rs | 7 | ||||
| -rw-r--r-- | library/src/text/shaping.rs | 9 |
3 files changed, 14 insertions, 8 deletions
diff --git a/library/src/text/deco.rs b/library/src/text/deco.rs index 90a6ca85..79917641 100644 --- a/library/src/text/deco.rs +++ b/library/src/text/deco.rs @@ -268,8 +268,8 @@ pub(super) fn decorate( }; let offset = deco.offset.unwrap_or(-metrics.position.at(text.size)) - shift; - let stroke = deco.stroke.unwrap_or(Stroke { - paint: text.fill, + let stroke = deco.stroke.clone().unwrap_or(Stroke { + paint: text.fill.clone(), thickness: metrics.thickness.at(text.size), }); @@ -284,7 +284,7 @@ pub(super) fn decorate( let target = Point::new(to - from, Abs::zero()); if target.x >= min_width || !deco.evade { - let shape = Geometry::Line(target).stroked(stroke); + let shape = Geometry::Line(target).stroked(stroke.clone()); frame.push(origin, FrameItem::Shape(shape, Span::detached())); } }; diff --git a/library/src/text/raw.rs b/library/src/text/raw.rs index c2630aef..3c9f86e5 100644 --- a/library/src/text/raw.rs +++ b/library/src/text/raw.rs @@ -134,8 +134,7 @@ impl Show for RawElem { .settings .foreground .map(to_typst) - .map_or(Color::BLACK, Color::from) - .into(); + .map_or(Color::BLACK, Color::from); let mut realized = if matches!(lang.as_deref(), Some("typ" | "typst" | "typc")) { let root = match lang.as_deref() { @@ -150,7 +149,7 @@ impl Show for RawElem { vec![], &highlighter, &mut |node, style| { - seq.push(styled(&text[node.range()], foreground, style)); + seq.push(styled(&text[node.range()], foreground.into(), style)); }, ); @@ -168,7 +167,7 @@ impl Show for RawElem { for (style, piece) in highlighter.highlight_line(line, &SYNTAXES).into_iter().flatten() { - seq.push(styled(piece, foreground, style)); + seq.push(styled(piece, foreground.into(), style)); } } diff --git a/library/src/text/shaping.rs b/library/src/text/shaping.rs index 15fbcd3f..4a62d538 100644 --- a/library/src/text/shaping.rs +++ b/library/src/text/shaping.rs @@ -122,7 +122,14 @@ impl<'a> ShapedText<'a> { }) .collect(); - let item = TextItem { font, size: self.size, lang, fill, glyphs }; + let item = TextItem { + font, + size: self.size, + lang, + fill: fill.clone(), + glyphs, + }; + let layer = frame.layer(); let width = item.width(); |
