Bug 36709 - For first line indent using Ch (Characters) as unit, the indent value should change when font-size changes
Summary: For first line indent using Ch (Characters) as unit, the indent value should ...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: Other All
: medium major
Assignee: Jonathan Clark
URL:
Whiteboard: target:25.2.0
Keywords:
: 97208 123938 (view as bug list)
Depends on:
Blocks: 80596 CJK 83844 Paragraph-Indent 146932
  Show dependency treegraph
 
Reported: 2011-04-30 06:27 UTC by Cheng-Chia Tseng
Modified: 2024-11-15 15:38 UTC (History)
9 users (show)

See Also:
Crash report or crash signature:


Attachments
The fixed size of 2 Ch. (77.61 KB, image/png)
2011-04-30 06:30 UTC, Cheng-Chia Tseng
Details
Test ODT Document (25.38 KB, application/vnd.oasis.opendocument.text)
2021-12-18 08:52 UTC, Kevin Suo
Details
screenshot showing the problem (110.47 KB, application/pdf)
2021-12-18 09:11 UTC, Kevin Suo
Details
Font-relative indentation in 25.2 (45.60 KB, image/png)
2024-11-15 12:05 UTC, Jonathan Clark
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Cheng-Chia Tseng 2011-04-30 06:27:05 UTC
Now, LireOffice can use Ch (It should be a full-width "Character") as units for First Line Indent. It is a great feature that MOST CJK users use 2 Ch in their documents! :)

However, "Ch" unit is fixed in deault font size (mine is 12).

When Using different font size in different paragraghs, "Ch" should be variable to fit the actual font size of 2 full-width characters.
Comment 1 Cheng-Chia Tseng 2011-04-30 06:30:42 UTC
Created attachment 46191 [details]
The fixed size of 2 Ch.

See the fixed size of 2 Ch indent.
Comment 2 Björn Michaelsen 2011-12-23 12:07:55 UTC Comment hidden (obsolete)
Comment 3 Cheng-Chia Tseng 2012-01-18 07:57:58 UTC
Because the unit is "Character", the indent or others should be variable along with the font size.

It is not solved at dev3.5 yet.
Comment 4 QA Administrators 2015-01-05 17:52:39 UTC Comment hidden (obsolete)
Comment 5 Cheng-Chia Tseng 2015-01-07 14:08:53 UTC
Still reproduced in LibreOffice 4.3.5.2 on fedora 21.
Comment 6 QA Administrators 2016-01-17 20:05:41 UTC Comment hidden (obsolete)
Comment 7 Kevin Suo 2016-02-12 01:22:58 UTC
*** Bug 97208 has been marked as a duplicate of this bug. ***
Comment 8 QA Administrators 2017-09-01 11:21:03 UTC Comment hidden (obsolete)
Comment 9 Kevin Suo 2017-09-02 00:10:05 UTC
The bug still exists in the most recent version.
Comment 10 Kevin Suo 2018-02-11 07:12:42 UTC
A workaround for Chinese users:
Use CM (厘米) instead.

