From 1bef59c318827666a2aa279ba4d1f59e53890a2b Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 11 Jan 2024 08:19:36 +0100 Subject: [PATCH] CppunitTest_sw_unowriter: turn on gb_CppunitTest_set_non_application_font_use And the same for CppunitTest_sw_uibase_wrtsh, which found two places where font fallback happens for the checkmark glyph from the Liberation Serif font, so explicitly set the font name in those cases to avoid the font fallback at a glyph level. Similar to commit dc4d7500c9d283e26d1553ce11366a217cf1f69d (Fix CppunitTest_sd_import_tests-smartart non_application_font_use, 2023-10-23). Change-Id: If72e94a61ef38f2f52e677ac989f60ccdae27cd0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161911 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- sw/CppunitTest_sw_uibase_wrtsh.mk | 4 ++++ sw/CppunitTest_sw_unowriter.mk | 4 ++++ sw/qa/uibase/wrtsh/wrtsh.cxx | 22 +++++++++++++++++++++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/sw/CppunitTest_sw_uibase_wrtsh.mk b/sw/CppunitTest_sw_uibase_wrtsh.mk index 02f54617dc22..88623b5c03fb 100644 --- a/sw/CppunitTest_sw_uibase_wrtsh.mk +++ b/sw/CppunitTest_sw_uibase_wrtsh.mk @@ -73,4 +73,8 @@ $(eval $(call gb_CppunitTest_use_uiconfigs,sw_uibase_wrtsh, \ $(eval $(call gb_CppunitTest_use_more_fonts,sw_uibase_wrtsh)) +ifneq ($(filter MORE_FONTS,$(BUILD_TYPE)),) +$(eval $(call gb_CppunitTest_set_non_application_font_use,sw_uibase_wrtsh,abort)) +endif + # vim: set noet sw=4 ts=4: diff --git a/sw/CppunitTest_sw_unowriter.mk b/sw/CppunitTest_sw_unowriter.mk index 9f1c586a0991..2babe32e19b1 100644 --- a/sw/CppunitTest_sw_unowriter.mk +++ b/sw/CppunitTest_sw_unowriter.mk @@ -76,4 +76,8 @@ $(call gb_CppunitTest_get_target,sw_unowriter): \ $(eval $(call gb_CppunitTest_use_more_fonts,sw_unowriter)) +ifneq ($(filter MORE_FONTS,$(BUILD_TYPE)),) +$(eval $(call gb_CppunitTest_set_non_application_font_use,sw_unowriter,abort)) +endif + # vim: set noet sw=4 ts=4: diff --git a/sw/qa/uibase/wrtsh/wrtsh.cxx b/sw/qa/uibase/wrtsh/wrtsh.cxx index 125a80584026..00b2d3a30ab1 100644 --- a/sw/qa/uibase/wrtsh/wrtsh.cxx +++ b/sw/qa/uibase/wrtsh/wrtsh.cxx @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -26,6 +27,7 @@ #include #include #include +#include namespace { @@ -100,6 +102,16 @@ CPPUNIT_TEST_FIXTURE(Test, testTickCheckboxContentControl) // Given a document with a checkbox (checked) content control: createSwDoc(); SwDoc* pDoc = getSwDoc(); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + + // The default Liberation Serif doesn't have a checkmark glyph, avoid font fallback. + SwView& rView = pWrtShell->GetView(); + SfxItemSetFixed aSet(rView.GetPool()); + SvxFontItem aFont(FAMILY_DONTKNOW, "DejaVu Sans", OUString(), PITCH_DONTKNOW, + RTL_TEXTENCODING_DONTKNOW, RES_CHRATR_FONT); + aSet.Put(aFont); + pWrtShell->SetAttrSet(aSet); + uno::Reference xMSF(mxComponent, uno::UNO_QUERY); uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference xText = xTextDocument->getText(); @@ -117,7 +129,6 @@ CPPUNIT_TEST_FIXTURE(Test, testTickCheckboxContentControl) xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true); // When clicking on that content control: - SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); SwTextNode* pTextNode = pWrtShell->GetCursor()->GetPointNode().GetTextNode(); SwTextAttr* pAttr = pTextNode->GetTextAttrForCharAt(0, RES_TXTATR_CONTENTCONTROL); auto pTextContentControl = static_txtattr_cast(pAttr); @@ -158,6 +169,15 @@ CPPUNIT_TEST_FIXTURE(Test, testInsertCheckboxContentControl) // When inserting a content control: SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + + // The default Liberation Serif doesn't have a checkmark glyph, avoid font fallback. + SwView& rView = pWrtShell->GetView(); + SfxItemSetFixed aSet(rView.GetPool()); + SvxFontItem aFont(FAMILY_DONTKNOW, "DejaVu Sans", OUString(), PITCH_DONTKNOW, + RTL_TEXTENCODING_DONTKNOW, RES_CHRATR_FONT); + aSet.Put(aFont); + pWrtShell->SetAttrSet(aSet); + pWrtShell->InsertContentControl(SwContentControlType::CHECKBOX); // Then make sure that the matching text attribute is added to the document model: