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 | |
| parent | 00f11ae56d6d20b92a8c6ad6f2245c3ad3e94d86 (diff) | |
Make `Paint` not implement `Copy`
Diffstat (limited to 'library/src')
| -rw-r--r-- | library/src/layout/container.rs | 8 | ||||
| -rw-r--r-- | library/src/layout/page.rs | 4 | ||||
| -rw-r--r-- | library/src/layout/table.rs | 6 | ||||
| -rw-r--r-- | library/src/math/fragment.rs | 6 | ||||
| -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 |
7 files changed, 29 insertions, 17 deletions
diff --git a/library/src/layout/container.rs b/library/src/layout/container.rs index ef7def7a..bac0cb7f 100644 --- a/library/src/layout/container.rs +++ b/library/src/layout/container.rs @@ -383,7 +383,13 @@ impl Layout for BlockElem { let outset = self.outset(styles); let radius = self.radius(styles); for frame in frames.iter_mut().skip(skip as usize) { - frame.fill_and_stroke(fill, stroke, outset, radius, self.span()); + frame.fill_and_stroke( + fill.clone(), + stroke.clone(), + outset, + radius, + self.span(), + ); } } diff --git a/library/src/layout/page.rs b/library/src/layout/page.rs index 66d2bcc0..8ad85c79 100644 --- a/library/src/layout/page.rs +++ b/library/src/layout/page.rs @@ -362,8 +362,8 @@ impl PageElem { } } - if let Some(fill) = fill { - frame.fill(fill); + if let Some(fill) = &fill { + frame.fill(fill.clone()); } } diff --git a/library/src/layout/table.rs b/library/src/layout/table.rs index 3b1f7247..d4238839 100644 --- a/library/src/layout/table.rs +++ b/library/src/layout/table.rs @@ -167,14 +167,14 @@ impl Layout for TableElem { // Add lines and backgrounds. for (frame, rows) in layout.fragment.iter_mut().zip(&layout.rows) { // Render table lines. - if let Some(stroke) = stroke { + if let Some(stroke) = &stroke { let thickness = stroke.thickness; let half = thickness / 2.0; // Render horizontal lines. for offset in points(rows.iter().map(|piece| piece.height)) { let target = Point::with_x(frame.width() + thickness); - let hline = Geometry::Line(target).stroked(stroke); + let hline = Geometry::Line(target).stroked(stroke.clone()); frame.prepend( Point::new(-half, offset), FrameItem::Shape(hline, self.span()), @@ -184,7 +184,7 @@ impl Layout for TableElem { // Render vertical lines. for offset in points(layout.cols.iter().copied()) { let target = Point::with_y(frame.height() + thickness); - let vline = Geometry::Line(target).stroked(stroke); + let vline = Geometry::Line(target).stroked(stroke.clone()); frame.prepend( Point::new(offset, -half), FrameItem::Shape(vline, self.span()), diff --git a/library/src/math/fragment.rs b/library/src/math/fragment.rs index 0d663d3f..a0951458 100644 --- a/library/src/math/fragment.rs +++ b/library/src/math/fragment.rs @@ -201,20 +201,20 @@ impl GlyphFragment { self.ascent + self.descent } - pub fn to_variant(&self) -> VariantFragment { + pub fn to_variant(self) -> VariantFragment { VariantFragment { c: self.c, id: Some(self.id), - frame: self.to_frame(), style: self.style, font_size: self.font_size, italics_correction: self.italics_correction, class: self.class, span: self.span, + frame: self.to_frame(), } } - pub fn to_frame(&self) -> Frame { + pub fn to_frame(self) -> Frame { let item = TextItem { font: self.font.clone(), size: self.font_size, 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(); |
