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

Question TextMesh Pro subscript

Discussion in 'UGUI & TextMesh Pro' started by Wattosan, Nov 11, 2020.

  1. Wattosan

    Wattosan

    Joined:
    Mar 22, 2013
    Posts:
    456
    Hello,

    I am using TextMesh Pro to write chemical reaction equations. These equations require the use of subscripts. However, only one Font seems to support it: Inter-Regular SDF.

    Any other font or a custom one (even when the asset is generated with the same settings as the Inter-Regular SDF) produce only squares in the text instead of the actual numbers. How would it be possible to support subscripts in a custom font?

    I am aware that it is possible to use <sub>3</sub> but I would not like to do that. Instead I would like it to work the same way, like the Inter-Regular SDF font works. The data for the equations is copied from several locations and it seems like an unnecessary extra step to find all of the numbers in the text and to add them between the <sub></sub>.

    Thanks!
     
    Canley likes this.
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I would recommend getting some font editing / viewing tool to view the Unicode / glyph coverage available in any given font file. There are many tools like BMFont, Font Forge, etc. I personally use FontCreator from High Logic.

    There are many fonts that include both superscript and subscript. Arial, FiraSans, etc.

    Be mindful that superscript characters are mapped in a funky way where 0, 4, 5, 6, 7, 8, 9 are at \u2070, \u2074, \u2075, \u2076, \u2077, \u2078, \u2079 and 1, 2, 3 are at \u00B9, \u00B2, \u00B3.