Support svg `white-space:pre`/`pre-wrap` wrapping with the text tool
Add alternative text wrapping modes to the text tool to support:
- Not using
dy
for line breaks and line height adjustments, and also keep consecutive whitespaces in text. - Support automatic wrapping with
inline-size
.
I have accepted that the way the rich text editor works means:
- It is impossible to make it handle line height like SVG does, and
- Old text shapes that use the
dy
method cannot be seamlessly converted to use SVGline-height
.
To allow the text tool to utilize SVG text wrapping in a limited manner, the text tool now has three modes:
-
Legacy Hard Wrap - the existing behaviour that uses
QTextLayout
to get metrics for settingdy
on each line. -
SVG Hard Wrap - emulates the existing behaviour (no auto word wrap) but with
white-space:pre
instead of explicitdy
offsets. -
SVG Auto Wrap with Fixed Width - uses
white-space:pre-wrap
andinline-size
to support auto word wrap.
In addition, line height now has an additional value named "Default", which is used to set line-height:normal
to enable the default line height (ascender-descender
). This is required because line-height
with a numeric value behaves wildly different from the legacy behaviour (see !1850 (closed)), and so we cannot use "100%" line height as the default.
Depends on !1850 (closed), keeping as draft until that is merged.
Edited by Alvin Wong