Prince xml - Justify Japanese Content
Hello there,
I'm encountering a problem when a piece of Japanese text is Justified (text-align: justify) on a p.
In the sample attached, the firefox displays properly but when pdf is generated the text does not seem to properly justify. I did try applying p { prince-text-replace: '\A0'''; } style but didn't help much.
The attached sample has both Html sample as well as the prince generated pdf.
The justification applied for the English text works fine but not when used with Japanese/Chinese text. Please help me if I'm missing anything.
Thanks,
Vivek
- Justification.zip 162.1 kB
At the moment Prince only justifies text that contains spaces, it does not insert spaces between two characters that don't have them. This restriction could be loosened for Japanese text, where variable width Hiragana characters increase the need for justification.
In my Prince 8 tests, justification worked fine so long as all the text in a paragraph was in Japanese. But add an English word and the paragraph loses its justification and lines run beyond the column margin. (I'm attaching a sample.) Is that possibly something we could add to the road map?
- japanese.jpg 56.1 kB
Is text vertical or left to right or right to left?
Jim Albright
Wycliffe Bible Translators
Is that really extending outside the element? For example, if you add a border to the element, does the text overlap the border? If so, please paste a HTML example, so that we can debug the problem.
The issue is that the addition of a single English word causes the justification to break down for the entire paragraph, as you can see in the example. If the longer lines are not overlapping the border then that would suggest that the justified lines are shorter than they should be, which would be a second issue.
In Prince 8.0, Japanese text without any spaces at all between the characters will not be justified, ie. Prince will not add any stretchable space between the characters. However, the lines may still line up if all the characters are the same width, which they are in some fonts. But then if some Latin text with spaces is added, those spaces will be justified, which could result in some lines being longer than others. So you may be better off disabling justification entirely for this text.
In Prince 8.1 we will be adding support for actual justification of Japanese text, where there will be stretchable space between Japanese characters.
Thanks so much for the explanation, Mike. I'm glad to hear you will have a solution soon.
Prince 8.1 is now available, and includes a new property "text-justify: prince-cjk" which will insert stretchable spaces between Chinese/Japanese/Korean characters to enable more pleasant justification when these scripts are mixed with Latin.