四号:0.98 厘米
小四:0.86 厘米
五号:0.74 厘米
Comment 11 Kevin Suo 2018-02-11 07:13:12 UTC
See also:
https://tieba.baidu.com/p/5516848517
Comment 12 Volga 2018-02-25 19:53:35 UTC Comment hidden (no-value)
Comment 13 Volga 2018-10-19 02:12:13 UTC
Addording to UAX 11 East Asian Width (https://www.unicode.org/reports/tr11/tr11-31.html#Overview): “For a traditional East Asian fixed pitch font, this width translates to a display width of either one half or a whole unit width. A common name for this unit width is “Em”. While an Em is customarily the height of the letter “M”, it is the same as the unit width in East Asian fonts, because in these fonts the standard character cell is square.” So we should making "Ch" unit identical to em unit.
Comment 14 QA Administrators 2019-10-20 02:32:53 UTC Comment hidden (obsolete)
Comment 15 Kevin Suo 2019-10-20 03:05:48 UTC
(In reply to QA Administrators from comment #14)
The bug still exists in the most recent version.
Comment 16 Franklin Weng 2019-11-25 12:25:43 UTC
Check the Format - Paragraph - Indent - Automatic, the first line of paragraph would indent two characters and would follow the font size.  I think technically it is possible.
Comment 17 Franklin Weng 2019-11-25 13:17:46 UTC
Even using English the "Enable char unit" is not precise either.

When checking "Enable char unit" can it just use relative unit like "em"?

https://www.w3.org/Style/Examples/007/units.en.html
Comment 18 Heiko Tietze 2019-11-27 12:10:31 UTC
Khaled, any idea about this? Font size seems to be calulated not correctly.
Comment 19 Volga 2019-12-19 10:12:59 UTC Comment hidden (obsolete)
Comment 20 Kevin Suo 2021-12-18 03:39:03 UTC
This is still producible on current master. Anyone interest in this one, or could some devs give some code pointers and advices?

I am adding Miklos Vajna to cc. Could you please advice? 
I am working bug 129448, they are related, but *this* one seems to be different and I do not know where to start, and I am not sure whether this is as easy as bug 129448 for me to work on.
Comment 21 Kevin Suo 2021-12-18 03:55:02 UTC
By the way, with the fix for bug 129448 (patch currently under review: https://gerrit.libreoffice.org/c/core/+/125627), the first line indent will not be effected by line space, thus when first line indent is set to Auto, then it will always be precisely 2-characters indent, and the indent will be updated upon font size change.

*This* bug is a little different as it only relates to when the "Use character units" option is enabled and one inputs an first line indent of e.g. "2 Ch" in the Paragraph Properties dialog. In other words, this bug is about the manually set first line indent, not Auto first line indent.
Comment 22 Kevin Suo 2021-12-18 08:52:12 UTC
Created attachment 176991 [details]
Test ODT Document

As shown in this test document, the first line indent for the 1st paragraph is correctly 2-characters, whereas it is wrong in the 2nd paragraph.
Comment 23 Kevin Suo 2021-12-18 09:11:33 UTC
Created attachment 176992 [details]
screenshot showing the problem

Attached is a screenshot illustrating the problem, as well as a comparison with MSO Word 2010.
Comment 24 Miklos Vajna 2021-12-20 07:33:00 UTC
It would be good to research what is that "ch" unit, I'm not familiar with that. Is that intentionally depending on the font size or is there a fixed conversion factor between ch and e.g. twips?
Comment 25 Kevin Suo 2021-12-20 08:27:00 UTC
One ch unit means one character unit, which equals to the height of the character of the current paragraph using the font of the current paragraph style.

In Chinese language there is a long standing convention that in a paragraph the first line indent should be 2 characters.
Comment 26 Kevin Suo 2021-12-23 01:33:53 UTC
The series of commits which added the "character unit" are:
https://cgit.freedesktop.org/libreoffice/core/log/?qt=grep&q=cjk-character-units
Comment 27 Volga 2021-12-23 03:27:22 UTC
(In reply to Kevin Suo from comment #10)
Another workaround for Chinese users:
Insert U+3000 IDEOGRAPHIC SPACE ( ) (known as 全角空格) twice at the beginning.
Comment 28 Volga 2021-12-23 03:40:20 UTC
(In reply to Kevin Suo from comment #25)
> One ch unit means one character unit, which equals to the height of the
> character of the current paragraph using the font of the current paragraph
> style.
> 
> In Chinese language there is a long standing convention that in a paragraph
> the first line indent should be 2 characters.
This is also documented in the Requirements for Chinese Text Layout by W3C.
https://www.w3.org/TR/clreq/#first_line_indents
Comment 29 Kevin Suo 2022-01-30 04:27:50 UTC
*** Bug 123938 has been marked as a duplicate of this bug. ***
Comment 30 AngelSherry 2022-05-29 17:20:00 UTC
I'm sure that it may cause by Line Spacing, which will mess up first line indent using Character with CJK language if it's not on Sing Line.

In my memory, Libreoffice did add the feather of first line indent using Character on 6.x version. But I find it only work on Sing Line. If I change to other Line Spacing, the characters of first line won't be aligned, and it will make no sense.

Testing on Libreoffce 7.3, still not fixed
Comment 31 Kevin Suo 2022-10-15 15:00:58 UTC
Some code reference: the CJK character units seems added by:
https://cgit.freedesktop.org/libreoffice/core/log/?qt=author&q=amwang
Comment 32 ⁨خالد حسني⁩ 2023-06-27 08:21:15 UTC
It seems that the ch and line units are implemented only when text grid is enabled, without the grid it defaults to a fixed value for both units.
Comment 33 Jonathan Clark 2024-08-01 13:54:10 UTC
This bug is a fairly large task, so I wanted to briefly review the current state as I understand it. Comments are appreciated.

1. The Ch unit

For the purposes of CJK typesetting, we want a variable-length unit equal to the advance measure of a Han ideograph in the current font. In CSS, this unit is called 'ic'. In Microsoft Word, this unit is called 'Ch'. From what I've seen, Ch is set as the default length unit when an Office CJK language pack is installed, so Word documents that use Ch as a unit are likely very common.

A unit called Ch was added to LibreOffice in 2010. Unlike the previous examples, this unit is hard-coded as equal to 210 twips. That hard-coded value is used unconditionally, regardless of font, style, or context, including if text grid is enabled. I suspect this was originally intended as a short-term fix to ease importing Word documents that use Ch units along with a specific default font/size. I wasn't able to locate any discussion or non-source artifacts concerning this design, so unfortunately I can only speculate.

Regarding standards: For length units, the ODF 1.3 specification only refers to a list of recommended units in §5.9.13 of the XSL 1.0 specification. The Ch unit is not mentioned at all, so we seem free to redefine Ch as we need. The standard does not seem to prohibit us from persisting or consuming Ch as a unit.

Regarding impact: A change to Ch would have no impact on existing Writer documents. Writer does not persist the Ch unit. Writer reports an error when parsing a document that contains the Ch unit. Currently, the Ch unit is an artifact of the user interface only. (Note that the example attachment above does not contain Ch units. They were automatically converted to cm.)

In the interest of compatibility with other programs, I recommend changing Ch from a fixed unit to a relative unit, formalized as equivalent to CSS 'ic'. I also recommend that we do not implement a compatibility flag, as such a flag will have no effect.


2. Relative units in Writer

Per ODF 1.3 §20.225, fo:text-indent only requires support for a single relative-length unit: percent. The standard neither prescribes nor proscribes support for other relative-length units, but does seem to recommend em (transitively via XSL 1.0 §5.9.13).

Currently, Writer supports percent in fo:text-indent. Writer does not support em, or any other relative-length unit. Percent may be used in the paragraph style editor, but it is ignored in the paragraph properties dialog.

This code change could end up being quite large, especially considering that once we start changing unit support for some attributes, we will likely want to keep it consistent across all of them. In order to manage the complexity for this code change, I recommend the following general breakdown:

- Start with a separate task(s) to add *em* support to fo:text-indent, as em is already recommended by the standard.
- Build relative Ch support on top of that change.
- File separate bugs against the remaining attributes, so they can be tackled one-by-one.
Comment 34 Volga 2024-08-26 13:37:42 UTC
(In reply to Jonathan Clark from comment #33)
> In the interest of compatibility with other programs, I recommend changing
> Ch from a fixed unit to a relative unit, formalized as equivalent to CSS
> 'ic'. I also recommend that we do not implement a compatibility flag, as
> such a flag will have no effect.
I agree with you, and I think it's time to replace such legacy codes. 

> Currently, Writer supports percent in fo:text-indent. Writer does not
> support em, or any other relative-length unit. Percent may be used in the
> paragraph style editor, but it is ignored in the paragraph properties dialog.
I think this require some new codes to provide essential algorithms first.
Comment 35 Jonathan Clark 2024-09-23 16:12:29 UTC
(In reply to Jonathan Clark from comment #33)
> Per ODF 1.3 §20.225, fo:text-indent only requires support for a single
> relative-length unit: percent. The standard neither prescribes nor
> proscribes support for other relative-length units, but does seem to
> recommend em (transitively via XSL 1.0 §5.9.13).

Although the language of the standard can be read to imply em support, the XML schema does not allow use of the em unit. ODF does not currently support any font-relative length units.

This feature has been proposed for addition to a future version of ODF. The proposal is tracked here:

https://issues.oasis-open.org/browse/OFFICE-4165
Comment 36 Commit Notification 2024-11-01 21:41:16 UTC
Jonathan Clark committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/6f16beca51c86e0decfde71236174b5e45a9e904

tdf#36709 Refactor Converter to separate parsing from unit conversion

It will be available in 25.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 37 Commit Notification 2024-11-02 00:10:48 UTC
Jonathan Clark committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/43cd683230bc05d294b1bd64f1e7932feccdd3fb

tdf#36709 Add loext:text-indent supporting font-relative units

It will be available in 25.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 38 Commit Notification 2024-11-13 08:35:35 UTC
Jonathan Clark committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/d3a59f7a915f9cc0864f2c76ccf90b6cd6fea339

tdf#36709 sw: Writer layout for font-relative first-line indent

It will be available in 25.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 39 Commit Notification 2024-11-13 14:01:28 UTC
Jonathan Clark committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/2cb039f570379213ffc9469a132f5b24f425b7be

tdf#36709 editeng: Layout for font-relative first-line indent

It will be available in 25.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 40 Commit Notification 2024-11-14 16:30:52 UTC
Jonathan Clark committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/78a18a5dc6986c9f5612f26d164c62202a1b94f8

tdf#36709 GUI changes for font-relative first-line indent

It will be available in 25.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 41 Jonathan Clark 2024-11-15 12:05:00 UTC
Created attachment 197627 [details]
Font-relative indentation in 25.2

Screenshot illustrating CJK font-relative paragraph first line indentation in Writer.
Comment 42 Jonathan Clark 2024-11-15 12:46:30 UTC
Font-relative paragraph first line indentation is now implemented. Indentation can be applied in the paragraph style dialog by entering a quantity followed by either 'em' or 'ic'.

For example: To indent the first line of a paragraph by 2 ideographic characters, enter "2 ic" in the first line indent textbox.

Please note that the existing 'Ch' unit has not changed, and still refers to a hard-coded constant width. Revising this behavior will be tracked as a separate bug.