Unity 2020.1.1f1
TextMeshPro 3.0.1
I put the Arial font in my project and created an SDF asset file with Ctrl+Shift+F12.
In UI → Text-TextMeshPro, the ARIAL SDF file created earlier was specified as Font Asset, and Atlas Population Mode on the SDF inspector was also changed to Dynamic.
The problem here is that the characters that are displayed are not displayed even if words from various countries such as Japanese, Korean, Russian, and Thai are entered.
The characters input by inputtext as shown in the source code below are divided for each character in the “SetCharactersToFontAsset” function, but most characters come back as missingUnicodes and cannot display all characters. Hmm.
For example, in UI→Text, Font can be Arial and can display characters mixed in multiple languages.
I thought that based on the Arial font, it would be possible to create characters in real time like the source code.
What is the cause of unexpected disappointment?
Thank you.
public TMP_FontAsset font;
private TextMeshProUGUI textbox_name;
// Start is called before the first frame update
void Start()
{
try
{
textbox_name = this.GetComponent<TextMeshProUGUI>();
↓ Because it was an error when creating a thread
string inputtext = "UI_TMP" + "\n" +
"Written as coronavirus in Japanese" + "\n" +
"Corona virus in Korean" + "\n" +
"Coronavirus in Russian" + "\n" +
"Coronavirus is written in Thai";
SetCharactersToFontAsset(font, inputtext);
textbox_name.text = inputtext;
}
catch (Exception ex)
{
string re = ex.ToString();
}
}
void SetCharactersToFontAsset(TMP_FontAsset font, string text)
{
try
{
HashSet<char> hashSet = new HashSet<char>(text.ToCharArray());
uint[] addCharacters = new uint[hashSet.Count];
uint[] missingUnicodes = new uint[hashSet.Count];
int n = 0;
foreach (char c in hashSet)
{
addCharacters[n++] = c;
}
font.ClearFontAssetData();
font.TryAddCharacters(addCharacters, out missingUnicodes);
}
catch (Exception ex)
{
string re = ex.ToString();
}
}