Bug 157103 - SVG: no space between tspan elements
Summary: SVG: no space between tspan elements
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: filters and storage (show other bugs)
Version:
(earliest affected)
24.2.0.0 alpha0+
Hardware: All All
: medium normal
Assignee: Mike Kaganski
URL:
Whiteboard: target:24.8.0
Keywords: bibisected, bisected
Depends on:
Blocks: SVG-Import
  Show dependency treegraph
 
Reported: 2023-09-05 14:18 UTC by Xisco Faulí
Modified: 2024-04-22 09:19 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
sample file (234 bytes, image/svg+xml)
2023-09-05 14:18 UTC, Xisco Faulí
Details
sample file (352 bytes, image/svg+xml)
2023-09-05 15:14 UTC, Xisco Faulí
Details
Some tests for spaces (724 bytes, image/svg+xml)
2024-04-18 09:19 UTC, Mike Kaganski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Xisco Faulí 2023-09-05 14:18:12 UTC
Created attachment 189370 [details]
sample file

Steps to reproduce:
1. Open attached document

-> No space between the words

Reproduced in

Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: d8dbf35c48698e49c527d740853ce4edc4f1afa9
CPU threads: 8; OS: Linux 5.10; UI render: default; VCL: gtk3
Locale: es-ES (es_ES.UTF-8); UI: en-US
Calc: threaded
Comment 1 Xisco Faulí 2023-09-05 14:19:44 UTC
Regression introduced by:

author	Xisco Fauli <xiscofauli@libreoffice.org>	2022-09-21 17:25:17 +0200
committer	Xisco Fauli <xiscofauli@libreoffice.org>	2022-09-21 21:04:40 +0200
commit a42f5faac7c6d4590e632cf40e3ba9eb618e6f56 (patch)
tree 6f59bb79a87930d51797101669afe9b442a86ccf
parent 5468a58c3244cf98341945c17db040b067c825f7 (diff)
tdf#103888: Do not add a gap at the end of each text portion

Bisected with: bibisect-linux64-7.5

Adding Cc: to Xisco Fauli
Comment 2 Xisco Faulí 2023-09-05 15:14:46 UTC
Created attachment 189371 [details]
sample file
Comment 3 Xisco Faulí 2023-09-05 15:15:32 UTC
The space is only added when each tspan is in a different line in the svg file
Comment 4 Xisco Faulí 2023-09-05 15:19:09 UTC
This actually not a regression. The behaviour changed in the commit mentioned in comment 1
Comment 5 Kira Tubo 2023-11-09 05:49:21 UTC
Reproduced 

Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 676e0527d2f31556eccae314fbb12ce204f02ec7
CPU threads: 6; OS: Windows 10.0 Build 22621; UI render: Skia/Raster; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: CL threaded
Comment 6 Mike Kaganski 2024-04-18 09:19:27 UTC
Created attachment 193741 [details]
Some tests for spaces

The attachment shows some specifics of SVG space handling.

== Line 1 ==

 <text y="1em">  <tspan xml:space="preserve" style="font-size:0.5em">  ← spaces xml:space="preserve", spaces →  </tspan>  </text>

It has two space leading text, then a tspan of a smaller size, with xml:space="preserve", having two leading and two trailing space; and then two space trailing text. It is meant to show, how the leading/trailing space is collapsed into nothing, but the spaces in the preserved case are kept (this was already OK). The changing size of the text allows to see which spaces are used, when you select the text in browser.

== Line 2 ==

 <text y="2em">  Spaces →  <tspan xml:space="preserve" style="font-size:0.5em">  ← spaces xml:space="preserve", spaces →  </tspan>  ← spaces</text>

In this case, the leading/trailing spaces are dropped; but the spaces before/after the "preserve" span are collapsed to a *single space* (not removed!), even though the "preserve" span itself has leading/trailing spaces.

== Line 3 ==

 <text y="3em">  No space test:<tspan>span1</tspan><tspan>span2</tspan>test end  </text>

Here, no spaces must be inserted (this was already OK).

== Line 4 ==

 <text y="4em">  Multiline test:
<tspan>span1</tspan>
<tspan>span2</tspan>
test end</text>

This one is confusing. According to the spec [1], it must remove all whitespace characters - so in the absence of other whitespace between tspans, the expected result is identical to Line 3. However, both Chrome and FF show spaces... The patch below follows the spec, but likely, it could be changed later.

== Line 5 ==

 <text y="5em">  Line shift test:  <tspan x="0" dy="1em" style="font-size:0.5em">  span1  </tspan>  <tspan x="0" dy="1em" style="font-size:0.5em">  span2  </tspan>  test end  </text>

This shows, that changing line does *not* cancel the spaces between the elements. Selecting the text "Line shift test: span1 " shows, that the space after "Line shift test:" is kept, that belongs to the first (larger) part of text, not from "span1"; the space after "span1" is small, and so on.

https://gerrit.libreoffice.org/c/core/+/166239

[1] https://www.w3.org/TR/SVG11/text.html#WhiteSpace
Comment 7 Mike Kaganski 2024-04-18 09:20:54 UTC
(In reply to Mike Kaganski from comment #6)
> == Line 4 ==
> 
> ...
> 
> This one is confusing. According to the spec [1], it must remove all
> whitespace characters

Sorry, I meant "it must remove all *newline* characters"
Comment 8 Mike Kaganski 2024-04-18 10:22:50 UTC
FTR: relevant commits are:

* a42f5faac7c6d4590e632cf40e3ba9eb618e6f56 tdf#103888: Do not add a gap at the end of each text portion (2022-09-21)
* 5079e7937ef471a44dcf119dc6ae0a334d9c6adc tdf#156251: Add gap between text elements when needed (2023-07-12)
* 4f656a057e2a92e2107f7820fc563498c801d7d3 svgio: handle addGap internally inside SvgCharacterNode (2023-08-10)
Comment 9 Commit Notification 2024-04-20 10:16:26 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/6e6081b3401de3a4799953edb5cccbeadcce6a2c

tdf#157103: fix SVG whitespace handling

It will be available in 24.8.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 Xisco Faulí 2024-04-22 09:19:03 UTC
Verified in

Version: 24.8.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: e902fe1b8bf03f9c3747685314f4d443bcea9333
CPU threads: 8; OS: Linux 6.1; UI render: default; VCL: gtk3
Locale: es-ES (es_ES.UTF-8); UI: en-US
Calc: threaded

@Mike, thanks for fixing this issue!!