Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

TextMesh Pro Glyph Scale dont change line height

Discussion in 'UGUI & TextMesh Pro' started by Rafael_CS, May 26, 2020.

  1. Rafael_CS

    Rafael_CS

    Joined:
    Sep 16, 2013
    Posts:
    161
    Hello @Stephan_B i found a bug related to Sprite Glyph Scale and Line Height

    When i changed the scale of sprite glyph, the lineheight will be calculated as if the scale equals 1.

    The "advance" will be calculated correctly but the lineheight will ignore the glyph scale

    In this image bellow i changed the Sprite Glyph Scale to 2
    upload_2020-5-26_18-34-55.png


    Best Regards
    Rafael
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Confirmed.

    Will make the necessary changes which I should be able to include in Preview 14.
     
    Rafael_CS likes this.
  3. tessellation

    tessellation

    Joined:
    Aug 11, 2015
    Posts:
    390
    Possibly a related bug? It looks like when there's only sprites on a line, the line height is no longer calculated correctly in Preview 14:
    Screen Shot 2020-06-30 at 3.47.32 PM.png
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I'll take a look.

    I would suggest defining Face Info metrics for your sprite asset(s) if they are going to be used on their own.

    Normally sprites inherit the metric of the current font asset whereas defining Face Info metrics will use these instead.
     
  5. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Do you get the same behavior when using EmojiOne default sprite asset?

    I am testing with
    "1 2 3
    <sprite=0><sprite=1>
    A B C"

    and that appears to be working as expected.

    upload_2020-6-30_17-19-44.png
     
  6. tessellation

    tessellation

    Joined:
    Aug 11, 2015
    Posts:
    390
    That's probably related, I didn't know Sprites had FaceInfo, I guess this is new-ish. The sprite FaceInfo is all zeros. I had upgraded them from older versions of TMP. I'm trying to fill it in so that it appears the same size and v-offset when the sprites are in a line with letters. I'm not sure how these metrics work or what they are relative to, because it's not sprite pixels. Is there more information about this somewhere? When I increase the sprite point size, the TMP mesh for it decreases in size on screen.

    My sprites are all 128x128, but the Face Info metrics that work best for me are PointSize=190, Scale=1, AscentLine=100, Baseline=0, DescentLine=0 I was able to find these numbers by experimenting and they seem to work for all my fonts, so that's good, even if they don't make sense intuitively (at least to me).
     
  7. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Sadly the metrics are up to what works for you.

    Typically, if the sprites are 128 x 128, a point size of 128 should get you close in terms of size. Then you will have to adjust the Ascent and Descent lines which should total close to 128 but again that is approximate.

    Normally, I set the point size to the size of the sprite and scale to 1. Then I adjustment the Ascent and Descent lines to match my primary font asset. This way I get consistent results between those.
     
  8. tessellation

    tessellation

    Joined:
    Aug 11, 2015
    Posts:
    390
    Thanks. OK, so in my case 128 point size would be too large relative to my fonts, so is it your advise to make the point size larger (e.g. 190 like I've done) or to adjust the scale?
     
  9. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Yes. As long as it looks the correct size and you adjust the Ascent and Descent lines, you should be fine.
     
    tessellation likes this.
  10. Repiteo

    Repiteo

    Joined:
    Jun 16, 2019
    Posts:
    5
    Tried the aforementioned test from a fresh install, EmojiOne didn't come with any Face Info set



    Could we potentially get some sort of "inherit parent" checkbox for the sprites' face info that auto-matches it to the font it's serving as a fallback for, even if it's on a new line?
     
  11. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    EmojiOne does not have metrics defined by default.

    This is the default behavior which is to use the metrics of the current font asset.

    To have the sprite asset use its own metrics, you need to define them manually as I have outline in previous posts above.
     
  12. Repiteo

    Repiteo

    Joined:
    Jun 16, 2019
    Posts:
    5
    Ahh, I misunderstood your image then. I thought that was what EmojiOne should've looked like out of the box

    It's what it uses when text is on the same line, but not when separated by a line. I suppose I meant a more global override (newlines and all), because it's still a bit inconsistent in practice. The best workaround I've found so far is to have lines with only sprites to start with "\u200b" to insert a zero-width space

    So instead of "inherit parent" maybe I should've said "inherit default" or "inherit always"? I apologize if I'm not making myself clear
     
    Last edited: Jul 5, 2020
  13. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Make sure you are using Preview 14 as you should no longer have to add any characters at the start of a line. It should work in either cases.

    Having said that, it is better to define metrics for the face info of your sprite asset to match the metrics of your primary font asset Ascent and Descent lines as explained in previous posts.
     
  14. Repiteo

    Repiteo

    Joined:
    Jun 16, 2019
    Posts:
    5
    On the contrary, I went back to Preview 13 to test & the issue isn't present there



    This problem of sprites not properly using the FontAsset is new in Preview 14
     
  15. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I'll take another look :confused:

    What font asset are you using?

    I presume the text is as follows:

    123
    <sprite=0><sprite=1>
    ABC

    Do you have any spacing adjustments on that text object?

    This is what I get with Preview 14

    upload_2020-7-6_19-13-38.png
     
    Last edited: Jul 7, 2020
  16. Repiteo

    Repiteo

    Joined:
    Jun 16, 2019
    Posts:
    5
    Back to a fresh Preview 14, captured the following using only the vanilla assets



    Not sure if Unity version has anything to do with it, but I'm on Unity 2019.4; Both 2019.4.1 and 2019.4.2 gave me this issue
     
  17. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    What font asset are you using?

    Can you provide me with your font asset?

    I have a feeling that your primary is missing the space character or something hence why I want to take a look at it.
     
    Last edited: Jul 7, 2020
  18. Repiteo

    Repiteo

    Joined:
    Jun 16, 2019
    Posts:
    5
    It's using everything that came with a fresh install of Preview 14, so LiberationSans. I grabbed the example-pack as well to test with them, and they all show the same issue



    Here's all the font assets from Preview 14 base & examples
     
  19. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I was able to reproduce and resolve the issue.

    This will be fixed in the next release which will be available within the next few days.
     
    Repiteo likes this.
  20. tessellation

    tessellation

    Joined:
    Aug 11, 2015
    Posts:
    390
    @Stephan_B Thanks to @Repiteo because I posted the same exact bug above about Preview 14 breaking things from Preview 13, I guess I was just not clear or something. The work-around of adding metrics to the sprite asset works, but I'm glad the issue was resolved regardless.