I created a proper wavy underline since I wanted to use it for one of my reports. It’s drawn using a tiling as suggested by some issues or discussions around here.
There’s actually a bug with PDF export of these tiling based strokes, so they don’t always draw correctly in the PDF, even if it looks correct in the typst.app preview - but this PDF issue is fixed in typst’s development version.
There’s a few other strange quirks with tilings when it comes to using them for strokes, but when focused on a single use case like horizontal lines, it seems to work.
Interesting. That might be tricky to fix because if I explain with this picture:
The upper part of the underline is drawn using the lowest edge of the tiling’s repeating area. For the wavy underline the lower part is just blank/“white”.
I think if the tiling adds a repeat of the wave like this
place(dy: offset + tiling-height, wavy-curve)
then it gets much better, but not yet pixel perfect compared with the regular underline. Or using offset: -0.1pt is as close as it gets, then they visually match very well.
It seems like I find the following equivalence when the tiling is repeated that way:
regular underline stroke X <=> wave stroke X + 0.1pt with offset -0.1pt. I’m not a fan of the rounding effect or this offset that I don’t yet understand.
Moreover, with this patch when you decrease offset to increase offset, the line gets thinner, and increasing thickness cancels the increased offset. So it’s impossible to have more offset and have any line thickness.
It should be one added place call, not a changed one - in reference to the black/red tiling above, current version of wave draws only in the upper black space and it needs to draw an additional copy in the bottom of the red space near the bottom of the tile.
This is only relevant if the wave overlaps with the tile boundary at coordinate y: 0pt.
it still falls into the same endless cycle. It is initially thicker. But the distance from glyph is now ~20% shorter than default. Though it is hard to spot this unintentionally.