Line above the text

Hi,

I’m trying to write some text with a line above it. Like “ ” with Rich Text, but I would like the line to be above instead of below.

I searched the internet for both Text and TextMeshPro, but found nothing about it.

I only found the “ ” and “ ” tags which are respectively underline and strikethrough. (Rich Text, TextMesh Pro Documentation)

Do you know how I can get a line above the text?

What you’re looking for is called overline, overscore or overbar and sadly doesn’t exist there.
In CSS/HTML, you’d normally use text-decoration: overline.

1 Like

I forgot to write that my goal was to write periodic numbers (from what I saw there are no unicode a so the only choice seemed to me the overline).

Thanks for the reply

You might be able to look at how TextMeshPRO renders out things like in-line sprites and hack something up to get the effect you want.

In the trivial sense it would be a single sprite (a bar up high) rendered at the width of the character, but made so that it does not advance the x position of the rendering. I think this is already possible for kerning and characters that have extra (or less) lateral spacing between them.

1 Like

Thanks for the advice.

At your suggestion I searched the options of TextMeshPro and found “textInfo” that through “characterInfo” I can get the vertices “topLeft” and “topRight” of the single character.

So already knowing the height of the line to add and its distance from the text, I use the “top” vertices to calculate the position and size of the line. Then I create an image (the line) based on the data.

Thanks again!

1 Like

I’ve found a much easier way to get it.

Just go to the TMP font, and in the inspector modify the “Strikethrough Offset” value, so as to raise the line that was created to strike out the text.

Now with “” you can get the top line.

1 Like

Clever, so long as you don’t need real strikethrough. :slight_smile:

1 Like