Skip to content

Improve text situation with SVG transforms.

This moves resolve transforms earlier, and handles white-space collapsing and transform addressing a little better so that Bidi marks and soft-hyphens are not considered addressable (bug 472382).

It also fixes some issues with ligatures, meaning !1867 (closed) is far less prudent.

The fundamental problem is that the SVG 2 text layout algorithm doesn't take into account that according to SVG 1.1 (and also SVG 2) text chunks should be individually shaped and bidi-ordered, furthermore, according to CSS 3, shaping should not break between regular non-text-chunk spans of text. These problems lead to issues like bidi-text getting really weird in certain situations, but also Bug 471374, which happens because our font-caching gives us the shaping-across-span-boundaries for free.

This patch does fix a number of things regarding that, so that the render of that last bug looks like this (not great, but better):

image.png

You can check that other applications don't have this cross-boundary shaping by testing /libs/flake/tests/data/fonts/textTestSvgs/test-text-multicolor.svg in them, krita's result looks like this (notice the FFI ligature):

load_text_multicolor_expected.png

Our options for Bug 471374 are as follows:

  • We apply the patch from !1867 (closed) anyway, which complicates things deps wise, but at the least it won't require us to lose cross-boundary shaping.
  • We remove our font-caching for 5.2 so that we lose the cross-boundary-shaping and bug 471374 is resolved. I would've previously been very unhappy with this, but it seems the Harfbuzz we ship is a little smarter than I thought, so we won't get (more) issues with Arabic. This will make Krita exactly as buggy as Firefox in this regard.
  • We don't do anything and accept the above screenshot as acceptable for now.

In all three cases, the solution will not be 100% correct, as that requires the raqm patch to actually handle breaking up the bidi shaping, which means I would need to extent/complete this patch.

Test Plan

Check bugs 471374 and 472382 for test files.

Formalities Checklist

  • I confirmed this builds.
  • I confirmed Krita ran and the relevant functions work.
  • I tested the relevant unit tests and can confirm they are not broken. (If not possible, don't hesitate to ask for help!)
    • Two of the tests are broken, so I'm still fixing those.
  • I made sure my commits build individually and have good descriptions as per KDE guidelines.
  • I made sure my code conforms to the standards set in the HACKING file.
  • I can confirm the code is licensed and attributed appropriately, and that unattributed code is mine, as per KDE Licensing Policy.

Reminder: the reviewer is responsible for merging the patch, this is to ensure at the least two people can build the patch. In case a patch breaks the build, both the author and the reviewer should be contacted to fix the build. If this is not possible, the commits shall be reverted, and a notification with the reasoning and any relevant logs shall be sent to the mailing list, kimageshop@kde.org.

Edited by Wolthera van Hövell

Merge request reports

Loading