Bug 155297 - FILEOPEN DOCX loading loses paragraph line spacing
Summary: FILEOPEN DOCX loading loses paragraph line spacing
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.1.0.4 release
Hardware: All All
: medium normal
Assignee: ⁨خالد حسني⁩
URL:
Whiteboard: target:7.6.0
Keywords: bibisectNotNeeded, filter:docx, regression
Depends on:
Blocks: Paragraph-Line-Spacing Regressions-Universal-Line-Spacing
  Show dependency treegraph
 
Reported: 2023-05-14 13:42 UTC by Hossein
Modified: 2023-06-05 14:58 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Sample DOCX file created in MS Word (13.13 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2023-05-14 13:42 UTC, Hossein
Details
"B Nazanin" font, used in the document (50.40 KB, application/zip)
2023-05-14 13:43 UTC, Hossein
Details
PDF Output created with MS Word (64.70 KB, application/pdf)
2023-05-14 13:44 UTC, Hossein
Details
PDF Output created with LibreOffice 7.6 dev master (21.18 KB, application/pdf)
2023-05-14 13:45 UTC, Hossein
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hossein 2023-05-14 13:42:46 UTC
Created attachment 187268 [details]
Sample DOCX file created in MS Word

Description:
Loading a docx file, loses paragraph properties, including justification and line spacing.

Steps to Reproduce:
1. Open DOCX attachment in LibreOffice and export it to PDF.
2. Open DOCX attachment in MS Word and export it to PDF.
3. Compare the results

Note: You may need "B Nazanin" font, in which I will add as an attachment later.

Actual Results:
Justification and line spacing is totally different in LibreOffice with MS Word.

Expected Results:
Justification and line spacing should be the same as MS Word.

Reproducible: Always


User Profile Reset: No

Additional Info:
Version: 7.6.0.0.alpha1+ (X86_64) / LibreOffice Community
Build ID: 6f1534940ac12ff8e46f4782e18cfb6cf585da39
CPU threads: 32; OS: Windows 10.0 Build 19044; UI render: default; VCL: win
Locale: en-US (en_DE); UI: en-US
Calc: threaded
Comment 1 Hossein 2023-05-14 13:43:57 UTC
Created attachment 187269 [details]
"B Nazanin" font, used in the document
Comment 2 Hossein 2023-05-14 13:44:23 UTC
Created attachment 187270 [details]
PDF Output created with MS Word
Comment 3 Hossein 2023-05-14 13:45:13 UTC
Created attachment 187271 [details]
PDF Output created with LibreOffice 7.6 dev master
Comment 4 Stéphane Guillou (stragu) 2023-05-30 13:32:24 UTC
MS Office has the paragraph with "Kashida" justified settings, whereas LO has it right-aligned.
Line spacing setting is the same in both (single line).

LO has text not justified, and a thinner line spacing.

Version: 7.6.0.0.alpha1+ (X86_64) / LibreOffice Community
Build ID: fc4f7db59152f606b6aa88cf32197700959d0f8b
CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded

Same in 6.0.0.3, but line spacing was respected back in OOo 3.3.

Khaled, what do you think?
Comment 5 ⁨خالد حسني⁩ 2023-06-04 20:16:16 UTC
(In reply to Stéphane Guillou (stragu) from comment #4)
> MS Office has the paragraph with "Kashida" justified settings, whereas LO
> has it right-aligned.
> Line spacing setting is the same in both (single line).
> 
> LO has text not justified, and a thinner line spacing.
> 
> Version: 7.6.0.0.alpha1+ (X86_64) / LibreOffice Community
> Build ID: fc4f7db59152f606b6aa88cf32197700959d0f8b
> CPU threads: 8; OS: Linux 5.15; UI render: default; VCL: gtk3
> Locale: en-AU (en_AU.UTF-8); UI: en-US
> Calc: threaded
> 
> Same in 6.0.0.3, but line spacing was respected back in OOo 3.3.
> 
> Khaled, what do you think?

No idea about the lost justification settings, but the line metrics issue can be explained. For historical reasons, fonts have three sets of line spacing settings. The font has two of them equal to each other (Windows GDI will select one of these, and older versions of LibreOffice got the values from Windows GDI), and the last set has smaller line spacing.

We end up using that last set for complicated reasons and we don’t want to touch this code anymore because whatever the way we change it will break some font.

We have an escape hatch where we can specify that certain fonts should use the values that Windows GDI uses, so we can do this here. Users should be able to do this yourself from the expert configuration dialog (search for FontsUseWinMetrics), but this is currently broken and works only for fonts already specified in the configuration.

I suggest keeping this bug to track the line metrics issue, and open a new one for the lost justification setting.
Comment 6 ⁨خالد حسني⁩ 2023-06-04 20:49:58 UTC
(In reply to ⁨خالد حسني⁩ from comment #5)
> Users should be
> able to do this yourself from the expert configuration dialog (search for
> FontsUseWinMetrics), but this is currently broken

https://bugs.documentfoundation.org/show_bug.cgi?id=155676
Comment 7 Commit Notification 2023-06-05 04:38:44 UTC
Khaled Hosny committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/1263873edf86ce223ee54ecd93297273ac3b0e9f

tdf#155297: Use usWinAscent and usWinDescent for B Nazanin font

It will be available in 7.6.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 8 Stéphane Guillou (stragu) 2023-06-05 14:56:14 UTC
(In reply to ⁨خالد حسني⁩ from comment #5)
> I suggest keeping this bug to track the line metrics issue, and open a new
> one for the lost justification setting.

Thanks Khaled, done in bug 155689.

I bibisected the line spacing regression down to the 4.1.0.0.beta1 release with the linux-64-releases repo, but not to a precise commit. So not sure about blocking bug 112839?
Comment 9 ⁨خالد حسني⁩ 2023-06-05 14:58:53 UTC
(In reply to Stéphane Guillou (stragu) from comment #8)
> (In reply to ⁨خالد حسني⁩ from comment #5)
> > I suggest keeping this bug to track the line metrics issue, and open a new
> > one for the lost justification setting.
> 
> Thanks Khaled, done in bug 155689.
> 
> I bibisected the line spacing regression down to the 4.1.0.0.beta1 release
> with the linux-64-releases repo, but not to a precise commit. So not sure
> about blocking bug 112839?

Originally Windows, Linux, and macOS didn’t all agree on the line spacing, so if you bibisect on Windows you should get different results.