[BUG] is voffset broken?

We recently update to 2020 and with it to the new TMPro (reproducible in 3.0.1 and 3.0.3).

voffset tag used to be the offset from the baseline where to render the word. It used to look like this:

but now it seems to be instead the space in between letters

6485861--728906--upload_2020-11-3_12-14-34.png

Edit: it seems that the problem is caused by the tab BR used in the string. Still investigating as the code of the package seems clear enough

this is the current string: <voffset=3900><size=120><color=#8c0101>E
A
S
Y

with the new text mesh pro, the old behaviour is equivalent to do

<size=120><color=#8c0101>
E
A
S
<voffset=3900>Y

which looks very weird to me.

I realised that the new behaviour may make sense because I don’t think before it was possible to do :

<size=120><color=#8c0101>E
<voffset=320>A
S
<voffset=3900>Y

6485984--728909--upload_2020-11-3_12-48-17.png

although maybe

<voffset=3900><size=120><color=#8c0101>E
<voffset=320>A
S
Y

could have worked? (tried it didn’t, before multiple voffset were ignored)

I did the naive thing to move voffset at the end of the string instead of the begin. It works in some cases, but not in another. This means I didn’t crack how voffset used to work in TextMesh Pro 2.0.1 and how is different from 3.0.3

please help

edit : it seems that when voffset is used with pixel values, it gives different results with 2.0.1 and 3.0.3. Did the unit reference change?

OK so after several hours investigating I realised that I cannot figure out on my own a way to revert to the old behaviour just parsing the string. I may be forced to actually revert the portion of code involved in the voffset logic hoping it would be neough

I have managed to make 2.0.1 work again in unity 2020 (was very simple actually), but I am not sure about it as long term solution

I will try taking a look at this later today.

Is the issue primarily the difference in spacing?

Changes were made to spacing which would affect voffset in the preview phase of 2.1, etc. This was done to make spacing more consistent. See the following thread related voffset which might provide some additional insight on this.

In terms of the voffset spacing, it is in pixels so assuming correct scaling of the camera, etc. a value of 3900 would be 3900 pixels which is massive. If you need the value to be relative to the point size of the text, then I would use an em value instead such as <voffset=1em> where assuming the point size is 100 would represent 100 pixels. if the point size was 50 than 1em would be 50 pixels.

1 Like

Yeah the problem is that we are letting the users input text with tags for customization and they get there with trial and error. Using pixels is a mess and a slight change breaks everything

You might want to switch to using em scale instead of pixel such as <voffset=1em> which would yield more predicable results.

Alternatively, you might want to use the ITextPreprocessor and PreprocessText() to filter / limit potential value ranges for users.

we literally let the users copy and paste tags, so I guess the second solution may be interesting. However I noticed that the problem wasn’t about the value, but the fact that the value seems to have a different scale between the two version of text mesh pro.

I didn’t get to the point where I understood what would cause the difference in scale. My limited understanding that could be wrong is that moving the voffset in such a way the result would be the same from before to after, would work only with em values, but not pixel values.

When I realised that, I stopped investigating and just made 2.0.1 work again, which luckily was just one line of code matter!

it would probably be extremely useful to have a conversion formula from pixel to em, so that we at least serialize the data only in em format. Do you have that?

The change with regards to handling of spacing values was necessary as the previous implementation was inconsistent and incorrect. There is no easy conversion since the inconsistency was due to how sampling point size vs text point size were handled.

Having said that, the tag value handling doesn’t seem affected contrary to my initial replies. As such, my apologies for the confusion. Please still note, this spacing change will affect spacing values in the inspector as well as tags like , which your users could end up running into but in this case, it is the other changes outlined in this thread that would be causing the change in behavior.

Now back to the main topic and figuring out if we are getting the desired / correct behavior.

The easiest way to understand the change is that now affects the baseline of the characters but not of the line.

Let’s take a look at a few examples to understand the difference between 2.0.1 and 2.1.3.

Given the following text “A<voffset=10>B”, we get the same behavior in 2.0.1 and 2.1.3. The letter “A” is positioned at the baseline and the “B” offset by 10.

6495327--730701--upload_2020-11-5_14-14-26.png

If we now remove the letter “A” where the text is now “<voffset=10>B” we get the following results in 2.0.1 and 2.1.3.

6495327--730710--upload_2020-11-5_14-24-50.png

In both cases, the letter “B” is offset by 10 but in 2.0.1, the line baseline shifted up as well whereas in 2.1.3, it remained unchanged. If we were to re-insert the letter “A” before the B or a space in 2.0.1, this would affect the line baseline but not in 2.1.3.

The above difference is important because, the subsequent line is positioned at the Descender of first line + line gap + ascender of subsequent line where in this case, the change in baseline between 2.0.1 and 2.1.3 produces the following results.

6495327--730719--upload_2020-11-5_14-37-22.png

Given the following text:
“A<voffset=10>B
C”

Where we again insert the letter “A” before the tag, thus producing roughly the same results with the exception of the baseline of the second line shifting up since the letter “C” is first on the 2nd line. Ie. Same results as with the first line with or without the letter “A” before the tag.

Now, removing the letter “A” from the first line, gives us the following:

6495327--730722--upload_2020-11-5_14-45-57.png

In 2.0.1, since the first line’s baseline and descender have shifted up resulting in the 2nd line and “C” being shifted up whereas in 2.1.3, the results remain consistent where the “C” is offset correctly above the line baseline which is also consistent whether the letter “A” is inserted above or not.

Basically, in 2.0.1, you would get different results whether you had a character at the start of the line before whereas in 2.1.3, that is no longer the case. In addition, in 2.0.1, you would get a different result if you had at the end of the line before a line feed or
because this line feed would be position on the line baseline just like when you have a letter at the start of the line. Now again, in 2.1.3, this is consistent as seen in the image below using the following text “<voffset=10>B
C”

6495327--730728--upload_2020-11-5_14-59-2.png

This is most certainly a change in behavior, especially when your line of text starts with or ends with but it will now produce more consistent layout results and behavior.

Please note that a positive value can affect the max line ascender which will affect top vertical alignment as the text is aligned based on the top ascender of the first line. A negative can affect the max line descender which will affect bottom vertical alignment as it uses the lowest descender of the last line. These max line ascender and descender do ultimately affect line spacing.

Please help me understand how your users were using this tag and for what purpose?

Hello,

I understood that the behaviour of the new text mesh pro was correct from my experiments. The problem is that we cannot use the new one as it will break our users previous generated. Our game is gamecraft. It’s a game that allows users to create games (ah!) through blocks.
one of these blocks is the Text Block. Modders started to create complex tool to use the block in unintended ways, like to create sprites.
You can see what I mean from this screenshot:

the easy text is a text block, but unexpectedly that big tapestry is also a text block. They use the voffset as trial and error mainly to find the correct vertical offset to match the environment

I presume users are doing this exclusively through the use of rich text. Correct?

Are these text objects using Baseline vertical alignment?

What if I added a new tag to offset the baseline? Not sure how it would behave yet but it should mirror the previous voffset behavior.

1 Like
  • yes rich text, they can input the tags directly
  • they usually use just one single voffset (which would cover most of the cases)
  • that would be incredibly awesome from you and very appreciated!