The overline function seems to produce underline when used from a custom function

Here is a minimum example.

#let col_overline = rgb("#007ACC")
#let fmt_overline(content) = overline(offset: 2pt,stroke: col_overline.lighten(50%)+2pt,content)
#overline[This works]
#overline(stroke: col_overline.lighten(50%)+2pt, [This also Works])
#fmt_overline[This does not work]

The above example produces…

image

This is as expected because you applied offset:

The position of the line relative to the baseline.

The baseline is at the bottom, not at the top of the text. Your offset: 2pt forces the line to the baseline, as well as the additional 2pt down.

Here’s another way to prove this:

Code
#let off = 0.5em
#overline(offset: off)[This does not work]
#text(baseline: off)[This]

To shift the line from the top of the text instead of the bottom, I assume you would need to consider text.size in the offset, as well as the text.baseline in the event that you altered that.


Unrelated to this, kebab-case is the code style used most often in Typst.

1 Like