Branch

Word wrap in other languages

Recommended Posts

https://github.com/pixijs/pixi.js/blob/dev/src/core/text/TextMetrics.js#L42

The only way is to try and then read the code and debug.

Btw, technically, there is a japanese space symbol, U+3000. It really messes messenger apps/chats that dont want empty lines to be posted, they just dont detect it :)

Share this post


Link to post
Share on other sites
On 11/3/2017 at 9:06 PM, Branch said:

Does anyone know if pixi.js takes into consideration word wrapping for languages like Japanese where there are no spaces?

There is no support for word wrapping for CJK languages (https://en.wikipedia.org/wiki/CJK_characters) - Boo

In any case, for these language what is _actually_ required is word wrap but with break words enabled; there are no spaces in CJK text, and word wrap usually just finds spaces in text. Break words allows word wrap to work without waiting for spaces. http://pixijs.download/dev/docs/PIXI.TextStyle.html#breakWords - Yay

However it's not quite as simple as enabling break words, as there are rules in place as to which characters are allowed to be broken and which aren't - https://en.wikipedia.org/wiki/Line_breaking_rules_in_East_Asian_languages - Boo

So you'll need to code your own custom solution at around this line: https://github.com/pixijs/pixi.js/blob/dev/src/core/text/TextMetrics.js#L122 - that checks the text wanting to be broken up to see if the rules allow for the breaking up of characters or not.

Share this post


Link to post
Share on other sites
On 11/5/2017 at 8:35 AM, themoonrat said:

There is no support for word wrapping for CJK languages (https://en.wikipedia.org/wiki/CJK_characters) - Boo

In any case, for these language what is _actually_ required is word wrap but with break words enabled; there are no spaces in CJK text, and word wrap usually just finds spaces in text. Break words allows word wrap to work without waiting for spaces. http://pixijs.download/dev/docs/PIXI.TextStyle.html#breakWords - Yay

However it's not quite as simple as enabling break words, as there are rules in place as to which characters are allowed to be broken and which aren't - https://en.wikipedia.org/wiki/Line_breaking_rules_in_East_Asian_languages - Boo

So you'll need to code your own custom solution at around this line: https://github.com/pixijs/pixi.js/blob/dev/src/core/text/TextMetrics.js#L122 - that checks the text wanting to be broken up to see if the rules allow for the breaking up of characters or not.

Thank you for your help! Do you by any chance understand why this line here adds a space to the beginning of each word?

https://github.com/pixijs/pixi.js/blob/dev/src/core/text/TextMetrics.js#L147

I don't really see a case where I would ever want that.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.