From 783f166793915a1c5a008de7142f773ad3898683 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Tue, 23 Aug 2022 14:22:23 +0200 Subject: tdf#127423: Allow disabling default features in Font Features dialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In OpenType fonts we have no way if detecting what features are on by default and what not (short of hard-coding this, since HarfBuzz has no API of giving us this information, and it is also not a fixed set per-font, depends also on the text being shaped). The dialog currently does not differentiate between a disabled feature and unset feature. To make this distinction, feature value is now signed and negative value means the feature is unset (i.e. the default is used), and the checkbox is now a try state one to reflect this. Change-Id: Iba5d13f02610e7b761677acc19872788c72afde1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138729 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- cui/source/dialogs/FontFeaturesDialog.cxx | 11 +++++++---- cui/source/inc/FontFeaturesDialog.hxx | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'cui') diff --git a/cui/source/dialogs/FontFeaturesDialog.cxx b/cui/source/dialogs/FontFeaturesDialog.cxx index 0d5d512bf053..53ca5f12f3c1 100644 --- a/cui/source/dialogs/FontFeaturesDialog.cxx +++ b/cui/source/dialogs/FontFeaturesDialog.cxx @@ -100,7 +100,7 @@ int FontFeaturesDialog::fillGrid(std::vector const& rFontFea m_aFeatureItems.emplace_back(m_xContentGrid.get()); - uint32_t nValue = 0; + int32_t nValue = 0; if (aExistingFeatures.find(nFontFeatureCode) != aExistingFeatures.end()) nValue = aExistingFeatures.at(nFontFeatureCode); else @@ -133,7 +133,10 @@ int FontFeaturesDialog::fillGrid(std::vector const& rFontFea } else { - aCurrentItem.m_xCheck->set_active(nValue > 0); + if (nValue < 0) + aCurrentItem.m_xCheck->set_state(TRISTATE_INDET); + else + aCurrentItem.m_xCheck->set_state(nValue > 0 ? TRISTATE_TRUE : TRISTATE_FALSE); aCurrentItem.m_xCheck->set_label(aDefinition.getDescription()); aCurrentItem.m_xCheck->connect_toggled(aCheckBoxToggleHandler); aCurrentItem.m_xCheck->show(); @@ -183,7 +186,7 @@ OUString FontFeaturesDialog::createFontNameWithFeatures() { if (rItem.m_xCheck->get_visible()) { - if (sal_uInt32(rItem.m_xCheck->get_active()) != rItem.m_nDefault) + if (rItem.m_xCheck->get_state() != TRISTATE_INDET) { if (!bFirst) sNameSuffix.append(vcl::font::FeatureSeparator); @@ -191,7 +194,7 @@ OUString FontFeaturesDialog::createFontNameWithFeatures() bFirst = false; sNameSuffix.append(vcl::font::featureCodeAsString(rItem.m_aFeatureCode)); - if (!rItem.m_xCheck->get_active()) + if (rItem.m_xCheck->get_state() == TRISTATE_FALSE) sNameSuffix.append("=0"); } } diff --git a/cui/source/inc/FontFeaturesDialog.hxx b/cui/source/inc/FontFeaturesDialog.hxx index f542566ae2f5..6b30a33111b2 100644 --- a/cui/source/inc/FontFeaturesDialog.hxx +++ b/cui/source/inc/FontFeaturesDialog.hxx @@ -22,7 +22,7 @@ struct FontFeatureItem { FontFeatureItem(weld::Widget* pParent) : m_aFeatureCode(0) - , m_nDefault(0) + , m_nDefault(-1) , m_xBuilder(Application::CreateBuilder(pParent, "cui/ui/fontfragment.ui")) , m_xContainer(m_xBuilder->weld_widget("fontentry")) , m_xText(m_xBuilder->weld_label("label")) @@ -32,7 +32,7 @@ struct FontFeatureItem } sal_uInt32 m_aFeatureCode; - sal_uInt32 m_nDefault; + sal_Int32 m_nDefault; std::unique_ptr m_xBuilder; std::unique_ptr m_xContainer; std::unique_ptr m_xText; -- cgit