sw/layoutwriter_setup.mk                   |    5 +++++
 vcl/unx/generic/fontmanager/fontconfig.cxx |   29 ++++++++++++++++++++++++++++-
 2 files changed, 33 insertions(+), 1 deletion(-)

New commits:
commit 172270a8f04388a8f8062f672f9c3f3144a01a1f
Author:     Caolán McNamara <[email protected]>
AuthorDate: Wed Apr 27 17:26:46 2022 +0100
Commit:     Caolán McNamara <[email protected]>
CommitDate: Sun May 1 15:43:31 2022 +0200

    abort writer layout tests if a font isn't found
    
    if (the default) of --with-fonts is enabled then additionally restrict
    fontconfig to those "application" fonts so the linux ci can be used to
    safeguard that font and glyph fallback isn't in operation during the
    layout tests
    
    Change-Id: Ic7fc705827c8177b8367cf41f55cdd8ae002c1f5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133523
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/sw/layoutwriter_setup.mk b/sw/layoutwriter_setup.mk
index cd0d86b7f98c..bf05b937764e 100644
--- a/sw/layoutwriter_setup.mk
+++ b/sw/layoutwriter_setup.mk
@@ -82,6 +82,11 @@ $(eval $(call 
gb_CppunitTest_use_uiconfigs,sw_layoutwriter$(1), \
 $(call gb_CppunitTest_get_target,sw_layoutwriter$(1)): \
     $(call gb_Library_get_target,textconv_dict)
 
+# reset the LD_LIBRARY_PATH for spawned GPG processes
+$(call gb_CppunitTest_get_target,sw_layoutwriter$(1)): \
+    EXTRA_ENV_VARS := \
+        SAL_ABORT_ON_NON_APPLICATION_FONT_USE=1
+
 $(eval $(call gb_CppunitTest_use_more_fonts,sw_layoutwriter$(1)))
 
 endef
diff --git a/vcl/unx/generic/fontmanager/fontconfig.cxx 
b/vcl/unx/generic/fontmanager/fontconfig.cxx
index 4546de18162a..c8852639c7b5 100644
--- a/vcl/unx/generic/fontmanager/fontconfig.cxx
+++ b/vcl/unx/generic/fontmanager/fontconfig.cxx
@@ -45,6 +45,7 @@
 #include <unicode/uscript.h>
 #include <officecfg/Office/Common.hxx>
 #include <org/freedesktop/PackageKit/SyncDbusSessionHelper.hpp>
+#include <config_fonts.h>
 
 using namespace psp;
 
@@ -305,7 +306,12 @@ FcFontSet* FontCfgWrapper::getFontSet()
     if( !m_pFontSet )
     {
         m_pFontSet = FcFontSetCreate();
-        addFontSet( FcSetSystem );
+        bool bRestrictFontSetToApplicationFonts = false;
+#if HAVE_MORE_FONTS
+        bRestrictFontSetToApplicationFonts = 
getenv("SAL_ABORT_ON_NON_APPLICATION_FONT_USE") != nullptr;
+#endif
+        if (!bRestrictFontSetToApplicationFonts)
+            addFontSet( FcSetSystem );
         addFontSet( FcSetApplication );
 
         
std::stable_sort(m_pFontSet->fonts,m_pFontSet->fonts+m_pFontSet->nfont,SortFont());
@@ -989,10 +995,13 @@ void 
PrintFontManager::Substitute(vcl::font::FontSelectPattern &rPattern, OUStri
     LanguageTag aLangTag(rPattern.meLanguage);
     OString aLangAttrib = mapToFontConfigLangTag(aLangTag);
 
+    bool bMissingJustBullet = false;
+
     // Add required Unicode characters, if any
     if ( !rMissingCodes.isEmpty() )
     {
         FcCharSet *codePoints = FcCharSetCreate();
+        bMissingJustBullet = rMissingCodes.getLength() == 1 && 
rMissingCodes[0] == 0xb7;
         for( sal_Int32 nStrIndex = 0; nStrIndex < rMissingCodes.getLength(); )
         {
             // also handle unicode surrogates
@@ -1162,6 +1171,24 @@ void 
PrintFontManager::Substitute(vcl::font::FontSelectPattern &rPattern, OUStri
     SAL_INFO("vcl.fonts", "PrintFontManager::Substitute: replacing missing 
font: '"
                               << rPattern.maTargetName << "' with '" << 
rPattern.maSearchName
                               << "'");
+
+    static bool bAbortOnFontSubstitute = 
getenv("SAL_ABORT_ON_NON_APPLICATION_FONT_USE") != nullptr;
+    if (bAbortOnFontSubstitute && rPattern.maTargetName != 
rPattern.maSearchName)
+    {
+        SAL_INFO("vcl.fonts", "PrintFontManager::Substitute: missing font: '" 
<< rPattern.maTargetName <<
+                              "' try: " << rPattern.maSearchName << " 
instead");
+        if (bMissingJustBullet)
+        {
+            assert(rPattern.maTargetName == "Amiri Quran" || 
rPattern.maTargetName == "David CLM" ||
+                   rPattern.maTargetName == "EmojiOne Color" || 
rPattern.maTargetName == "Frank Ruehl CLM" ||
+                   rPattern.maTargetName == "KacstBook" || 
rPattern.maTargetName == "KacstOffice");
+            // These fonts exist in "more_fonts", but have no U+00B7 MIDDLE DOT
+            // so will always glyph fallback on measuring mnBulletOffset in
+            // ImplFontMetricData::ImplInitTextLineSize
+            return;
+        }
+        std::abort();
+    }
 }
 
 FontConfigFontOptions::~FontConfigFontOptions()

Reply via email to