Branch 0 Report post 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 Share this post Link to post Share on other sites
ivan.popelyshev 1072 Report post 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 1 Branch reacted to this Quote Share this post Link to post Share on other sites
themoonrat 105 Report post 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. 1 Branch reacted to this Quote Share this post Link to post Share on other sites
Branch 0 Report post 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 Share this post Link to post Share on other sites