Bug 149248 - Feature request: Option to not hyphenate last word in a paragraph
Summary: Feature request: Option to not hyphenate last word in a paragraph
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.3.3.2 release
Hardware: x86-64 (AMD64) Windows (All)
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard: target:7.4.0
Keywords: needsUXEval
Depends on:
Blocks:
 
Reported: 2022-05-23 19:11 UTC by rferraro
Modified: 2022-08-01 07:52 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:
Regression By:


Attachments
Example file with last word hyphenated (13.63 KB, application/vnd.oasis.opendocument.text)
2022-05-24 11:55 UTC, rferraro
Details
Text Flow Settings (22.19 KB, image/png)
2022-05-24 12:01 UTC, rferraro
Details
Workarounds to disable hyphenation of the last word of the paragraphs (27.85 KB, application/vnd.oasis.opendocument.text)
2022-05-24 16:14 UTC, László Németh
Details
Select all last words by a regex to format their languages to [None] to disable their hyphenation (169.87 KB, image/png)
2022-05-24 16:16 UTC, László Németh
Details
MSO hyphenation options (9.86 KB, image/png)
2022-05-25 07:40 UTC, Heiko Tietze
Details
Example from Adobe Indesign (149.68 KB, image/png)
2022-05-25 10:48 UTC, rferraro
Details
screenshot: new option "Don't hyphenate the last word" in Text Flow page of paragraph settings (61.82 KB, image/png)
2022-05-26 09:02 UTC, László Németh
Details

Note You need to log in before you can comment on or make changes to this bug.
Description rferraro 2022-05-23 19:11:22 UTC
Description:
I am using justified paragraphs in a long document. It often hyphenates the last word in a paragraph. This is typographically incorrect and there is no option to prevent this in the options. Please add this feature to hyphenation options.

Steps to Reproduce:
Nothing to enter here

Actual Results:
Nothing to enter here

Expected Results:
Nothing to enter here


Reproducible: Always


User Profile Reset: No



Additional Info:
Nothing to enter here
Comment 1 Rafael Lima 2022-05-23 19:26:07 UTC
Could you provide a sample file where this happens?

