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.
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.
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.
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.