vcl/unx/generic/fontmanager/fontconfig.cxx |   10 ++++++++++
 1 file changed, 10 insertions(+)

New commits:
commit 5ca5acdd6e12fec08927743b60899100bc89af4d
Author:     Khaled Hosny <kha...@libreoffice.org>
AuthorDate: Thu Aug 24 10:49:42 2023 +0000
Commit:     خالد حسني <kha...@libreoffice.org>
CommitDate: Thu Aug 24 22:22:17 2023 +0200

    tdf#140881: Ignore WOFF/WOFF2 fonts with FontConfig
    
    FC_FONT_WRAPPER requires unreleased FontConfig, but lets have this in so
    it works when FontConfig have it.
    
    Change-Id: I8f48ac1f68a3af6e1853e9eb1925d382b57136c0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156049
    Tested-by: Jenkins
    Reviewed-by: خالد حسني <kha...@libreoffice.org>

diff --git a/vcl/unx/generic/fontmanager/fontconfig.cxx 
b/vcl/unx/generic/fontmanager/fontconfig.cxx
index 113171445760..ae190ab96e58 100644
--- a/vcl/unx/generic/fontmanager/fontconfig.cxx
+++ b/vcl/unx/generic/fontmanager/fontconfig.cxx
@@ -187,6 +187,10 @@ FontCfgWrapper::FontCfgWrapper()
     FcInit();
 }
 
+#ifndef FC_FONT_WRAPPER
+#define FC_FONT_WRAPPER "fontwrapper"
+#endif
+
 void FontCfgWrapper::addFontSet( FcSetName eSetName )
 {
     // Add only acceptable fonts to our config, for future fontconfig use.
@@ -212,6 +216,12 @@ void FontCfgWrapper::addFontSet( FcSetName eSetName )
         if ((eFormatRes == FcResultMatch) && 
(strcmp(reinterpret_cast<char*>(pFormat), "Type 1") == 0))
             continue;
 
+        // Ignore any other non-SFNT wrapper format, including WOFF and WOFF2, 
too.
+        FcChar8* pWrapper = nullptr;
+        FcResult eWrapperRes = FcPatternGetString(pPattern, FC_FONT_WRAPPER, 
0, &pWrapper);
+        if ((eWrapperRes == FcResultMatch) && 
(strcmp(reinterpret_cast<char*>(pWrapper), "SFNT") != 0))
+            continue;
+
         FcPatternReference( pPattern );
         FcFontSetAdd( m_pFontSet, pPattern );
     }

Reply via email to