Also, what version of LibreOffice are you using? What operating system?
Comment 2 Regina Henschel 2022-05-23 21:18:44 UTC
Which settings do you use in section 'Hyphenation' on tab 'Text Flow' of the paragraph style?
Comment 3 rferraro 2022-05-24 11:55:58 UTC
Created attachment 180331 [details]
Example file with last word hyphenated
Comment 4 rferraro 2022-05-24 11:58:57 UTC
(In reply to Rafael Lima from comment #1)
> Could you provide a sample file where this happens?
> 
> Also, what version of LibreOffice are you using? What operating system?

Version 7.3.3.2 (x64) O/S Windows 10 Pro 21H2, OS Build 19044.1706

I attached a file for you. It is very easy to reproduce. Just type a paragraph with justified text and slightly manipulate the page size and you will see that you can get the last word to hyphenate.
Comment 5 rferraro 2022-05-24 12:01:03 UTC
Created attachment 180334 [details]
Text Flow Settings
Comment 6 rferraro 2022-05-24 12:01:35 UTC
(In reply to Regina Henschel from comment #2)
> Which settings do you use in section 'Hyphenation' on tab 'Text Flow' of the
> paragraph style?

I attached this as a screenshot for you.
Comment 7 Regina Henschel 2022-05-24 13:04:50 UTC
I do not support the idea to have a special rule to prevent hyphenation between second last line and last line. But let's discuss it with UX-team.

The lines are so wide here and really long words are so seldom in English, that an automatic hyphenation makes no sense in context of justified alignment. And if you really need automatic hyphenation - for example for small newspaper columns - then it would be more helpful, when the author would decide whether he wants to hyphenate the word or not in this special case of second last line. Excluding hyphenation for single words is requested in bug 106733.

You should disable automatic hyphenation in your text and only manually insert a soft hyphen were it is really needed. The hyphenation "at-mosphere" is not nice at all, not only in the second last line.
Comment 8 László Németh 2022-05-24 16:13:50 UTC
It's easy to disable hyphenation of the last word, if you really need it, using one of the following workarounds:

– Replace the space before the word with a line break (Shift-Enter);

– Insert Word Joiners (U+2060) by Insert→Formatting Mark→Word Joiner;

– Set language of the word to [None] in Format→Character…

See the attached test document.

To disable hyphenation of all last words, search them by using the

[^ ]*$

regex clicking on the "Find All" button, close Find and Replace, and set language of the selected words to [None] (see the attached screenshot).
Comment 9 László Németh 2022-05-24 16:14:38 UTC
Created attachment 180345 [details]
Workarounds to disable hyphenation of the last word of the paragraphs
Comment 10 László Németh 2022-05-24 16:16:03 UTC
Created attachment 180346 [details]
Select all last words by a regex to format their languages to [None] to disable their hyphenation
Comment 11 Heiko Tietze 2022-05-25 07:40:47 UTC
Created attachment 180361 [details]
MSO hyphenation options

To avoids the "at-" ugliness we have the option "Characters at line end" (known in CSS as hyphenate-limit-chars [1]; set it to 3 to keep "atmosphere" together), "...line begin", and "consecutive lines" (probably hyphenate-limit-lines [2]). These options are badly indented looking as if belonging to CAPS.

The actual numbers depend on the language- two characters might be too low for English but good for other.

CSS does also define hyphenate-limit-last [3] "This property indicates hyphenation behavior at the end of elements, column, pages, and spreads." (and more).

We should add such an option, also with the idea that a hyphenation should not happen at the page/column break.

Attaching also what options MSO offers. The example breaks here at "atmos-phere".

[1] https://www.w3.org/TR/css-text-4/#hyphenate-char-limits
[2] https://www.w3.org/TR/css-text-4/#hyphenate-line-limits
[3] https://www.w3.org/TR/css-text-4/#hyphenate-size-limits
Comment 12 rferraro 2022-05-25 10:46:52 UTC
Ok, ignoring the bad 2 character hyphenation in the example I gave, there should be no hyphenation of the last word in a paragraph. It is a typographic standard and I think you should support it, regardless of the alignment.

Please see attachment - Adobe InDesign (pretty much the standard for publishing) offers that option.
Comment 13 rferraro 2022-05-25 10:48:21 UTC
Created attachment 180366 [details]
Example from Adobe Indesign

Please see this image from Indesign. Last word paragraph hyphenation should be an option.
Comment 14 László Németh 2022-05-26 09:00:24 UTC
Proposed fix: https://gerrit.libreoffice.org/c/core/+/134985

See the attached screenshot about the new option
Comment 15 László Németh 2022-05-26 09:02:37 UTC
Created attachment 180398 [details]
screenshot: new option "Don't hyphenate the last word" in Text Flow page of paragraph settings
Comment 16 Telesto 2022-05-26 09:40:38 UTC
(In reply to László Németh from comment #14)
> Proposed fix: https://gerrit.libreoffice.org/c/core/+/134985
> 
> See the attached screenshot about the new option

A) How is this handled at DOCX/DOC export code? Or is this an incompatible feature  (off-topic: is there a incompatibility list for DOCX/DOC. I thought Justin L keeping track of that somewhere on a wikipage)
B) Does the setting also appear in the Style Inspector (yes, I can also check it myself after the patch is merged). I assume the code being genetic enough, but checking never hurts)
Comment 17 Commit Notification 2022-05-26 14:37:28 UTC
László Németh committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/8c018910ae4d8701b1ce2a95727b9baed4016da3

tdf#149248 sw offapi xmloff: add option to not hyphenate last word

It will be available in 7.4.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 18 László Németh 2022-05-26 14:38:15 UTC
Commit description:

tdf#149248 sw offapi xmloff: add option to not hyphenate last word

Add option to disable automatic hyphenation of the last word of
paragraphs for better typography.

Note: the same option used e.g. in Adobe InDesign, and a
similar one in CSS Text Module Level 4 (hyphenate-limit-last).

* Add checkbox to Text Flow in paragraph dialog
* Store property in paragraph model (com::sun::star::style::ParagraphProperties::ParaHyphenationNoLastWord)
* Add ODF import/export
* Add ODF unit test
* Add layout test

