Jump to content
Search Community

SplitText problem with Chinese characters

AP IDW
Moderator Tag

Recommended Posts

Posted

I have a problem with how SplitText handles line breaks with Chinese characters. Please see the example below of how this same text looks with and without SplitText implementation. I suspect that is because of , and   characters. They are not treated as line-breakable so something like this is treated as whole word 11.59系列发布五年以来,不断推陈出新,采用极具现代

Screenshot 2024-12-05 at 12.09.41.png

Screenshot 2024-12-05 at 12.11.45.png

See the Pen KwPVWXQ by marcin_tapptic_1 (@marcin_tapptic_1) on CodePen.

Posted

Hi there!

 

I don't understand where the characters should split, but we have custom delimiters so you could do something like this?

See the Pen KwPVWXQ by marcin_tapptic_1 (@marcin_tapptic_1) on CodePen.



Alternately could you explain in a little more detail where you would expect chinese characters to split into words. If you give us a clear spec we can potentially create a solution in the future.

Posted

Hi, I don't think you clicked save, because you sent exactly this same codepen that I have :) 

  • Like 1
Posted

Characters should split the same way as they split native in the browser. Please compare this codepen with my previous one. After removing the implementation of SplitText paragraph takes less space by at least 1-2 lines. 

See the Pen GgKoEYV by marcin_tapptic_1 (@marcin_tapptic_1) on CodePen.

 

Posted

Thanks for delving into the topic. Yes, splitting by characters works better.  But it is not what I'm trying to achieve. I try to split text line by line in Chinese. But it doesn't seem to work check my code pen example. After splitting there are just 2 lines.

See the Pen qEWbXxe by marcin_tapptic_1 (@marcin_tapptic_1) on CodePen.

 

Screenshot 2024-12-05 at 15.35.33.png

Screenshot 2024-12-05 at 15.36.12.png

Posted

I would like to achieve lines split like this 

Screenshot2024-12-05at15_58_16.png.9cb75e061a3baf73424b69e77ed96532.png

Posted

Sure, because SplitText splits up words and lines using the space character " " and you only have one of those in between code and 11.59

Code 11.59


So as far as SplitText is concerned, you have two words, which it can't split up any smaller. If you want to split by line (and divide words up between lines) you'll need to specify where you want your code to divide, you can do that with custom delimiters.

See the Pen pbWwLe by GreenSock (@GreenSock) on CodePen.

Posted

Hello, I managed to adjust my behaviour as  I need for this specific case.  I'm just worried because there could be a lot of Chinese characters to cover all the cases  😕 


See the Pen qEWbXxe by marcin_tapptic_1 (@marcin_tapptic_1) on CodePen.

Posted

I'm afraid I can't really advise any more than splitting by chars and using delimiters as I don't understand the language and SplitText wasn't designed with it in mind.


Sorry I can't help more here!

Posted

Hi,

 

We've seen this on oriental languages (saw it with Japanese and now Chinese), the issue here is that there are no spaces between words so SplitText interprets all those words as a single line. On top of that the elements you're passing as word delimiter are not actually working, so I made a fork of your demo with a regular comma (IDK if there is an actual difference between an occidental and Chinese comma though):

See the Pen pvzbEOW by GreenSock (@GreenSock) on CodePen.

 

But of course this brings up the issue of the text rendering in a different way because those elements end up creating a different way the text is initially rendered which is what GSAP takes in order to position the elements after the SplitText instance is created.

 

Again I wish there was something we could do about it, but these languages work in a different way when it comes to rendering I'm afraid 😞

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...