Implement text-in-shape and text-on-path.
I wanted to hack this together, because one of the things that bothered me with T16862 is that there are a few oddities with the KoShape system that make it really hard to discuss if you are not aware of them:
- The dependee system is necessary even with simple embedded shapes, as it allows for those to send updates to the main text shape.
- The "scale styles" option works inverse from what you expect: when it is enabled, it sets a transform, when disabled, it tries to use "setSize" on the KoShape in question.
Beyond that, I'm just really really worried about scope.
TODO
-
Contour mode: - The base implementation point is KisCanvas2::shapeManager()
- when contour editing mode is activated,
KisCanvas2::localShapeManager()will create a specialKoShapeManagerobject for the contents of the text shape (might be returned viaKoShape::internalShapes()). There will be problems with update signals, the change should be done very carefully. - This local shape manager will have its own
KoSelectionthat will handle selections. Normal shapes of the layer will not be available. - This internal shape manager should use dummy canvas (just inherit the resolution from the actual layer’s canvas (might be not needed))
-
Saving - Invisible shapes will be added to defs, visible shapes to special group shape. -
Rendering -
setSize Unittest -
Rotation unittest? -
Functioning UI. -
Contour mode button. -
Flow in Shape command -
Subtract from flow command -
Remove shape from flow command -
toggle shape in flow command -
reorder shapes in flow area. -
set textpath on range -
undo set textpath from range -
edit text path info -
strategy for text path info -
shape padding/margin sliders. -
Speedups for shape padding/margin? -
strategy for shape padding/margin -
Fix slowdown setSize()
-
Above: Current look and feel in text tool. There's a text inside a series of wrapping areas, with said wrapping areas computer from shape-inside/shape-subtract, shape padding and shape margins. The arrows between the wrapping areas show the order in which the areas are used for layout.
Testing:
I've implemented the ability to create a text in shape (with an embedded shape) (layout was already possible).
- Create a few path shapes on a vector layer. (save this if you want to test this branch a bunch of times)
- Now, with the text tool selected, hover over a shape -> the icon will change to a T inside a rectangle with two rounded corners.
- Click the shape -> You now have a text in shape. You can type and use the text properties docker to set the size and whatnot.
Creating a text path is done by hovering over the border of the shape, until the icon changes to a text-on-path icon. Then click.
And I've create a "setSize" for the text shape:
- Select the "Select Shapes/Default Tool", try to scale the text in shape. In some cases, this is still bugged.
- Create and scale a non-text-in-shape. This (right now) applies a basic scale.
Save and load should work fine.
Editing shapes when they're part of a text shape can be done by clicking the new top right icon to enter "contour mode".
Shape-Padding and Shape Margin have been added in the text properties docker under paragraph->Text Area. You can also change these by dragging the text area bounds inside the text tool. Warning: these are slow
Shape Selection Tool
The rightclick menu of the shape selection tool has received a number of new actions under "text":
- "Flow text in shapes" and "Subtract shapes from text flow" adds the shape as a inside or subtract shape respectively and are only enabled when text and non-text shapes are selected.
- The others are only available in Contour mode, and will adjust the order of the shapes inside or toggle a given shape between subtract and inside, or just remove the shape.
- When in contour mode, default tool will treat the parent text as the target for the text properties adjustments.
see also woltherav/krita#33 (closed) and T16862 BUG:391796
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. -
Does the patch add a user-visible feature? If yes, is there a documentation MR ready for it at Krita Documentation Repository?
