Search Unity

TextMesh Pro Covering all world currencies (well, sort of)

Discussion in 'UGUI & TextMesh Pro' started by Starbox, Feb 19, 2021.

  1. Starbox

    Starbox

    Joined:
    Sep 17, 2014
    Posts:
    470
    I'm facing a problem with managing currencies. Surely this could be extended to the whole topic of support for a multitude of languages–and localisation is quite a nightmare in itself–but let's keep focused on simple things here.

    Since my app relies on IAPs, I have tried to find a font that would contain most of the required symbols to display all possible prices permutations for the whole globe. After hours of search and some tests in Textmesh Pro's Font Asset Creator, I found that CODE2000, NotoSand and the Roboto family (I tried the medium type) should contain these symbols.
    However, thus far I obtained only mixed results. Eastern Europe or Asian currencies can be missing from one font to the other.

    I watched this video to see if I had missed something important regarding the management of static + dynamic fonts but nothing special came up.
    Luckily someone recently posted a summary of what should be done to support several types of currency symbols.

    I tried this specific range: 000-07f,400-4ff

    The best fonts have been NotoSans and Roboto yet BOTH are missing 31 characters.

    Here's the list of currencies I want to include:

    (all characters are displayed in my browser, no squares)

    I currently have a very stylized main font that's quite restricted in the number of characters it can display although it possesses some of the main currencies.
    I switched between either the NotoSans or Roboto one as a dynamic fallback font and, with a few material set ups, managed to have the missing character match relatively well the style of the main font (which is static).

    But I'm still getting squares for the Russian and Gregorian currencies for example.

    Any idea how I could solve that?
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    That has to be a font file that contains all currency glyphs...

    With a font editing tool, you edit an existing font to add the missing symbols you need. You would need to make the licensing terms of the font file allows it but that might be an option.
     
  3. Starbox

    Starbox

    Joined:
    Sep 17, 2014
    Posts:
    470
    I find it weird because as I understood it, Roboto included the latest additions, for example for ₾ (Georgian lari, U+20BE) ₽ (Russian ruble, U+20BD) and ₺ (Turkish lira, U+20Ba). I don't understand why such characters can be missing.
    I expected 0400-04FF to cover Cyrillic and some major Eurasian symbols (to compare, see with the listing here).

    For example, as custom characters in the Font Atlas creator:

    I get the following results ('characters included') in the following fonts:

    NotoSans Regular or Bold
    2/4 (only ₺)

    Roboto Medium
    1/4

    CODE2000
    1/4

    Here, Roboto is listed as a font that supports the Russian ruble. It's also compatible with the Georgian lari and the Turkish lira.
    I tried Futura and Arial Rounded Bold and they also only get 1/4 and a black atlas.
    All fonts that have an output of 1/4 return a black atlas. These fonts should support them, or at the very least the Russian ruble so I don't understand where the problem lies exactly here. This is strange. Arial, Times New Roman, Tahoma, Cambria and Calibri all included the Russian ruble since many years now. I thought I wasn't giving the atlas enough room, taking too much padding, etc., but these shouldn't have mattered much since the sprites would have simply been smaller.

    I haven't modified the Textmesh Pro settings in Player Settings either.
    TMP v2.0.1.

    So I'm inclined to ask if you have experience of similar past issues where for some reason expected characters could not be extracted, and if yes, what was the method to solve them?
     
  4. Starbox

    Starbox

    Joined:
    Sep 17, 2014
    Posts:
    470
    I have been unable to extract the necessary symbols thus far despite numerous tests. I understand that creating a new font system or editing an existing one would not change anything since Unity's TMP is unable to extract the relevant symbols regardless of the font used (assuming it contains those symbols).

    This means I will have to create an atlas outside Unity, import it and associate it to a new TMP font, static because it relies on an atlas even if it's meant to be used as a fallback resource.

    If for some reason the fallback would not work as planned, then I'd have to rely on code that will check the user device's language to use, if needed, the fallback font instead of the main one. This will require separating the price itself from the currency symbol. :(
     
  5. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    There should be no issue accessing the glyphs provided they exist in the source font file.

    What specific symbol that are known to be contained in a font file were you not able to access?
     
  6. Starbox

    Starbox

    Joined:
    Sep 17, 2014
    Posts:
    470
    At least these three:

    ₾ ₽ ₺

    There are also a few other squares for far secondary currency symbols but they're not as important right now. I don't understand why the extraction doesn't work on these. Are there specific settings I could try in Project Settings > TMP > Settings? I have not altered them.

    The only other (weak) option I am left with is to update to the last verified TMP package and hope this solves the issue.

    Also, it is possible to use an external atlas and then manually edit a new font to help TMP point to the appropriate sprite coordinates on this imported atlas?
     
  7. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    There are not special options. For testing purposes, just create a dynamic font asset from one of those fonts. Then assign it to a text object and copy / paste those characters. If they are present in the font file, they will be displayed.

    There is no need to try to create an atlas outside of Unity as dynamic font assets with multi atlas texture enabled make it possible to handle / display every single glyph present in a font file. Multi Atlas texture support was added in version 2.1.x of the TMP package.

    I would also suggest watching the following two videos which cover most of the functionality of dynamic font assets as well as Multi Atlas texture support.

    I would recommend updating to the latest release of TMP which is version 2.1.4 as version 2.0.1 is pretty old.





    P.S. Since it is already almost 4:00 am on my end, I'll test those 3 characters tomorrow with the font files you referenced in your previous posts.
     
  8. Starbox

    Starbox

    Joined:
    Sep 17, 2014
    Posts:
    470
    Right, nice. I'll move to 2.1.4 right away and hope all goes well!
     
  9. Starbox

    Starbox

    Joined:
    Sep 17, 2014
    Posts:
    470
    No luck. The update hasn't unlocked the super powerful option to grab some Slavic runes. ((
    Whatever causes the blocking remains a mystery, so I'll fall back onto a cheap method of prerending the symbols into PNG files and then use the sprites instead of crude text when the currency code requires it.