TextField wrong selection area for Chinese texts

Unity Editor version: 2022.1.4f1
TextMeshPro version: 4.0.0 pre.1 (To be able to use dynamic font assets in UIToolKit)

Hi, I am currently having visual selection issue when I put Chinese text in UIToolkit’s TextField, with text wrap in UIBuilder. I notice that with latin text it works as expected (eg: English), but the issue occurs when I put Chinese text in it. Actually the selection did select all texts, but visually there is an offset at the end.

I searched all over the places but didn’t find any workable solution to fix it.
I am wondering if the font I use is causing the wrong text area calculation? (I am using NotoSans CJK SDF, and it’s used for all texts).

Please see the attachment for the screenshot.
Any help is highly appreciated. :slight_smile:

Hi @BojayDE ! Thanks a lot for bringing this up, it’s really appreciated. This issue is already known by the team and it will be backported up to 2022.1 once fixed.

Are you using both UI Toolkit and TextMesh Pro in the same project? The main reason behind 4.0 is to allow Text Assets (FontAssets, SpriteAssets…) to be shared between the 2 UI Frameworks.

@HugoBD-Unity Thanks. :slight_smile: It’s good to know that the team is fixing it.

For UI part I use UIToolkit only, but since my project needs a lot of user input text, I need to use dynamic font feature on my UIElements. And currently the UIToolkit can only use normal font assets, which require us to provide character sets manually, and it doesn’t meet my project’s requirement. Until I found that TextMeshPro version: 4.0.0 pre.1 allow us to use dynamic font on UIToolkit elements.

Hi @BojayDE !

UI Toolkit supports dynamic FontAsset. You can create one through the Font Asset Creator (Window/Text/Font Asset Creator) or by right-clicking a Font and through Create/Text/Font Asset.

For a bit of context, UI Toolkit is using TextCore for its TextEngine which is close to being a clone of TextMesh Pro. We are slowly transitioning TextMesh Pro to also use TextCore as its foundation with the end goal of consolidating all Text logic in TextCore and having TextCore be the TextEngine for all unity’s UI framework (UI Toolkit, IMGUI and TMP’s component). The 4.0.0 release is one step in that direction.

Cool, thanks for your info. :slight_smile: