Problems with alignment "justify"

Kohei Yoshida kohei at libreoffice.org
Thu May 8 01:32:25 UTC 2025


Hi Regina,

Sorry for replying so late.

On 4/26/25 14:53, Regina Henschel wrote:
> Hi Kohei,
>
> thank you for looking at it.
>
> Kohei Yoshida schrieb am 23.04.2025 um 04:20:
>> Hi Regina,
>>
>> On 4/22/25 11:29, Regina Henschel wrote:
>>> Hi all,
>>>
>>> The ODF TC currently discusses OFFICE-2317 "Text distribute 
>>> justification" [1]. The issue is about the proposal in the 
>>> OASIS-Wiki [2].
>>
>> I can see myself being the author of this proposal... This was 
>> authored almost 15 years ago.  I must say I could have added a bit 
>> more detail in this proposal to make less open to interpretation, but 
>> alas, I can't go back in time to fix it. :-)
>
> The ODF TC makes some house keeping and examines those proposals that 
> do not yet have a decision whether to accept them.
>>
>>>
>>> (A)
>>> The proposal wants to introduce a new attribute "css3t:text-justify" 
>>> with values "auto" and "distribute".
>>> Problem is, that the actual CSS3 draft [3] has the values "auto", 
>>> "none", "inter-word" and "inter-character". The draft states in 
>>> addition, that a UA must additionally support "distribute" and treat 
>>> it as "inter-character".
>>
>> CCS3's "inter-character" appears to correspond with the "distribute" 
>> mode. So I would say ODF can also inherit this "inter-character" 
>> value here instead of the old "distribute" value as specified in the 
>> proposal.  When I authored this proposal I chose the value 
>> "distribute" likely because the CSS3 draft proposal available back 
>> then also used that word.  The latest CCS2 draft still references the 
>> word "distribute" as the legacy value to support.
>
> We can likely add into the text, that consumers shall accept the value 
> "distribute" in addition.
>>
>>>
>>> (B)
>>> The proposal wants to introduce a special attribute 
>>> style:vertical-justify for use in style:vertical-align. There has 
>>> been some work on this in bug tdf#45450. On the other hand, bug 
>>> tdf#112843 was rejected.
>>> Is such property really needed?
>>
>> Yes, but only when the text is oriented 90 degrees or 270 degrees 
>> i.e. flows either either top-to-bottom or bottom-to-top, or when the 
>> text is vertically stacked.  This feature is useful at least in 
>> Japanese setting.  I can't speak for Chinese or Korean settings, but 
>> it may be relevant in those languages as well, or not. I'm not really 
>> sure.
>
> I disagree her. The proposal misunderstands fo:text-align and 
> style:vertical-align attributes.
> The fo:text-align attribute (current values start, end, left, right, 
> center or justify) always works in line direction and the line 
> direction is given by the style:writing-mode attribute.
> The style:vertical-align attribute is orthogonal to the line 
> direction. It determines how the entire text content is positioned in 
> the cell area. Current values are top, middle, bottom or automatic.

Ok.  I'm all for using style:writing-mode attribute to make this part 
more "ergonomic" and less awkward. No objections there.

>
> If we really want to distribute the lines of the text content, then it 
> would be enough to add a new value "distributed" to the 
> style:vertical-align attribute of the <style:table-cell-properties> 
> without any further attributes. In case the new value "distributed" is 
> set, any line spacing and margin related attributes of the 
> <style:paragraph-properties> element assigned to the text in the cell 
> has to be ignored.
>
> The result of such distribution is ugly for normal text. It might be 
> useful for "stacked" characters to have something compatible to Excel. 
> Albeit, currently LibreOffice has no wrap for "stacked" characters in 
> Calc.
>
> If we have a vertical writing mode (in ODF 1.4 these are tb-rl, tb-lr, 
> sideways-rl, sideways-lr), then the fo:text-align attribute still 
> works in line direction and with value 'justify' the text is aligned 
> with the top and bottom edge of the cell. That does neither require a 
> new css3t:text-justify nor a new style:vertical-justify attribute.
>
> And in case of paragraph-properties, a value of "justify" for 
> attribute style:vertical-align makes no sense at all. The attribute 
> style:vertical-align (20.396.1 ODF 1.4) of a 
> <style:paragraph-properties> element specifies the position of a 
> _character_ relative to the line to which the character belongs.

