Bug 395769 - Multi-line paragraph transform into single line when edited
Summary: Multi-line paragraph transform into single line when edited
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Tool/Text (show other bugs)
Version: 4.0.4
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Dmitry Kazakov
URL:
Keywords: regression
: 396518 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-06-22 20:40 UTC by David REVOY
Modified: 2018-09-26 09:11 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
[^ *.kra with text file to reproduce the bug] (1.24 MB, application/x-krita)
2018-06-22 20:40 UTC, David REVOY
Details
(video example) (651.62 KB, video/mp4)
2018-06-23 06:05 UTC, mvowada
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David REVOY 2018-06-22 20:40:21 UTC
Created attachment 113516 [details]
[^ *.kra with text file to reproduce the bug]

Hi,
When I edit paragraph with multi-lines of text in certain conditions(often) they transform into single line as soon as I edit them.

To reproduce:
=============
- Open the Krita file in attachement.
- On the vector "txt" layer, select the text
- Edit the text

Result:
=======
- On the WYSIWYG area the two lines merge into one
Comment 1 mvowada 2018-06-23 06:05:28 UTC
Created attachment 113518 [details]
(video example)

Hi. I can confirm.
In my case it always happens when text is center or right aligned.
Comment 2 David REVOY 2018-06-23 08:52:48 UTC
Thank you @mvowada for finding the exact condition, and the video very well made to demo the bug.
Comment 3 mvowada 2018-07-15 09:25:06 UTC
*** Bug 396518 has been marked as a duplicate of this bug. ***
Comment 4 katearcher89 2018-09-21 11:27:47 UTC
I can confirm this, although in my case it happens regardless the text alignment. Any editing of the previously created multi-line text(created using enter-key to change lines) destroys that line-break information completely.
Comment 5 katearcher89 2018-09-21 11:52:50 UTC
Really annoying, a single missed dot in a text and you have to redo all of the line-breaks in the text :(
Comment 6 David REVOY 2018-09-21 12:18:03 UTC
@katearcher89 : Yes, that's one of my top annoying bug of the moment.

It prevents me to storyboard Pepper&Carrot episode in Krita as I did in the past (eg. https://www.peppercarrot.com/extras/temp/2017-06-30_screenshot_163319_net.jpg
 ) because each time I have to edit a speechbubble I have to redo the correct line-break. And that, even when I just edit a single word or a punctuation. So, I abandoned the idea of using Krita text tool. I wish this bug could get a higher priority.
Comment 7 katearcher89 2018-09-21 13:02:15 UTC
(In reply to David REVOY from comment #6)
> @katearcher89 : Yes, that's one of my top annoying bug of the moment.
> 
> It prevents me to storyboard Pepper&Carrot episode in Krita as I did in the
> past (eg.
> https://www.peppercarrot.com/extras/temp/2017-06-30_screenshot_163319_net.jpg
>  ) because each time I have to edit a speechbubble I have to redo the
> correct line-break. And that, even when I just edit a single word or a
> punctuation. So, I abandoned the idea of using Krita text tool. I wish this
> bug could get a higher priority.

My problem with it exactly the same -- every time I do speech bubbles it's a quite the pain. Not a such deal breaker as for you since I'm still not abandoned text tools in krita but definitely frustrating a lot.
Comment 8 David REVOY 2018-09-23 13:22:29 UTC
Here are results my investigations:

Saving multiline SVG text
=========================
It is working. (screenshot: https://www.peppercarrot.com/extras/temp/2018-09-23_screenshot_150851_net.jpg)
The markup is like that:
<tspan x="54.390625pt">This line one</tspan>
<tspan x="54.390625pt" dy="21pt">This is line two</tspan>
If saved as *.kra file and then *.kra unziped; the SVG data layer contains same markup.

Loading multiline SVG text (editing)
====================================
Broken. (screenshot: https://www.peppercarrot.com/extras/temp/2018-09-23_screenshot_151238_net.jpg)
The markup is like that:
<tspan x="100.1171875pt">This line oneThis is line two</tspan>
The two <tspan> markup were merged. Probably a rule a bit too aggressive of merging similar markup (a sort of SVG autoclean?).

I tried to look at libs/flake/text/KoSvgTextChunkShape.cpp to find how this cleanup was performed into KoSvgTextChunkShape::loadSvgTextNode (around line 694) and manually modify hasNextSibling and hasPreviousSibling rules with tspan.

I unfortunately failed at tweaking something that could solve the bug...
Help?
Comment 9 David REVOY 2018-09-23 15:24:29 UTC
More investigations:

Bug didn't existed into krita-4.0.0-x86_64.appimage (20 March = git tag 4.0.0)
Bug was introduced at: krita-4.0.1-x86_64.appimage (10 april = git tag 4.0.1)

I tried to rebuild 4.0.0 but even if it builds, the app crashes at start-up. I tried to rebuild a git version between 4.0.0 and 4.0.1, crashes too at startup. So, I can't test what commit exactly introduced the bug ¯\(ツ)/¯
Comment 10 Halla Rempt 2018-09-25 10:26:12 UTC
Hm, unless I misunderstand something, I still see the issue happening with the 4.0.0 appimage: I select the text shape, open the editor and close it. The two lines will be joined up into one line.
Comment 11 David REVOY 2018-09-25 11:28:09 UTC
Hi Boud. Here my 4.0.0appimage can't reproduce it (while 4.0.1 can):  you can see it in this short video: https://www.peppercarrot.com/extras/temp/2018-09-25_Multine-bug_comparing-Krita400and401appimage.webm
Comment 12 David REVOY 2018-09-25 13:09:57 UTC
@boud: I can confirm 4.0.0 bugs also with the *.kra in attachement.  4.0.0 does the multiline text well only if generated from scratch in 4.0.0.

This observation made me investigate more.

Here is the content of the SVG inside the *.kra of the bugged file in attachement:
 <tspan x="49.0546875">main critic: Github-like </tspan>
 <tspan x="49.0546875" dy="17">--&gt; NEED FIX</tspan>

While working generated text box multiline done from scratch in 4.0.0 looks like:
 <tspan>Lorem ipsum dolor sit amet, </tspan>
 <tspan x="0" dy="21pt">consectetur adipiscing elit.</tspan>

I tried to unzip the bugged *.kra, change the SVG to:
<tspan>main critic: Github-like </tspan><tspan x="0" dy="17">--&gt; NEED FIX</tspan>
https://www.peppercarrot.com/extras/temp/txt.kra
Comment 13 David REVOY 2018-09-25 13:14:37 UTC
[...] (sorry I accidentally hit <tab> + <spacebar> while tapping, it immediately sent the previous message, not finished!) 

so:
I tried to unzip the bugged *.kra, change the SVG to:
 <tspan>main critic: Github-like </tspan>
 <tspan x="0" dy="17">--&gt; NEED FIX</tspan>
(file here https://www.peppercarrot.com/extras/temp/txt.kra)

and suddently, even git~master can edit the multiline! My guess; the newest way to add coordinate of tspan with same x data merge them together (getting two time <tspan x="49.0546875">).
Comment 14 Dmitry Kazakov 2018-09-25 14:11:09 UTC
Just to keep the history, it was reported that this commit might be related:

https://phabricator.kde.org/R37:ea60cd8a930334fc544284034bc5c4d797b3e94b
Comment 15 Dmitry Kazakov 2018-09-26 09:04:54 UTC
Git commit e90873b8dbcac9dc69d5d15cf05bc3a2572a1b69 by Dmitry Kazakov.
Committed on 26/09/2018 at 09:04.
Pushed by dkazakov into branch 'master'.

Fix saving line breaks when the text is not left aligned

M  +20   -12   libs/flake/text/KoSvgTextShapeMarkupConverter.cpp

https://commits.kde.org/krita/e90873b8dbcac9dc69d5d15cf05bc3a2572a1b69
Comment 16 Halla Rempt 2018-09-26 09:11:43 UTC
Git commit c767686e98214dca653796005161336b49fe288d by Boudewijn Rempt, on behalf of Dmitry Kazakov.
Committed on 26/09/2018 at 09:11.
Pushed by rempt into branch 'krita/4.1'.

Fix saving line breaks when the text is not left aligned

M  +20   -12   libs/flake/text/KoSvgTextShapeMarkupConverter.cpp

https://commits.kde.org/krita/c767686e98214dca653796005161336b49fe288d