Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Type Setting Mode: Fix number of issues when setting transforms.
Wolthera van Hövell tot Westerfliera4e1922c317a
diff --git a/libs/flake/text/KoSvgTextShape.cpp b/libs/flake/text/KoSvgTextShape.cppindex 811e021af0..931fbc7798 100644--- a/libs/flake/text/KoSvgTextShape.cpp+++ b/libs/flake/text/KoSvgTextShape.cpp@@ -1339,6 +1339,9 @@ bool KoSvgTextShape::setCharacterTransformsOnRange(const int startPos, const inttf.xPos = p.x();tf.yPos = p.y();}+ if (!tf.rotate) {+ tf.rotate = 0.0;+ }}transforms << tf;continue;diff --git a/libs/flake/text/KoSvgTextShape_p.h b/libs/flake/text/KoSvgTextShape_p.hindex 4576adfb84..5a023b4082 100644--- a/libs/flake/text/KoSvgTextShape_p.h+++ b/libs/flake/text/KoSvgTextShape_p.h@@ -975,8 +975,9 @@ public:}}if (transformOffset < currentTextElement->localTransformations.size()) {+ int length = qBound(0, transformOffsetEnd-transformOffset, qMax(0, currentTextElement->localTransformations.size()-transformOffset));currentTextElement->localTransformations.remove(transformOffset,- qBound(0, transformOffsetEnd-transformOffset, currentTextElement->localTransformations.size()));+ length);}}diff --git a/plugins/tools/svgtexttool/SvgTextTypeSettingStrategy.cpp b/plugins/tools/svgtexttool/SvgTextTypeSettingStrategy.cppindex ffdb604488..b7575dc60d 100644--- a/plugins/tools/svgtexttool/SvgTextTypeSettingStrategy.cpp+++ b/plugins/tools/svgtexttool/SvgTextTypeSettingStrategy.cpp@@ -95,12 +95,31 @@ KUndo2Command *SvgTextTypeSettingStrategy::createCommand()KoSvgTextProperties props;KoSvgTextProperties oldProps = m_shape->propertiesForPos(closestPos, true);+ /// Used to synchronise the offsets when changing fontsize...+ QVector<QPointF> newPositions;+ QVector<qreal> newRotations;+if (m_editingType == int(SvgTextCursor::Ascender) || m_editingType == int(SvgTextCursor::Descender)) {const qreal distOld = kisDistanceToLine(dragStart, line);- const qreal scale = distNew/distOld;+ const qreal scale = qMax(0.000001, distNew/distOld);KoSvgText::CssLengthPercentage length = oldProps.fontSize();length.value *= scale;props.setFontSize(length);++ if (m_shape->textType() == KoSvgTextShape::PreformattedText || m_shape->textType() == KoSvgTextShape::PrePositionedText) {+ // When we change font size, we need to correct the offset for the scaled advances.+ // Technically, we need to test against the laid out text to get the correct advance, but that's really complicated...+ QPointF diff = QPointF();++ Q_FOREACH(const KoSvgTextCharacterInfo originalInfo, originalTf) {+ const QTransform rotate = QTransform().rotate(originalInfo.rotateDeg);+ const QPointF newPos = originalInfo.finalPos + diff;+ const QTransform oTf = QTransform::fromTranslate(originalInfo.finalPos.x(), originalInfo.finalPos.y()) * rotate;+ diff += (oTf.map(originalInfo.advance*scale) - oTf.map(originalInfo.advance));+ newPositions.append(newPos);+ newRotations.append(originalInfo.rotateDeg);+ }+ }} else if (m_editingType == int(SvgTextCursor::BaselineShift)) {KoSvgText::CssLengthPercentage length;@@ -125,7 +144,14 @@ KUndo2Command *SvgTextTypeSettingStrategy::createCommand()if (!props.isEmpty()) {int pos = m_cursorPos == m_cursorAnchor? -1: m_cursorPos;int anchor = m_cursorPos == m_cursorAnchor? -1: m_cursorAnchor;- cmd = new SvgTextMergePropertiesRangeCommand(m_shape, props, pos, anchor);+ if (!newPositions.isEmpty()) {+ cmd = new KUndo2Command();+ KUndo2Command *cmd2 = new SvgTextMergePropertiesRangeCommand(m_shape, props, pos, anchor, QSet<KoSvgTextProperties::PropertyId>(), cmd);+ new SvgTextChangeTransformsOnRange(m_shape, m_cursorPos, m_cursorAnchor, newPositions, newRotations, m_deltaCalc, cmd);+ cmd->setText(cmd2->text());+ } else {+ cmd = new SvgTextMergePropertiesRangeCommand(m_shape, props, pos, anchor);+ }}}return cmd;