Bug 392242 - Imported SVG is corrupted
Summary: Imported SVG is corrupted
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Layers/Vector (show other bugs)
Version: 4.0
Platform: Manjaro Linux
: NOR normal
Target Milestone: ---
Assignee: Dmitry Kazakov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-23 17:38 UTC by Konstantin
Modified: 2020-01-28 13:56 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Problematic file (3.15 MB, image/svg+xml)
2018-03-23 17:38 UTC, Konstantin
Details
1.svg in Krita 4.0 (screenshot) (120.41 KB, image/png)
2018-03-24 15:28 UTC, Mikhail Novosyolov
Details
1.svg in Gwenview and KolourPaint (identical corruption, screenshot) (245.60 KB, image/png)
2018-03-24 15:28 UTC, Mikhail Novosyolov
Details
How it looks in Inkscape (87.08 KB, image/png)
2018-03-24 15:48 UTC, Konstantin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Konstantin 2018-03-23 17:38:19 UTC
Created attachment 111585 [details]
Problematic file

Hello.

I have problems with opening svg files in Krita.

I've tried to open svg file, which was generated by pdf2svg application from pdf file, which was produced with MuseScore. File contains raster graphics, vector lines, texts (with this font https://www.fonts-online.ru/font/Amsdam-cyr-lat ) and all musical scores are, in fact, text objects with custom  MuseScore fonts. When I open this svg file in Inkscape, it looks fine (at least to my eye). When imported it to GIMP, it rasterizes it, but everything looks fine.

But Krita opens this file wrong. Raster objects have wring scale, Texts are missing, scores looks wrong to.

Thank you for your attention.

P.s. Maybe it's not related directly to Vector Layers, but I didn't found a better component in the list, sorry.
Comment 1 Dmitry Kazakov 2018-03-23 19:14:46 UTC
I can confirm, the file opens fine in Inkscape and Firefox, but doesn't open in Krita. The file uses SVG 'symbol' functionality extensively.
Comment 2 Konstantin 2018-03-23 19:20:41 UTC
A bit more info. Opening this file in Gwenview gives same corruption. Maybe because they both use same libraries from KDE?
Comment 3 Mikhail Novosyolov 2018-03-24 15:28:01 UTC
Created attachment 111606 [details]
1.svg in Krita 4.0 (screenshot)
Comment 4 Mikhail Novosyolov 2018-03-24 15:28:49 UTC
Created attachment 111607 [details]
1.svg in Gwenview and KolourPaint (identical corruption, screenshot)
Comment 5 Mikhail Novosyolov 2018-03-24 15:38:53 UTC
I've posted this bug in Qt's bugtracker: https://bugreports.qt.io/browse/QTBUG-67297
Comment 6 Konstantin 2018-03-24 15:48:30 UTC
Created attachment 111608 [details]
How it looks in Inkscape

Added "reference" look in Inkscape.
Comment 7 Dmitry Kazakov 2020-01-28 13:56:24 UTC
Git commit e62259f2952506881689f57d835d4a642d6813a9 by Dmitry Kazakov.
Committed on 26/11/2019 at 10:28.
Pushed by dkazakov into branch 'master'.

Implement KisForest container for tree-like structures

Historically, we implemented tree-like structures by putting
the linked-lists inside the objects themselves (see KisNode and
KoShape). It it not very convenient in cases when you need a custom
hierarchy over existing objects, e.g. for composing.

KisForest implements a container for building tree-like structures from
arbitrary objects. The stored elements don't have to have know anything
about hierarchy and, more than that, they may be contained in multiple
different hierarchies.

See KisForestTest for examples on how to use the forest.

Ref T11969
CC:kimageshop@kde.org

A  +45   -0    libs/global/KisCppQuirks.h     [License: GPL (v2+)]
A  +881  -0    libs/global/KisForest.h     [License: GPL (v2+)]
M  +1    -0    libs/global/tests/CMakeLists.txt
A  +884  -0    libs/global/tests/KisForestTest.cpp     [License: GPL (v2+)]
A  +55   -0    libs/global/tests/KisForestTest.h     [License: GPL (v2+)]

