Search Unity

TextMesh Pro TMPro 2018.4 font generator doesn't center characters like 2017.4 source version

Discussion in 'UGUI & TextMesh Pro' started by wahlerdigital, Oct 20, 2019.

  1. wahlerdigital

    wahlerdigital

    Joined:
    Jul 1, 2019
    Posts:
    16
    The 1.4.1 and 1.5.0 font generator using SDF32 rendering is offsetting characters to the left, this did not happen in 2017.4 using the latest source version of TMPro from the old forums. I have a workaround, I generate the fonts in 2017.4 and copy them over to 2018.4. They are still off center, but not nearly as much as generating the fonts directly in 2018.4 Characters generated and displayed in 2017.4 are perfectly centered.

    This only seems to happen using SDF32 rendering and the non GUI version of TMPro components. Using SDFAA or SDFAA-HINTED rendering centers the characters properly but doesn't look very good due to rough outlines and very rough shader glow effects.

    Here is an screenshot of the issue. These are two TMPro non GUI components overlayed. Each has a single glyph. The white glyph is a perfect circle. The green collider is centered at 0,0,0. Note the offset left. The component is set to align center in both directions.

    Any help to get me going with SDF32 rendering and centered glyphs in 2018.4 would be very appreciated.

    robert

    Puck.2018.4 SDF32 Generated.png
     
  2. wahlerdigital

    wahlerdigital

    Joined:
    Jul 1, 2019
    Posts:
    16
    My workaround is not effective. Is this a bug that will be addressed? Is there a workaround? It appears to be a fixed offset on each character. Is there a way to apply an offset right to all characters in an SDF asset?

    The left offset appears using any of the SDF render modes in Unity 2018.4 using TMP 1.5.0 and 1.4.1. The offset does not appear on SDFAA but that doesn't look good. See below for examples. Thanks for the help.

    This font was generated using SDF16, note the left offset.

    Fredoka-2018.4-SDF16.png

    The same font generated using SDFAA rendering and no other changes. Note that the character is centered but doesn't look as smooth as SDF16.

    Fredoka-2018.4.SDFAA.png
     
  3. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    The Legacy SDF modes like SDF16 and SDF32 are very accurate but extremely slow. The SDFAA modes are super fast where they can be used for dynamic support but less accurate.

    When comparing legacy SDFXX and SDFAA modes, make sure you are using the same sampling point size and padding.

    Here is an example comparing the 2 modes with sampling point size of 90 and padding of 9.

    upload_2019-10-22_14-55-50.png

    As you can see, at equal sampling point size, the SDFXX and SDFAA are virtually identical. However, when adding an outline, we can see the difference in terms of accuracy. There is an additional issue in the SDFAA generation, that is causing the cuts in the outline which is something that I will be able to address when I have time.

    Having said that, unless the text is displayed at greater than 90 point size with a similar outline, these inaccuracies are not visible due to the fact there are not enough pixel to reflect them. Below is an image of the above text at 36 point size at 1X & 5X zoom.

    upload_2019-10-22_15-5-34.png

    upload_2019-10-22_15-5-42.png

    As you can see, at 36 points and displayed at proper scale, the difference between them is marginal and in most case not noticeable.

    Now same example at 92 point size at 1X & 5X zoom

    upload_2019-10-22_15-5-53.png

    upload_2019-10-22_15-12-59.png

    So unless the text is going to be a title with heavy styling like Outline, Shadow and displayed at larger than 90 point size, using the Legacy SDF modes will provide best results.
     
    Last edited: Oct 22, 2019
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,596
    In terms of the positioning of the glyph in the texture / offset, this is something that I need to investigate and will provide feedback once I have more information.
     
  5. wahlerdigital

    wahlerdigital

    Joined:
    Jul 1, 2019
    Posts:
    16
    Thank you for looking into this. I have two games that make heavy use of TMPro large point fonts with lots of outlining and styling with individual characters arranged on a grid. I would revert to 2017.4 but that will complicate my Xbox ports. I can live with using the 2017.4 system to generate fonts at higher visual quality but I can't manage to fix the biggest issue of the character offset to the left. The offset left on the lower right glyph in your first image is the problem I'm dealing with, it is very prominent when displayed on a grid when you expect everything to line up. Here is a screenshot of the game I'm working on so you can get an idea of the importance of alignment to me, all the foreground items are made with TMPro and line renderers. The screenshot is from Unity 2017.4 and everything aligns perfectly.

    Level035.E.600.jpg
     
  6. wahlerdigital

    wahlerdigital

    Joined:
    Jul 1, 2019
    Posts:
    16
    Actually, center alignment is my only real issue as the reason I'm dropping down to 2017.4 to do the SDF32 generation is that the alignment is much better than SDF32 generated on 2018.4. Better, but there is still a shift left.