diff options
| author | Martin Haug <mhaug@live.de> | 2021-06-10 23:08:52 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-06-10 23:15:51 +0200 |
| commit | c28708aa196eaca247cdab6b5e8af9751b4f1dad (patch) | |
| tree | e390e84d1a7a1eb2789680a39141c804ff3f85a1 /src/export/pdf.rs | |
| parent | 5611c26577c4cf6d52b9b66b7b1a32253aa23ec1 (diff) | |
Text decorations
Diffstat (limited to 'src/export/pdf.rs')
| -rw-r--r-- | src/export/pdf.rs | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/export/pdf.rs b/src/export/pdf.rs index 1cc62332..da3c9369 100644 --- a/src/export/pdf.rs +++ b/src/export/pdf.rs @@ -183,12 +183,17 @@ impl<'a> PdfExporter<'a> { content.rect(x, y - h, w, h, false, true); } } - Shape::Ellipse(size) => { let path = geom::Path::ellipse(size); write_path(&mut content, x, y, &path, false, true); } - + Shape::Line(target, stroke) => { + write_stroke(&mut content, fill, stroke.to_pt() as f32); + content.path(true, false).move_to(x, y).line_to( + x + target.x.to_pt() as f32, + y - target.y.to_pt() as f32, + ); + } Shape::Path(ref path) => { write_path(&mut content, x, y, path, false, true) } @@ -371,6 +376,20 @@ fn write_fill(content: &mut Content, fill: Fill) { } } +/// Write a stroke change into a content stream. +fn write_stroke(content: &mut Content, fill: Fill, thickness: f32) { + match fill { + Fill::Color(Color::Rgba(c)) => { + content.stroke_rgb( + c.r as f32 / 255.0, + c.g as f32 / 255.0, + c.b as f32 / 255.0, + ); + } + } + content.line_width(thickness); +} + /// Write a path into a content stream. fn write_path( content: &mut Content, |
