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++
Add Text Rendering to the text properties docker.
Wolthera van Hövell tot Westerflierc17e4aef4a9f
diff --git a/libs/flake/text/lager/KoSvgTextPropertiesModel.cpp b/libs/flake/text/lager/KoSvgTextPropertiesModel.cppindex cd02a8788f..ee839dc343 100644--- a/libs/flake/text/lager/KoSvgTextPropertiesModel.cpp+++ b/libs/flake/text/lager/KoSvgTextPropertiesModel.cpp@@ -295,6 +295,8 @@ KoSvgTextPropertiesModel::KoSvgTextPropertiesModel(lager::cursor<KoSvgTextProper, LAGER_QT(textCollapseState) {textData.zoom(propertyModifyState(KoSvgTextProperties::TextCollapseId))}, LAGER_QT(textWrap){textData.zoom(createTextProperty(KoSvgTextProperties::TextWrapId)).zoom(variant_to<int>)}, LAGER_QT(textWrapState) {textData.zoom(propertyModifyState(KoSvgTextProperties::TextWrapId))}+ , LAGER_QT(textRendering){textData.zoom(createTextProperty(KoSvgTextProperties::TextRenderingId)).zoom(variant_to<int>)}+ , LAGER_QT(textRenderingState) {textData.zoom(propertyModifyState(KoSvgTextProperties::TextRenderingId))}, LAGER_QT(spanSelection) {textData[&KoSvgTextPropertyData::spanSelection]}{lager::watch(textData, std::bind(&KoSvgTextPropertiesModel::textPropertyChanged, this));diff --git a/libs/flake/text/lager/KoSvgTextPropertiesModel.h b/libs/flake/text/lager/KoSvgTextPropertiesModel.hindex f0a7cadc59..69548a3726 100644--- a/libs/flake/text/lager/KoSvgTextPropertiesModel.h+++ b/libs/flake/text/lager/KoSvgTextPropertiesModel.h@@ -214,6 +214,9 @@ public:LAGER_QT_CURSOR(int, textWrap);LAGER_QT_CURSOR(PropertyState, textWrapState);+ LAGER_QT_CURSOR(int, textRendering);+ LAGER_QT_CURSOR(PropertyState, textRenderingState);+/// We're selecting a span of text instead of the whole paragraph.LAGER_QT_CURSOR(bool, spanSelection);diff --git a/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml b/plugins/dockers/textproperties/qml/TextPropertyBaseList.qmlindex eaa551c679..aaece2cf59 100644--- a/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml+++ b/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml@@ -109,6 +109,7 @@ ColumnLayout {}TabSize {}+ TextRendering {}FontSize {}FontSizeAdjust {diff --git a/plugins/dockers/textproperties/qml/TextRendering.qml b/plugins/dockers/textproperties/qml/TextRendering.qmlnew file mode 100644index 0000000000..a0f017291d--- /dev/null+++ b/plugins/dockers/textproperties/qml/TextRendering.qml@@ -0,0 +1,81 @@+/*+ * SPDX-FileCopyrightText: 2025 Wolthera van Hövell tot Westerflier <[email protected]>+ *+ * SPDX-License-Identifier: GPL-2.0-or-later+ */+import QtQuick 2.15+import QtQuick.Controls 2.15+import QtQuick.Layouts 1.15+import org.krita.flake.text 1.0++TextPropertyBase {+ propertyName: i18nc("@title:group", "Text Rendering");+ propertyType: TextPropertyBase.Paragraph;+ toolTip: i18nc("@info:tooltip",+ "Text Rendering controls the hinting and rendering style for the property");+ searchTerms: i18nc("comma separated search terms for the text-rendering property, matching is case-insensitive",+ "text-rendering, hinting, anti-aliasing");+ property int textRendering;++ onPropertiesUpdated: {+ blockSignals = true;+ textRendering = properties.textRendering;+ visible = properties.textRenderingState !== KoSvgTextPropertiesModel.PropertyUnset+ blockSignals = false;+ }++ onTextRenderingChanged: {+ renderingCmb.currentIndex = renderingCmb.indexOfValue(textRendering);+ if (!blockSignals) {+ properties.textRendering = textRendering;+ }+ }++ onEnableProperty: properties.textRenderingState = KoSvgTextPropertiesModel.PropertySet;++ GridLayout {+ columns: 2;+ columnSpacing: columnSpacing;+ width: parent.width;++ RevertPropertyButton {+ revertState: properties.textRenderingState;+ onClicked: properties.textRenderingState = KoSvgTextPropertiesModel.PropertyUnset;+ }++ Label {+ text: propertyName;+ elide: Text.ElideRight;+ Layout.fillWidth: true;+ font.italic: properties.textRenderingState === KoSvgTextPropertiesModel.PropertyTriState;+ }+++ Item {+ width: firstColumnWidth;+ height: 1;+ }+ SqueezedComboBox {+ model: [+ {text: i18nc("@label:inlistbox", "Auto"), value: KoSvgText.RenderingAuto, icon: "",+ toolTip: i18nc("@info:tooltip", "Same as geometric precision, uses no hinting and avoid loading internal bitmaps.")},+ {text: i18nc("@label:inlistbox", "Optimize Speed"), value: KoSvgText.RenderingOptimizeSpeed, icon: "qrc:///light_select-pixel.svg",+ toolTip: i18nc("@info:tooltip", "Renders without antialiasing.")},+ {text: i18nc("@label:inlistbox", "Optimize Legibility"), value: KoSvgText.RenderingOptimizeLegibility, icon: "",+ toolTip: i18nc("@info:tooltip", "Uses 'light' hinting in horizontal and 'full' hinting in vertical.")},+ {text: i18nc("@label:inlistbox", "Geometric Precision"), value: KoSvgText.RenderingGeometricPrecision, icon: "qrc:///light_select-shape.svg",+ toolTip: i18nc("@info:tooltip", "No hinting and avoids loading bitmap strikes unless the font has no paths.")},++ ]+ Layout.fillWidth: true;+ id: renderingCmb;+ textRole: "text";+ valueRole: "value";+ iconRole: "icon";+ iconSize: 16;+ toolTipRole: "toolTip";+ onActivated: textRendering = currentValue;+ wheelEnabled: true;+ }+ }+}diff --git a/plugins/dockers/textproperties/textproperties.qrc b/plugins/dockers/textproperties/textproperties.qrcindex 0319e40312..652269dc1d 100644--- a/plugins/dockers/textproperties/textproperties.qrc+++ b/plugins/dockers/textproperties/textproperties.qrc@@ -59,5 +59,6 @@<file alias="baseline-ideo-embox-horizontal-center.svg">icons/baseline-ideo-embox-horizontal-center.svg</file><file alias="16_light_format-text-overline.svg">icons/16_light_format-text-overline.svg</file><file alias="FontSizeAdjust.qml">qml/FontSizeAdjust.qml</file>+ <file alias="TextRendering.qml">qml/TextRendering.qml</file></qresource></RCC>