I want to wrap the Han character 囚 with a green square, and draw blue dots on the top and bottom edge of the square.
As shown below, I’ve achieved that with box("" + place(dx: …, dy: …, circle(…))).
set text(5em, font: "Noto Serif CJK SC", lang: "zh")
set text(bottom-edge: "descender", top-edge: "ascender")
box(stroke: green)[囚]
let r = 0.08em
set circle(fill: teal.transparentize(50%))
box("" + place(dx: -0.5em - r, dy: -r, circle(radius: r)))
box("" + place(dx: -0.5em - r, dy: -1em - r, circle(radius: r)))
Note that joining place(circle) with "" is necessary. If I delete "" + from the above code, then the dots will be vertically shifted:
I don’t quite understand why "" makes difference. Is it a bug of Typst?
Any help is appreciated!
More experiments
From top to bottom:
set text(bottom-edge: "baseline", top-edge: "cap-height")
set text(bottom-edge: "descender", top-edge: "ascender")
From left to right:
[囚]
box[囚]
box(width: 1em, height: 1em, "")
box(width: 1em, height: 1em)
box(width: 1em, height: 1em)[]
box[囚]
box(place(…, circle(…)))
box[囚]
box("" + place(…, circle(…)))
Full code
#set page(height: auto, width: auto)
#let test = {
set text(5em, font: "Noto Serif CJK SC", lang: "zh")
set box(stroke: green)
set circle(fill: teal.transparentize(50%))
[囚]
box[囚]
box(width: 1em, height: 1em, "")
box(width: 1em, height: 1em)
box(width: 1em, height: 1em)[]
let r = 0.08em
box[囚]
box(place(dx: -0.5em - r, dy: -r, circle(radius: r)))
box(place(dx: -0.5em - r, dy: -1em - r, circle(radius: r)))
box[囚]
box("" + place(dx: -0.5em - r, dy: -r, circle(radius: r)))
box("" + place(dx: -0.5em - r, dy: -1em - r, circle(radius: r)))
}
= baseline to cap-height (default)
#set text(bottom-edge: "baseline", top-edge: "cap-height")
#test
= descender to ascender
#set text(bottom-edge: "descender", top-edge: "ascender")
#test
(Tested with Typst v0.15.1)


