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++
Support variable font slant as well as toggles to turn off font-synthesis.
Wolthera van Hövell tot Westerflier02128280ba9f
diff --git a/libs/flake/CMakeLists.txt b/libs/flake/CMakeLists.txtindex 54da5d1187..e87ce73921 100644--- a/libs/flake/CMakeLists.txt+++ b/libs/flake/CMakeLists.txt@@ -233,6 +233,7 @@ set(kritaflake_SRCStext/lager/TextIndentModel.cpptext/lager/TabSizeModel.cpptext/lager/TextTransformModel.cpp+ text/lager/CssFontStyleModel.cpptext/KoFFWWSConverter.cppresources/KoSvgSymbolCollectionResource.cppdiff --git a/libs/flake/svg/SvgStyleParser.cpp b/libs/flake/svg/SvgStyleParser.cppindex e513681822..5fb8823ce1 100644--- a/libs/flake/svg/SvgStyleParser.cpp+++ b/libs/flake/svg/SvgStyleParser.cpp@@ -52,6 +52,11 @@ public:<< "font" // why are we doing this after the rest?<< "font-optical-sizing"<< "font-variation-settings"+ << "font-synthesis-weight"+ << "font-synthesis-style"+ << "font-synthesis-small-caps"+ << "font-synthesis-position"+ << "font-synthesis"<< "text-decoration"<< "text-decoration-line"<< "text-decoration-style"@@ -258,6 +263,10 @@ void SvgStyleParser::parsePA(SvgGraphicsContext *gc, const QString &command, congc->textProperties.parseSvgTextAttribute(d->context, command, params);} else if (command == "font-size-adjust") {gc->textProperties.parseSvgTextAttribute(d->context, command, params);+ } else if (command == "font-synthesis"+ || command == "font-synthesis-weight" || command == "font-synthesis-style"+ || command == "font-synthesis-small-caps" || command == "font-synthesis-position") {+ gc->textProperties.parseSvgTextAttribute(d->context, command, params);} else if (command == "font") {qWarning() << "Krita does not support the 'font' shorthand";} else if (command == "text-decoration" || command == "text-decoration-line" || command == "text-decoration-style" || command == "text-decoration-color"diff --git a/libs/flake/tests/TestSvgText.cpp b/libs/flake/tests/TestSvgText.cppindex cf653992fc..e90b8abb20 100644--- a/libs/flake/tests/TestSvgText.cpp+++ b/libs/flake/tests/TestSvgText.cpp@@ -274,7 +274,8 @@ void TestSvgText::testParseFontStyles()}QCOMPARE(getFont().fontSize().value, 15.0);- QCOMPARE(QFont::Style(getFont().property(KoSvgTextProperties::FontStyleId).toInt()), QFont::StyleOblique);++ QCOMPARE(getFont().property(KoSvgTextProperties::FontStyleId).value<KoSvgText::CssFontStyleData>(), KoSvgText::CssFontStyleData(QFont::StyleOblique));QCOMPARE(getFont().property(KoSvgTextProperties::FontVariantCapsId).toInt(), KoSvgText::SmallCaps);QCOMPARE(getFont().property(KoSvgTextProperties::FontWeightId).toInt(), 600);@@ -2544,7 +2545,7 @@ void TestSvgText::testTextCleanUp()el1.text = "The quick brown fox";KoSvgTextContentElement el2;el2.text = " jumps over the";- el2.properties.setProperty(KoSvgTextProperties::FontStyleId, QFont::StyleItalic);+ el2.properties.setProperty(KoSvgTextProperties::FontStyleId, QVariant::fromValue(KoSvgText::CssFontStyleData(QFont::StyleItalic)));KoSvgTextContentElement el3;el3.text = " lazy dog.";auto child1 = forest.insert(childEnd(root), el1);@@ -2556,13 +2557,13 @@ void TestSvgText::testTextCleanUp()QCOMPARE(depth(forest), 2);// test merging siblings with the same properties.- child1->properties.setProperty(KoSvgTextProperties::FontStyleId, QFont::StyleItalic);+ child1->properties.setProperty(KoSvgTextProperties::FontStyleId, QVariant::fromValue(KoSvgText::CssFontStyleData(QFont::StyleItalic)));KoSvgTextShape::Private::cleanUp(forest);QCOMPARE(size(forest), 3);QCOMPARE(depth(forest), 2);// test merging children with parents.- child2->properties.setProperty(KoSvgTextProperties::FontStyleId, QFont::StyleItalic);+ child2->properties.setProperty(KoSvgTextProperties::FontStyleId, QVariant::fromValue(KoSvgText::CssFontStyleData(QFont::StyleItalic)));KoSvgTextShape::Private::cleanUp(forest);QCOMPARE(size(forest), 1);QCOMPARE(depth(forest), 1);diff --git a/libs/flake/text/KoSvgText.cpp b/libs/flake/text/KoSvgText.cppindex 03ee7ed689..017ce6b3f3 100644--- a/libs/flake/text/KoSvgText.cpp+++ b/libs/flake/text/KoSvgText.cpp@@ -34,6 +34,8 @@ KIS_DECLARE_STATIC_INITIALIZER {qRegisterMetaTypeStreamOperators<KoSvgText::FontFamilyAxis>("KoSvgText::FontFamilyAxis");qRegisterMetaType<KoSvgText::FontFamilyStyleInfo>("KoSvgText::FontFamilyStyleInfo");qRegisterMetaTypeStreamOperators<KoSvgText::FontFamilyStyleInfo>("KoSvgText::FontFamilyStyleInfo");+ qRegisterMetaType<KoSvgText::CssFontStyleData>("KoSvgText::CssSlantData");+ qRegisterMetaType<KoSvgText::BackgroundProperty>("KoSvgText::BackgroundProperty");#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))QMetaType::registerEqualsComparator<KoSvgText::CssLengthPercentage>();@@ -46,7 +48,9 @@ KIS_DECLARE_STATIC_INITIALIZER {QMetaType::registerEqualsComparator<KoSvgText::AutoLengthPercentage>();QMetaType::registerDebugStreamOperator<KoSvgText::AutoLengthPercentage>();-+ QMetaType::registerEqualsComparator<KoSvgText::CssFontStyleData>();+ QMetaType::registerDebugStreamOperator<KoSvgText::CssFontStyleData>();+QMetaType::registerEqualsComparator<KoSvgText::BackgroundProperty>();QMetaType::registerDebugStreamOperator<KoSvgText::BackgroundProperty>();@@ -74,6 +78,7 @@ KIS_DECLARE_STATIC_INITIALIZER {QMetaType::registerEqualsComparator<KoSvgText::FontFamilyStyleInfo>();QMetaType::registerDebugStreamOperator<KoSvgText::FontFamilyStyleInfo>();+#endif}namespace KoSvgText {@@ -262,6 +267,19 @@ QDebug operator<<(QDebug dbg, const KoSvgText::AutoValue &value)return dbg.space();}+QDebug operator<<(QDebug dbg, const KoSvgText::CssFontStyleData &value)+{+ if (value.style == QFont::StyleOblique) {+ dbg.nospace() << "oblique ";+ dbg.nospace() << value.slantValue;+ } else {+ dbg.nospace() << (value.style == QFont::StyleItalic? "italic": "roman");+ }+++ return dbg.space();+}+void CharTransformation::mergeInParentTransformation(const CharTransformation &t){if (!xPos && t.xPos) {@@ -1163,4 +1181,34 @@ QDataStream &operator>>(QDataStream &in, KoSvgText::FontFamilyStyleInfo &style)return in;}+CssFontStyleData parseFontStyle(const QString &value)+{+ CssFontStyleData slant;+ QStringList params = value.split(" ");+ if (!params.isEmpty()) {+ QString style = params.first();+ slant.style = style == "italic"? QFont::StyleItalic: style == "oblique"? QFont::StyleOblique: QFont::StyleNormal;+ }+ if (params.size() > 1) {+ QString angle = params.last();+ if (angle.endsWith("deg")) {+ angle.chop(3);+ slant.slantValue.isAuto = false;+ slant.slantValue.customValue = angle.toDouble();+ }+ }+ return slant;+}++QString writeFontStyle(CssFontStyleData value)+{+ QString style =+ value.style == QFont::StyleItalic ? "italic" :+ value.style == QFont::StyleOblique ? "oblique" : "normal";+ if (value.style == QFont::StyleOblique && !value.slantValue.isAuto) {+ style.append(QString(" ")+QString::number(value.slantValue.customValue)+QString("deg"));+ }+ return style;+}+} // namespace KoSvgTextdiff --git a/libs/flake/text/KoSvgText.h b/libs/flake/text/KoSvgText.hindex c6b38dc651..29500d8f0c 100644--- a/libs/flake/text/KoSvgText.h+++ b/libs/flake/text/KoSvgText.h@@ -443,10 +443,25 @@ struct AutoLengthPercentage : public boost::equality_comparable<AutoLengthPercen}};+/// When style is oblique, a custom slant value can be specified for variable fonts.+struct CssFontStyleData : public boost::equality_comparable<CssFontStyleData>+{+ CssFontStyleData() {}+ CssFontStyleData(QFont::Style _style): style(_style){}+ QFont::Style style = QFont::StyleNormal;+ KoSvgText::AutoValue slantValue;++ bool operator==(const CssFontStyleData & other) const {+ return style == other.style+ && (style != QFont::StyleOblique || slantValue == other.slantValue);+ }+};+QDebug KRITAFLAKE_EXPORT operator<<(QDebug dbg, const KoSvgText::AutoValue &value);QDebug KRITAFLAKE_EXPORT operator<<(QDebug dbg, const KoSvgText::AutoLengthPercentage &value);+QDebug KRITAFLAKE_EXPORT operator<<(QDebug dbg, const KoSvgText::CssFontStyleData &value);inline QVariant fromAutoValue(const KoSvgText::AutoValue &value) {return QVariant::fromValue(value);@@ -489,6 +504,8 @@ WordBreak parseWordBreak(const QString &value);LineBreak parseLineBreak(const QString &value);TextAlign parseTextAlign(const QString &value);+CssFontStyleData parseFontStyle(const QString &value);+Baseline parseBaseline(const QString &value);BaselineShiftMode parseBaselineShiftMode(const QString &value);@@ -545,6 +562,8 @@ QString writeWordBreak(WordBreak value);QString writeLineBreak(LineBreak value);QString writeTextAlign(TextAlign value);+QString writeFontStyle(CssFontStyleData value);+/*** @brief writeWhiteSpaceValue* determine the CSS-3-Whitespace shorthand value.@@ -807,6 +826,7 @@ Q_DECLARE_METATYPE(KoSvgText::TextTransformInfo)Q_DECLARE_METATYPE(KoSvgText::TextIndentInfo)Q_DECLARE_METATYPE(KoSvgText::TabSizeInfo)Q_DECLARE_METATYPE(KoSvgText::LineHeightInfo)+Q_DECLARE_METATYPE(KoSvgText::CssFontStyleData)Q_DECLARE_METATYPE(KoSvgText::FontFamilyAxis)Q_DECLARE_METATYPE(KoSvgText::FontFamilyStyleInfo)diff --git a/libs/flake/text/KoSvgTextProperties.cpp b/libs/flake/text/KoSvgTextProperties.cppindex 429fa2eaa2..563f23f201 100644--- a/libs/flake/text/KoSvgTextProperties.cpp+++ b/libs/flake/text/KoSvgTextProperties.cpp@@ -319,12 +319,7 @@ void KoSvgTextProperties::parseSvgTextAttribute(const SvgLoadingContext &contextsetProperty(FontFamiliesId, familiesList);} else if (command == "font-style") {- const QFont::Style style =- value == "italic" ? QFont::StyleItalic :- value == "oblique" ? QFont::StyleOblique :- QFont::StyleNormal;-- setProperty(FontStyleId, style);+ setProperty(FontStyleId, QVariant::fromValue(KoSvgText::parseFontStyle(value)));} else if (command == "font-variant" || command == "font-variant-ligatures" || command == "font-variant-position" || command == "font-variant-caps"|| command == "font-variant-numeric" || command == "font-variant-east-asian" || command == "font-variant-alternates") {const QStringList features = value.split(" ");@@ -584,6 +579,34 @@ void KoSvgTextProperties::parseSvgTextAttribute(const SvgLoadingContext &contextsetProperty(ShapePaddingId, SvgUtil::parseUnitXY(context.currentGC(), context.resolvedProperties(), value));} else if (command == "shape-margin") {setProperty(ShapeMarginId, SvgUtil::parseUnitXY(context.currentGC(), context.resolvedProperties(), value));+ } else if (command == "font-synthesis") {+ setProperty(FontSynthesisBoldId, false);+ setProperty(FontSynthesisItalicId, false);+ setProperty(FontSynthesisSuperSubId, false);+ setProperty(FontSynthesisSmallCapsId, false);+ if (value != "none") {+ QStringList params = value.split(" ");+ if (params.contains("position")) {+ setProperty(FontSynthesisSuperSubId, true);+ }+ if (params.contains("weight")) {+ setProperty(FontSynthesisBoldId, true);+ }+ if (params.contains("style")) {+ setProperty(FontSynthesisItalicId, false);+ }+ if (params.contains("small-caps")) {+ setProperty(FontSynthesisSmallCapsId, false);+ }+ }+ } else if (command == "font-synthesis-weight") {+ setProperty(FontSynthesisBoldId, (value == "auto"));+ } else if (command == "font-synthesis-style") {+ setProperty(FontSynthesisItalicId, (value == "auto"));+ } else if (command == "font-synthesis-small-caps") {+ setProperty(FontSynthesisSmallCapsId, (value == "auto"));+ } else if (command == "font-synthesis-position") {+ setProperty(FontSynthesisSuperSubId, (value == "auto"));} else {qFatal("FATAL: Unknown SVG property: %s = %s", command.toUtf8().data(), value.toUtf8().data());}@@ -686,13 +709,8 @@ QMap<QString, QString> KoSvgTextProperties::convertToSvgTextAttributes() const}if (hasProperty(FontStyleId)) {- const QFont::Style style = QFont::Style(property(FontStyleId).toInt());-- const QString value =- style == QFont::StyleItalic ? "italic" :- style == QFont::StyleOblique ? "oblique" : "normal";-- result.insert("font-style", value);+ const KoSvgText::CssFontStyleData style = property(FontStyleId).value<KoSvgText::CssFontStyleData>();+ result.insert("font-style", KoSvgText::writeFontStyle(style));}QStringList features;@@ -913,6 +931,38 @@ QMap<QString, QString> KoSvgTextProperties::convertToSvgTextAttributes() const}}+ if (hasProperty(FontSynthesisBoldId) && hasProperty(FontSynthesisItalicId)+ && hasProperty(FontSynthesisSuperSubId) && hasProperty(FontSynthesisSmallCapsId)) {+ bool weight = property(FontSynthesisBoldId).toBool();+ bool italic = property(FontSynthesisItalicId).toBool();+ bool caps = property(FontSynthesisSmallCapsId).toBool();+ bool super = property(FontSynthesisSuperSubId).toBool();++ if (!weight && !italic && !caps && !super) {+ result.insert("font-synthesis", "none");+ } else {+ QStringList params;+ if (weight) params.append("weight");+ if (italic) params.append("style");+ if (caps) params.append("small-caps");+ if (super) params.append("position");+ result.insert("font-synthesis", params.join(" "));+ }+ } else {+ if (hasProperty(FontSynthesisBoldId)) {+ result.insert("font-synthesis-weight", property(FontSynthesisBoldId).toBool()? "auto": "none");+ }+ if (hasProperty(FontSynthesisItalicId)) {+ result.insert("font-synthesis-style", property(FontSynthesisItalicId).toBool()? "auto": "none");+ }+ if (hasProperty(FontSynthesisSmallCapsId)) {+ result.insert("font-synthesis-small-caps", property(FontSynthesisSmallCapsId).toBool()? "auto": "none");+ }+ if (hasProperty(FontSynthesisSuperSubId)) {+ result.insert("font-synthesis-position", property(FontSynthesisSuperSubId).toBool()? "auto": "none");+ }+ }+return result;}@@ -1099,12 +1149,11 @@ QMap<QString, qreal> KoSvgTextProperties::fontAxisSettings() constif (propertyOrDefault(KoSvgTextProperties::FontOpticalSizingId).toBool()) {settings.insert("opsz", fontSize().value);}- const QFont::Style style = QFont::Style(propertyOrDefault(KoSvgTextProperties::FontStyleId).toInt());- if (style == QFont::StyleItalic) {+ const KoSvgText::CssFontStyleData style = propertyOrDefault(KoSvgTextProperties::FontStyleId).value<KoSvgText::CssFontStyleData>();+ if (style.style == QFont::StyleItalic) {settings.insert("ital", 1);- } else if (style == QFont::StyleOblique) {- settings.insert("ital", 1);- settings.insert("slnt", 11);+ } else if (style.style == QFont::StyleOblique) {+ settings.insert("slnt", -(style.slantValue.isAuto? 14: style.slantValue.customValue));} else {settings.insert("ital", 0);}@@ -1181,12 +1230,17 @@ const KoSvgTextProperties &KoSvgTextProperties::defaultProperties()s_defaultProperties->setProperty(WordSpacingId, QVariant::fromValue(AutoLengthPercentage()));s_defaultProperties->setProperty(FontFamiliesId, QStringLiteral("sans-serif"));- s_defaultProperties->setProperty(FontStyleId, QFont::StyleNormal);+ s_defaultProperties->setProperty(FontStyleId, QVariant::fromValue(KoSvgText::CssFontStyleData()));s_defaultProperties->setProperty(FontStretchId, 100);s_defaultProperties->setProperty(FontWeightId, 400);s_defaultProperties->setProperty(FontSizeId, QVariant::fromValue(KoSvgText::CssLengthPercentage(12.0)));s_defaultProperties->setProperty(FontSizeAdjustId, fromAutoValue(AutoValue()));+ s_defaultProperties->setProperty(FontSynthesisBoldId, true);+ s_defaultProperties->setProperty(FontSynthesisItalicId, true);+ s_defaultProperties->setProperty(FontSynthesisSmallCapsId, true);+ s_defaultProperties->setProperty(FontSynthesisSuperSubId, true);+s_defaultProperties->setProperty(FontOpticalSizingId, true);{using namespace KoSvgText;diff --git a/libs/flake/text/KoSvgTextProperties.h b/libs/flake/text/KoSvgTextProperties.hindex c7dd73795b..32586db19c 100644--- a/libs/flake/text/KoSvgTextProperties.h+++ b/libs/flake/text/KoSvgTextProperties.h@@ -59,7 +59,7 @@ public:WordSpacingId, ///< KoSvgText::AutoLengthPercentageFontFamiliesId, ///< QStringList- FontStyleId, ///< QFont::Style+ FontStyleId, ///< KoSvgText::CssSlantDataFontStretchId, ///< IntFontWeightId, ///< IntFontSizeId, ///< Double@@ -118,6 +118,11 @@ public:ShapePaddingId, ///< DoubleShapeMarginId, ///< Double+ FontSynthesisBoldId, ///< Bool+ FontSynthesisItalicId, ///< Bool+ FontSynthesisSmallCapsId, ///< Bool+ FontSynthesisSuperSubId, ///< Bool+KraTextVersionId ///< Int, used for handling incorrectly saved files.};diff --git a/libs/flake/text/KoSvgTextShape_p_glyphs.cpp b/libs/flake/text/KoSvgTextShape_p_glyphs.cppindex 2ca5e78971..d5eaa7e230 100644--- a/libs/flake/text/KoSvgTextShape_p_glyphs.cpp+++ b/libs/flake/text/KoSvgTextShape_p_glyphs.cpp@@ -122,6 +122,29 @@ emboldenGlyphIfNeeded(const FT_Face ftface, const CharacterResult &charResult, i}}+bool faceIsItalic(const FT_Face face) {+ bool isItalic = (face->style_flags & FT_STYLE_FLAG_ITALIC);++ if (FT_IS_SFNT(face) && FT_HAS_MULTIPLE_MASTERS(face)) {+ FT_MM_Var *amaster = nullptr;+ FT_Get_MM_Var(face, &amaster);+ std::vector<FT_Fixed> designCoords(amaster->num_axis);+ FT_Get_Var_Design_Coordinates(face, amaster->num_axis, designCoords.data());+ for (FT_UInt i = 0; i < amaster->num_axis; i++) {+ FT_Var_Axis axis = amaster->axis[i];+ if (axis.tag == FT_MAKE_TAG('i', 't', 'a', 'l')) {+ isItalic = !(designCoords[i] == axis.def);+ break;+ } else if (axis.tag == FT_MAKE_TAG('s', 'l', 'n', 't')) {+ isItalic = !(designCoords[i] == axis.def);+ break;+ }+ }++ }+ return isItalic;+}+/*** @brief Calculate the transformation matrices for an outline glyph, taking* synthesized italic into account.@@ -141,7 +164,7 @@ static std::pair<QTransform, QTransform> calcOutlineGlyphTransform(const QTransfQTransform glyphObliqueTf;// Check whether we need to synthesize italic by shearing the glyph:- if (charResult.fontStyle != QFont::StyleNormal && !(currentGlyph.ftface->style_flags & FT_STYLE_FLAG_ITALIC)) {+ if (charResult.fontStyle != QFont::StyleNormal && !faceIsItalic(currentGlyph.ftface)) {// CSS Fonts Module Level 4, 2.4. Font style: the font-style property:// For `oblique`, "lack of an <angle> represents 14deg".constexpr double SLANT_14DEG = 0.24932800284318069162403993780486;diff --git a/libs/flake/text/KoSvgTextShape_p_layout.cpp b/libs/flake/text/KoSvgTextShape_p_layout.cppindex 2dd7da8b6d..147e490a93 100644--- a/libs/flake/text/KoSvgTextShape_p_layout.cpp+++ b/libs/flake/text/KoSvgTextShape_p_layout.cpp@@ -389,8 +389,10 @@ void KoSvgTextShape::Private::relayout()QStringList fontFeatures = properties.fontFeaturesForText(start, length);qreal fontSize = properties.fontSize().value;- const QFont::Style style = QFont::Style(properties.propertyOrDefault(KoSvgTextProperties::FontStyleId).toInt());+ const KoSvgText::CssFontStyleData style = properties.propertyOrDefault(KoSvgTextProperties::FontStyleId).value<KoSvgText::CssFontStyleData>();KoSvgText::AutoValue fontSizeAdjust = properties.propertyOrDefault(KoSvgTextProperties::FontSizeAdjustId).value<KoSvgText::AutoValue>();+ bool synthesizeWeight = properties.propertyOrDefault(KoSvgTextProperties::FontSynthesisBoldId).toBool();+ bool synthesizeStyle = properties.propertyOrDefault(KoSvgTextProperties::FontSynthesisItalicId).toBool();if (properties.hasProperty(KoSvgTextProperties::KraTextVersionId)) {fontSizeAdjust.isAuto = (properties.property(KoSvgTextProperties::KraTextVersionId).toInt() < 3);}@@ -405,7 +407,7 @@ void KoSvgTextShape::Private::relayout()fontSizeAdjust.isAuto ? 1.0 : fontSizeAdjust.customValue,properties.propertyOrDefault(KoSvgTextProperties::FontWeightId).toInt(),properties.propertyOrDefault(KoSvgTextProperties::FontStretchId).toInt(),- style != QFont::StyleNormal);+ style.style != QFont::StyleNormal);if (properties.hasProperty(KoSvgTextProperties::TextLanguage)) {raqm_set_language(layout.data(),properties.property(KoSvgTextProperties::TextLanguage).toString().toUtf8(),@@ -550,8 +552,8 @@ void KoSvgTextShape::Private::relayout()}}result[j].fontHalfLeading = leading * 0.5;- result[j].fontStyle = style;- result[j].fontWeight = properties.propertyOrDefault(KoSvgTextProperties::FontWeightId).toInt();+ result[j].fontStyle = synthesizeStyle? style.style: QFont::StyleNormal;+ result[j].fontWeight = synthesizeWeight? properties.propertyOrDefault(KoSvgTextProperties::FontWeightId).toInt(): 400;}start += length;@@ -1160,7 +1162,7 @@ void KoSvgTextShape::Private::computeFontMetrics( // NOLINT(readability-function}QVector<int> lengths;- const QFont::Style style = QFont::Style(properties.propertyOrDefault(KoSvgTextProperties::FontStyleId).toInt());+ const KoSvgText::CssFontStyleData style = properties.propertyOrDefault(KoSvgTextProperties::FontStyleId).value<KoSvgText::CssFontStyleData>();KoSvgText::AutoValue fontSizeAdjust = properties.propertyOrDefault(KoSvgTextProperties::FontSizeAdjustId).value<KoSvgText::AutoValue>();if (properties.hasProperty(KoSvgTextProperties::KraTextVersionId)) {fontSizeAdjust.isAuto = (properties.property(KoSvgTextProperties::KraTextVersionId).toInt() < 3);@@ -1176,7 +1178,7 @@ void KoSvgTextShape::Private::computeFontMetrics( // NOLINT(readability-functionfontSizeAdjust.isAuto ? 1.0 : fontSizeAdjust.customValue,properties.propertyOrDefault(KoSvgTextProperties::FontWeightId).toInt(),properties.propertyOrDefault(KoSvgTextProperties::FontStretchId).toInt(),- style != QFont::StyleNormal);+ style.style != QFont::StyleNormal);hb_font_t_sp font(hb_ft_font_create_referenced(faces.front().data()));const qreal freetypePixelsToPt = (1.0 / 64.0) * (72. / res);diff --git a/libs/flake/text/lager/CssFontStyleModel.cpp b/libs/flake/text/lager/CssFontStyleModel.cppnew file mode 100644index 0000000000..0780de24f4--- /dev/null+++ b/libs/flake/text/lager/CssFontStyleModel.cpp@@ -0,0 +1,47 @@+/*+ * SPDX-FileCopyrightText: 2024 Wolthera van Hövell tot Westerflier <[email protected]>+ *+ * SPDX-License-Identifier: GPL-2.0-or-later+ */+#include "CssFontStyleModel.h"++namespace {++auto getValue = lager::lenses::getset (+ [] (const KoSvgText::CssFontStyleData &data) -> qreal {+ if (data.style == QFont::StyleOblique) {+ if (data.slantValue.isAuto) {+ return 14;+ } else {+ return data.slantValue.customValue;+ }+ }+ return 0;+}, [] (KoSvgText::CssFontStyleData data, const qreal &val) -> KoSvgText::CssFontStyleData {+ if (data.style == QFont::StyleOblique) {+ data.slantValue.isAuto = false;+ data.slantValue = val;+ }+ return data;+});++auto getStyle = lager::lenses::getset (+ [] (const KoSvgText::CssFontStyleData &data) -> CssFontStyleModel::FontStyle {+ return CssFontStyleModel::FontStyle(data.style);+}, [] (KoSvgText::CssFontStyleData data, const CssFontStyleModel::FontStyle &val) -> KoSvgText::CssFontStyleData {+ data.style = QFont::Style(val);+ if (data.style != QFont::StyleOblique) {+ data.slantValue.isAuto = true;+ data.slantValue = 0;+ }+ return data;+});+}++CssFontStyleModel::CssFontStyleModel(lager::cursor<KoSvgText::CssFontStyleData> _data)+ : data(_data)+ , LAGER_QT(style) {data.zoom(getStyle)}+ , LAGER_QT(value) {data.zoom(getValue)}+{++}diff --git a/libs/flake/text/lager/CssFontStyleModel.h b/libs/flake/text/lager/CssFontStyleModel.hnew file mode 100644index 0000000000..b3adb54e86--- /dev/null+++ b/libs/flake/text/lager/CssFontStyleModel.h@@ -0,0 +1,38 @@+/*+ * SPDX-FileCopyrightText: 2024 Wolthera van Hövell tot Westerflier <[email protected]>+ *+ * SPDX-License-Identifier: GPL-2.0-or-later+ */+#ifndef CSSFONTSTYLEMODEL_H+#define CSSFONTSTYLEMODEL_H++#include <QObject>++#include <KoSvgText.h>+#include <lager/state.hpp>+#include <lager/cursor.hpp>+#include <lager/extra/qt.hpp>++#include <kritaflake_export.h>++class KRITAFLAKE_EXPORT CssFontStyleModel: public QObject+{+ Q_OBJECT+public:+ CssFontStyleModel(lager::cursor<KoSvgText::CssFontStyleData> _data = lager::make_state(KoSvgText::CssFontStyleData(), lager::automatic_tag{}));++ // QFont::Style isn't exposed to qml.+ enum FontStyle {+ StyleNormal = QFont::StyleNormal,+ StyleItalic = QFont::StyleItalic,+ StyleOblique = QFont::StyleOblique+ };+ Q_ENUM(FontStyle)++ lager::cursor<KoSvgText::CssFontStyleData> data;++ LAGER_QT_CURSOR(FontStyle, style);+ LAGER_QT_CURSOR(qreal, value);+};++#endif // CSSFONTSTYLEMODEL_Hdiff --git a/libs/flake/text/lager/KoSvgTextPropertiesModel.cpp b/libs/flake/text/lager/KoSvgTextPropertiesModel.cppindex a489eeeba8..53c58215cf 100644--- a/libs/flake/text/lager/KoSvgTextPropertiesModel.cpp+++ b/libs/flake/text/lager/KoSvgTextPropertiesModel.cpp@@ -127,7 +127,6 @@ auto hangingPunactuationCommaPropImpl = lager::lenses::getset(auto hangingPunactuationCommaProp =variant_to<KoSvgText::HangingPunctuations> | hangingPunactuationCommaPropImpl;-}auto propertyState = [](const KoSvgTextProperties::PropertyId &propId) { return [propId] (const KoSvgTextPropertyData &value) -> KoSvgTextPropertiesModel::PropertyState {@@ -152,6 +151,7 @@ KoSvgTextPropertiesModel::KoSvgTextPropertiesModel(lager::cursor<KoSvgTextProper, textIndentData(textData.zoom(createTextProperty(KoSvgTextProperties::TextIndentId)).zoom(variant_to<KoSvgText::TextIndentInfo>)), tabSizeData(textData.zoom(createTextProperty(KoSvgTextProperties::TabSizeId)).zoom(variant_to<KoSvgText::TabSizeInfo>)), textTransformData(textData.zoom(createTextProperty(KoSvgTextProperties::TextTransformId)).zoom(variant_to<KoSvgText::TextTransformInfo>))+ , cssFontStyleData(textData.zoom(createTextProperty(KoSvgTextProperties::FontStyleId)).zoom(variant_to<KoSvgText::CssFontStyleData>)), fontSizeModel(fontSizeData), lineHeightModel(lineHeightData), letterSpacingModel(letterSpacingData)@@ -160,6 +160,7 @@ KoSvgTextPropertiesModel::KoSvgTextPropertiesModel(lager::cursor<KoSvgTextProper, textIndentModel(textIndentData), tabSizeModel(tabSizeData), textTransformModel(textTransformData)+ , cssFontStyleModel(cssFontStyleData), LAGER_QT(fontSizeState) {textData.zoom(propertyModifyState(KoSvgTextProperties::FontSizeId))}, LAGER_QT(lineHeightState) {textData.zoom(propertyModifyState(KoSvgTextProperties::LineHeightId))}, LAGER_QT(letterSpacingState) {textData.zoom(propertyModifyState(KoSvgTextProperties::LetterSpacingId))}@@ -167,6 +168,7 @@ KoSvgTextPropertiesModel::KoSvgTextPropertiesModel(lager::cursor<KoSvgTextProper, LAGER_QT(textIndentState) {textData.zoom(propertyModifyState(KoSvgTextProperties::TextIndentId))}, LAGER_QT(tabSizeState) {textData.zoom(propertyModifyState(KoSvgTextProperties::TabSizeId))}, LAGER_QT(textTransformState) {textData.zoom(propertyModifyState(KoSvgTextProperties::TextTransformId))}+ , LAGER_QT(fontStyleState) {textData.zoom(propertyModifyState(KoSvgTextProperties::FontStyleId))}, LAGER_QT(writingMode) {textData.zoom(createTextProperty(KoSvgTextProperties::WritingModeId)).zoom(variant_to<int>)}, LAGER_QT(writingModeState) {textData.zoom(propertyModifyState(KoSvgTextProperties::WritingModeId))}, LAGER_QT(direction) {textData.zoom(createTextProperty(KoSvgTextProperties::DirectionId)).zoom(variant_to<int>)}@@ -183,8 +185,6 @@ KoSvgTextPropertiesModel::KoSvgTextPropertiesModel(lager::cursor<KoSvgTextProper, LAGER_QT(fontWeightState) {textData.zoom(propertyModifyState(KoSvgTextProperties::FontWeightId))}, LAGER_QT(fontWidth) {textData.zoom(createTextProperty(KoSvgTextProperties::FontStretchId)).zoom(variant_to<int>)}, LAGER_QT(fontWidthState) {textData.zoom(propertyModifyState(KoSvgTextProperties::FontStretchId))}- , LAGER_QT(fontStyle) {textData.zoom(createTextProperty(KoSvgTextProperties::FontStyleId)).zoom(variant_to<KoSvgTextPropertiesModel::FontStyle>)}- , LAGER_QT(fontStyleState) {textData.zoom(propertyModifyState(KoSvgTextProperties::FontStyleId))}, LAGER_QT(fontOpticalSizeLink) {textData.zoom(createTextProperty(KoSvgTextProperties::FontOpticalSizingId)).zoom(variant_to<bool>)}, LAGER_QT(fontOpticalSizeLinkState) {textData.zoom(propertyModifyState(KoSvgTextProperties::FontOpticalSizingId))}, LAGER_QT(fontFamilies) {textData.zoom(createTextProperty(KoSvgTextProperties::FontFamiliesId)).zoom(variant_to<QStringList>)}@@ -211,6 +211,10 @@ KoSvgTextPropertiesModel::KoSvgTextPropertiesModel(lager::cursor<KoSvgTextProper, LAGER_QT(wordBreakState) {textData.zoom(propertyModifyState(KoSvgTextProperties::WordBreakId))}, LAGER_QT(lineBreak){textData.zoom(createTextProperty(KoSvgTextProperties::LineBreakId)).zoom(variant_to<int>)}, LAGER_QT(lineBreakState) {textData.zoom(propertyModifyState(KoSvgTextProperties::LineBreakId))}+ , LAGER_QT(fontSynthesisWeight){textData.zoom(createTextProperty(KoSvgTextProperties::FontSynthesisBoldId)).zoom(variant_to<bool>)}+ , LAGER_QT(fontSynthesisWeightState) {textData.zoom(propertyModifyState(KoSvgTextProperties::FontSynthesisBoldId))}+ , LAGER_QT(fontSynthesisStyle){textData.zoom(createTextProperty(KoSvgTextProperties::FontSynthesisItalicId)).zoom(variant_to<bool>)}+ , LAGER_QT(fontSynthesisStyleState) {textData.zoom(propertyModifyState(KoSvgTextProperties::FontSynthesisItalicId))}, LAGER_QT(spanSelection) {textData[&KoSvgTextPropertyData::spanSelection]}{lager::watch(textData, std::bind(&KoSvgTextPropertiesModel::textPropertyChanged, this));@@ -225,6 +229,7 @@ KoSvgTextPropertiesModel::KoSvgTextPropertiesModel(lager::cursor<KoSvgTextProperconnect(&textIndentModel, SIGNAL(lengthChanged()), this, SIGNAL(textIndentChanged()));lager::watch(tabSizeData, std::bind(&KoSvgTextPropertiesModel::tabSizeChanged, this));lager::watch(textTransformData, std::bind(&KoSvgTextPropertiesModel::textTransformChanged, this));+ lager::watch(cssFontStyleData, std::bind(&KoSvgTextPropertiesModel::fontStyleChanged, this));}CssLengthPercentageModel *KoSvgTextPropertiesModel::fontSize()@@ -267,6 +272,11 @@ TextTransformModel *KoSvgTextPropertiesModel::textTransform()return &this->textTransformModel;}+CssFontStyleModel *KoSvgTextPropertiesModel::fontStyle()+{+ return &this->cssFontStyleModel;+}+qreal KoSvgTextPropertiesModel::resolvedFontSize(bool fontSize){KoSvgTextPropertyData data = textData.get();diff --git a/libs/flake/text/lager/KoSvgTextPropertiesModel.h b/libs/flake/text/lager/KoSvgTextPropertiesModel.hindex 9436663744..725d7bd714 100644--- a/libs/flake/text/lager/KoSvgTextPropertiesModel.h+++ b/libs/flake/text/lager/KoSvgTextPropertiesModel.h@@ -18,6 +18,7 @@#include "TextIndentModel.h"#include "TabSizeModel.h"#include "TextTransformModel.h"+#include "CssFontStyleModel.h"#include <kritaflake_export.h>@@ -41,6 +42,7 @@ class KRITAFLAKE_EXPORT KoSvgTextPropertiesModel : public QObjectQ_PROPERTY(TextIndentModel *textIndent READ textIndent NOTIFY textIndentChanged)Q_PROPERTY(TabSizeModel *tabSize READ tabSize NOTIFY tabSizeChanged)Q_PROPERTY(TextTransformModel *textTransform READ textTransform NOTIFY textTransformChanged)+ Q_PROPERTY(CssFontStyleModel *fontStyle READ fontStyle NOTIFY fontStyleChanged)public:KoSvgTextPropertiesModel(lager::cursor<KoSvgTextPropertyData> _textData = lager::make_state(KoSvgTextPropertyData(), lager::automatic_tag{}));@@ -54,6 +56,7 @@ public:lager::cursor<KoSvgText::TextIndentInfo> textIndentData;lager::cursor<KoSvgText::TabSizeInfo> tabSizeData;lager::cursor<KoSvgText::TextTransformInfo> textTransformData;+ lager::cursor<KoSvgText::CssFontStyleData> cssFontStyleData;CssLengthPercentageModel fontSizeModel;@@ -66,6 +69,7 @@ public:TextIndentModel textIndentModel;TabSizeModel tabSizeModel;TextTransformModel textTransformModel;+ CssFontStyleModel cssFontStyleModel;// Whether a given property is set, unset or tristate.enum PropertyState {@@ -94,6 +98,9 @@ public:TextTransformModel *textTransform();LAGER_QT_CURSOR(PropertyState, textTransformState);+ CssFontStyleModel *fontStyle();+ LAGER_QT_CURSOR(PropertyState, fontStyleState);+LAGER_QT_CURSOR(int, writingMode);LAGER_QT_CURSOR(PropertyState, writingModeState);LAGER_QT_CURSOR(int, direction);@@ -112,16 +119,6 @@ public:LAGER_QT_CURSOR(int, fontWidth);LAGER_QT_CURSOR(PropertyState, fontWidthState);- // QFont::Style isn't exposed to qml.- enum FontStyle {- StyleNormal = QFont::StyleNormal,- StyleItalic = QFont::StyleItalic,- StyleOblique = QFont::StyleOblique- };- Q_ENUM(FontStyle)-- LAGER_QT_CURSOR(FontStyle, fontStyle);- LAGER_QT_CURSOR(PropertyState, fontStyleState);LAGER_QT_CURSOR(bool, fontOpticalSizeLink);LAGER_QT_CURSOR(PropertyState, fontOpticalSizeLinkState);@@ -163,6 +160,11 @@ public:LAGER_QT_CURSOR(int, lineBreak);LAGER_QT_CURSOR(PropertyState, lineBreakState);+ LAGER_QT_CURSOR(bool, fontSynthesisWeight);+ LAGER_QT_CURSOR(PropertyState, fontSynthesisWeightState);+ LAGER_QT_CURSOR(bool, fontSynthesisStyle);+ LAGER_QT_CURSOR(PropertyState, fontSynthesisStyleState);+/// We're selecting a span of text instead of the whole paragraph.LAGER_QT_CURSOR(bool, spanSelection);@@ -196,6 +198,7 @@ Q_SIGNALS:void textIndentChanged();void tabSizeChanged();void textTransformChanged();+ void fontStyleChanged();};#endif // KOSVGTEXTPROPERTIESMODEL_Hdiff --git a/plugins/dockers/textproperties/FontStyleModel.cpp b/plugins/dockers/textproperties/FontStyleModel.cppindex cf0530e1d4..a7bc0a6eb3 100644--- a/plugins/dockers/textproperties/FontStyleModel.cpp+++ b/plugins/dockers/textproperties/FontStyleModel.cpp@@ -67,7 +67,18 @@ qreal FontStyleModel::widthValue(int row)int FontStyleModel::styleModeValue(int row){KoSvgText::FontFamilyStyleInfo style = d->styles.value(row);- return style.isItalic? style.isOblique? QFont::StyleOblique: QFont::StyleItalic: QFont::StyleNormal;+ QFont::Style styleType = style.isItalic? style.isOblique? QFont::StyleOblique: QFont::StyleItalic: QFont::StyleNormal;+ if (style.instanceCoords.value(ITALIC_TAG, 0) != 0) {+ styleType = QFont::StyleItalic;+ } else if (style.instanceCoords.value(SLANT_TAG, 0) != 0) {+ styleType = QFont::StyleOblique;+ }+ return styleType;+}++qreal FontStyleModel::slantValue(int row)+{+ return -(d->styles.value(row).instanceCoords.value(SLANT_TAG, 0));}QVariantHash FontStyleModel::axesValues(int row)@@ -127,6 +138,7 @@ int FontStyleModel::rowForStyle(qreal weight, qreal width, int styleMode)QModelIndex FontStyleModel::index(int row, int column, const QModelIndex &parent) const{+ Q_UNUSED(parent)if (column != 0) return QModelIndex();if (row >= 0 && row < d->styles.size()) return createIndex(row, column, &row);return QModelIndex();@@ -134,16 +146,19 @@ QModelIndex FontStyleModel::index(int row, int column, const QModelIndex &parentQModelIndex FontStyleModel::parent(const QModelIndex &child) const{+ Q_UNUSED(child)return QModelIndex();}int FontStyleModel::rowCount(const QModelIndex &parent) const{+ Q_UNUSED(parent)return d->styles.size();}int FontStyleModel::columnCount(const QModelIndex &parent) const{+ Q_UNUSED(parent)return 1;}@@ -167,9 +182,15 @@ QVariant FontStyleModel::data(const QModelIndex &index, int role) const} else if (role == Width){return style.instanceCoords.value(WIDTH_TAG, 100.0);} else if (role == StyleMode){- return style.isItalic? style.isOblique? QFont::StyleOblique: QFont::StyleItalic: QFont::StyleNormal;+ QFont::Style styleType = style.isItalic? style.isOblique? QFont::StyleOblique: QFont::StyleItalic: QFont::StyleNormal;+ if (style.instanceCoords.value(ITALIC_TAG, 0) != 0) {+ styleType = QFont::StyleItalic;+ } else if (style.instanceCoords.value(SLANT_TAG, 0) != 0) {+ styleType = QFont::StyleOblique;+ }+ return styleType;} else if (role == Slant){- return style.instanceCoords.value(SLANT_TAG, 0);+ return -(style.instanceCoords.value(SLANT_TAG, 0));} else if (role == AxisValues) {QVariantHash vals;for (auto it = style.instanceCoords.begin(); it != style.instanceCoords.end(); it++) {diff --git a/plugins/dockers/textproperties/FontStyleModel.h b/plugins/dockers/textproperties/FontStyleModel.hindex b051abea16..50de75b8d9 100644--- a/plugins/dockers/textproperties/FontStyleModel.h+++ b/plugins/dockers/textproperties/FontStyleModel.h@@ -39,6 +39,7 @@ public:Q_INVOKABLE qreal weightValue(int row);Q_INVOKABLE qreal widthValue(int row);Q_INVOKABLE int styleModeValue(int row);+ Q_INVOKABLE qreal slantValue(int row);Q_INVOKABLE QVariantHash axesValues(int row);/// Find the closest style that represents the current width, weight and stylemode.diff --git a/plugins/dockers/textproperties/TextPropertiesDock.cpp b/plugins/dockers/textproperties/TextPropertiesDock.cppindex 30236f6b9c..c8b40d0647 100644--- a/plugins/dockers/textproperties/TextPropertiesDock.cpp+++ b/plugins/dockers/textproperties/TextPropertiesDock.cpp@@ -36,6 +36,7 @@#include <text/lager/TextIndentModel.h>#include <text/lager/TabSizeModel.h>#include <text/lager/TextTransformModel.h>+#include <text/lager/CssFontStyleModel.h>#include <resources/KoFontFamily.h>#include <lager/state.hpp>@@ -51,6 +52,7 @@ KIS_DECLARE_STATIC_INITIALIZER {qmlRegisterType<TextIndentModel>("org.krita.flake.text", 1, 0, "TextIndentModel");qmlRegisterType<TabSizeModel>("org.krita.flake.text", 1, 0, "TabSizeModel");qmlRegisterType<TextTransformModel>("org.krita.flake.text", 1, 0, "TextTransformModel");+ qmlRegisterType<CssFontStyleModel>("org.krita.flake.text", 1, 0, "CssFontStyleModel");qmlRegisterUncreatableMetaObject(KoSvgText::staticMetaObject, "org.krita.flake.text", 1, 0, "KoSvgText", "Error: Namespace with enums");qmlRegisterType<FontStyleModel>("org.krita.flake.text", 1, 0, "FontStyleModel");diff --git a/plugins/dockers/textproperties/qml/FontStyle.qml b/plugins/dockers/textproperties/qml/FontStyle.qmlindex fc5f984bdf..e5fd328c33 100644--- a/plugins/dockers/textproperties/qml/FontStyle.qml+++ b/plugins/dockers/textproperties/qml/FontStyle.qml@@ -18,27 +18,36 @@ CollapsibleGroupProperty {property alias fontWeight: fontWeightSpn.value;property alias fontWidth: fontStretchSpn.value;+ property alias fontSlantSlope: fontSlantSpn.value;property int fontSlant: KoSvgTextPropertiesModel.StyleNormal;onFontSlantChanged: {fontSlantCmb.currentIndex = fontSlantCmb.indexOfValue(fontSlant);if (!blockSignals) {- properties.fontStyle = fontSlant;+ properties.fontStyle.style = fontSlant;}}property alias fontOptical: opticalSizeCbx.checked;+ property alias fontSynthesizeWeight: synthesizeWeightCbx.checked;+ property alias fontSynthesizeSlant: synthesizeSlantCbx.checked;onPropertiesUpdated: {blockSignals = true;fontWeight = properties.fontWeight;fontWidth = properties.fontWidth;fontOptical = properties.fontOpticalSizeLink;- fontSlant = properties.fontStyle;+ fontSlant = properties.fontStyle.style;+ fontSlantSlope = properties.fontStyle.value;+ fontSynthesizeSlant = properties.fontSynthesisStyle;+ fontSynthesizeWeight = properties.fontSynthesisWeight;styleCmb.currentIndex = fontStylesModel.rowForStyle(properties.fontWeight, properties.fontWidth, properties.fontStyle);visible = properties.fontWeightState !== KoSvgTextPropertiesModel.PropertyUnset- || properties.fontStyleState !== KoSvgTextPropertiesModel.PropertyUnset- || properties.fontWidthState !== KoSvgTextPropertiesModel.PropertyUnset- || properties.fontOpticalSizeLinkState !== KoSvgTextPropertiesModel.PropertyUnset;+ || properties.fontStyleState !== KoSvgTextPropertiesModel.PropertyUnset+ || properties.fontWidthState !== KoSvgTextPropertiesModel.PropertyUnset+ || properties.fontOpticalSizeLinkState !== KoSvgTextPropertiesModel.PropertyUnset+ || properties.axisValueState !== KoSvgTextPropertiesModel.PropertyUnset+ || properties.fontSynthesisStyleState !== KoSvgTextPropertiesModel.PropertyUnset+ || properties.fontSynthesisWeightState !== KoSvgTextPropertiesModel.PropertyUnset;blockSignals = false;}onFontWeightChanged: {@@ -53,12 +62,30 @@ CollapsibleGroupProperty {}}+ onFontSlantSlopeChanged: {+ if (!blockSignals) {+ properties.fontStyle.value = fontSlantSlope;+ }+ }+onFontOpticalChanged: {if (!blockSignals) {properties.fontOpticalSizeLink = fontOptical;}}+ onFontSynthesizeSlantChanged: {+ if (!blockSignals) {+ properties.fontSynthesisStyle = fontSynthesizeSlant;+ }+ }++ onFontSynthesizeWeightChanged: {+ if (!blockSignals) {+ properties.fontSynthesisWeight = fontSynthesizeWeight;+ }+ }+onEnableProperty: {properties.fontWeightState = KoSvgTextPropertiesModel.PropertySet;}@@ -75,10 +102,14 @@ CollapsibleGroupProperty {var weight = fontStylesModel.weightValue(currentIndex);var width = fontStylesModel.widthValue(currentIndex);var styleMode = fontStylesModel.styleModeValue(currentIndex);+ var styleVal = fontStylesModel.slantValue(currentIndex);var axesValues = fontStylesModel.axesValues(currentIndex);properties.fontWeight = weight;properties.fontWidth = width;- properties.fontStyle = styleMode;+ properties.fontStyle.style = styleMode;+ if (styleMode === CssFontStyleModel.StyleOblique) {+ properties.fontStyle.value = styleVal;+ }properties.axisValues = axesValues;}}@@ -116,6 +147,20 @@ CollapsibleGroupProperty {wheelEnabled: true;}+ RevertPropertyButton {+ revertState: properties.fontSynthesisWeightState;+ onClicked: properties.fontSynthesisWeightState = KoSvgTextPropertiesModel.PropertyUnset;+ }+ Item {+ width: 1;+ height: 1;}++ CheckBox {+ id: synthesizeWeightCbx+ text: i18nc("@option:check", "Synthesize Bold")+ Layout.fillWidth: true;+ font.italic: properties.fontSynthesisWeightState === KoSvgTextPropertiesModel.PropertyTriState;+ }RevertPropertyButton {@@ -156,9 +201,9 @@ CollapsibleGroupProperty {ComboBox {id: fontSlantCmbmodel: [- {text: i18nc("@label:inlistbox", "Normal"), value: KoSvgTextPropertiesModel.StyleNormal},- {text: i18nc("@label:inlistbox", "Italic"), value: KoSvgTextPropertiesModel.StyleItalic},- {text: i18nc("@label:inlistbox", "Oblique"), value: KoSvgTextPropertiesModel.StyleOblique}+ {text: i18nc("@label:inlistbox", "Normal"), value: CssFontStyleModel.StyleNormal},+ {text: i18nc("@label:inlistbox", "Italic"), value: CssFontStyleModel.StyleItalic},+ {text: i18nc("@label:inlistbox", "Oblique"), value: CssFontStyleModel.StyleOblique}]Layout.fillWidth: truetextRole: "text";@@ -167,6 +212,37 @@ CollapsibleGroupProperty {wheelEnabled: true;}+ Item {+ width: 1;+ height: 1;+ Layout.columnSpan: 2;+ }+ SpinBox {+ id: fontSlantSpn+ from: -90;+ to: 90;+ editable: true;+ Layout.fillWidth: true;++ wheelEnabled: true;++ }++ RevertPropertyButton {+ revertState: properties.fontSynthesisStyleState;+ onClicked: properties.fontSynthesisStyleState = KoSvgTextPropertiesModel.PropertyUnset;+ }+ Item {+ width: 1;+ height: 1;}++ CheckBox {+ id: synthesizeSlantCbx+ text: i18nc("@option:check", "Synthesize Slant")+ Layout.fillWidth: true;+ font.italic: properties.fontSynthesisStyleState === KoSvgTextPropertiesModel.PropertyTriState;+ }+RevertPropertyButton {revertState: properties.fontOpticalSizeLinkState;onClicked: properties.fontOpticalSizeLinkState = KoSvgTextPropertiesModel.PropertyUnset;diff --git a/plugins/tools/svgtexttool/SvgTextCursor.cpp b/plugins/tools/svgtexttool/SvgTextCursor.cppindex f980a00850..1e217bffdb 100644--- a/plugins/tools/svgtexttool/SvgTextCursor.cpp+++ b/plugins/tools/svgtexttool/SvgTextCursor.cpp@@ -898,9 +898,17 @@ void SvgTextCursor::toggleProperty(KoSvgTextProperties::PropertyId property)newVal = value == 400? QVariant(700): QVariant(400);if (value == 400) break;} else if (property == KoSvgTextProperties::FontStyleId) {- QFont::Style value = QFont::Style(it->property(property, QVariant(QFont::StyleNormal)).toInt());- newVal = value == QFont::StyleNormal? QVariant(QFont::StyleItalic): QVariant(QFont::StyleNormal);- if (value == QFont::StyleNormal) break;+ KoSvgText::CssFontStyleData value = it->property(property, QVariant(QFont::StyleNormal)).value<KoSvgText::CssFontStyleData>();+ KoSvgText::CssFontStyleData newSlant = value;+ if (value.style == QFont::StyleNormal) {+ newSlant.style = QFont::StyleItalic;+ } else {+ newSlant.style = QFont::StyleNormal;+ newSlant.slantValue.customValue = 0;+ newSlant.slantValue.isAuto = true;+ }+ newVal = QVariant::fromValue(newSlant);+ if (value.style == QFont::StyleNormal) break;} else if (property == KoSvgTextProperties::TextDecorationLineId) {KoSvgText::TextDecorations decor = it->propertyOrDefault(KoSvgTextProperties::TextDecorationLineId).value<KoSvgText::TextDecorations>();KoSvgText::TextDecorations newDecor;