Author Topic: Text for multiple languages  (Read 7405 times)

raydekk

  • Newbie
  • *
  • Posts: 11
Text for multiple languages
« on: October 30, 2016, 08:25:01 AM »
In the TextMeshPRO Font Asset Creator I'm trying to create a font asset (for Arial) that can be used for any language.
Basically I have a TextMesh PRO gameobject with a text that can be in Latin, Greek, Chinese, Russian, Thai/any language. So I'm choosing Character Set  = Custom Range and specifying the intervals.
The problem is that if I add all the intervals that I want, the output asset looks really bad(distorted, blurry). If I add only Latin + Cyrillic for example, it works fine. But when I add in Chinese, Japanese - it starts to break.

Any idea of a workaround for this? Or maybe some other font settings in the Font Asset Creator?

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5687
Re: Text for multiple languages
« Reply #1 on: October 30, 2016, 12:53:35 PM »
In the TextMeshPRO Font Asset Creator I'm trying to create a font asset (for Arial) that can be used for any language.
Basically I have a TextMesh PRO gameobject with a text that can be in Latin, Greek, Chinese, Russian, Thai/any language. So I'm choosing Character Set  = Custom Range and specifying the intervals.
The problem is that if I add all the intervals that I want, the output asset looks really bad(distorted, blurry). If I add only Latin + Cyrillic for example, it works fine. But when I add in Chinese, Japanese - it starts to break.

Any idea of a workaround for this? Or maybe some other font settings in the Font Asset Creator?

When targeting mobile platforms and although newer mobile devices support higher texture resolutions, you want to keep your font asset atlas resolutions to 2048 X 2048 or less. In order for the font to look good in terms of the reproduction of the shape, you want to target a sampling point size of about 72 points. Keep in mind that some fonts will looks fine even at 36 sampling point size but targeting that 72 is good. The included ARIAL SDF has a sampling point size of 85.

Given you want to have a good enough sampling point size and a texture atlas that is 2048 X 2048 (for mobile), this will limit how many characters you can fit in a single font asset. You also have to keep in mind the padding which as explained in this video https://www.youtube.com/watch?v=qzJNIGCFFtY should be a ratio of around 7 to 10% of the sampling point size to padding to have a decent range on the material properties. So if you need to include more characters than you can fit in a single font asset, this is where you will use the Fallback system to split up those characters into several font assets.

The recommended way to go about this is to use language files which contain all the text / characters for each of the languages you are planning on supporting. Then depending on how many characters you have in your project / game, for those given languages, you will be able to group some of them. With those groups of languages sorted out, you will use the Characters from File option or the other options to define the characters to be included in those Primary and Fallback Font Assets. (This is also explained in the video above).

Typically, Latin based languages can be grouped together where all the characters are include in a single font asset. You could end up with one Fallback font asset which would be assigned to the Primary Font Asset for the Latin based language. You could also split Cyrillic to have them in their own Fallback. The system is very flexible here there are no limits on the number of fallback you can use. You just have to keep in mind that a text object made up / using 4 Font Asset (combination of primary and fallback) will result in 4 draw calls for that object which can be batched with other objects so it isn't any issue but something to keep in mind.

For Chinese, Japanese and Korean you will typically end up with separate Font Asset with a few Fallbacks for each. There are several posts around the forum covering way to split some of those language but again there is no limit here as the given the Sampling Point Size and Padding you want will determine how many characters can fit into a single Font Asset and the number of total characters determine how many Fallbacks you might end up needing.

When creating the Fallback Font Assets, it is important to maintain the same Sampling Point Size to Padding ratio to make sure the visual appearance of material properties like Outline Thickness, Shadow, etc appears consistent. So if the Primary has a Sampling Point Size of 72 and padding of 5, the Fallback should either have the same or multiple of that like 144 Sampling Point Size and Padding of 10.

Using this information and to maximize visual appearance, this makes it possible to create your Primary Font Assets which include all the known text / characters used by a given language or group of languages in your project at a higher sampling point size and then create Fallback which will include characters that you think might be needed for like user input and use a lower Sampling Point Size while maintaining the same ratio of Sampling Point Size to Padding. For example your Primary could be created at 144 / 12 while the Fallback would be using 72 / 6 or 48 / 4 or even 36 / 3.

Another example.. For Chinese, you will typically want to have a Primary Font Asset which include all the known characters used in your project. Then for your Chinese Fallback Font Assets, you would want to include the characters found in the Table of General Standard Chinese Characters which is comprised of 8105 characters. So your first fallback would include all 3500 characters minus those already contained in your primary. Although these 3500 is likely to be used in use input, you already have all the characters used in your project in the primary so you could actually use a lower sampling point size / padding (maintaining the same ratio) on this 1st Fallback Font Asset. The next fallback would include the 3000 characters from this list again minus those in the primary. This time again you could use a smaller sampling point size and lastly created the 3rd Fallback which would contain the last 1805 characters minus those in the primary. Again depending on the number of characters in your primary, and sampling point size used on the Fallbacks, you could combine some of those. Again you have a lot of flexibility here.

This is a lot of information to digest but the key part is having a list of all your languages and characters used by them. Choosing how you will group these languages and then planning your Primary and Fallbacks.

See the following video about the Fallback system and the following post which describes some of the new changes coming where Fallbacks can even have fallback assigns to them.   
« Last Edit: March 28, 2017, 07:15:43 PM by Stephan B. »

raydekk

  • Newbie
  • *
  • Posts: 11
Re: Text for multiple languages
« Reply #2 on: October 31, 2016, 01:30:21 AM »
Wow, thanks for the reply!
Will give it a shot when I get home.