Follow-up to commit 72bd0df107ee47c4d54fa88b4960d32ea03e9f69
"tdf#121658 Add option to not hyphenate words in CAPS".
Comment 19 László Németh 2022-05-26 18:33:48 UTC
(In reply to Telesto from comment #16)
> (In reply to László Németh from comment #14)
> > Proposed fix: https://gerrit.libreoffice.org/c/core/+/134985
> > 
> > See the attached screenshot about the new option
> 
> A) How is this handled at DOCX/DOC export code? Or is this an incompatible
> feature  (off-topic: is there a incompatibility list for DOCX/DOC. I thought
> Justin L keeping track of that somewhere on a wikipage)

If Word will implement the similar CSS settings, it will be possible to support those immediately. Also it's possible to add this to the HTML/CSS export (first, start with the missing hyphenation).

> B) Does the setting also appear in the Style Inspector (yes, I can also
> check it myself after the patch is merged). I assume the code being genetic
> enough, but checking never hurts)

Yes, it's generic. Moreover, it needed to fix the style inspector tests, which contain direct property count, so it works well

See also tdf#149324 for the similar typographic option, the paragraph-level limit for the min. word length for hyphenation.
Comment 20 László Németh 2022-05-26 18:56:36 UTC
@rferraro@sccoast.net, Heiko, Regina: thanks for the report!

(In reply to Regina Henschel from comment #7)
> I do not support the idea to have a special rule to prevent hyphenation
> between second last line and last line. But let's discuss it with UX-team.

Likely the requirement related to the easier work-flow: accessing to the paragraph-level settings i.e. trying different hyphenation options is much more comfortable for adjusting errors of the automatic hyphenation: you can try a lot of combinations with a few click or short cuts, than selecting words and text parts, which less productive, especially if the problematic word occurs more in the document.

Interestingly, CSS 4 has got line-level rule, but Adobe InDesign has a word-level, limiting the prevention only for the last word.

I think, it's really important to give similarly rich options for hyphenation, than DTP software and future web browsers. My next plan to implement hyphenation zone, which is a Word/OOXML feature. I have long term plan to give some settings for better hyphenation for compound words, e.g. for German/Hungarian. Maybe Better Spacing / Fewer Hyphens slider of InDesign is a good user interface for that.

But ODF don't hyphenate character property is a nice feature, especially if we could add a shortcut for that. In fact, if this is not for adjustment of the paragraph text flow, but a bad or unwanted automatic hyphenation, Writer has already supported to disable the hyphenation of a specific word, by adding an equal mark to the plain word ("word=") in the custom hyphenation dictionary:

https://help.libreoffice.org/latest/lo/text/swriter/guide/hyphen_prevent.html?&DbPAR=SHARED&System=UNIX
Comment 21 Heiko Tietze 2022-05-27 07:49:06 UTC
(In reply to László Németh from comment #20)
> My next plan to implement hyphenation zone, which is a Word/OOXML feature.

:thumbs-up:

The on/off solution for the last word seems a bit unflexible to me, I'd have appreciated something like n words/lines. But thanks for the patch, fixes the issue efficiently! Hope you enabled the option by default.
Comment 22 rferraro 2022-06-05 12:22:10 UTC
Also, if you want to be strictly typographically correct you should also disallow hyphenation across columns (Indesign has that feature) and even more important would be to disallow hyphenation across pages. It makes for nicer typography.
Comment 23 László Németh 2022-06-06 14:57:58 UTC
(In reply to Heiko Tietze from comment #21)
> (In reply to László Németh from comment #20)
> > My next plan to implement hyphenation zone, which is a Word/OOXML feature.
> 
> :thumbs-up:
> 
> The on/off solution for the last word seems a bit unflexible to me, I'd have
> appreciated something like n words/lines. But thanks for the patch, fixes
> the issue efficiently! Hope you enabled the option by default.

@Heiko: Thanks for your feedback! For interoperability, it's better to avoid of to use this, as a default option, because OOXML doesn't contain such a thing.
Comment 24 László Németh 2022-06-06 15:01:53 UTC
(In reply to rferraro from comment #22)
> Also, if you want to be strictly typographically correct you should also
> disallow hyphenation across columns (Indesign has that feature) and even
> more important would be to disallow hyphenation across pages. It makes for
> nicer typography.

@Rferraro: you are right! Moreover, it seems, it needs for for interoperability, too, because from Word 2013, this is the default behavior there:

https://docs.microsoft.com/en-us/openspecs/office_standards/ms-docx/e0c0663e-a5e7-4a44-8360-b0b5df1f43e6

See tdf#132599 for that bug.