Bug 471374 - Line breaks not working when font has ligatures
Summary: Line breaks not working when font has ligatures
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: wolthera
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2023-06-23 10:49 UTC by Alvin Wong
Modified: 2023-08-14 16:17 UTC (History)
1 user (show)

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


Attachments
Screenshot (20.22 KB, image/png)
2023-06-23 10:49 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-06-23 10:49:09 UTC
Created attachment 159852 [details]
Screenshot

SUMMARY
Line breaks in between characters with ligatures does not work correctly.

STEPS TO REPRODUCE
1. Create a text object with:
This text
is 9pt
in size
2. Set font to "Calibri"
3. Save the text object

Or alternatively, use the following SVG source:

<text style="fill:#000000; letter-spacing:0; word-spacing:0; kerning:auto; font-family:Calibri; font-size:9; font-size-adjust:0.464355; font-weight:400; font-style:normal; stroke-width:0; font-stretch:100"><tspan x="0">This text</tspan><tspan x="0" dy="10.5pt">is 9pt</tspan><tspan x="0" dy="10.5pt">in</tspan><tspan x="0" dy="10.5pt">size</tspan></text>

OBSERVED RESULT
The text doesn't break in the expected places.

EXPECTED RESULT
The text should break in the expected places.

SOFTWARE/OS VERSIONS
Windows: 10
Krita: commit 821fedf45

ADDITIONAL INFORMATION
Wolthera: "apparantly callibri has ligatures for t and i, and thus the adjustments on those codepoints isn't calculated correctly. if you add font-variant-ligatures:none; to the style list it shows properly."
Comment 1 wolthera 2023-07-11 13:50:40 UTC
Ok, given that neither firefox, chromium nor inkscape have the same problem...

The proper fix is to patch raqm so it will be able to do arbitrary run breaks, however, that means Krita will rely on a patched raqm, which may not propagate to the distros. The other solution is to do some convoluted nonsense where anchored characters explicitely have ligatures disabled. This is wrong as it will prevent ligatures after this first character. Another wrong solution might be to turn off font-caching, as this will give us a freetype face per chunk, which in turn means that raqm will treat these as seperate runs. This will break some tests and is incorrect as per CSS spec, but I suspect this is why firefox in particular works here (as it breaks for test-text-right-to-left-text-paths).

I'll see how tricky patching raqm for this is, first.
Comment 2 Bug Janitor Service 2023-07-25 13:52:38 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/1867
Comment 3 wolthera 2023-08-14 14:35:00 UTC
Git commit e66763c492adfb6c8c163ae90e69fb4d7b5a7277 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'.

Make transformationResolution happen earlier and be a bit
better aligned to the SVG 2 spec.

A bit contradictory, becuase the SVG spec wants it to happen later, but we
should have it this early to eventually apply shaping breaks.

Collapsing is now handled by the resolveTransforms function.

This also handles adressability and 'middle' glyphs a little better,
which means we have less problems with ligatures.
Related: bug 472382

M  +1    -1    libs/flake/text/KoSvgTextShape_p.h
M  +106  -74   libs/flake/text/KoSvgTextShape_p_layout.cpp

https://invent.kde.org/graphics/krita/-/commit/e66763c492adfb6c8c163ae90e69fb4d7b5a7277
Comment 4 wolthera 2023-08-14 14:38:54 UTC
Git commit 054fbd20d57a093ec4baabc5555659eb4b669a29 by Wolthera van Hövell tot Westerflier.
Committed on 14/08/2023 at 16:36.
Pushed by woltherav into branch 'krita/5.2'.

Make transformationResolution happen earlier and be a bit
better aligned to the SVG 2 spec.

A bit contradictory, becuase the SVG spec wants it to happen later, but we
should have it this early to eventually apply shaping breaks.

Collapsing is now handled by the resolveTransforms function.

This also handles adressability and 'middle' glyphs a little better,
which means we have less problems with ligatures.
Related: bug 472382

M  +1    -1    libs/flake/text/KoSvgTextShape_p.h
M  +106  -74   libs/flake/text/KoSvgTextShape_p_layout.cpp

https://invent.kde.org/graphics/krita/-/commit/054fbd20d57a093ec4baabc5555659eb4b669a29
Comment 5 wolthera 2023-08-14 16:17:07 UTC
Git commit 125c5c186b348411d882e007fe595c1d5aa7dcc7 by Wolthera van Hövell tot Westerflier.
Committed on 14/08/2023 at 18:16.
Pushed by woltherav into branch 'master'.

Implement the arbitrary breaks call inside the layout

This doesn't work for required ligatures, and bidi still needs
to be handled as well, but at the least non-required ligatures will
be broken.

M  +4    -0    libs/flake/text/KoSvgTextShape_p_layout.cpp

https://invent.kde.org/graphics/krita/-/commit/125c5c186b348411d882e007fe595c1d5aa7dcc7
Comment 6 wolthera 2023-08-14 16:17:37 UTC
Git commit 0321af9fc2c255984a93aa7cf9e46fc40fc0f1ae by Wolthera van Hövell, on behalf of Wolthera van Hövell tot Westerflier.
Committed on 14/08/2023 at 18:17.
Pushed by woltherav into branch 'krita/5.2'.

Implement the arbitrary breaks call inside the layout

This doesn't work for required ligatures, and bidi still needs
to be handled as well, but at the least non-required ligatures will
be broken.


(cherry picked from commit 125c5c186b348411d882e007fe595c1d5aa7dcc7)

M  +4    -0    libs/flake/text/KoSvgTextShape_p_layout.cpp

https://invent.kde.org/graphics/krita/-/commit/0321af9fc2c255984a93aa7cf9e46fc40fc0f1ae