summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorKhaled Hosny <khaled@aliftype.com>2022-08-23 14:22:23 +0200
committerTomaž Vajngerl <quikee@gmail.com>2022-08-23 16:59:56 +0200
commit783f166793915a1c5a008de7142f773ad3898683 (patch)
tree288eacbc84db0b7bd6563585533a66aa8056fcec /cui
parent31cb5b5538b9fd91dafb067ce961f2540555ad2b (diff)
tdf#127423: Allow disabling default features in Font Features dialog
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 <quikee@gmail.com>
Diffstat (limited to 'cui')
-rw-r--r--cui/source/dialogs/FontFeaturesDialog.cxx11
-rw-r--r--cui/source/inc/FontFeaturesDialog.hxx4
2 files changed, 9 insertions, 6 deletions
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<vcl::font::Feature> 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<vcl::font::Feature> 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<weld::Builder> m_xBuilder;
std::unique_ptr<weld::Widget> m_xContainer;
std::unique_ptr<weld::Label> m_xText;