Bug 162422 - Need ability to have automated line breaking to prefer uniformity over all lines
Summary: Need ability to have automated line breaking to prefer uniformity over all lines
Status: RESOLVED WONTFIX
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Word-Line-Break
  Show dependency treegraph
 
Reported: 2024-08-10 12:41 UTC by Eyal Rozenberg
Modified: 2024-08-28 19:30 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Illustration of the request (31.21 KB, application/vnd.oasis.opendocument.presentation)
2024-08-13 22:21 UTC, Eyal Rozenberg
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eyal Rozenberg 2024-08-10 12:41:56 UTC
At the moment, the line breaking algorithm for paragraph tries to optimize one thing: Minimum length, i.e. miniumum number of lines and minimum length of text on last line.

However, one often wants to optimize a different metric: Minimum number of lines, but most uniform distribution of words or characters over those lines.

Thus, we would currently prefer:

+-------------------------------------+
| The quick brown fox jumped over the |
| lazy dog.                           |
+-------------------------------------+

over:

+---------------------------+
| The quick brown fox       |
| jumped over the lazy dog. |
+---------------------------+

I would like to be able to format a paragraph to have the line breaking algorithm prefer the latter over the former. That would be another toggle-able property in paragraph styles within the ODT, if it's not already in there.
Comment 1 Eyal Rozenberg 2024-08-12 19:04:46 UTC
(In reply to Eyal Rozenberg from comment #0)

Note that an improvement, falling short of complete optimization, is "pulling" words towards the line with the least length covered by words, greedily:

+-------------------------------------+
| The quick brown fox jumped over the |
| lazy dog.                           |
+-------------------------------------+

=> 

+-------------------------------------+
| The  quick  brown  fox  jumped over |
| the lazy dog.                       |
+-------------------------------------+

=> 

+-------------------------------------+
| The   quick   brown   fox   jumped  |
| over the lazy dog.                  |
+-------------------------------------+

and not continuing, because "jumped" would make it so that the second line has more than the first. Of course it is trickier with multiple lines which can pull words from previous as well as successive lines.
Comment 2 Heiko Tietze 2024-08-13 06:46:36 UTC
The illustrations indicate that you have a text box in mind. Otherwise, for ordinary pages a line break just happens at the end of the page. But the first example shows different width, and don't we break respectively? So please provide some STR.
Comment 3 Eyal Rozenberg 2024-08-13 22:19:44 UTC
(In reply to Heiko Tietze from comment #2)
> The illustrations indicate that you have a text box in mind.

Yes and no. This comes up for me in the context of working on a presentation, but I'm interested in _paragraphs_ within textboxes, not the whole textbox.

> Otherwise, for ordinary pages a line break just happens at the end of
> the page. 

I'm not sure I understand how that relates to this bug...

> But the
> first example shows different width, and don't we break respectively? So
> please provide some STR.

I don't understand the question; but - I'll attach a presentation to illustrate my point.

Also, a clarification: While my textual examples involved justification, the bug is not about the justification, it's about the line breaking, i.e. it's just as relevant for Right, Left, or Center alignments.
Comment 4 Eyal Rozenberg 2024-08-13 22:21:06 UTC
Created attachment 195816 [details]
Illustration of the request

Look at the textboxes in the presentation. I would like to get the same line-breaking-points as the second textbox, but automatically, not using manual breaks. (Of course, as an option, not as the default.)
Comment 5 Heiko Tietze 2024-08-14 06:14:42 UTC
(In reply to Eyal Rozenberg from comment #4)
> I would like to get the same line-breaking-points as the second textbox...
Paragraph properties > Indent > After Text = 2cm

This attribute is also available in the drawing style which makes switching from one to another easy. => INV
Comment 6 Eyal Rozenberg 2024-08-14 06:32:19 UTC
(In reply to Heiko Tietze from comment #5)
> (In reply to Eyal Rozenberg from comment #4)
> > I would like to get the same line-breaking-points as the second textbox...
> Paragraph properties > Indent > After Text = 2cm

That's not "automatic". If I then add or remove text, the lines will again not be broken to achieve a uniform distribution of line lengths.
Comment 7 Heiko Tietze 2024-08-14 06:39:46 UTC
(In reply to Eyal Rozenberg from comment #6)
> (In reply to Heiko Tietze from comment #5)
> > (In reply to Eyal Rozenberg from comment #4)
> > > I would like to get the same line-breaking-points as the second textbox...
> > Paragraph properties > Indent > After Text = 2cm
> 
> That's not "automatic". If I then add or remove text, the lines will again
> not be broken to achieve a uniform distribution of line lengths.

Can you illustrate this? An indentation is automatic and will be applied to any text.
Comment 8 Eyal Rozenberg 2024-08-14 06:54:00 UTC
(In reply to Heiko Tietze from comment #7)
> Can you illustrate this? An indentation is automatic and will be applied to
> any text.

I mean that as you type more words in a paragraph, the line breaking changes - including in previous lines - so that the lines are kept at a length which is as close to uniform as possible. Of course, for a given fixed line length limit (i.e. not when the textbox can stretch).

So, suppose my line is 30 chars long, and I start typing. Here is some text animation for you...

123456789012345678901234567890
The

123456789012345678901234567890
The quick

123456789012345678901234567890
The quick brown fox

123456789012345678901234567890
The quick brown fox jumped


here is where things diverge from the default line breaking strategy. The next work, currently, produces:

123456789012345678901234567890
The quick brown fox jumped 
over

123456789012345678901234567890
The quick brown fox jumped 
over the


123456789012345678901234567890
The quick brown fox jumped 
over the lazy

but with the alternative line breaking strategy, this would happen:

123456789012345678901234567890
The quick brown 
fox jumped over

123456789012345678901234567890
The quick brown fox
jumped over the

123456789012345678901234567890
The quick brown fox 
jumped over the lazy

123456789012345678901234567890
The quick brown fox 
jumped over the lazy dog

See what I mean?
Comment 9 Heiko Tietze 2024-08-14 07:04:17 UTC
(In reply to Eyal Rozenberg from comment #8)
> | 123456789012345678901234567890       |
> | The quick brown fox jumped           |
> | over                                 |

(should become)
 
> | 123456789012345678901234567890       |
> | The quick brown                      |
> | fox jumped over                      |
(with virtual paragraph boundaries)

Some kind of "optimal text distribution" regardless the text box width and the paragraph properties. This is certainly not covered by the file format and quite niche. There are plenty alternative workflows to achieve it (admittedly with some more steps).

My take: => WF
Comment 10 Heiko Tietze 2024-08-23 07:54:11 UTC
No further input, => WF

The use case is extremely niche, involves tremendous effort to implement, the solution offers no flexibility, and the alternative - insert line breaks - is simple and well-known.