stride3d / stride

Stride (formerly Xenko), a free and open-source cross-platform C# game engine.
https://stride3d.net
MIT License
6.62k stars 956 forks source link

[UI] Support for OpenType text layout. #684

Open wutipong opened 4 years ago

wutipong commented 4 years ago

Is your feature request related to a problem? Please describe. When using TextBlock to display text written in certain script (in my case, Thai), text is not displayed correctly due to lacking of OpenType layout capability.

For example, this is from Stride 4.0.0.1-beta2-0926 image

And this is from Notepad image

Font in use is Sarabun.

notice that the tick (Mai-ek, for those who knows Thai) on the top of certain character is missing from a number of positions. This particular character is a mark which would attach to the character before itself. Without mark-to-mark or mark-to-base feature, it would be positioned statically and could be obstructed by surrounding character.

This character also have a smaller variant to be used in some case. This requires Glyph Substitution.

Describe the solution you'd like To add support for OpenType text shaping. This could be done using either OS's text rendering service like DirectWrite or Core Text, or using opensource library like Harfbuzz.

Describe alternatives you've considered There are fonts that designed specifically to avoid the limitation of TrueType-like text shaping. The output might not be perfect but at least it is readable.

Of course this would not work on Arabic or Persian scripts.

Additional context From what I've researched, there are engines that support OpenType layout, and those not.

wutipong commented 4 years ago

Personally I think ... implementing mark-to-mark and mark-to-base feature should suffice for most scripts (outside of those RTL of course). I will be looking more into the current spritefont implementation in Xenko and how could it be enhanced to support this. Please don't hold your breath though, I can't even got the source built at this point...