Bug 472571

Summary: Mismatch between Krita and Inkscape text on path.
Product: [Applications] krita Reporter: wolthera <griffinvalley>
Component: Tools/VectorAssignee: Krita Bugs <krita-bugs-null>
Status: REPORTED ---    
Severity: normal CC: alvin
Priority: NOR    
Version: git master (please specify the git hash!)   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: test file with mm units.
Inkscape file based on pt

Description wolthera 2023-07-24 11:09:46 UTC
Created attachment 160494 [details]
test file with mm units.

SUMMARY
When inkscape documents with text on path use units other than pt, Krita will not lay out the text on path correctly.
This is because to deal with Inkscape's notion of the default unit being a mm or the like, Krita just scales up the paths while parsing. This in turn means that paths for 'text-on-path' or 'text-in-shape' may be scaled up twice, because we need to apply the local transform before laying out the text onto the path.

STEPS TO REPRODUCE
1. Make a document in inkscape with text-on-path (or check the attached file) whose unit is set to 'mm'
2. load this into Krita
3. observe the offset from the text to the path, as if the text is put on a scaled-up-path.

OTHER:
Whenever I make basic test files, they work within both Inkscape and Krita, but when it comes to these more organic files things go pear-shaped.
For some reason it seems that the paths in shape seem to work in the millimeter file but not the point file ( no clue yet what is causing that...), and Inkscape's text area (which should be a rectangle text-in-shape) is somehow not loading in either...
Comment 1 wolthera 2023-07-24 11:11:16 UTC
Created attachment 160495 [details]
Inkscape file based on pt

For comparison, a file with a pt-unit basis.
Comment 2 wolthera 2023-08-13 14:09:16 UTC
Ok this:

> For some reason it seems that the paths in shape seem to work in the millimeter file but not the point file ( no clue yet what is causing that...), and Inkscape's text area (which should be a rectangle text-in-shape) is somehow not loading in either...

is not caused by loading (though, the MM file never loads the path shape), but rather because Inkscape by default writes its white-space as 'pre', instead of 'pre-wrap'. This is a nightmare.
Comment 3 wolthera 2023-08-13 16:07:16 UTC
Git commit afb761c5d889165dd180fb7f4acd235b8d30d3aa by Wolthera van Hövell tot Westerflier.
Committed on 13/08/2023 at 18:07.
Pushed by woltherav into branch 'master'.

Attempt to position the first few glyphs inside a shape.

This is necessary for when there's no wrapping enabled.

M  +24   -0    libs/flake/text/KoSvgTextShapeLayoutFunc_inShape.cpp

https://invent.kde.org/graphics/krita/-/commit/afb761c5d889165dd180fb7f4acd235b8d30d3aa
Comment 4 wolthera 2023-08-13 16:07:56 UTC
Git commit 974dc19c9ecf27308db553d788a0dc912d3391f0 by Wolthera van Hövell, on behalf of Wolthera van Hövell tot Westerflier.
Committed on 13/08/2023 at 18:07.
Pushed by woltherav into branch 'krita/5.2'.

Attempt to position the first few glyphs inside a shape.

This is necessary for when there's no wrapping enabled.


(cherry picked from commit afb761c5d889165dd180fb7f4acd235b8d30d3aa)

M  +24   -0    libs/flake/text/KoSvgTextShapeLayoutFunc_inShape.cpp

https://invent.kde.org/graphics/krita/-/commit/974dc19c9ecf27308db553d788a0dc912d3391f0
Comment 5 Bug Janitor Service 2023-08-29 11:00:46 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/1923
Comment 6 Dmitry Kazakov 2023-08-31 09:00:57 UTC
Git commit 033280a0b2abd25617986b0af63d61aab01c41b6 by Dmitry Kazakov, on behalf of Alvin Wong.
Committed on 31/08/2023 at 11:00.
Pushed by dkazakov into branch 'master'.

flake: Fix transformation of text path and shape-inside

Shapes referenced by text path and shape-inside should ignore any
transformation of their parents. When the shapes are loaded from SVG,
they have the absolute transformation baked in. In order to get the
transform we need, we invert the transform of a shape's parent and
combine it with the shape's own absolute transform.

M  +25   -9    libs/flake/svg/SvgParser.cpp
M  +1    -1    libs/flake/svg/SvgParser.h

https://invent.kde.org/graphics/krita/-/commit/033280a0b2abd25617986b0af63d61aab01c41b6
Comment 7 Dmitry Kazakov 2023-08-31 09:01:28 UTC
Git commit 8ec8f4bb0b35450dc4c8f14f30ae068c2540ecbe by Dmitry Kazakov, on behalf of Alvin Wong.
Committed on 31/08/2023 at 11:01.
Pushed by dkazakov into branch 'krita/5.2'.

flake: Fix transformation of text path and shape-inside

Shapes referenced by text path and shape-inside should ignore any
transformation of their parents. When the shapes are loaded from SVG,
they have the absolute transformation baked in. In order to get the
transform we need, we invert the transform of a shape's parent and
combine it with the shape's own absolute transform.


(cherry picked from commit 033280a0b2abd25617986b0af63d61aab01c41b6)

M  +25   -9    libs/flake/svg/SvgParser.cpp
M  +1    -1    libs/flake/svg/SvgParser.h

https://invent.kde.org/graphics/krita/-/commit/8ec8f4bb0b35450dc4c8f14f30ae068c2540ecbe