https://invent.kde.org/kde/krita/commit/e62259f2952506881689f57d835d4a642d6813a9
Comment 8 Dmitry Kazakov 2020-01-28 13:56:24 UTC
Git commit 9212bea1a2ca728b58054c495827a93ca199cbd7 by Dmitry Kazakov.
Committed on 29/11/2019 at 16:57.
Pushed by dkazakov into branch 'master'.

Fix loading SVG files with symbols

We should also parse symbols as a normal cycle of 'defs', so that the
child shapes would also be parsed.

M  +14   -7    libs/flake/svg/SvgParser.cpp
M  +1    -1    libs/flake/svg/SvgParser.h
M  +53   -11   libs/flake/tests/TestSvgParser.cpp
M  +1    -0    libs/flake/tests/TestSvgParser.h
A  +-    --    libs/flake/tests/data/svg_render/load_clip_mask_on_group_obb.png

https://invent.kde.org/kde/krita/commit/9212bea1a2ca728b58054c495827a93ca199cbd7
Comment 9 Dmitry Kazakov 2020-01-28 13:56:25 UTC
Git commit 2e8294becc66a548321d9274dfe4109963ea6577 by Dmitry Kazakov.
Committed on 29/11/2019 at 17:31.
Pushed by dkazakov into branch 'master'.

Fix rendering of vector masks applied to group shapes

The patch does multiple things:

1) Refactors KoShapeManager::paint() to use KisForest implementation
   to render shapes hierarchy. It is needed because we need to be able
   only a part of the shapes, and their parents might have filtering or
   masks. Theoretically, it is possible to implement this algorithm
   without KisForest, but it this case populateRenderSubtree(),
   buildRenderTree() and renderShapes() will be merged into a single
   function (or some counter-intuitive templated strategy), which would
   make the code hard to debug and maintain.

2) KoViewConverter is gone! Gone! You hear it?! It is gone!!! No more
   KoViewConverter in any rendering! :)
   Well, it is still used in the tools, but we can live with it for now.
   The main point, there is no ugly hacks in KoShape::absoluteTransformation()
   to correct shape's offset to let view scaling transform be applied
   *after* the shape. Now view tranform in applied *before* the shapes,
   right in KisShapeLayerCanvas (or the like).

The code touches a lot of code, so some testing is needed.

