cui/source/inc/chardlg.hxx | 2 cui/source/tabpages/chardlg.cxx | 59 +++++++++++++++++++++-- cui/uiconfig/ui/positionpage.ui | 50 +++++++++++++++++++- include/editeng/unoprnms.hxx | 1 include/editeng/unotext.hxx | 3 - sd/qa/unit/export-tests.cxx | 100 ++++++++++++++++++++++++++++++++++++++++ sd/source/core/drawdoc4.cxx | 4 + sd/source/core/stlpool.cxx | 13 +++++ 8 files changed, 225 insertions(+), 7 deletions(-)
New commits: commit 059b717535bf48243b7a63e309d6e22d7b2fcd1b Author: Khaled Hosny <[email protected]> AuthorDate: Mon Mar 2 02:02:30 2026 +0200 Commit: Khaled Hosny <[email protected]> CommitDate: Mon Mar 2 21:46:01 2026 +0100 tdf#153368: Support optical size for variable fonts, part 7 Enable by default for new documents in Draw/Impress. Change-Id: I07d306c744703b01958e8bb86101e112c8ad9b0c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200741 Tested-by: Jenkins Reviewed-by: Khaled Hosny <[email protected]> diff --git a/include/editeng/unoprnms.hxx b/include/editeng/unoprnms.hxx index 33662cf3ac9f..b5d354d695bf 100644 --- a/include/editeng/unoprnms.hxx +++ b/include/editeng/unoprnms.hxx @@ -319,6 +319,7 @@ inline constexpr OUString UNO_NAME_EDIT_CHAR_FONTCHARSET = u"CharFontCharSet"_us inline constexpr OUString UNO_NAME_EDIT_CHAR_FONTPITCH = u"CharFontPitch"_ustr; inline constexpr OUString UNO_NAME_EDIT_CHAR_POSTURE = u"CharPosture"_ustr; inline constexpr OUString UNO_NAME_EDIT_CHAR_WEIGHT = u"CharWeight"_ustr; +inline constexpr OUString UNO_NAME_EDIT_CHAR_OPTICALSIZING = u"CharOpticalSizing"_ustr; inline constexpr OUString UNO_NAME_EDIT_CHAR_LOCALE = u"CharLocale"_ustr; inline constexpr OUString UNO_NAME_EDIT_CHAR_HEIGHT_ASIAN = u"CharHeightAsian"_ustr; diff --git a/include/editeng/unotext.hxx b/include/editeng/unotext.hxx index 37e82293dbb3..65824411a0bd 100644 --- a/include/editeng/unotext.hxx +++ b/include/editeng/unotext.hxx @@ -137,7 +137,8 @@ struct SfxItemPropertyMapEntry; { UNO_NAME_EDIT_CHAR_RUBY_TEXT, EE_CHAR_RUBY, ::cppu::UnoType<OUString>::get(), 0, MID_RUBY_TEXT }, \ { UNO_NAME_EDIT_CHAR_RUBY_ADJUST, EE_CHAR_RUBY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_RUBY_ADJUST }, \ { UNO_NAME_EDIT_CHAR_RUBY_POSITION, EE_CHAR_RUBY, ::cppu::UnoType<sal_Int16>::get(), 0, MID_RUBY_POSITION }, \ - { UNO_NAME_EDIT_CHAR_SCRIPT_HINT, EE_CHAR_SCRIPT_HINT, ::cppu::UnoType<sal_Int16>::get(), 0, MID_SCRIPTHINT } + { UNO_NAME_EDIT_CHAR_SCRIPT_HINT, EE_CHAR_SCRIPT_HINT, ::cppu::UnoType<sal_Int16>::get(), 0, MID_SCRIPTHINT }, \ + { UNO_NAME_EDIT_CHAR_OPTICALSIZING, EE_CHAR_OPTICALSIZING, ::cppu::UnoType<bool>::get(), 0, 0 } #define SVX_UNOEDIT_FONT_PROPERTIES \ diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index 386b42fcdf3f..5c495533e60d 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -2558,6 +2558,106 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testTableBordersTransparancy) Color(ColorTransparency, aBorderLine.Color)); } +// CharOpticalSizing should be enabled by default for new documents +CPPUNIT_TEST_FIXTURE(SdExportTest, testOpticalSizing1) +{ + createSdImpressDoc(); + + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<drawing::XDrawPages> xDrawPages = xDrawPagesSupplier->getDrawPages(); + uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPages->insertNewByIndex(0), + uno::UNO_SET_THROW); + uno::Reference<drawing::XShapes> xShapes(xDrawPage, uno::UNO_QUERY_THROW); + + uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY); + uno::Reference<drawing::XShape> xShape( + xFactory->createInstance(u"com.sun.star.drawing.TextShape"_ustr), uno::UNO_QUERY_THROW); + xShapes->add(xShape); + + uno::Reference<text::XText> xText(xShape, uno::UNO_QUERY_THROW); + xText->setString(u"test"_ustr); + + { + // It should be true by default for new documents + uno::Reference<beans::XPropertySet> xProps(xShape, uno::UNO_QUERY_THROW); + uno::Reference<text::XTextRange> const xParagraph(getParagraphFromShape(0, xProps)); + uno::Reference<text::XTextRange> xRun(getRunFromParagraph(0, xParagraph)); + uno::Reference<beans::XPropertySet> xRunProps(xRun, uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(true, + xRunProps->getPropertyValue(u"CharOpticalSizing"_ustr).get<bool>()); + + // and it should survive save-and-reload + saveAndReload(TestFilter::ODP); + uno::Reference<beans::XPropertySet> xProps2(getShapeFromPage(0, 1)); + uno::Reference<text::XTextRange> const xParagraph2(getParagraphFromShape(0, xProps2)); + uno::Reference<text::XTextRange> xRun2(getRunFromParagraph(0, xParagraph2)); + uno::Reference<beans::XPropertySet> xRunProps2(xRun2, uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(true, + xRunProps2->getPropertyValue(u"CharOpticalSizing"_ustr).get<bool>()); + } + + { + // Setting it manually should set it in contents + uno::Reference<beans::XPropertySet> xProps(getShapeFromPage(0, 1)); + uno::Reference<text::XTextRange> const xParagraph(getParagraphFromShape(0, xProps)); + uno::Reference<text::XTextRange> xRun(getRunFromParagraph(0, xParagraph)); + uno::Reference<beans::XPropertySet> xRunProps(xRun, uno::UNO_QUERY_THROW); + xRunProps->setPropertyValue(u"CharOpticalSizing"_ustr, uno::Any(true)); + save(TestFilter::ODP); + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); + assertXPath(pXmlDoc, + "//style:style/style:text-properties[@loext:font-optical-sizing='auto']", 1); + + // and it should survive save-and-reload + saveAndReload(TestFilter::ODP); + uno::Reference<beans::XPropertySet> xProps2(getShapeFromPage(0, 1)); + uno::Reference<text::XTextRange> const xParagraph2(getParagraphFromShape(0, xProps2)); + uno::Reference<text::XTextRange> xRun2(getRunFromParagraph(0, xParagraph2)); + uno::Reference<beans::XPropertySet> xRunProps2(xRun2, uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(true, + xRunProps2->getPropertyValue(u"CharOpticalSizing"_ustr).get<bool>()); + pXmlDoc = parseExport(u"content.xml"_ustr); + assertXPath(pXmlDoc, + "//style:style/style:text-properties[@loext:font-optical-sizing='auto']", 1); + } + + { + // It can also be disabled + uno::Reference<beans::XPropertySet> xProps(getShapeFromPage(0, 1)); + uno::Reference<text::XTextRange> const xParagraph(getParagraphFromShape(0, xProps)); + uno::Reference<text::XTextRange> xRun(getRunFromParagraph(0, xParagraph)); + uno::Reference<beans::XPropertySet> xRunProps(xRun, uno::UNO_QUERY_THROW); + xRunProps->setPropertyValue(u"CharOpticalSizing"_ustr, uno::Any(false)); + save(TestFilter::ODP); + xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); + assertXPath(pXmlDoc, + "//style:style/style:text-properties[@loext:font-optical-sizing='none']", 1); + + // and it should survive save-and-reload + saveAndReload(TestFilter::ODP); + uno::Reference<beans::XPropertySet> xProps2(getShapeFromPage(0, 1)); + uno::Reference<text::XTextRange> const xParagraph2(getParagraphFromShape(0, xProps2)); + uno::Reference<text::XTextRange> xRun2(getRunFromParagraph(0, xParagraph2)); + uno::Reference<beans::XPropertySet> xRunProps2(xRun2, uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(false, + xRunProps2->getPropertyValue(u"CharOpticalSizing"_ustr).get<bool>()); + pXmlDoc = parseExport(u"content.xml"_ustr); + assertXPath(pXmlDoc, + "//style:style/style:text-properties[@loext:font-optical-sizing='none']", 1); + } +} + +// CharOpticalSizing should be disabled by default for old documents +CPPUNIT_TEST_FIXTURE(SdExportTest, testOpticalSizing2) +{ + createSdImpressDoc("odp/transparent_background.odp"); + uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(1, 0)); + uno::Reference<text::XTextRange> const xParagraph(getParagraphFromShape(0, xShape)); + uno::Reference<text::XTextRange> xRun(getRunFromParagraph(0, xParagraph)); + uno::Reference<beans::XPropertySet> xRunProps(xRun, uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(false, xRunProps->getPropertyValue(u"CharOpticalSizing"_ustr).get<bool>()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/core/drawdoc4.cxx b/sd/source/core/drawdoc4.cxx index 772507eb04b9..9401c3277e5b 100644 --- a/sd/source/core/drawdoc4.cxx +++ b/sd/source/core/drawdoc4.cxx @@ -78,6 +78,7 @@ #include <editeng/udlnitem.hxx> #include <editeng/contouritem.hxx> #include <editeng/emphasismarkitem.hxx> +#include <editeng/opticalsizingitem.hxx> #include <editeng/fontitem.hxx> #include <editeng/shdditem.hxx> #include <editeng/cmapitem.hxx> @@ -275,6 +276,9 @@ void SdDrawDocument::CreateLayoutTemplates() // #i16874# enable kerning by default but only for new documents rISet.Put(SvxAutoKernItem(true, EE_CHAR_PAIRKERNING)); + // tdf#153368 Optical sizing by default but only for new documents + rISet.Put(SvxOpticalSizingItem(true, EE_CHAR_OPTICALSIZING)); + // Bullet // BulletItem and BulletFont for title and outline SvxBulletItem aBulletItem(EE_PARA_BULLET); diff --git a/sd/source/core/stlpool.cxx b/sd/source/core/stlpool.cxx index 7316a8f6a547..e85e60a89787 100644 --- a/sd/source/core/stlpool.cxx +++ b/sd/source/core/stlpool.cxx @@ -41,6 +41,7 @@ #include <editeng/ulspitem.hxx> #include <editeng/numitem.hxx> #include <editeng/cmapitem.hxx> +#include <editeng/opticalsizingitem.hxx> #include <svl/hint.hxx> #include <editeng/charreliefitem.hxx> #include <editeng/emphasismarkitem.hxx> @@ -249,6 +250,8 @@ void SdStyleSheetPool::CreateLayoutStyleSheets(std::u16string_view rLayoutName, rSet.Put( makeSdrTextAutoGrowHeightItem(false) ); // #i16874# enable kerning by default but only for new documents rSet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) ); + // tdf#153368 Optical sizing by default but only for new documents + rSet.Put(SvxOpticalSizingItem(true, EE_CHAR_OPTICALSIZING)); vcl::Font f( GetBulletFont() ); PutNumBulletItem( pSheet, f ); @@ -359,6 +362,8 @@ void SdStyleSheetPool::CreateLayoutStyleSheets(std::u16string_view rLayoutName, rTitleSet.Put( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) ); // #i16874# enable kerning by default but only for new documents rTitleSet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) ); + // tdf#153368 Optical sizing by default but only for new documents + rTitleSet.Put(SvxOpticalSizingItem(true, EE_CHAR_OPTICALSIZING)); aBulletFont.SetFontSize(Size(0,1552)); // 44 pt PutNumBulletItem( pSheet, aBulletFont ); @@ -405,6 +410,8 @@ void SdStyleSheetPool::CreateLayoutStyleSheets(std::u16string_view rLayoutName, rSubtitleSet.Put( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) ); // #i16874# enable kerning by default but only for new documents rSubtitleSet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) ); + // tdf#153368 Optical sizing by default but only for new documents + rSubtitleSet.Put(SvxOpticalSizingItem(true, EE_CHAR_OPTICALSIZING)); aSvxLRSpaceItem.SetTextLeft(SvxIndentValue::zero()); rSubtitleSet.Put(aSvxLRSpaceItem); @@ -454,6 +461,8 @@ void SdStyleSheetPool::CreateLayoutStyleSheets(std::u16string_view rLayoutName, SvxIndentValue::twips(-600.0), EE_PARA_LRSPACE)); // #i16874# enable kerning by default but only for new documents rNotesSet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) ); + // tdf#153368 Optical sizing by default but only for new documents + rNotesSet.Put(SvxOpticalSizingItem(true, EE_CHAR_OPTICALSIZING)); /* #i35937# */ @@ -479,6 +488,8 @@ void SdStyleSheetPool::CreateLayoutStyleSheets(std::u16string_view rLayoutName, // #i16874# enable kerning by default but only for new documents rBackgroundObjectsSet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) ); rBackgroundObjectsSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_BLOCK)); + // tdf#153368 Optical sizing by default but only for new documents + rBackgroundObjectsSet.Put(SvxOpticalSizingItem(true, EE_CHAR_OPTICALSIZING)); } /************************************************************************** @@ -498,6 +509,8 @@ void SdStyleSheetPool::CreateLayoutStyleSheets(std::u16string_view rLayoutName, rBackgroundSet.Put(XFillStyleItem(drawing::FillStyle_NONE)); // #i16874# enable kerning by default but only for new documents rBackgroundSet.Put( SvxAutoKernItem( true, EE_CHAR_PAIRKERNING ) ); + // tdf#153368 Optical sizing by default but only for new documents + rBackgroundSet.Put(SvxOpticalSizingItem(true, EE_CHAR_OPTICALSIZING)); } DBG_ASSERT( !bCheck || !bCreated, "missing layout style sheets detected!" ); commit 3fb0c4e15f66e383c6fe2e44eeb6b3a3b64b2721 Author: Khaled Hosny <[email protected]> AuthorDate: Mon Mar 2 02:02:27 2026 +0200 Commit: Khaled Hosny <[email protected]> CommitDate: Mon Mar 2 21:45:51 2026 +0100 tdf#153368: Support optical size for variable fonts, part 6 Add Optical Font Sizing checkbox to the Position page of Character dialog. I’m not sure if this is the best place, but I have no better idea. Change-Id: Ice019da856dbd9f1195941706f26b175bb931c97 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200625 Tested-by: Jenkins Reviewed-by: Khaled Hosny <[email protected]> diff --git a/cui/source/inc/chardlg.hxx b/cui/source/inc/chardlg.hxx index e3f1240774f6..ef2b99761410 100644 --- a/cui/source/inc/chardlg.hxx +++ b/cui/source/inc/chardlg.hxx @@ -272,6 +272,7 @@ private: std::unique_ptr<weld::MetricSpinButton> m_xKerningMF; std::unique_ptr<weld::CheckButton> m_xPairKerningBtn; std::unique_ptr<weld::CheckButton> m_xNoHyphenationBtn; + std::unique_ptr<weld::CheckButton> m_xOpticalSizingBtn; void Initialize(); void UpdatePreview_Impl( sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc ); @@ -284,6 +285,7 @@ private: DECL_LINK(KerningModifyHdl_Impl, weld::MetricSpinButton&, void); DECL_LINK(ValueChangedHdl_Impl, weld::MetricSpinButton&, void); DECL_LINK(ScaleWidthModifyHdl_Impl, weld::MetricSpinButton&, void); + DECL_LINK(OpticalSizingHdl_Impl, weld::Toggleable&, void); void FontModifyHdl_Impl(); public: diff --git a/cui/source/tabpages/chardlg.cxx b/cui/source/tabpages/chardlg.cxx index a92ae65f5ffa..a67d3af2a375 100644 --- a/cui/source/tabpages/chardlg.cxx +++ b/cui/source/tabpages/chardlg.cxx @@ -44,6 +44,7 @@ #include <editeng/autokernitem.hxx> #include <editeng/nhypitem.hxx> #include <editeng/colritem.hxx> +#include <editeng/opticalsizingitem.hxx> #include <dialmgr.hxx> #include <sfx2/htmlmode.hxx> #include <svx/cuicharmap.hxx> @@ -78,7 +79,8 @@ const WhichRangesContainer SvxCharNamePage::pNameRanges(svl::Items< SID_ATTR_CHAR_COLOR, SID_ATTR_CHAR_COLOR, SID_ATTR_CHAR_LANGUAGE, SID_ATTR_CHAR_LANGUAGE, SID_ATTR_CHAR_CJK_FONT, SID_ATTR_CHAR_CJK_WEIGHT, - SID_ATTR_CHAR_CTL_FONT, SID_ATTR_CHAR_CTL_WEIGHT + SID_ATTR_CHAR_CTL_FONT, SID_ATTR_CHAR_CTL_WEIGHT, + SID_ATTR_CHAR_OPTICAL_SIZING, SID_ATTR_CHAR_OPTICAL_SIZING >); const WhichRangesContainer SvxCharEffectsPage::pEffectsRanges(svl::Items< @@ -375,7 +377,8 @@ namespace const SvxLanguageBox* _pLanguageLB, const FontList* _pFontList, sal_uInt16 _nFontWhich, - sal_uInt16 _nFontHeightWhich) + sal_uInt16 _nFontHeightWhich, + sal_uInt16 _nOpticalSizingWhich) { Size aSize = _rFont.GetFontSize(); aSize.setWidth( 0 ); @@ -433,6 +436,10 @@ namespace _rFont.SetWeight( aFontMetrics.GetWeightMaybeAskConfig() ); _rFont.SetItalic( aFontMetrics.GetItalicMaybeAskConfig() ); _rFont.SetFontSize( aFontMetrics.GetFontSize() ); + bool bOpticalSizing = false; + if (_pPage->GetItemSet().GetItemState(_nOpticalSizingWhich) >= SfxItemState::DEFAULT) + bOpticalSizing = static_cast<const SvxOpticalSizingItem&>(_pPage->GetItemSet().Get(_nOpticalSizingWhich)).GetValue(); + _rFont.SetOpticalSizing(bOpticalSizing); return aFontMetrics; } @@ -450,21 +457,21 @@ void SvxCharNamePage::UpdatePreview_Impl() FontMetric aWestFontMetric = calcFontMetrics(rFont, this, m_xWestFontNameLB.get(), m_xWestFontStyleLB.get(), m_xWestFontSizeLB.get(), m_xWestFontLanguageLB.get(), &rFontList, GetWhich(SID_ATTR_CHAR_FONT), - GetWhich(SID_ATTR_CHAR_FONTHEIGHT)); + GetWhich(SID_ATTR_CHAR_FONTHEIGHT), GetWhich(SID_ATTR_CHAR_OPTICAL_SIZING)); m_xWestFontTypeFT->set_label(rFontList.GetFontMapText(aWestFontMetric)); FontMetric aEastFontMetric = calcFontMetrics(rCJKFont, this, m_xEastFontNameLB.get(), m_xEastFontStyleLB.get(), m_xEastFontSizeLB.get(), m_xEastFontLanguageLB.get(), &rFontList, GetWhich(SID_ATTR_CHAR_CJK_FONT), - GetWhich(SID_ATTR_CHAR_CJK_FONTHEIGHT)); + GetWhich(SID_ATTR_CHAR_CJK_FONTHEIGHT), GetWhich(SID_ATTR_CHAR_OPTICAL_SIZING)); m_xEastFontTypeFT->set_label(rFontList.GetFontMapText(aEastFontMetric)); FontMetric aCTLFontMetric = calcFontMetrics(rCTLFont, this, m_xCTLFontNameLB.get(), m_xCTLFontStyleLB.get(), m_xCTLFontSizeLB.get(), m_xCTLFontLanguageLB.get(), &rFontList, GetWhich(SID_ATTR_CHAR_CTL_FONT), - GetWhich(SID_ATTR_CHAR_CTL_FONTHEIGHT)); + GetWhich(SID_ATTR_CHAR_CTL_FONTHEIGHT), GetWhich(SID_ATTR_CHAR_OPTICAL_SIZING)); m_xCTLFontTypeFT->set_label(rFontList.GetFontMapText(aCTLFontMetric)); @@ -1243,6 +1250,7 @@ bool SvxCharNamePage::FillItemSet( SfxItemSet* rSet ) bool bModified = FillItemSet_Impl( *rSet, Western ); bModified |= FillItemSet_Impl( *rSet, Asian ); bModified |= FillItemSet_Impl( *rSet, Ctl ); + return bModified; } @@ -2445,6 +2453,7 @@ SvxCharPositionPage::SvxCharPositionPage(weld::Container* pPage, weld::DialogCon , m_xKerningMF(m_xBuilder->weld_metric_spin_button(u"kerningsb"_ustr, FieldUnit::POINT)) , m_xPairKerningBtn(m_xBuilder->weld_check_button(u"pairkerning"_ustr)) , m_xNoHyphenationBtn(m_xBuilder->weld_check_button(u"nohyphenation"_ustr)) + , m_xOpticalSizingBtn(m_xBuilder->weld_check_button(u"opticalsizing"_ustr)) { m_xPreviewWin.reset(new weld::CustomWeld(*m_xBuilder, u"preview"_ustr, m_aPreviewWin)); #ifdef IOS @@ -2488,6 +2497,7 @@ void SvxCharPositionPage::Initialize() m_xFitToLineCB->connect_toggled(LINK(this, SvxCharPositionPage, FitToLineHdl_Impl)); m_xKerningMF->connect_value_changed(LINK(this, SvxCharPositionPage, KerningModifyHdl_Impl)); m_xScaleWidthMF->connect_value_changed(LINK(this, SvxCharPositionPage, ScaleWidthModifyHdl_Impl)); + m_xOpticalSizingBtn->connect_toggled(LINK(this, SvxCharPositionPage, OpticalSizingHdl_Impl)); } void SvxCharPositionPage::UpdatePreview_Impl( sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc ) @@ -2641,6 +2651,20 @@ IMPL_LINK_NOARG(SvxCharPositionPage, ScaleWidthModifyHdl_Impl, weld::MetricSpinB m_aPreviewWin.SetFontWidthScale(sal_uInt16(m_xScaleWidthMF->get_value(FieldUnit::PERCENT))); } +IMPL_LINK_NOARG(SvxCharPositionPage, OpticalSizingHdl_Impl, weld::Toggleable&, void) +{ + SvxFont& rFont = GetPreviewFont(); + SvxFont& rCJKFont = GetPreviewCJKFont(); + SvxFont& rCTLFont = GetPreviewCTLFont(); + + bool bOpticalSizing = m_xOpticalSizingBtn->get_active(); + rFont.SetOpticalSizing(bOpticalSizing); + rCJKFont.SetOpticalSizing(bOpticalSizing); + rCTLFont.SetOpticalSizing(bOpticalSizing); + + m_aPreviewWin.Invalidate(); +} + DeactivateRC SvxCharPositionPage::DeactivatePage( SfxItemSet* _pSet ) { if ( _pSet ) @@ -2820,6 +2844,20 @@ void SvxCharPositionPage::Reset( const SfxItemSet* rSet ) else m_xNoHyphenationBtn->set_active(false); + // Optical Sizing + nWhich = GetWhich(SID_ATTR_CHAR_OPTICAL_SIZING); + if (rSet->GetItemState(nWhich) >= SfxItemState::DEFAULT) + { + const SvxOpticalSizingItem& rItem = static_cast<const SvxOpticalSizingItem&>(rSet->Get(nWhich)); + m_xOpticalSizingBtn->set_active(rItem.GetValue()); + } + else + m_xOpticalSizingBtn->set_active(false); + bool bOpticalSizing = m_xOpticalSizingBtn->get_active(); + rFont.SetOpticalSizing(bOpticalSizing); + rCJKFont.SetOpticalSizing(bOpticalSizing); + rCTLFont.SetOpticalSizing(bOpticalSizing); + // Scale Width nWhich = GetWhich( SID_ATTR_CHAR_SCALEWIDTH ); if ( rSet->GetItemState( nWhich ) >= SfxItemState::DEFAULT ) @@ -2899,6 +2937,7 @@ void SvxCharPositionPage::ChangesApplied() m_xKerningMF->save_value(); m_xPairKerningBtn->save_state(); m_xNoHyphenationBtn->save_state(); + m_xOpticalSizingBtn->save_state(); } bool SvxCharPositionPage::FillItemSet( SfxItemSet* rSet ) @@ -3000,6 +3039,16 @@ bool SvxCharPositionPage::FillItemSet( SfxItemSet* rSet ) else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) ) rSet->InvalidateItem(nWhich); + // Optical Sizing + nWhich = GetWhich(SID_ATTR_CHAR_OPTICAL_SIZING); + if (m_xOpticalSizingBtn->get_state_changed_from_saved()) + { + rSet->Put(SvxOpticalSizingItem(m_xOpticalSizingBtn->get_active(), GetWhich(SID_ATTR_CHAR_OPTICAL_SIZING))); + bModified = true; + } + else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false)) + rSet->InvalidateItem(nWhich); + // Scale Width nWhich = GetWhich( SID_ATTR_CHAR_SCALEWIDTH ); if (m_xScaleWidthMF->get_value_changed_from_saved()) diff --git a/cui/uiconfig/ui/positionpage.ui b/cui/uiconfig/ui/positionpage.ui index a959c7da7ee0..ad8569eeb696 100644 --- a/cui/uiconfig/ui/positionpage.ui +++ b/cui/uiconfig/ui/positionpage.ui @@ -499,6 +499,54 @@ <property name="position">3</property> </packing> </child> + <child> + <object class="GtkFrame" id="frame9"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label-xalign">0</property> + <property name="shadow-type">none</property> + <child> + <object class="GtkBox" id="box9"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="margin-start">12</property> + <property name="margin-top">6</property> + <property name="spacing">12</property> + <child> + <object class="GtkCheckButton" id="opticalsizing"> + <property name="label" translatable="yes" context="positionpage|opticalsizing">Auto</property> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">False</property> + <property name="tooltip-text" translatable="yes" context="positionpage|opticalsizing">Enable optical font sizing based on font's point size for fonts that support it</property> + <property name="use-underline">True</property> + <property name="draw-indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="label25"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes" context="positionpage|label25">Optical Font Sizing</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">4</property> + </packing> + </child> <child> <object class="GtkScrolledWindow"> <property name="visible">True</property> @@ -534,7 +582,7 @@ <property name="expand">False</property> <property name="fill">True</property> <property name="pack-type">end</property> - <property name="position">4</property> + <property name="position">5</property> </packing> </child> </object>
