Search Unity

TextMesh Pro Character gone wrong when use Bitmap Font

Discussion in 'UGUI & TextMesh Pro' started by dohaiha930, Mar 31, 2018.

  1. dohaiha930

    dohaiha930

    Joined:
    Mar 27, 2018
    Posts:
    55
    Hi, I'm use TextMeshPro for my Bitmap Font. But when i modify my atlas with effect character, character gone wrong cause charater limit area, you can see bellow picture for detail. So i must modify glyph info of X, Y,W, H for all chars to increase its area, it's very hard when i have over 100 chars. So my question is How can i increase char area on atlas? I'm use padding but it not working on this situation.

    My step create Bitmap Font With TextMeshPro(fix me if i'm wrong some step):
    - Create font asset with bellow settings.
    - Export atlas
    - Modify Atlas
    - Change Shader of textmesh material to TextMeshPro/Sprite.
    - Drag and drop my new atlas to material
    - Done

    My TextMeshPro Font asset for test under bellow!

    Thanks!


    My Settings Export



    My Default Atlas Export


    My Atlas after modify




    Wrong Text


    After i modify Glyph Info,
    number 5 for example
     
    Last edited: Mar 31, 2018
  2. dohaiha930

    dohaiha930

    Joined:
    Mar 27, 2018
    Posts:
    55
    Unity forum block me to update my post with test asset, so i post it in here.
     

    Attached Files:

  3. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I just tried the same process and everything lines up correctly.

    Since I don't have access to the Rubrik font file, I used Oswald-Bold included with TextMesh Pro. I followed the same steps you outlined and simply added a green outline in Photoshop.

    In the image below I have two text objects on top of each other.

    upload_2018-3-30_23-42-9.png

    Check to make sure your modified texture didn't get shifted in Photoshop or as a result of some texture setting when you re-imported it.
     
  4. dohaiha930

    dohaiha930

    Joined:
    Mar 27, 2018
    Posts:
    55
    Can you try to make bigger outline geometry for each character? I try Oswald-Bold but same result. My Texture setting is Default. I try to change to sprite (2d and UI) but nothing change.



    I uploaded split font asset file bellow, you can check it.

    Oswald Bold.asset.txt - plz remove .txt cause i can't up file with .asset
     

    Attached Files:

    Last edited: Mar 31, 2018
  5. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The behavior is related to the padding value not being correctly applied when the geometry of the characters is created. As a result, the characters end up being clipped.

    I'll take a look tomorrow but this is something that I should be able to change fairly easily. This will require a new release of TMP unless you are using the source code version or the Unity 2018.1 release of the TMP which is available via the package manager.

    Alternatively, the individual glyphs (x, y, width and height) and offset (ox, oy) can be edited manually in the font asset glyph table.
     
  6. dohaiha930

    dohaiha930

    Joined:
    Mar 27, 2018
    Posts:
    55
    - I'm using newest version of TMP from asset store - Unity 2017.1.1f1
    - About padding, so TMP don't affect clip area for characters by padding? If not, i truly hope you will add some option to modify that. Thanks!
    - Yeah, i must modify all individual glyphs of chars to make it look perfect, but it's truly painful when i have to do for multi font or atlas, or contain many characters.

    Btw: This is the quick way for anyone need to modify individual glyphs:
    1. Download and install paint.net
    2. Use Magic Wand to select one character you want to set glyphs.
    3. Look at bottom left, then you can see X, Y, Width, Height.
    4. Fill on glyphs info, ez pz. LOL

    fd.PNG
     
    Last edited: Mar 31, 2018
  7. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I modified the Normal Bitmap shader to add a padding property as seen below.

    upload_2018-3-31_14-23-42.png

    Since this padding value is related to the modified font atlas texture, it makes sense to have padding set per material and not per font asset. This way, you could use multiple modified font atlas textures each with their own specific padding values.

    Here is an example where I modified the font atlas texture in Photoshop to add an Outline and Shadow. I switched to the Normal TMP Bitmap shader. Assigned the new atlas as well as a texture on the face (for fun). Lastly I adjusted the padding on this material.

    upload_2018-3-31_14-28-28.png

    Note that I did not have to touch any of the Glyph Table data for the font asset.
     
  8. dohaiha930

    dohaiha930

    Joined:
    Mar 27, 2018
    Posts:
    55
    - I'm use Sprite shader to make bitmap font working, use Bimap font it 's just show white charater.
    - So i just need to update my TMP to newest version to use this feature?

    Thanks!
     
  9. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I modified the TextMesh Pro bitmap shader to add this new functionality. You will need a new version of TextMesh Pro unless you are using the paid / source code version or the Unity 2018.1 version where both include source code and as such I could provide you the changes.
     
  10. dohaiha930

    dohaiha930

    Joined:
    Mar 27, 2018
    Posts:
    55
    Can you send to me shader? Cause i can overwrite it(TMP_Bitmap) on resource folder. I'm use newest version of TMP from asset store.
     
  11. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The shader alone won't do it as this requires also code changes.
     
  12. dohaiha930

    dohaiha930

    Joined:
    Mar 27, 2018
    Posts:
    55
    Please give me the changes, i will try to modify on 2018.1 version. Thanks!
     
  13. dohaiha930

    dohaiha930

    Joined:
    Mar 27, 2018
    Posts:
    55
    Hello? Anything wrong? :rolleyes:
     
  14. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Replace your current TMPro_ShaderUtilities.cs file with the one below.

    Copy this new shader shader in the same location as the other TMP shaders.
     

    Attached Files:

  15. dohaiha930

    dohaiha930

    Joined:
    Mar 27, 2018
    Posts:
    55
    Thank you very much! :D