Japanese text line breaks

#1

What to do about text that’s all on one line technically?

Here’s a machine translated sample

Do we need to manually apply line breaks in cases like these either in the text itself or code so that the linebreakless text fits better within text nodes or is there an option I’m not thinking of?

1 Like

#2

There is an old issue to correctly handle line breaks in Asian (and other) languages; DEF-1509

However, there is support for zero-width space character that you could include in your strings. (Granted not the best solution though…)

In Lua, I think you could do something like this (I haven’t tried it myself):

local zws = "\xe2\x80\x8b"
local a = "モグは厚いかみそりの" .. zws .. "鋭いシダを突き破った。"
4 Likes

#3

The “zero-width space” character “\xe2\x80\x8b” does actually produce spaces. This should probably be fixed to not happen by engine.

2019-05-13%2011_39_48-UTF8JapaneseText

If I add some negative text tracking it does look better

2019-05-13%2011_41_55-UTF8JapaneseText

Here is example project

UTF8JapaneseText.zip (2.1 MB)

This could probably be made smarter by detecting non-Japanese chars and not adding zero-width space char after them so they don’t split in half when mixed in but then that would mess up the tracking.

There are also some special situations to consider https://www.w3.org/TR/2009/NOTE-jlreq-20090604/#en-subheading2_1_7

2 Likes

#4

We do nothing special with the zero-width space character except use it when calculating linebreaks. If the zero-width space character has some width it is probably because it’s like that in the font.

2 Likes

#5

Opened font in FontForge

View-Goto

U+200B https://www.utf8-chartable.de/unicode-utf8-table.pl?start=8192&number=128&utf8=string-literal

Width was at 512

Set to 0

Set leading back to 0 on the text node

Before

2019-05-13%2013_32_00-UTF8JapaneseText

After

2019-05-13%2013_32_20-UTF8JapaneseText

So should be possible to detect English words and not add zero width spaces within them. There are still more considerations until this is really good too.

1 Like