Skip to content

Draft: Replace QTextLayout with Raqm and Freetype.

Wolthera van Hövell requested to merge work/wolthera/text-layout-refactor into master

This replaces QTextLayout with Raqm and Freetype. I followed the text-layout algorithm in SVG2, with a number of adjustments to get around bugs and peculiarities. This means we now also support rotation, text-on-path and textLength. Furthermore, I went and implemented opentype font features, language tagging and very basic opentype variable font support.

image

This code also draws using the KoPainterBackgrounds, meaning that gradients, patterns and the various outlines possible for other shapes are now possible for text.

Finally, because I had to implement our own variation of fontconfig support (QFontDatabase doesn't provide filenames), using multiple families as a fallback has also been implemented, though the 'generic' families aren't quite what I expect, so that needs fiddling.

The code doesn't support...

  • text-decoration
  • lengthAdjust="spacingAndGlyphs"
  • textPath method="stretch"
  • convert-text-to-path function is dead, though it will not be hard to revive.

yet for no reason beyond 'have plenty of things to do'.

Textwrapping is not implemented either, and requires:

  • the ability to store wrapping boxes. (Only inlinesize is done for now, CSS-shapes will be later.)
  • building a unicode linebreaking algorithm library, like lib unibreak.
  • implementing css-white space property.

Other things that are not supported, and I want to get into raqm:

  • Baseline handling (requires interogating the font with harfbuzz). (Actually may need to go into Krita.) (Went into krita)
  • letterspacing and wordspacing (requires knowing the script in use, as different scripts have different whitespace rules) Raqm #171
  • glyph-orientation/mixed vertical text (requires raqm doing seperate call for horizontal layout and then rotating the result). Later

Other than that, the code is a mess, the unittests are broken and generally everything is in need of a clean-up. There's a number of architectural issues that I need some help with, and I will post these as seperate comments below so we can keep everything in the same thread.

NOTE: When building raqm, make sure to set the PKG_CONFIG_PATH variable to your 3rdparty install folder, as raqm uses pkgconfig to find it's dependancies. In my case, I had to point specifically to the pkgconfig folders inside the 3rdparty install, which are inside /lib/x86_64-linux-gnu/pkgconfig for ubuntu. (EDIT amyspark: This is no longer needed, as Find Modules are in place for all the new dependencies, and the 3rdparty support also injects PKG_CONFIG_PATH where relevant.)

Test Plan

Build and use the text-tool. For the majority of features, you'll need to use the svg editor directly.

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!)
  • 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.
Edited by Amy spark

Merge request reports