summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorDeb Barkley-Yeung <dbarkleyyeung@gmail.com>2021-06-27 23:28:50 -0700
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-07-16 09:02:28 +0200
commit44db9f08077f388306ef0bf7277c93a1e5cd89b8 (patch)
tree7deae22af1dbde827b82b12289db636b6d0b607f /cui
parentfce76110e02409b67ad977ae0077adf55ca58065 (diff)
tdf#139654 Font feature sensativity
Disable font preview's "Features..." button if there are no features Change-Id: Ibcf6b34abe55818a3b938a65f4fd720ed724c8ee Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118965 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'cui')
-rw-r--r--cui/Library_cui.mk1
-rw-r--r--cui/source/dialogs/FontFeaturesDialog.cxx13
-rwxr-xr-xcui/source/inc/FontFeatures.hxx17
-rw-r--r--cui/source/inc/chardlg.hxx4
-rw-r--r--cui/source/tabpages/chardlg.cxx34
-rwxr-xr-xcui/source/util/FontFeatures.cxx30
6 files changed, 88 insertions, 11 deletions
diff --git a/cui/Library_cui.mk b/cui/Library_cui.mk
index bc4f1e50c139..fb3546b4e9ad 100644
--- a/cui/Library_cui.mk
+++ b/cui/Library_cui.mk
@@ -230,6 +230,7 @@ $(eval $(call gb_Library_add_exception_objects,cui,\
cui/source/tabpages/tpshadow \
cui/source/tabpages/tptrans \
cui/source/tabpages/transfrm \
+ cui/source/util/FontFeatures \
))
# vim: set noet sw=4 ts=4:
diff --git a/cui/source/dialogs/FontFeaturesDialog.cxx b/cui/source/dialogs/FontFeaturesDialog.cxx
index aaa9eb86136a..4735de194255 100644
--- a/cui/source/dialogs/FontFeaturesDialog.cxx
+++ b/cui/source/dialogs/FontFeaturesDialog.cxx
@@ -11,7 +11,7 @@
#include <FontFeaturesDialog.hxx>
#include <rtl/ustrbuf.hxx>
#include <vcl/font/FeatureParser.hxx>
-#include <vcl/virdev.hxx>
+#include <FontFeatures.hxx>
#include <svtools/colorcfg.hxx>
#include <unordered_set>
@@ -51,16 +51,7 @@ void FontFeaturesDialog::initialize()
{
ScopedVclPtrInstance<VirtualDevice> aVDev(*Application::GetDefaultDevice(),
DeviceFormat::DEFAULT, DeviceFormat::DEFAULT);
- aVDev->SetOutputSizePixel(Size(10, 10));
-
- vcl::Font aFont = aVDev->GetFont();
- aFont.SetFamilyName(m_sFontName);
- aVDev->SetFont(aFont);
-
- std::vector<vcl::font::Feature> rFontFeatures;
-
- if (!aVDev->GetFontFeatures(rFontFeatures))
- return;
+ std::vector<vcl::font::Feature> rFontFeatures = getFontFeatureList(m_sFontName, *aVDev);
std::unordered_set<sal_uInt32> aDoneFeatures;
std::vector<vcl::font::Feature> rFilteredFontFeatures;
diff --git a/cui/source/inc/FontFeatures.hxx b/cui/source/inc/FontFeatures.hxx
new file mode 100755
index 000000000000..f16c11628143
--- /dev/null
+++ b/cui/source/inc/FontFeatures.hxx
@@ -0,0 +1,17 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+#pragma once
+
+#include <vector>
+#include <vcl/font/Feature.hxx>
+#include <vcl/virdev.hxx>
+
+std::vector<vcl::font::Feature> getFontFeatureList(OUString const& rFontName, VirtualDevice& rVDev);
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file
diff --git a/cui/source/inc/chardlg.hxx b/cui/source/inc/chardlg.hxx
index 281a86b4d826..be4db989b57d 100644
--- a/cui/source/inc/chardlg.hxx
+++ b/cui/source/inc/chardlg.hxx
@@ -101,11 +101,15 @@ private:
std::unique_ptr<weld::Label> m_xCTLFontTypeFT;
std::unique_ptr<weld::Button> m_xCTLFontFeaturesButton;
+ //for getting FontFeatures
+ ScopedVclPtrInstance<VirtualDevice> m_xVDev;
+
void Initialize();
const FontList* GetFontList() const;
void UpdatePreview_Impl();
void FillStyleBox_Impl(const weld::Widget& rBox);
void FillSizeBox_Impl(const weld::Widget& rBox);
+ void EnableFeatureButton(const weld::Widget& rNameBox);
enum LanguageGroup
{
diff --git a/cui/source/tabpages/chardlg.cxx b/cui/source/tabpages/chardlg.cxx
index 0bb9460745dd..a829ace12795 100644
--- a/cui/source/tabpages/chardlg.cxx
+++ b/cui/source/tabpages/chardlg.cxx
@@ -56,6 +56,7 @@
#include <twolines.hrc>
#include <svl/intitem.hxx>
#include <svx/flagsdef.hxx>
+#include <FontFeatures.hxx>
#include <FontFeaturesDialog.hxx>
#include <sal/log.hxx>
#include <osl/diagnose.h>
@@ -209,6 +210,7 @@ SvxCharNamePage::SvxCharNamePage(weld::Container* pPage, weld::DialogController*
, m_xCTLFontLanguageLB(new SvxLanguageBox(m_xBuilder->weld_combo_box("ctllanglb")))
, m_xCTLFontTypeFT(m_xBuilder->weld_label("ctlfontinfo"))
, m_xCTLFontFeaturesButton(m_xBuilder->weld_button("ctl_features_button"))
+ , m_xVDev(*Application::GetDefaultDevice(), DeviceFormat::DEFAULT, DeviceFormat::DEFAULT)
{
m_xPreviewWin.reset(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWin));
#ifdef IOS
@@ -478,6 +480,35 @@ void SvxCharNamePage::UpdatePreview_Impl()
m_aPreviewWin.Invalidate();
}
+void SvxCharNamePage::EnableFeatureButton(const weld::Widget& rNameBox)
+{
+ OUString sFontName;
+ weld::Button* pButton= nullptr;
+ if (m_xWestFontNameLB.get() == &rNameBox)
+ {
+ sFontName = m_xWestFontNameLB->get_active_text();
+ pButton= m_xWestFontFeaturesButton.get();
+ }
+ else if (m_xEastFontNameLB.get() == &rNameBox)
+ {
+ sFontName = m_xEastFontNameLB->get_active_text();
+ pButton=m_xEastFontFeaturesButton.get();
+ }
+ else if (m_xCTLFontNameLB.get() == &rNameBox)
+ {
+ sFontName = m_xCTLFontNameLB->get_active_text();
+ pButton= m_xCTLFontFeaturesButton.get();
+ }
+ else
+ {
+ SAL_WARN( "cui.tabpages", "invalid font name box" );
+ return;
+ }
+
+ bool bEnable = !getFontFeatureList(sFontName, *m_xVDev).empty();
+
+ pButton->set_sensitive(bEnable);
+}
void SvxCharNamePage::FillStyleBox_Impl(const weld::Widget& rNameBox)
{
@@ -800,6 +831,8 @@ void SvxCharNamePage::Reset_Impl( const SfxItemSet& rSet, LanguageGroup eLangGrp
break;
}
+ EnableFeatureButton(*pNameBox);
+
// save these settings
pNameBox->save_value();
pStyleBox->save_value();
@@ -1145,6 +1178,7 @@ void SvxCharNamePage::FontModifyHdl_Impl(const weld::Widget& rNameBox)
{
FillStyleBox_Impl(rNameBox);
FillSizeBox_Impl(rNameBox);
+ EnableFeatureButton(rNameBox);
}
}
diff --git a/cui/source/util/FontFeatures.cxx b/cui/source/util/FontFeatures.cxx
new file mode 100755
index 000000000000..f50980aabfa7
--- /dev/null
+++ b/cui/source/util/FontFeatures.cxx
@@ -0,0 +1,30 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#include <FontFeatures.hxx>
+
+std::vector<vcl::font::Feature> getFontFeatureList(OUString const& rFontName, VirtualDevice& rVDev)
+{
+ rVDev.SetOutputSizePixel(Size(10, 10));
+
+ vcl::Font aFont = rVDev.GetFont();
+ aFont.SetFamilyName(rFontName);
+ rVDev.SetFont(aFont);
+
+ std::vector<vcl::font::Feature> vFontFeatures;
+
+ if (!rVDev.GetFontFeatures(vFontFeatures))
+ {
+ vFontFeatures.clear();
+ }
+
+ return vFontFeatures;
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file