So, I haven't done a deep dive of the current ODF specification text, so 
I'll trust you on this one.

>
>>
>> When the text flows horizontally i.e. not vertically stacked, the 
>> vertically distributed justification works identically to the normal 
>> vertical justification.  There is no difference between these two modes.
>>
>> You can try this in Calc by putting some Japanese sentence into a 
>> cell, go to the Format Cells dialog, switch to the Alignment tab and 
>> check the "Vertically stacked" check box in the Text Orientation 
>> section.  Or leave the check box unchecked, and change the text 
>> orientation to either 90 degrees or 270 degrees.  Set the vertical 
>> text alignment to "Distributed" and compare how that differs from the 
>> "Justified" alignment.  Change the row height if you have difficulty 
>> seeing the effect of this distributed alignment.
>
> There are two problems:
> - The current implementation does not use the attribute 
> style:writing-mode to describe vertical writing modes, but a 
> workaround with attributes style:glyph-orientation="auto" and 
> style:direction="ttb". But this workaround has not the ability to 
> distinguish whether the block direction is from right-to-left or 
> left-to-right.
> - As far as I see, the values "justified" and "distributed" in the UI 
> are only different in the way the last line of a paragraph is handled. 
> But the method for handling the last line is already specified as 
> style:justify-single-word attribute (20.301 ODF 1.4) and 
> fo:text-align-last (20.224 ODF 1.4). Only that LibreOffice does not 
> use these in Calc.
I agree that these can be used in lieu of the current implementation.
>
>>
>> You may need to enable Asian language features in the Language 
>> Settings in case it's not there.  I'm not sure whether this feature 
>> is visible without the Asian language features enabled.
>>
>>>
>>> (C)
>>> LO has implemented something for OFFICE-2317, see around lines #2848 
>>> to #2891 in the schema
>>> /core/schema/libreoffice/OpenDocument-v1.4+libreoffice-schema.rng
>>> Is there a UI in LibreOffice for these properties?
>>> When are these properties written to file?
>>
>> See my reply above.  For horizontal distribution, put some Japanese 
>> text into a cell, go to the same dialog location I described above, 
>> and simply set the horizontal text alignment to "Distributed".  If 
>> it's hard to see, try widening the column width.
>
> For horizontal Japanese text too, I see only a difference in the last 
> line of the text.
Yup. That's my observation and understanding of what the distributed 
text alignment does.
>
> BTW, Excel seems to be not able to set Japanese vertical writing mode 
> for a single cell and keep the other cells in a horizontal writing 
> mode. At least I do not find it in Excel. I only find "vertical Text" 
> for the cell, but that does not make Japanese vertical writing mode 
> (tategaki) but stacks all glyphs upright, which is 
> style:direction="ttb" in ODF.

I believe that stacking of glyphs in vertical direction is essentially 
what tategaki mode does.  In this mode, the glyphs stay upright (i.e. 
not rotated) but the flow of the text becomes vertical.

This article has some screenshots of the relevant UI for tategaki mode: 
https://atmarkit.itmedia.co.jp/ait/articles/1912/20/news020.html

>
>> Hopefully this helps a bit.  Let me know if you need more 
>> clarification on this stuff. 
>
> How about becoming a member of the ODF TC?

Well, right now, the time I can spend aside from my life's obligation is 
rather limited, so I don't think I can find enough time to dedicate 
myself to join the TC.  Sorry about this.

Kohei



More information about the LibreOffice mailing list