From 67ba8d6c0e7b3326283a8f67d2546cd52df59970 Mon Sep 17 00:00:00 2001
From: frozolotl <44589151+frozolotl@users.noreply.github.com>
Date: Fri, 1 Mar 2024 09:18:32 +0000
Subject: Add rounded corners and strokes to highlight (#3526)
---
crates/typst/src/text/deco.rs | 65 +++++++++++++++++++++++++++++++++++-------
tests/ref/text/deco.png | Bin 55184 -> 64132 bytes
tests/typ/text/deco.typ | 12 +++++++-
3 files changed, 66 insertions(+), 11 deletions(-)
diff --git a/crates/typst/src/text/deco.rs b/crates/typst/src/text/deco.rs
index 7f0b9e46..d105a353 100644
--- a/crates/typst/src/text/deco.rs
+++ b/crates/typst/src/text/deco.rs
@@ -5,12 +5,14 @@ use ttf_parser::{GlyphId, OutlineBuilder};
use crate::diag::SourceResult;
use crate::engine::Engine;
use crate::foundations::{elem, Content, Packed, Show, Smart, StyleChain};
-use crate::layout::{Abs, Em, Frame, FrameItem, Length, Point, Size};
+use crate::layout::{
+ Abs, Corners, Em, Frame, FrameItem, Length, Point, Rel, Sides, Size,
+};
use crate::syntax::Span;
use crate::text::{
BottomEdge, BottomEdgeMetric, TextElem, TextItem, TopEdge, TopEdgeMetric,
};
-use crate::visualize::{Color, FixedStroke, Geometry, Paint, Stroke};
+use crate::visualize::{styled_rect, Color, FixedStroke, Geometry, Paint, Stroke};
/// Underlines text.
///
@@ -283,6 +285,12 @@ pub struct HighlightElem {
#[default(Color::from_u8(0xFF, 0xFD, 0x11, 0xA1).into())]
pub fill: Paint,
+ /// The highlight's border color. See the
+ /// [rectangle's documentation]($rect.stroke) for more details.
+ #[resolve]
+ #[fold]
+ pub stroke: Sides