Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overlapping display of the upper vowel and the tone character in Thai Language #28371

Closed
nthana opened this issue Apr 24, 2019 · 10 comments · Fixed by #41100
Closed

Overlapping display of the upper vowel and the tone character in Thai Language #28371

nthana opened this issue Apr 24, 2019 · 10 comments · Fixed by #41100
Milestone

Comments

@nthana
Copy link

nthana commented Apr 24, 2019

[Godot v. 3.1 stable]
[Tested on: Godot on MacOS]

In Thai language, a consonant character may be followed by an upper vowel, a tone character, or both. These characters must be displayed above the consonant. When these characters appear simultaneously, the tone character's vertical position should be moved to above the upper vowel character, preventing the overlap.

Currently, Godot can display upper vowels and tone characters correctly. However, when both occurs, they are incorrectly displayed in run-time (overlapping occur), but correctly displayed on the label-text editor in design-time.

The test project: https://github.com/nthana/ThaiFont

In label-text editor (correctly displayed):
In label-text editor (correctly displayed)

On runtime (incorrectly displayed):
On runtime (incorrectly displayed)

Thanks.

@akien-mga akien-mga added this to the 3.2 milestone Apr 24, 2019
@akien-mga
Copy link
Member

The difference between the in-game display and the editor display is due to the font Trirong-Medium.ttf. If you use the same font as editor font, you'll see the problem appear in the Inspector too.

The font itself is fine though, here's how it looks like in LibreOffice:
Screenshot_20190424_123404

So there's an issue in how we/freetype handles this font.

@nthana
Copy link
Author

nthana commented Apr 24, 2019

@akien-mga Thank you. I'm grateful for the response. I'm totally agree with you. The font is fine, because I use this font with other applications. I also tried with other fonts, and the problem still occur.

I couldn't help on C++ coding because my knowledge on C++ & the Godot source code is limited.
But I am very glad to help on how the algorithm should be. With my Thai language knowledge, I will try to describe the algorithm on my next post. The algorithm is not too complex.

p.s. I'm native Thai and I've currently strived to promote Godot Engine usage in Thailand.

@nthana
Copy link
Author

nthana commented Apr 24, 2019

The below picture shows all of Thai characters in Unicode.
(adapt from source: https://jrgraphix.net/r/Unicode/0E00-0E7F )

Thai Unicode

Upper Vowels : shown in Blue frames.
Tone characters : shown in Red frame.

The algorithm is:

  • whenever an "upper vowel" is followed by a "tone character", The tone character should be vertically raised to prevent overlapping.
  • Special case: "Any Tone Character" + "0E33". In this case, the tone character should also be vertically raised to avoid overlapping.

(note: the only upper vowel that may follows a tone is "0E33")

Thanks.

@starry-abyss
Copy link
Contributor

starry-abyss commented Apr 24, 2019

The algorithm is:

whenever an "upper vowel" is followed by a "tone character", The tone character should be vertically raised to prevent overlapping.

Not a languages guy, but I guess if there's an algorithm involved, one might need this feature #21791

@nthana
Copy link
Author

nthana commented Apr 24, 2019

@starry-abyss Wow! From the screen shot of #21791, it displays Thai language perfectly.

So, may be, this issue is the sub-problem of that general implementation in #21791

@akien-mga
Copy link
Member

Since it works with the default editor font though (NotoSansThaiUI_Regular.ttf), it seems like we can already support the features needed for Thai even without advanced font shaping needed for e.g. Arabic.

Here's how Label looks like in game with NotoSansThaiUI_Regular.ttf (+ NotoSansUI_Regular.ttf as fallback to have the latin glyphs):
Screenshot_20190425_092418

The diacritics are not shown on the two middle lines, which is weird as they are actually visible in the Inspector.

@akien-mga
Copy link
Member

With both fonts, I can get the diacritics to show on the middle lines by changing the extra_spacing/char property of the DynamicFontData.

E.g. here with 1:
Screenshot_20190425_094305

And with -3:
Screenshot_20190425_094418

So yeah, there's definitely something fishy in the way DynamicFont handles those.

@nthana
Copy link
Author

nthana commented Apr 25, 2019

@akien-mga Thank you so much.

I think the reason that sometimes the diacritics are not shown is because there is no meaning in Thai when diacritics appear without preceded consonants. So, many font rendering engines will not render a diacritic alone. This also happen in many softwares such as Microsoft Office, and it is totally acceptable because any diacritic will never be used alone, in real-life sentence.

For the reason why the NotoSansThaiUI_Regular.ttf is displayed correctly, I think it is because its diacritics' positions are designed to always be at top most level to avoid overlapping with upper vowels. However, currently, many other Thai fonts place diacritics and vowels at the same vertical positions (because of aesthetic reason). So, these troubled fonts would need additional placement logics like in #21791.

In conclusion, at this time, if Thai language display is needed, the NotoSansThaiUI_Regular.ttf font should be used. However, for other Thai fonts, we should wait for the complex glyph positioning in #21791 to be completely implemented.

Thanks again :)

@nthana
Copy link
Author

nthana commented Apr 25, 2019

Just for information. I have additionally tested some Thai fonts and found that:

Some Thai Fonts that correctly displayed by Godot 3.1:

  • Arial Unicode.ttf
  • Ayuthaya.ttf
  • Krungthep.ttf
  • NotoSansThaiUI-Regular.ttf
  • Sathu.ttf
  • Silom.ttf

So, the worked fonts are much more than I previously understand.

Some Thai Fonts that incorrectly displayed by Godot 3.1 (Overlapping Occurs):

  • Kanit-Regular.ttf
  • Pridi-Regular.ttf
  • Prompt-Regular.ttf
  • Trirong-Medium.ttf

@bruvzg
Copy link
Member

bruvzg commented Nov 10, 2020

Should be fixed by CTL implementation (#41100):
Screenshot 2020-11-10 at 10 54 40

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants