Multiple Language Support - Font Display Issues

Hey!

I was recently talking to someone through support and was suggested to come here in hopes of a solution. I am working on making my app support multiple languages. Right now, I am interested in fixing my issues with our Thai font. I have tried a variety of fonts now and have noticed they all have one of two issues:

  • Vowel and tone characters are overlapping.

  • Vowels and tones are sometimes placed incorrectly (floating) and, in the case of NGUI Labels at least, these additional characters do not count towards the label height, making it very difficult to scale properly.

I have attached an image to help reference the issues. First, I showcase how the font should appear and how the vowels and tones work. Then, I showcase the two types of issues I am running into and how they are incorrect. I have tried to do everything I could to correct this. Here is my current set up:

  • My Unity is up to date at Version 4.3.4f1.
  • My fonts are all set to Dynamic.
  • I am using Unicode 16.
  • Finally, I tested with both the NGUI UILabel and Unity Font Class. Both produced the same types of issues.

So far, I have tried these font files:

  • Angsana New
  • Browallia New
  • Cordia New
  • DileniaUPC
  • DokChampa
  • EucrosialUPC
  • FreesiaUPC
  • IrisUPC
  • JasmineUPC
  • KodChiangUPC
  • Leelawadee
  • LilyUPC
  • Microsoft Sans Serif
  • Tahoma

Is there anything I could be overlooking that is causing the issue? Please help :sad:

I’ve no experience whatsoever with Thai fonts. What I do know is some fonts contain data tables called GSUB and GPOS. GSUB is a table that tells the glyph renderer how to replace sequences of characters with glyphs. A trivial example might be a font that has accents, and uses two glyphs to display the character. GPOS is similar, but tells the renderer how to position glyphs. I suspect that the Thai fonts make extensive use of these tables. These tables are not processed by the font code in Unity. I would expect that a dynamic font in Unity - that’s to say one that uses the OS to do the rendering - would display correctly. As I said though, I’ve never tried and wouldn’t know if the results were correct or not. If your screenshots are from dynamic fonts, then I guess the answer is that Unity/OS isn’t doing the correct thing.

All I know about Thai I gathered in 30 seconds looking at:

If that is a correct document, then to me it looks like there are not large numbers of characters used in Thai. I guess that the right-most character in your first screen shot is U0E19-U0E35-U0E49, which the font renderer knows to composite as a single entity. I obviously don’t know if all Consonants, Vowels and Tone-marks can be combined, or if the set of legitimate characters is restricted. If the latter, then you could consider rendering these characters into your own font, and then have some string manipulation code that says if the sequence U0E19-U0E35-U0E49 is found, then swap it for U0E80, which in your font is those three glyphs composed together. To take an English language example, perhaps you want the letters ae to be swapped out for æ ligature. If you font didn’t happen to have that glyph, you could render one and place it somewhere in your font, and then replace each occurrence of ae with the unicode value that maps to where you’ve placed the glyph in your font. The support for Farsi was implemented this way.

If this approach is feasible, then it will impose some effort on your team to implement. It should deliver you a working solution.

Sorry for the delayed response.

I went the route of creating new glyphs in the font and then, in code, called for a switch based on the combination of characters (as suggested).

This quick-fix works perfectly :slight_smile: thank you for the help!

Glad that worked out for you! Nice one.

Recently I got same problem for displaying Thai letters. With garuda font, Unity3D 5.3 renders it unnaturally. (red-boxed-area is hotspot)

I wrote a simple utility to solve this problem (green-boxed-area is result) and shared it on github.