Bug 472829 - White-space at soft wrap opportunity should hang
Summary: White-space at soft wrap opportunity should hang
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Tool/Text (show other bugs)
Version: 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-31 08:14 UTC by Alvin Wong
Modified: 2023-08-14 14:38 UTC (History)
1 user (show)

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


Attachments
Screenshot (39.11 KB, image/png)
2023-07-31 08:14 UTC, Alvin Wong
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alvin Wong 2023-07-31 08:14:26 UTC
With this SVG:
```svg
<text text-rendering="auto" fill="#000000" stroke-opacity="0" stroke="#000000"
stroke-width="0" stroke-linecap="square" stroke-linejoin="bevel"
letter-spacing="0" word-spacing="0" style="inline-size: 84.88;text-align: start;
text-align-last: auto;font-family: Noto Sans;font-size: 9;
white-space: pre-wrap;"><tspan>Alpha Bravo Charlie Delta Echo</tspan></text>
```

In Krita, the word "Charlie" is soft wrapped onto the second line. However, there is still enough room on the first line to place the word "Charlie" so the soft wrap should only happen after it. (See screenshot.)

CSS Text Module Level 3 §4.1.2 (https://www.w3.org/TR/css-text-3/#white-space-phase-2) states:

> 4. If there remains any sequence of white space, other space separators,
> and/or preserved tabs at the end of a line [...]:
> - If `white-space` is set to `normal`, `nowrap`, or `pre-line`, the UA
>   must hang this sequence (unconditionally).
> - If `white-space` is set to `pre-wrap`, the UA must (unconditionally)
>   hang this sequence, unless the sequence is followed by a forced line
>   break, in which case it must conditionally hang the sequence instead.
>   It may also visually collapse the character advance widths of any that
>   would otherwise overflow.
> [...]

See also Example 9.
Comment 1 Alvin Wong 2023-07-31 08:14:52 UTC
Created attachment 160638 [details]
Screenshot
Comment 2 wolthera 2023-07-31 09:22:26 UTC
right the fundamental problem is that the white-space doesn't 'hang'.
Comment 3 Bug Janitor Service 2023-08-08 16:59:52 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/1894
Comment 4 wolthera 2023-08-14 14:35:01 UTC
Git commit fe677d9b57085c60f1a1f937bf32a98738ec2df5 by Wolthera van Hövell, on behalf of Wolthera van Hövell tot Westerflier.
Committed on 14/08/2023 at 16:34.
Pushed by woltherav into branch 'master'.

Reimplement !1894, handling the hanging of white-spaces.

Original implementation by Alvin Wong,
implemented according to css-text-3 section 4.1.2 point 4:
https://www.w3.org/TR/css-text-3/#white-space-phase-2

M  +31   -0    libs/flake/text/KoCssTextUtils.cpp
M  +16   -0    libs/flake/text/KoCssTextUtils.h
M  +33   -8    libs/flake/text/KoSvgTextShape_p_layout.cpp

https://invent.kde.org/graphics/krita/-/commit/fe677d9b57085c60f1a1f937bf32a98738ec2df5
Comment 5 wolthera 2023-08-14 14:38:48 UTC
Git commit 8a3ed45cd77bd8f134c27739adfb9946f387d59e by Wolthera van Hövell tot Westerflier.
Committed on 14/08/2023 at 16:37.
Pushed by woltherav into branch 'krita/5.2'.

Reimplement !1894, handling the hanging of white-spaces.

Original implementation by Alvin Wong,
implemented according to css-text-3 section 4.1.2 point 4:
https://www.w3.org/TR/css-text-3/#white-space-phase-2

M  +31   -0    libs/flake/text/KoCssTextUtils.cpp
M  +16   -0    libs/flake/text/KoCssTextUtils.h
M  +33   -8    libs/flake/text/KoSvgTextShape_p_layout.cpp

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