diff options
Diffstat (limited to 'cui/source')
-rw-r--r-- | cui/source/dialogs/FontFeaturesDialog.cxx | 13 | ||||
-rwxr-xr-x | cui/source/inc/FontFeatures.hxx | 17 | ||||
-rw-r--r-- | cui/source/inc/chardlg.hxx | 4 | ||||
-rw-r--r-- | cui/source/tabpages/chardlg.cxx | 34 | ||||
-rwxr-xr-x | cui/source/util/FontFeatures.cxx | 30 |
5 files changed, 87 insertions, 11 deletions
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 |