From 71dccde031dedc285042257c7e16bafb152dde58 Mon Sep 17 00:00:00 2001 From: LU Jialin Date: Mon, 11 Sep 2023 16:46:39 +0800 Subject: Provide `highlight` function for setting the background color of text (#2076) --- tests/ref/text/deco.png | Bin 32958 -> 48180 bytes tests/typ/text/deco.typ | 32 +++++++++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/ref/text/deco.png b/tests/ref/text/deco.png index 7e3195ca..006c969f 100644 Binary files a/tests/ref/text/deco.png and b/tests/ref/text/deco.png differ diff --git a/tests/typ/text/deco.typ b/tests/typ/text/deco.typ index f3be17e7..b79b80b2 100644 --- a/tests/typ/text/deco.typ +++ b/tests/typ/text/deco.typ @@ -20,14 +20,40 @@ --- #let redact = strike.with(stroke: 10pt, extent: 0.05em) -#let highlight = strike.with(stroke: 10pt + rgb("abcdef88"), extent: 0.05em) +#let highlight-custom = strike.with(stroke: 10pt + rgb("abcdef88"), extent: 0.05em) // Abuse thickness and transparency for redacting and highlighting stuff. Sometimes, we work #redact[in secret]. -There might be #highlight[redacted] things. - underline() +There might be #highlight-custom[redacted] things. --- // Test stroke folding. #set underline(stroke: 2pt, offset: 2pt) #underline(text(red, [DANGER!])) + +--- +// Test highlight. +This is the built-in #highlight[highlight with default color]. +We can also specify a customized value +#highlight(fill: green.lighten(80%))[to highlight]. + +--- +// Test default highlight bounds. +#highlight[ace], +#highlight[base], +#highlight[super], +#highlight[phone #sym.integral] + +--- +// Test a tighter highlight. +#set highlight(top-edge: "x-height", bottom-edge: "baseline") +#highlight[ace], +#highlight[base], +#highlight[super], +#highlight[phone #sym.integral] + +--- +// Test a bounds highlight. +#set highlight(top-edge: "bounds", bottom-edge: "bounds") +#highlight[abc] +#highlight[abc #sym.integral] -- cgit v1.2.3