Bug 172233 - Line spacing gap placed differently in LO compared to Microsoft Office
Summary: Line spacing gap placed differently in LO compared to Microsoft Office
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Justin L
URL:
Whiteboard: target:27.2.0
Keywords:
Depends on:
Blocks: Paragraph-Line-Spacing 172113
  Show dependency treegraph
 
Reported: 2026-05-25 14:22 UTC by Justin L
Modified: 2026-06-26 23:42 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
172113_linespacingGapAfter.odt (17.02 KB, application/vnd.oasis.opendocument.text)
2026-05-25 14:22 UTC, Justin L
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Justin L 2026-05-25 14:22:49 UTC
Created attachment 207207 [details]
172113_linespacingGapAfter.odt

Meta-ish bug 172113 mentioned that LO places the line-spacing gap above the line, while MS Word places it below the line. IMHO it tends to look better Microsoft's way. This different implementation also results in layout incompatibilities.

Steps to reproduce:
-open 172113_linespacingGapAfter.odt in LO - notice it takes up two pages
-save as DOCX and reload. In MS Word it all fits on one page.

Bug 94464 seems to suggest that there is no advantage in putting a gap above instead of below. The way I read those comments is that font designers already add a gap above for reasonable single-space reading. So if the user/style wants to add an additional gap, it makes sense to add it below the line instead of above.

bug 172113 also mentions that in LO the height of the first line is dis-regarded in terms of line-spacing - because for the first line gap LO re-uses the height of the last line. So in LO the last line's height informs two gaps (although the resulting gap size can be different). [See attachment 207103 [details] (172113_linespacingFirstLine.docx)]


In order to fix all of these differences, we might as well change the native implementation (using a compatibility flag) to match how Microsoft does it. I imagine that the implementation might be able to ALWAYS use the previous line's linespacingBaseHeight as the 'gap above' (instead of only doing this for the first line). That might allow re-using the existing code.

Alternatively, the layout could be changed to always add the gap below the line. In my simplistic mind, these two should result in identical results.
Comment 1 Jonathan Clark 2026-06-23 21:57:33 UTC
(In reply to Justin L from comment #0)
> In order to fix all of these differences, we might as well change the native
> implementation (using a compatibility flag) to match how Microsoft does it.
There are two parts to this bug, so I suggest splitting it: we can use this bug to track implementing the compat flag as a MSO conformance task, and use a separate bug to address making it the default behaviour for ODF going forward.

I agree with your aesthetic sense here, but just to be safe I'd rather not entwine the uncontroversial MSO conformance parts with a change that could open a larger discussion.
Comment 2 Jonathan Clark 2026-06-25 14:47:49 UTC
I discussed this with some other developers, and there were no immediate concerns about making this the default behaviour as long as the compat flag can be toggled in options.

We can always adjust the default value for the compat flag later on if needed.
Comment 3 Commit Notification 2026-06-26 23:32:19 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/9082a3bd8a94208ce834920546b8d8b8bf551f8e

tdf#172233 sw: apply line spacing gap after the line, not before

It will be available in 27.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 4 Justin L 2026-06-26 23:42:55 UTC
(In reply to Jonathan Clark from comment #1)
> use a separate bug to address making it the default behaviour for ODF
We can use bug 172113 for that.