Search Unity

TextMesh Pro Combinig Font Assets

Discussion in 'Unity UI (uGUI) & TextMesh Pro' started by Eastwing, Aug 15, 2019.

  1. Eastwing

    Eastwing

    Joined:
    Mar 30, 2013
    Posts:
    18
    Hey there,

    We need to have a font asset containing all the existing currency signs. To achieve that I had to use several different source fonts. Now I have the main SDF and 8 fallbacks, like that:

    upload_2019-8-15_11-16-18.png

    I would like to combine CurrencySign assets to a single one. Is that possible?
     
  2. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,348
    Any reason why these currency symbols are all from different font files?

    You should be able to find a source font file that contains all the currency symbols. Then you would only need to assign one fallback to your primary font asset.
     
  3. Eastwing

    Eastwing

    Joined:
    Mar 30, 2013
    Posts:
    18
    The reason is: there's no font contains all the glyphs at once.
     
  4. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,348
    I am surprised that no font contains all the currency symbols or most of them.

    Assuming you cannot find such a source font file, you could pick a source font file that contains most of the symbols and then add the missing ones with some font editing tool.

    Another way which I have not explored that could work would be to manually combine the SDF glyphs from separate textures into a single atlas texture.

    You would need to make sure you select symbols from similar sizes fonts / metrics.

    You would then manually add glyphs to this custom Font Asset and define the GlyphRect (coordinates and size / scale of those glyphs in the combined texture).

    Define the metrics for these glyphs as well which you could copy paste from the original font asset assuming they were all created at the same point size / padding values.

    Then add Characters in the table pointing to those glyphs for the given unicode values for those currency symbols.

    To normalize their appearance given there could be differences, you would adjust the individual scaling of the glyphs in the Glyph table of table.

    The above is all manual editing of these values but a Font Asset is simply a collection of Glyphs that contains GlyphRects which define the position of these glyphs in a texture and their size. Then Characters have a unicode value and point to those glyphs.
     
    Last edited: Aug 15, 2019
    Eastwing likes this.
  5. Eastwing

    Eastwing

    Joined:
    Mar 30, 2013
    Posts:
    18
    I will try that, thanks a lot!
     
  6. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,348
    Let me know how it turns out.