diff options
-rw-r--r-- | vcl/CppunitTest_vcl_unx_generic.mk | 60 | ||||
-rw-r--r-- | vcl/Module_vcl.mk | 8 | ||||
-rw-r--r-- | vcl/qa/unx/generic/generic.cxx | 60 | ||||
-rw-r--r-- | vcl/unx/generic/fontmanager/fontconfig.cxx | 16 |
4 files changed, 144 insertions, 0 deletions
diff --git a/vcl/CppunitTest_vcl_unx_generic.mk b/vcl/CppunitTest_vcl_unx_generic.mk new file mode 100644 index 000000000000..231be2aec7ec --- /dev/null +++ b/vcl/CppunitTest_vcl_unx_generic.mk @@ -0,0 +1,60 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +#************************************************************************* +# +# 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/. +# +#************************************************************************* + +$(eval $(call gb_CppunitTest_CppunitTest,vcl_unx_generic)) + +$(eval $(call gb_CppunitTest_use_externals,vcl_unx_generic,\ + boost_headers \ + harfbuzz \ +)) + +$(eval $(call gb_CppunitTest_set_include,vcl_unx_generic,\ + -I$(SRCDIR)/vcl/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_add_exception_objects,vcl_unx_generic, \ + vcl/qa/unx/generic/generic \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,vcl_unx_generic, \ + comphelper \ + cppu \ + cppuhelper \ + sal \ + subsequenttest \ + test \ + tl \ + unotest \ + utl \ + vcl \ +)) + +$(eval $(call gb_CppunitTest_use_sdk_api,vcl_unx_generic)) + +$(eval $(call gb_CppunitTest_use_ure,vcl_unx_generic)) +$(eval $(call gb_CppunitTest_use_vcl,vcl_unx_generic)) + +$(eval $(call gb_CppunitTest_use_rdb,vcl_unx_generic,services)) + +$(eval $(call gb_CppunitTest_use_custom_headers,vcl_unx_generic,\ + officecfg/registry \ +)) + +$(eval $(call gb_CppunitTest_use_configuration,vcl_unx_generic)) + +# Note that this is intentionally 'deny' and not 'abort', so we allow font fallback (we want to to +# test that code), but we want predictable results, so not considering system fonts. +$(eval $(call gb_CppunitTest_set_non_application_font_use,vcl_unx_generic,deny)) + +$(eval $(call gb_CppunitTest_use_more_fonts,vcl_unx_generic)) + +# vim: set noet sw=4 ts=4: diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk index 35c6427b4ed1..c0a624acdc95 100644 --- a/vcl/Module_vcl.mk +++ b/vcl/Module_vcl.mk @@ -293,4 +293,12 @@ $(eval $(call gb_Module_add_slowcheck_targets,vcl,\ )) endif +ifneq ($(filter MORE_FONTS,$(BUILD_TYPE)),) +ifeq ($(OS),LINUX) +$(eval $(call gb_Module_add_slowcheck_targets,vcl,\ + CppunitTest_vcl_unx_generic \ +)) +endif +endif + # vim: set noet sw=4 ts=4: diff --git a/vcl/qa/unx/generic/generic.cxx b/vcl/qa/unx/generic/generic.cxx new file mode 100644 index 000000000000..60f91266e067 --- /dev/null +++ b/vcl/qa/unx/generic/generic.cxx @@ -0,0 +1,60 @@ +/* -*- 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 <test/unoapi_test.hxx> + +#include <vcl/font.hxx> + +#include <font/FontSelectPattern.hxx> +#include <unx/fontmanager.hxx> + +using namespace ::com::sun::star; + +namespace +{ +/// Covers vcl/unx/generic/ fixes. +class Test : public UnoApiTest +{ +public: + Test() + : UnoApiTest(u"/vcl/qa/unx/generic/data/"_ustr) + { + } +}; + +CPPUNIT_TEST_FIXTURE(Test, testFontFallbackSerif) +{ + // Given a font select pattern with a font name we don't bundle and with a serif family: + vcl::Font aFont; + aFont.SetFamilyName("IBM Plex Serif"); + aFont.SetFamily(FAMILY_ROMAN); + Size aSize(0, 3840); + float fExactHeight = 3840; + bool bNonAntialias = false; + vcl::font::FontSelectPattern aPattern(aFont, aFont.GetFamilyName(), aSize, fExactHeight, + bNonAntialias); + aPattern.maTargetName = aFont.GetFamilyName(); + psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); + OUString aMissingCodes; + + // When substituting that font: + rMgr.Substitute(aPattern, aMissingCodes); + + // Then make sure we get a serif fallback: + // Without the accompanying fix in place, this test would have failed with: + // - Expected: Noto Serif (or DejaVu Serif) + // - Actual : Noto Kufi Arabic + // i.e. we got a sans fallback for a serif pattern, which is clearly poor. + CPPUNIT_ASSERT(aPattern.maSearchName.endsWith(u"Serif")); +} +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/generic/fontmanager/fontconfig.cxx b/vcl/unx/generic/fontmanager/fontconfig.cxx index 2cf486a23582..061e5256fc1c 100644 --- a/vcl/unx/generic/fontmanager/fontconfig.cxx +++ b/vcl/unx/generic/fontmanager/fontconfig.cxx @@ -984,6 +984,22 @@ void PrintFontManager::Substitute(vcl::font::FontSelectPattern &rPattern, OUStri const FcChar8* pTargetNameUtf8 = reinterpret_cast<FcChar8 const *>(aTargetName.getStr()); FcPatternAddString(pPattern, FC_FAMILY, pTargetNameUtf8); + // Try to map tools FontFamily to fontconfig FC_FAMILY. Note that FcPatternAddString() appends + // to a list, so it won't overwrite the previous FcPatternAddString(FC_FAMILY), this way we can + // express that we wanted a certain font, and otherwise a given family style. + FontFamily eFamilyType = rPattern.GetFamilyType(); + switch (eFamilyType) + { + case FAMILY_ROMAN: + FcPatternAddString(pPattern, FC_FAMILY, reinterpret_cast<const FcChar8*>("serif")); + break; + case FAMILY_SWISS: + FcPatternAddString(pPattern, FC_FAMILY, reinterpret_cast<const FcChar8*>("sans")); + break; + default: + break; + } + LanguageTag aLangTag(rPattern.meLanguage); OString aLangAttrib = mapToFontConfigLangTag(aLangTag); |