Sprite size

Using TextMeshPro-1.0.55.56.0b12 in Unity 2017.4.0f1

I was fixing text baseline alignment issues we had in our game and remembered to also test sprites. As I was suspecting, they all have different sizes and positionings. In the screenshot above, all texts have a font size of 50. The japanese one (3rd line) has a scale of 1.3 but changing it to 1 also scales the sprites so that’s not the issue (and is the behavior I would expect).

Is there a way to normalize sprite size and positioning accross different fonts ?

As you have discovered, Sprites are normalized based on the Primary Font Asset assigned to the text object.

I can look into revising the implementation to be relative to the current font. I just need to make sure this doesn’t negatively impact any other use cases.

Hum, actually, what you see in the screenshot are different game objects with different main fonts. The screenshot doesn’t rely on fallback fonts

On a side note, I’m still getting baseline issues when changing fonts at runtime. Is there anything else to do besides assigning the font member? I tried calling UpdateFontAsset but my texts still are weirdly aligned vertically. But it could be unrelated, I see other weird positionning behavior in my scene.
EDIT: Ah! Nevermind, switching to midline instead of Middle fixed all my issues.
EDIT2: All my issues related to the sidenote. The sprites still are weird.

Can you provide me with the raw text you are using for testing?

The baselines should still be aligned provided the font themselves are sticking to normal design rules.

http://lywenn.eu.org/bazar/FontTest.zip I extracted my test scene here, I think properly.

I just noticed that I was in top mode in my test scene instead of middle mode. I fixed my baselines in middle mode and it looks better now even in middle mode, although it’s not perfect yet. (not in the zip)

I just noticed something else: the baseline changes whenever a fallback font is used:
If I remove that A, the korean text jumps up to be properly aligned to the reference line


Ok so, in this screenshot, you can see what I did : I scaled up/down some fonts and changed their baselines to harmonize them. If I use them separately, all goes well, which is the main case in the game so I’m mostly fine with that. But in the bottom you can see what happens when I use fallback fonts, it looks like the baseline of fallback fonts is not used and the one from the main one is instead, creating that subscript/superscript kind of look… Am I using textmeshpro wrong here is that to be expected? With how I just generated the fonts, it shouldn’t be much of an issue in our game, but still…

And we still have the uneven sprites which is my biggest problem here actually.

I have made the change to have sprites scaled based on the current font. This also required changes to baseline positioning.

If you can send me a Repro of your test project, I can take a look at the handling of the baseline when the fallback kicks in.

Great! I assume it will be available in the next update on the asset store? Any ETA?

Here’s a repro project for the multi-font baseline issue: http://lywenn.eu.org/bazar/FontTest2.zip

I didn’t see anything related to this in the text mesh pro changelog. Any ETA on when the patch will be available?

New package manager version of TextMesh Pro should be available within a day or so.

Is this fix available for 2017.4 LTS ?

We’re using 2017.4 LTS too. Will TextMesh Pro be also updated in the asset store?

I am working on a new major feature. Once done, I’ll try to get that release available for 2017.4 as well.

Thanks!

We’re now on Unity 2018.3.8 and the 1.3.0 TMPro package. It looks way better but it’s still not there yet.

The most annoying part is not really the vertical alignment of texts in fallback mode but really the scale of the sprites that looks a bit random…

I had tweaked the fonts to work around the issues we had. For this screenshot, I’ve reset all the baselines to 0 and the scales to 1. (it looks better than with the workarounds…)

imho, for the vertical alignment issues, it seems the computations are done relative to the topmost part of the font while it should be with the bottom. So that the baselines end up aligned.

I’ll revisit this as soon as I find the time.

Please give this a try in version 1.4.0 which includes the new Dynamic system. Be sure to test using a backup of the project.

1 Like

The sprite scale seems fixed in 1.4. It’s only the vertical alignment that is still weird.

But now the behaviour is much more consistent! Modifying scales & baselines, I can get something perfect!

Thanks! :slight_smile:

Unrelated: the only thing that broke in my test project when upgrading to 1.4 is the link to the fallback fonts

Known issue which will be fixed in the soon to be release version 1.4.1 and 2.0.1.

I am still planning on revisiting the vertical placement of the sprites when time permits.

On that note, the sprites are placed based on their pivot being at Origin (which is the advanced of the previous character) and Baseline.

1 Like

Sorry for not being clear, the vertical placement of sprites is fine now. I was rather talking about the vertical placement of fallback fonts, which seems to be computed from the top of the characters, rather than from the bottom.

4448272--407734--upload_2019-4-19_15-4-13.png