Things that were deprecated:
 * SVG-filtering rendering code was removed. It used an ugly hack to
   let it work on groups. It couldn't be kept after refactoring. When
   we implement it correctly, it should be just placed into renderShapes().

 * some features of ODF text and raster-based vector patterns might
   have become broken. But we have no way to test that :(

M  +8    -6    libs/basicflakes/tools/KoCreatePathTool.cpp
M  +6    -4    libs/basicflakes/tools/KoPencilTool.cpp
M  +3    -0    libs/flake/KisGamutMaskViewConverter.h
M  +2    -1    libs/flake/KoCanvasControllerWidgetViewport_p.cpp
M  +1    -3    libs/flake/KoClipMask.cpp
M  +18   -27   libs/flake/KoClipPath.cpp
M  +1    -2    libs/flake/KoClipPath.h
M  +1    -1    libs/flake/KoColorBackground.cpp
M  +1    -1    libs/flake/KoColorBackground.h
M  +7    -8    libs/flake/KoConnectionShape.cpp
M  +1    -1    libs/flake/KoDrag.cpp
M  +6    -6    libs/flake/KoFlake.cpp
M  +1    -1    libs/flake/KoGradientBackground.cpp
M  +1    -1    libs/flake/KoGradientBackground.h
M  +2    -2    libs/flake/KoHatchBackground.cpp
M  +1    -1    libs/flake/KoHatchBackground.h
M  +4    -7    libs/flake/KoMarker.cpp
M  +1    -1    libs/flake/KoOdfGradientBackground.cpp
M  +1    -1    libs/flake/KoOdfGradientBackground.h
M  +8    -10   libs/flake/KoPathShape.cpp
M  +1    -1    libs/flake/KoPathShape.h
M  +3    -8    libs/flake/KoPatternBackground.cpp
M  +1    -1    libs/flake/KoPatternBackground.h
M  +4    -5    libs/flake/KoSelection.cpp
M  +1    -2    libs/flake/KoSelection.h
M  +34   -53   libs/flake/KoShape.cpp
M  +12   -41   libs/flake/KoShape.h
M  +2    -2    libs/flake/KoShapeAnchor.cpp
M  +1    -2    libs/flake/KoShapeBackground.h
M  +2    -3    libs/flake/KoShapeContainer.cpp
M  +2    -4    libs/flake/KoShapeContainer.h
M  +2    -2    libs/flake/KoShapeGroup.cpp
M  +1    -1    libs/flake/KoShapeGroup.h
M  +1    -1    libs/flake/KoShapeLayer.cpp
M  +1    -1    libs/flake/KoShapeLayer.h
M  +203  -229  libs/flake/KoShapeManager.cpp
M  +2    -12   libs/flake/KoShapeManager.h
M  +0    -12   libs/flake/KoShapeManager_p.h
M  +1    -1    libs/flake/KoShapeRegistry.cpp
M  +18   -19   libs/flake/KoShapeShadow.cpp
M  +1    -2    libs/flake/KoShapeShadow.h
M  +1    -4    libs/flake/KoShapeStroke.cpp
M  +1    -2    libs/flake/KoShapeStroke.h
M  +1    -3    libs/flake/KoShapeStrokeModel.h
M  +2    -2    libs/flake/KoSnapProxy.cpp
M  +1    -1    libs/flake/KoSnapStrategy.cpp
M  +1    -1    libs/flake/KoTosContainer.cpp
M  +1    -1    libs/flake/KoTosContainer.h
M  +2    -5    libs/flake/KoVectorPatternBackground.cpp
M  +1    -1    libs/flake/KoVectorPatternBackground.h
M  +17   -0    libs/flake/KoViewConverter.cpp
M  +5    -0    libs/flake/KoViewConverter.h
M  +4    -4    libs/flake/commands/KoShapeGroupCommand.cpp
M  +2    -2    libs/flake/commands/KoShapeUngroupCommand.cpp
M  +10   -11   libs/flake/resources/KoGamutMask.cpp
M  +4    -4    libs/flake/resources/KoGamutMask.h
M  +1    -23   libs/flake/resources/KoSvgSymbolCollectionResource.cpp
M  +0    -1    libs/flake/resources/KoSvgSymbolCollectionResource.h
M  +6    -6    libs/flake/svg/KoShapePainter.cpp
M  +1    -2    libs/flake/svg/KoShapePainter.h
M  +3    -3    libs/flake/svg/SvgParser.cpp
M  +1    -1    libs/flake/svg/SvgStyleWriter.cpp
M  +3    -6    libs/flake/tests/MockShapes.h
M  +1    -2    libs/flake/tests/SvgParserTestingUtils.h
M  +1    -1    libs/flake/tests/TestKoShapeRegistry.cpp
M  +2    -2    libs/flake/tests/TestPointMergeCommand.cpp
M  +1    -3    libs/flake/tests/TestShapeBackgroundCommand.cpp
M  +1    -1    libs/flake/tests/TestShapeContainer.cpp
M  +10   -15   libs/flake/tests/TestShapePainting.cpp
M  +14   -14   libs/flake/tests/TestSvgParser.cpp
M  +1    -2    libs/flake/text/KoSvgTextChunkShape.cpp
M  +1    -1    libs/flake/text/KoSvgTextChunkShape.h
M  +2    -4    libs/flake/text/KoSvgTextShape.cpp
M  +2    -2    libs/flake/text/KoSvgTextShape.h
M  +3    -3    libs/flake/tools/KoPathConnectionPointStrategy.cpp
M  +4    -4    libs/flake/tools/KoPathTool.cpp
M  +2    -2    libs/flake/tools/KoPathToolHandle.cpp
M  +1    -1    libs/flake/tools/KoPathToolSelection.cpp
M  +3    -5    libs/ui/KisReferenceImage.cpp
M  +1    -1    libs/ui/KisReferenceImage.h
M  +37   -36   libs/ui/canvas/kis_canvas_widget_base.cpp
M  +2    -1    libs/ui/flake/KisReferenceImagesLayer.cpp
M  +1    -1    libs/ui/flake/kis_node_shape.cpp
M  +1    -3    libs/ui/flake/kis_node_shape.h
M  +8    -8    libs/ui/flake/kis_shape_layer.cc
M  +6    -3    libs/ui/flake/kis_shape_layer_canvas.cpp
M  +3    -4    libs/ui/flake/kis_shape_selection.cpp
M  +1    -1    libs/ui/flake/kis_shape_selection.h
M  +2    -2    libs/ui/kis_import_catcher.cc
M  +1    -2    libs/ui/kis_selection_manager.cc
M  +0    -1    libs/ui/kis_selection_manager.h
M  +2    -2    libs/ui/tool/kis_selection_tool_helper.cpp
M  +1    -1    libs/ui/widgets/KoStrokeConfigWidget.cpp
M  +1    -1    libs/widgets/KoStrokeConfigWidget.cpp
M  +3    -2    plugins/dockers/advancedcolorselector/kis_color_selector_wheel.cpp
M  +3    -2    plugins/dockers/artisticcolorselector/kis_color_selector.cpp
M  +7    -8    plugins/flake/artistictextshape/ArtisticTextShape.cpp
M  +1    -1    plugins/flake/artistictextshape/ArtisticTextShape.h
M  +6    -5    plugins/flake/artistictextshape/ArtisticTextTool.cpp
M  +2    -5    plugins/flake/artistictextshape/ArtisticTextToolSelection.cpp
M  +1    -2    plugins/flake/artistictextshape/ArtisticTextToolSelection.h
M  +1    -3    plugins/flake/imageshape/ImageShape.cpp
M  +1    -1    plugins/flake/imageshape/ImageShape.h
M  +1    -2    plugins/flake/textshape/ShrinkToFitShapeContainer.cpp
M  +1    -1    plugins/flake/textshape/ShrinkToFitShapeContainer.h
M  +12   -15   plugins/flake/textshape/TextShape.cpp
M  +2    -2    plugins/flake/textshape/TextShape.h
M  +7    -7    plugins/flake/textshape/TextTool.cpp
M  +1    -1    plugins/flake/textshape/dialogs/BibliographyPreview.cpp
M  +1    -1    plugins/flake/textshape/dialogs/SimpleParagraphWidget.cpp
M  +1    -1    plugins/flake/textshape/dialogs/TableOfContentsPreview.cpp
M  +2    -2    plugins/flake/textshape/textlayout/FloatingAnchorStrategy.cpp
M  +1    -1    plugins/flake/textshape/textlayout/KoTextDocumentLayout.cpp
M  +1    -3    plugins/flake/textshape/textlayout/KoTextDocumentLayout.h
M  +1    -1    plugins/flake/textshape/textlayout/KoTextLayoutObstruction.cpp
M  +1    -0    plugins/flake/textshape/textlayout/KoTextShapeContainerModel.cpp
M  +4    -3    plugins/tools/defaulttool/connectionTool/ConnectionTool.cpp
M  +6    -5    plugins/tools/defaulttool/defaulttool/DefaultTool.cpp
M  +2    -2    plugins/tools/defaulttool/defaulttool/DefaultToolGeometryWidget.cpp
M  +1    -1    plugins/tools/defaulttool/defaulttool/DefaultToolWidget.cpp
M  +3    -3    plugins/tools/defaulttool/defaulttool/KoShapeGradientHandles.cpp
M  +1    -1    plugins/tools/defaulttool/defaulttool/KoShapeGradientHandles.h
M  +5    -5    plugins/tools/defaulttool/defaulttool/SelectionDecorator.cpp
M  +2    -2    plugins/tools/defaulttool/defaulttool/ShapeResizeStrategy.cpp
M  +1    -1    plugins/tools/defaulttool/defaulttool/ShapeShearStrategy.cpp
M  +3    -2    plugins/tools/karbonplugins/tools/CalligraphyTool/KarbonCalligraphyTool.cpp
M  +2    -5    plugins/tools/karbonplugins/tools/KarbonPatternEditStrategy.cpp
M  +1    -0    plugins/tools/karbonplugins/tools/KarbonPatternTool.cpp
M  +4    -5    plugins/tools/karbonplugins/tools/filterEffectTool/KarbonFilterEffectsTool.cpp
M  +1    -1    plugins/tools/svgtexttool/SvgTextTool.cpp

https://invent.kde.org/kde/krita/commit/2e8294becc66a548321d9274dfe4109963ea6577