Bug 168002 - CairoSDPR breaks SVG text layout
Summary: CairoSDPR breaks SVG text layout
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: graphics stack (show other bugs)
Version:
(earliest affected)
25.2.0.0 alpha0+
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Armin Le Grand (collabora)
URL:
Whiteboard: target:26.2.0 target:25.8.2
Keywords: bibisected, bisected, regression
Depends on:
Blocks: CairoSDPR
  Show dependency treegraph
 
Reported: 2025-08-18 20:20 UTC by Buovjaga
Modified: 2025-08-28 13:28 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
ReducedBugDoc using draw (simpler) and SVG stripped to one text (9.97 KB, application/vnd.oasis.opendocument.graphics)
2025-08-19 17:31 UTC, Armin Le Grand (collabora)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Buovjaga 2025-08-18 20:20:33 UTC
1. Open Writer on Linux
2. Insert attachment 179090 [details] from bug 148167 as an image

Compare to screenshot of "Firefox (top) vs LibreOffice 7.4 (bottom)", attachment 179100 [details]

Bibisected with linux-64-25.2 to bf3cd8e50f886084500e3a8ff72ff4ffab05ddd7
CairoSDPR: Make using SDPR dependent of ExperimentalMode

Arch Linux 64-bit
Version: 26.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 1313be884c4ded639a5f53694c82a1cf2e77fe70
CPU threads: 8; OS: Linux 6.15; UI render: default; VCL: kf6 (cairo+wayland)
Locale: fi-FI (fi_FI.UTF-8); UI: en-US
Calc: CL threaded
Built on 12 August 2025
Comment 1 Xisco Faulí 2025-08-19 09:35:22 UTC
Reproduced in

Version: 26.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: f3522ba36c867f4eb69fabcf293419f1d69caffa
CPU threads: 8; OS: Linux 6.1; UI render: default; VCL: gtk3
Locale: es-ES (es_ES.UTF-8); UI: en-US
Calc: threaded
Comment 2 Xisco Faulí 2025-08-19 09:53:06 UTC
Using TEST_SYSTEM_PRIMITIVE_RENDERER=1 I bisected it further to ff46c8bf598481ae37022414f3495c1e9385eb7c
Comment 3 Armin Le Grand (collabora) 2025-08-19 11:02:25 UTC
Also in Draw, so created simple test doc.
Using DISABLE_SYSTEM_DEPENDENT_PRIMITIVE_RENDERER shows it has to do with CairoSDPR - strange since SVG import is not different, so same TextPrimitives create different renderings -> have to check...
Comment 4 Armin Le Grand (collabora) 2025-08-19 13:22:45 UTC
Seems to have to do with TextSimplePortionPrimitive2D's having no DxArray, the current stuff works in ObjectCoordinates then and that are small doubles, so also some old int/rounding involved i fear...
Comment 5 Armin Le Grand (collabora) 2025-08-19 17:31:02 UTC
Created attachment 202383 [details]
ReducedBugDoc using draw (simpler) and SVG stripped to one text
Comment 6 Armin Le Grand (collabora) 2025-08-20 11:50:58 UTC
After some experimenting I identified the basic problem: In GenericSalLayout::LayoutText:821 we have

                if (!GetSubpixelPositioning())
                {
                    nAdvance = std::round(nAdvance);
                    nXOffset = std::round(nXOffset);
                    nYOffset = std::round(nYOffset);
                }

and thus the *correctly* created DXArray values which are in logical object coordinates for the text (0..1) get killed. As can be seen that does not happen when GetSubpixelPositioning is active. that again depends on code in OutputDevice::ImplLayout, see

    if (pSalLayout)
        pSalLayout->SetSubpixelPositioning(mbMap);

where mbMap is

    bool                        IsMapModeEnabled() const { return mbMap; }

which is not the case for the OutDev (ImpTimedRefDev) used in TextLayouterDevice. Just setting it does not help - unfortunately, so have to check how I can get SubpixelPositioning to the needed places...
Comment 7 Armin Le Grand (collabora) 2025-08-21 11:05:22 UTC
Solution on gerrit , see https://gerrit.libreoffice.org/c/core/+/189993
Comment 8 Armin Le Grand (collabora) 2025-08-26 08:45:39 UTC
Had to change, the 1st solution stopped working, see comments and new solution in https://gerrit.libreoffice.org/c/core/+/189993
Comment 9 Commit Notification 2025-08-26 08:45:44 UTC
Armin Le Grand (collabora) committed a patch related to this issue.
It has been pushed to "master":

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

tdf#168002 CairoSDPR breaks SVG text layout

It will be available in 26.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 10 Buovjaga 2025-08-26 10:51:11 UTC
Fix verified.

Arch Linux 64-bit
Version: 26.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 554aa00b556dfc461ea32ebcb8abd98061629599
CPU threads: 8; OS: Linux 6.16; UI render: default; VCL: kf6 (cairo+wayland)
Locale: fi-FI (fi_FI.UTF-8); UI: en-US
Calc: CL threaded
Built on 26 August 2025
Comment 11 Commit Notification 2025-08-28 13:28:45 UTC
Armin Le Grand (collabora) committed a patch related to this issue.
It has been pushed to "libreoffice-25-8":

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

tdf#168002 CairoSDPR breaks SVG text layout

It will be available in 25.8.2.

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.