Branch Posted November 3, 2017 Share Posted November 3, 2017 Does anyone know if pixi.js takes into consideration word wrapping for languages like Japanese where there are no spaces? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted November 4, 2017 Share Posted November 4, 2017 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 Branch and fuR 2 Quote Link to comment Share on other sites More sharing options...
themoonrat Posted November 5, 2017 Share Posted November 5, 2017 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. Branch 1 Quote Link to comment Share on other sites More sharing options...
Branch Posted November 10, 2017 Author Share Posted November 10, 2017 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.