Hi,
I have read the discussion about TMP and OS Font as below:
// Get the file path of all OS fonts. string[ ] fontPaths = Font.GetPathsToOSFonts(); // Create new Font using one of those paths. Font osFont = new Font(fontPaths[124]); // Create new font asset using this OS font. TMP_FontAsset fontAsset = TMP_FontAsset.CreateFontAsset(osFont);
I want to use this to create Font on cross-platform device. But there is still a problem here, the code above list all the fontpath of the OS, but how do I decide which one to use? Is there any way to get the default font used by the OS? Then I can use it directly.
E.g, if I use the UI.Text, and set font to Arial, Then on cross-platform device, it will use default OS font. Is there similar method for TMP?
When using this default Arial, the legacy text system uses some hard coded list to go thru those OS fonts looking for characters and this is different on each platform. In this implementation, you have no control over what font ends up being used.
Although using TMP requires you learn about what fonts are available on those platforms and select which font you wish to use, you have full control over it all.
On most platforms, your will find the NotoSans font family which does provide support for most language although from different font file. Ie. on Android you have several NotoSans font files and for different language groups.
You can learn about this NotoSans font family here.
You can also check out Google Fonts where you can find fonts per language or cross reference the fonts available on each platform to select which one have what language coverage and which you want to use that have a design style that suites your taste / design.
Apple / Android and all platforms also publish a list of the fonts they include. It is a good idea to look thru that list.
// Get paths to OS Fonts
string[] fontPaths = Font.GetPathsToOSFonts();
// Create new font object from one of those paths
Font osFont = new Font(fontPaths[index]);
// Create new dynamic font asset
TMP_FontAsset fontAsset = TMP_FontAsset.CreateFontAsset(osFont);