Bug 472333

Summary: Mixed text alignment not working in pre-wrap text with inline-size
Product: [Applications] krita Reporter: Alvin Wong <alvin>
Component: Tool/TextAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED INTENTIONAL    
Severity: normal CC: griffinvalley
Priority: NOR    
Version First Reported In: git master (please specify the git hash!)   
Target Milestone: ---   
Platform: Microsoft Windows   
OS: Microsoft Windows   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Alvin Wong 2023-07-17 16:36:53 UTC
With this SVG:
```
<text text-rendering="auto" fill="#000000" stroke-opacity="0" stroke="#000000" stroke-width="0" stroke-linecap="square" stroke-linejoin="bevel" style="inline-size: 100;text-align: start;text-align-last: auto;font-family: Noto Sans;font-size: 9;font-size-adjust: 0.536;white-space: pre-wrap;"><tspan x="0">Testing line 1: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
</tspan><tspan x="50" text-anchor="middle">Line 2 (centre)
</tspan><tspan x="100" text-anchor="end">Line 3 (right)</tspan></text>
```
The second and third lines don't align correctly.

(Base commit 6540ff1c0)
Comment 1 Alvin Wong 2023-07-18 19:04:04 UTC
DId a little bit of quick reading of the SVG 2 spec. So it seems for auto-wrapped text, x/y (other than those on the `text` element or the first `tspan` when using `inline-size`) are ignored, and I suppose as a result `text-anchor` on these `tspan`s doesn't do anything. (When using `inline-size`, `text-anchor` can only anchor the wrapping area determined by `inline-size`.)

This means it is not a bug, that `inline-size` doesn't support lines with different alignment. It will require using `text-align` with text-in-shape.

@Wolthera Did I understand it correctly?
Comment 2 wolthera 2023-07-31 11:52:53 UTC
So, the core problem here is that SVG text overall only has a single block/paragraph per text, while Qt text document of course allows for multiple. So neither text-anchor nor text-align would allow for mixed-alignment in a wrapped text. I remember when Halla and I were pair programming on the conversion for QTextDocument to SVG, we discussed whether it would make sense to have the conversion spit out multiple text shapes, one for each block, but it was deemed too complicated to roundtrip.

I'll close it as intentional.