Bug 472333 - Mixed text alignment not working in pre-wrap text with inline-size
Summary: Mixed text alignment not working in pre-wrap text with inline-size
Status: RESOLVED INTENTIONAL
Alias: None
Product: krita
Classification: Applications
Component: Tool/Text (other bugs)
Version First Reported In: git master (please specify the git hash!)
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-07-17 16:36 UTC by Alvin Wong
Modified: 2023-07-31 11:52 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.