diff options
| author | Martin <mhaug@live.de> | 2021-08-23 23:56:33 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-23 23:56:33 +0200 |
| commit | d546453880721d7a12ea228e5c1ed6c65b653ca2 (patch) | |
| tree | 6dee8615a0755f2376d557328eee070de2dcb744 /tests | |
| parent | 0806af4aecc9414962b13894a2a3c4befd2ca3c8 (diff) | |
Links! (#43)
Co-authored-by: Laurenz <laurmaedje@gmail.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ref/text/links.png | bin | 0 -> 6947 bytes | |||
| -rw-r--r-- | tests/typ/text/links.typ | 12 | ||||
| -rw-r--r-- | tests/typeset.rs | 7 |
3 files changed, 18 insertions, 1 deletions
diff --git a/tests/ref/text/links.png b/tests/ref/text/links.png Binary files differnew file mode 100644 index 00000000..5ac7ee00 --- /dev/null +++ b/tests/ref/text/links.png diff --git a/tests/typ/text/links.typ b/tests/typ/text/links.typ new file mode 100644 index 00000000..eabb316a --- /dev/null +++ b/tests/typ/text/links.typ @@ -0,0 +1,12 @@ +// Link without body. +#link("https://example.com/") + +// Link with body. +#link("https://typst.app/")[Some text text text] + +// With line break. +This link appears #link("https://google.com/")[in the middle of] a paragraph. + +// Styled with underline and color. +#let link(url, body) = link(url, [#font(fill: rgb("283663")) #underline(body)]) +You could also make the #link("https://html5zombo.com/")[link look way more typical.] diff --git a/tests/typeset.rs b/tests/typeset.rs index 80eb9da4..b788f74d 100644 --- a/tests/typeset.rs +++ b/tests/typeset.rs @@ -9,7 +9,7 @@ use tiny_skia as sk; use ttf_parser::{GlyphId, OutlineBuilder}; use walkdir::WalkDir; -use typst::color::Color; +use typst::color::{Color, RgbaColor}; use typst::diag::Error; use typst::eval::{State, Value}; use typst::geom::{self, Length, PathElement, Point, Sides, Size}; @@ -428,6 +428,11 @@ fn draw(ctx: &Context, frames: &[Rc<Frame>], dpi: f32) -> sk::Pixmap { Element::Image(id, size) => { draw_image(&mut canvas, ts, ctx, id, size); } + Element::Link(_, s) => { + let outline = Geometry::Rect(s); + let paint = Paint::Color(Color::Rgba(RgbaColor::new(40, 54, 99, 40))); + draw_geometry(&mut canvas, ts, &outline, paint); + } } } |
