Bug 391160 - Handmade SVG file using list values for the x, y, dx, and dy values won't load right.
Summary: Handmade SVG file using list values for the x, y, dx, and dy values won't loa...
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Tool/Text (show other bugs)
Version: git master (please specify the git hash!)
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Dmitry Kazakov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-02-27 11:41 UTC by wolthera
Modified: 2018-03-19 14:32 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description wolthera 2018-02-27 11:41:51 UTC
(From phabricator)
There's a weird thing going on with the character offsets, the following SVG loads properly in Firefox and Inkscape, but not in Krita:

------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<svg viewbox="0 0 1800 1200" xmlns="http://www.w3.org/2000/svg">
    
    <text x="200" y="50" style="font-family:Noto mono; font-size:12pt; text-anchor:start">
    <tspan dy="0 -3 -3 -3 -3 3 3 3 3 0 -3 -3 -3 -3 3 3 3 3 0 -3 -3 -3 -3 3 3 3 3 0 -3 -3 -3 -3 3 3 3 3 0">Lorem ipsum dolor sit amet</tspan>
    </text>
    
    <text x="200" y="100" style="font-family:Noto mono; font-size:12pt; text-anchor:start">
    <tspan dx="0 -3 -3 -3 -3 3 3 3 3 0 -3 -3 -3 -3 3 3 3 3 0 -3 -3 -3 -3 3 3 3 3 0 -3 -3 -3 -3 3 3 3 3 0">consectetur adipiscing elit.</tspan>
    </text>
    
    <text x="200" y="150" style="font-family:Noto mono; font-size:12pt; text-anchor:start">
    <tspan y="150 155 160 155 150 155 160 155 150 155 160 155 150 155 160 155 150 155 160 155 150 155 160 155 150 155 160 155">Lorem ipsum dolor sit amet</tspan>
    </text>
    <text x="150" y="200" style="font-family:Noto mono; font-size:12pt; text-anchor:start">
    <tspan x="150 170 190 210 230 250 270 290 310 330 350 370 390 410 430 450 470 490 510 530 550 570 590 610 630 650 670 690">Lorem ipsum dolor sit amet</tspan>
    </text>
</svg>
-----------------------------------------------------------------------------
And the code for handling the offsets like this is there, it's just not interpreted properly.
Comment 1 Dmitry Kazakov 2018-03-16 05:46:21 UTC
Oups, after my recent fix for text bounding rect, this test file just crashes Krita :(
Comment 2 Dmitry Kazakov 2018-03-17 07:14:40 UTC
Git commit 7317b69c9464fe3600cf672ebea1cb18ac97bfe1 by Dmitry Kazakov.
Committed on 17/03/2018 at 07:14.
Pushed by dkazakov into branch 'master'.

Fix crash when a format range wraps a fully whitespace run of symbols

M  +5    -0    libs/flake/text/KoSvgTextShape.cpp

https://commits.kde.org/krita/7317b69c9464fe3600cf672ebea1cb18ac97bfe1
Comment 3 Dmitry Kazakov 2018-03-17 07:15:32 UTC
After the crash is fixed it is just a bug, not a release blocker anymore
Comment 4 Halla Rempt 2018-03-17 08:53:31 UTC
Git commit 72c4f497f733ee85a620874f00234c54988d5aa0 by Boudewijn Rempt, on behalf of Dmitry Kazakov.
Committed on 17/03/2018 at 08:53.
Pushed by rempt into branch 'krita/4.0'.

Fix crash when a format range wraps a fully whitespace run of symbols
(cherry picked from commit 7317b69c9464fe3600cf672ebea1cb18ac97bfe1)

M  +5    -0    libs/flake/text/KoSvgTextShape.cpp

https://commits.kde.org/krita/72c4f497f733ee85a620874f00234c54988d5aa0
Comment 5 Dmitry Kazakov 2018-03-19 12:23:21 UTC
Git commit c764a68e1df604e7ccd453bac4ccf23182038479 by Dmitry Kazakov.
Committed on 19/03/2018 at 12:15.
Pushed by dkazakov into branch 'master'.

Fix rendering of the text with relative offsets

1) Relative offsets were calculated incorrectly: null offsets should
   not repeat itself, but define a new noop offset, which will
   be handled on a lower level

2) Workaround QTextLayout "weirdness" that makes it skip the space
   characters and not include them into "horizontal advance" of the
   text chunk

M  +80   -0    libs/flake/tests/TestSvgText.cpp
M  +3    -0    libs/flake/tests/TestSvgText.h
A  +-    --    libs/flake/tests/data/svg_render/load_text_multiple_absolute_offsets_arabic.png
A  +-    --    libs/flake/tests/data/svg_render/load_text_multiple_relative_offsets.png
M  +3    -1    libs/flake/text/KoSvgTextChunkShape.cpp
M  +104  -31   libs/flake/text/KoSvgTextShape.cpp

https://commits.kde.org/krita/c764a68e1df604e7ccd453bac4ccf23182038479
Comment 6 Halla Rempt 2018-03-19 14:32:44 UTC
Git commit 3fb3824e436df7a997c02f3ab59472be9e114de2 by Boudewijn Rempt, on behalf of Dmitry Kazakov.
Committed on 19/03/2018 at 14:32.
Pushed by rempt into branch 'krita/4.0'.

Fix rendering of the text with relative offsets

1) Relative offsets were calculated incorrectly: null offsets should
   not repeat itself, but define a new noop offset, which will
   be handled on a lower level

2) Workaround QTextLayout "weirdness" that makes it skip the space
   characters and not include them into "horizontal advance" of the
   text chunk

M  +80   -0    libs/flake/tests/TestSvgText.cpp
M  +3    -0    libs/flake/tests/TestSvgText.h
A  +-    --    libs/flake/tests/data/svg_render/load_text_multiple_absolute_offsets_arabic.png
A  +-    --    libs/flake/tests/data/svg_render/load_text_multiple_relative_offsets.png
M  +3    -1    libs/flake/text/KoSvgTextChunkShape.cpp
M  +104  -31   libs/flake/text/KoSvgTextShape.cpp

https://commits.kde.org/krita/3fb3824e436df7a997c02f3ab59472be9e114de2