[Libreoffice-commits] core.git: 2 commits - include/xmloff offapi/com sc/inc sc/qa sc/source sd/inc sd/source sfx2/source sfx2/uiconfig sw/inc sw/source xmloff/source

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Tue Jul 10 14:15:22 UTC 2018


 include/xmloff/AutoStyleEntry.hxx             |   32 ++++++
 include/xmloff/XMLFontAutoStylePool.hxx       |   19 +++
 include/xmloff/txtparae.hxx                   |    2 
 include/xmloff/xmlaustp.hxx                   |    3 
 offapi/com/sun/star/document/Settings.idl     |   23 ++++
 sc/inc/document.hxx                           |   22 +++-
 sc/inc/unonames.hxx                           |    6 +
 sc/qa/unit/ucalc.cxx                          |    6 +
 sc/source/core/data/documen2.cxx              |    6 +
 sc/source/filter/xml/xmlfonte.cxx             |   13 +-
 sc/source/filter/xml/xmlimprt.cxx             |    4 
 sc/source/ui/unoobj/confuno.cxx               |   49 +++++++--
 sd/inc/drawdoc.hxx                            |   20 +++-
 sd/source/core/drawdoc.cxx                    |    6 +
 sd/source/ui/unoidl/UnoDocumentSettings.cxx   |   92 +++++++++++++++++-
 sfx2/source/dialog/documentfontsdialog.cxx    |   42 +++++++-
 sfx2/source/inc/documentfontsdialog.hxx       |    4 
 sfx2/uiconfig/ui/documentfontspage.ui         |  117 +++++++++++++++++++++--
 sw/inc/IDocumentSettingAccess.hxx             |    4 
 sw/source/core/doc/DocumentSettingManager.cxx |   20 ++++
 sw/source/core/inc/DocumentSettingManager.hxx |    6 +
 sw/source/filter/xml/xmlfonte.cxx             |   17 ++-
 sw/source/uibase/uno/SwXDocumentSettings.cxx  |   52 ++++++++++
 xmloff/source/draw/sdxmlexp.cxx               |   30 ++++--
 xmloff/source/style/XMLFontAutoStylePool.cxx  |  130 +++++++++++++++++++++++---
 xmloff/source/style/impastpl.cxx              |   31 ++++++
 xmloff/source/style/impastpl.hxx              |    3 
 xmloff/source/style/xmlaustp.cxx              |    5 +
 xmloff/source/text/txtparae.cxx               |    5 +
 29 files changed, 691 insertions(+), 78 deletions(-)

New commits:
commit 3bc3ddc11fd94877d9c5d2b8313ab53150818236
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Mon Jul 9 00:47:07 2018 +0200

    tdf#65353 filter fonts when embedding (unused, font script)
    
    When embedding, the fonts are gathered and added to the ODF
    document. This change in addition adds the functionallity to
    embed used fonts only and filtering out of font scripts. When
    embedding used fonts only, they are filtered depending on if
    the style (referencing the font) is in use and in addition if
    the font is used in direct formatting.
    
    Change-Id: I1ba0066b1eb34bdde7247eeb63c1be5a91db984d
    Reviewed-on: https://gerrit.libreoffice.org/57168
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/include/xmloff/AutoStyleEntry.hxx b/include/xmloff/AutoStyleEntry.hxx
new file mode 100644
index 000000000000..c313aac15313
--- /dev/null
+++ b/include/xmloff/AutoStyleEntry.hxx
@@ -0,0 +1,32 @@
+/* -*- 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/.
+ *
+ */
+
+#ifndef INCLUDED_XMLOFF_AUTOSTYLEENTRY_HXX
+#define INCLUDED_XMLOFF_AUTOSTYLEENTRY_HXX
+
+#include <sal/config.h>
+#include <xmloff/dllapi.h>
+#include <memory>
+
+namespace xmloff
+{
+struct XMLOFF_DLLPUBLIC AutoStyleEntry
+{
+    sal_Int32 m_nFamily;
+    OUString m_aParentName;
+    OUString m_aName;
+    std::vector<std::pair<OUString, css::uno::Any>> m_aXmlProperties;
+};
+
+} // end xmloff
+
+#endif // INCLUDED_XMLOFF_AUTOSTYLEENTRY_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/xmloff/XMLFontAutoStylePool.hxx b/include/xmloff/XMLFontAutoStylePool.hxx
index 3380fc96d532..2354bcf8ce7d 100644
--- a/include/xmloff/XMLFontAutoStylePool.hxx
+++ b/include/xmloff/XMLFontAutoStylePool.hxx
@@ -26,6 +26,7 @@
 #include <tools/fontenum.hxx>
 #include <salhelper/simplereferenceobject.hxx>
 #include <set>
+#include <unordered_set>
 #include <unordered_map>
 #include <memory>
 
@@ -44,6 +45,8 @@ private:
 
     OUString embedFontFile(OUString const & rFileUrl, OUString const & rFamilyName);
 
+    std::unordered_set<OUString> getUsedFontList();
+
 protected:
     bool m_bEmbedUsedOnly;
     bool m_bEmbedLatinScript;
@@ -53,7 +56,6 @@ protected:
     SvXMLExport& GetExport() { return rExport; }
 
 public:
-
     XMLFontAutoStylePool( SvXMLExport& rExport, bool tryToEmbedFonts = false );
     virtual ~XMLFontAutoStylePool() override;
 
diff --git a/include/xmloff/txtparae.hxx b/include/xmloff/txtparae.hxx
index d06a335f1f83..7bf35536156f 100644
--- a/include/xmloff/txtparae.hxx
+++ b/include/xmloff/txtparae.hxx
@@ -111,6 +111,8 @@ class XMLOFF_DLLPUBLIC XMLTextParagraphExport : public XMLStyleExport
     XMLTextListsHelper* mpTextListsHelper;
     ::std::vector< std::unique_ptr<XMLTextListsHelper> > maTextListsHelperStack;
 
+    bool mbCollected;
+
     enum class FrameType { Text, Graphic, Embedded, Shape };
 public:
 
diff --git a/include/xmloff/xmlaustp.hxx b/include/xmloff/xmlaustp.hxx
index 7b270ce09724..1d708ad12806 100644
--- a/include/xmloff/xmlaustp.hxx
+++ b/include/xmloff/xmlaustp.hxx
@@ -24,6 +24,7 @@
 #include <xmloff/dllapi.h>
 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
 #include <xmloff/xmlprmap.hxx>
+#include <xmloff/AutoStyleEntry.hxx>
 #include <salhelper/simplereferenceobject.hxx>
 #include <memory>
 
@@ -116,6 +117,8 @@ public:
     void exportXML( sal_Int32 nFamily ) const;
 
     void ClearEntries();
+
+    std::vector<xmloff::AutoStyleEntry> GetAutoStyleEntries() const;
 };
 
 #endif // INCLUDED_XMLOFF_XMLAUSTP_HXX
diff --git a/xmloff/source/style/XMLFontAutoStylePool.cxx b/xmloff/source/style/XMLFontAutoStylePool.cxx
index c410624ee9ce..56bb2211e990 100644
--- a/xmloff/source/style/XMLFontAutoStylePool.cxx
+++ b/xmloff/source/style/XMLFontAutoStylePool.cxx
@@ -32,8 +32,12 @@
 #include <com/sun/star/embed/XTransactedObject.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/ucb/SimpleFileAccess.hpp>
+#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
+#include <com/sun/star/style/XStyle.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
 
 #include <XMLBase64Export.hxx>
+#include <xmloff/AutoStyleEntry.hxx>
 #include <comphelper/hash.hxx>
 
 using namespace ::com::sun::star;
@@ -290,6 +294,93 @@ OUString FontItalicToString(FontItalic eWeight)
 
 }
 
+std::unordered_set<OUString> XMLFontAutoStylePool::getUsedFontList()
+{
+    std::unordered_set<OUString> aReturnSet;
+
+    uno::Reference<style::XStyleFamiliesSupplier> xFamiliesSupp(GetExport().GetModel(), UNO_QUERY);
+    if (!xFamiliesSupp.is())
+        return aReturnSet;
+
+    // Check styles first
+    uno::Reference<container::XNameAccess> xFamilies(xFamiliesSupp->getStyleFamilies());
+    if (xFamilies.is())
+    {
+        for (OUString const & sFamilyName : xFamilies->getElementNames())
+        {
+            uno::Reference<container::XNameAccess> xStyleContainer;
+            xFamilies->getByName(sFamilyName) >>= xStyleContainer;
+
+            if (xStyleContainer.is())
+            {
+                for (OUString const & rName : xStyleContainer->getElementNames())
+                {
+                    uno::Reference<style::XStyle> xStyle;
+                    xStyleContainer->getByName(rName) >>= xStyle;
+                    if (xStyle->isInUse())
+                    {
+                        uno::Reference<beans::XPropertySet> xPropertySet(xStyle, UNO_QUERY);
+                        if (xPropertySet.is())
+                        {
+                            uno::Reference<beans::XPropertySetInfo> xInfo(xPropertySet->getPropertySetInfo());
+                            if (m_bEmbedLatinScript && xInfo->hasPropertyByName("CharFontName"))
+                            {
+                                OUString sCharFontName;
+                                Any aFontAny = xPropertySet->getPropertyValue("CharFontName");
+                                aFontAny >>= sCharFontName;
+                                if (!sCharFontName.isEmpty())
+                                    aReturnSet.insert(sCharFontName);
+                            }
+                            if (m_bEmbedAsianScript && xInfo->hasPropertyByName("CharFontNameAsian"))
+                            {
+                                OUString sCharFontNameAsian;
+                                Any aFontAny = xPropertySet->getPropertyValue("CharFontNameAsian");
+                                aFontAny >>= sCharFontNameAsian;
+                                if (!sCharFontNameAsian.isEmpty())
+                                    aReturnSet.insert(sCharFontNameAsian);
+                            }
+                            if (m_bEmbedComplexScript && xInfo->hasPropertyByName("CharFontNameComplex"))
+                            {
+                                OUString sCharFontNameComplex;
+                                Any aFontAny = xPropertySet->getPropertyValue("CharFontNameComplex");
+                                aFontAny >>= sCharFontNameComplex;
+                                if (!sCharFontNameComplex.isEmpty())
+                                    aReturnSet.insert(sCharFontNameComplex);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    // make sure auto-styles are collected
+    GetExport().GetTextParagraphExport()->collectTextAutoStylesOptimized(false);
+
+    // Check auto-styles for fonts
+    std::vector<xmloff::AutoStyleEntry> aAutoStyleEntries;
+    aAutoStyleEntries = GetExport().GetAutoStylePool()->GetAutoStyleEntries();
+    for (auto const & rAutoStyleEntry : aAutoStyleEntries)
+    {
+        for (auto const & rPair : rAutoStyleEntry.m_aXmlProperties)
+        {
+            if (rPair.first == "font-name" ||
+                rPair.first == "font-weight-asian" ||
+                rPair.first == "font-weight-complex")
+            {
+                if (rPair.second.has<OUString>())
+                {
+                    OUString sFontName = rPair.second.get<OUString>();
+                    if (!sFontName.isEmpty())
+                        aReturnSet.insert(sFontName);
+                }
+            }
+        }
+    }
+
+    return aReturnSet;
+}
+
 void XMLFontAutoStylePool::exportXML()
 {
     SvXMLElementExport aElem(GetExport(), XML_NAMESPACE_OFFICE,
@@ -306,6 +397,10 @@ void XMLFontAutoStylePool::exportXML()
     std::map<OUString, OUString> fontFilesMap; // our url to document url
     sal_uInt32 nCount = m_pFontAutoStylePool->size();
 
+    std::unordered_set<OUString> aUsedFontNames;
+    if (m_bEmbedUsedOnly)
+        aUsedFontNames = getUsedFontList();
+
     for (sal_uInt32 i = 0; i < nCount; i++)
     {
         const XMLFontAutoStylePoolEntry_Impl* pEntry = (*m_pFontAutoStylePool)[i];
@@ -369,20 +464,25 @@ void XMLFontAutoStylePool::exportXML()
                 if (sFileUrl.isEmpty())
                     continue;
 
-                if (!fontFilesMap.count(sFileUrl))
+                // When embeded only is not set or font is used
+                if (!m_bEmbedUsedOnly ||
+                    aUsedFontNames.find(pEntry->GetFamilyName()) != aUsedFontNames.end())
                 {
-                    const OUString docUrl = bExportFlat ?
-                                                lcl_checkFontFile(sFileUrl) : embedFontFile(sFileUrl, pEntry->GetFamilyName());
-                    if (!docUrl.isEmpty())
-                        fontFilesMap[sFileUrl] = docUrl;
-                    else
-                        continue; // --> failed to embed
+                    if (!fontFilesMap.count(sFileUrl))
+                    {
+                        const OUString docUrl = bExportFlat ?
+                                                    lcl_checkFontFile(sFileUrl) : embedFontFile(sFileUrl, pEntry->GetFamilyName());
+                        if (!docUrl.isEmpty())
+                            fontFilesMap[sFileUrl] = docUrl;
+                        else
+                            continue; // --> failed to embed
+                    }
+                    EmbeddedFontInfo aEmbeddedFont;
+                    aEmbeddedFont.aURL = sFileUrl;
+                    aEmbeddedFont.eWeight = aCombinationPair.first;
+                    aEmbeddedFont.eItalic = aCombinationPair.second;
+                    aEmbeddedFonts.push_back(aEmbeddedFont);
                 }
-                EmbeddedFontInfo aEmbeddedFont;
-                aEmbeddedFont.aURL = sFileUrl;
-                aEmbeddedFont.eWeight = aCombinationPair.first;
-                aEmbeddedFont.eItalic = aCombinationPair.second;
-                aEmbeddedFonts.push_back(aEmbeddedFont);
             }
             if (!aEmbeddedFonts.empty())
             {
diff --git a/xmloff/source/style/impastpl.cxx b/xmloff/source/style/impastpl.cxx
index 69ad5d3e05ce..ed5f0e32eecb 100644
--- a/xmloff/source/style/impastpl.cxx
+++ b/xmloff/source/style/impastpl.cxx
@@ -591,6 +591,37 @@ OUString SvXMLAutoStylePoolP_Impl::Find( sal_Int32 nFamily,
     return sName;
 }
 
+std::vector<xmloff::AutoStyleEntry> SvXMLAutoStylePoolP_Impl::GetAutoStyleEntries() const
+{
+    std::vector<xmloff::AutoStyleEntry> rReturnVector;
+
+    for (std::unique_ptr<XMLAutoStyleFamily> const & rFamily : m_FamilySet)
+    {
+        rtl::Reference<XMLPropertySetMapper> aPropertyMapper = rFamily->mxMapper->getPropertySetMapper();
+        sal_Int32 nFamily = rFamily->mnFamily;
+        for (auto const & rParent : rFamily->m_ParentSet)
+        {
+            for (auto const & rProperty : rParent->GetPropertiesList())
+            {
+                rReturnVector.emplace_back();
+                xmloff::AutoStyleEntry & rEntry = rReturnVector.back();
+                rEntry.m_nFamily = nFamily;
+                rEntry.m_aParentName = rParent->GetParent();
+                rEntry.m_aName = rProperty->GetName();
+                for (XMLPropertyState const & rPropertyState : rProperty->GetProperties())
+                {
+                    if (rPropertyState.mnIndex >= 0)
+                    {
+                        OUString sXmlName = aPropertyMapper->GetEntryXMLName(rPropertyState.mnIndex);
+                        rEntry.m_aXmlProperties.emplace_back(sXmlName, rPropertyState.maValue);
+                    }
+                }
+            }
+        }
+    }
+    return rReturnVector;
+}
+
 namespace {
 
 struct AutoStylePoolExport
diff --git a/xmloff/source/style/impastpl.hxx b/xmloff/source/style/impastpl.hxx
index eec145cd19c9..49a93fc2a742 100644
--- a/xmloff/source/style/impastpl.hxx
+++ b/xmloff/source/style/impastpl.hxx
@@ -33,6 +33,7 @@
 
 #include <xmloff/maptype.hxx>
 #include <xmloff/xmlexppr.hxx>
+#include <xmloff/AutoStyleEntry.hxx>
 
 class SvXMLAutoStylePoolP;
 class XMLAutoStylePoolParent;
@@ -174,6 +175,8 @@ public:
         const SvXMLAutoStylePoolP *pAntiImpl) const;
 
     void ClearEntries();
+
+    std::vector<xmloff::AutoStyleEntry> GetAutoStyleEntries() const;
 };
 
 #endif
diff --git a/xmloff/source/style/xmlaustp.cxx b/xmloff/source/style/xmlaustp.cxx
index 863f740b24b8..c5256a49f12b 100644
--- a/xmloff/source/style/xmlaustp.cxx
+++ b/xmloff/source/style/xmlaustp.cxx
@@ -382,4 +382,9 @@ void SvXMLAutoStylePoolP::ClearEntries()
     pImpl->ClearEntries();
 }
 
+std::vector<xmloff::AutoStyleEntry> SvXMLAutoStylePoolP::GetAutoStyleEntries() const
+{
+    return pImpl->GetAutoStyleEntries();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx
index d039682eb856..cd9eba5f801b 100644
--- a/xmloff/source/text/txtparae.cxx
+++ b/xmloff/source/text/txtparae.cxx
@@ -1173,6 +1173,7 @@ XMLTextParagraphExport::XMLTextParagraphExport(
     bOpenRuby( false ),
     mpTextListsHelper( nullptr ),
     maTextListsHelperStack(),
+    mbCollected(false),
     // Implement Title/Description Elements UI (#i73249#)
     sTitle("Title"),
     sDescription("Description"),
@@ -1432,6 +1433,9 @@ void XMLTextParagraphExport::collectTextAutoStylesOptimized( bool bIsProgress )
 {
     GetExport().GetShapeExport(); // make sure the graphics styles family is added
 
+    if (mbCollected)
+        return;
+
     const bool bAutoStyles = true;
     const bool bExportContent = false;
 
@@ -1630,6 +1634,7 @@ void XMLTextParagraphExport::collectTextAutoStylesOptimized( bool bIsProgress )
             }
         }
     }
+    mbCollected = true;
 }
 
 void XMLTextParagraphExport::exportText(
commit eb6ff07605a55675e7007ac0cb5604fb13a9ddf9
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri Jul 6 12:45:31 2018 +0200

    [API CHANGE] tdf#65353 Add more doc. settings more embedding fonts
    
    - Add setting to embed used fonts only
    - Add setting for filtering of Latin, Asian, Complex script fonts
    
    Change-Id: I8d093ed05fdcef3715616c008f6eeaa8cfbcc850
    Reviewed-on: https://gerrit.libreoffice.org/57167
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/include/xmloff/XMLFontAutoStylePool.hxx b/include/xmloff/XMLFontAutoStylePool.hxx
index 530d05b2762a..3380fc96d532 100644
--- a/include/xmloff/XMLFontAutoStylePool.hxx
+++ b/include/xmloff/XMLFontAutoStylePool.hxx
@@ -45,6 +45,10 @@ private:
     OUString embedFontFile(OUString const & rFileUrl, OUString const & rFamilyName);
 
 protected:
+    bool m_bEmbedUsedOnly;
+    bool m_bEmbedLatinScript;
+    bool m_bEmbedAsianScript;
+    bool m_bEmbedComplexScript;
 
     SvXMLExport& GetExport() { return rExport; }
 
@@ -68,6 +72,17 @@ public:
             rtl_TextEncoding eEnc )const;
 
     void exportXML();
+
+    void setEmbedOnlyUsedFonts(bool bEmbedUsedOnly)
+    {
+        m_bEmbedUsedOnly = bEmbedUsedOnly;
+    }
+    void setEmbedFontScripts(bool bEmbedLatinScript, bool bEmbedAsianScript, bool bEmbedComplexScript)
+    {
+        m_bEmbedLatinScript = bEmbedLatinScript;
+        m_bEmbedAsianScript = bEmbedAsianScript;
+        m_bEmbedComplexScript = bEmbedComplexScript;
+    }
 };
 
 #endif // INCLUDED_XMLOFF_XMLFONTAUTOSTYLEPOOL_HXX
diff --git a/offapi/com/sun/star/document/Settings.idl b/offapi/com/sun/star/document/Settings.idl
index 9d4fa929a4c4..d9c8164fe306 100644
--- a/offapi/com/sun/star/document/Settings.idl
+++ b/offapi/com/sun/star/document/Settings.idl
@@ -260,6 +260,29 @@ published service Settings
      */
     [optional, property] boolean EmbedSystemFonts;
 
+    /** Whether to embed only the fonts that are used in the document.
+
+        @since LibreOffice 6.2
+     */
+     [optional, property] boolean EmbedOnlyUsedFonts;
+
+    /** Whether to embed Latin script fonts.
+
+        @since LibreOffice 6.2
+     */
+    [optional, property] short EmbedLatinScriptFonts;
+
+    /** Whether to embed Asian script fonts.
+
+        @since LibreOffice 6.2
+     */
+    [optional, property] short EmbedAsianScriptFonts;
+
+    /** Whether to embed Complex script fonts.
+
+        @since LibreOffice 6.2
+     */
+    [optional, property] short EmbedComplexScriptFonts;
 };
 
 
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 07e16a8388de..f2ee35bc693a 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -523,7 +523,12 @@ private:
 
     std::set<ScFormulaCell*> maSubTotalCells;
 
-    bool                mbUseEmbedFonts;
+
+    bool mbEmbedFonts : 1;
+    bool mbEmbedUsedFontsOnly : 1;
+    bool mbEmbedFontScriptLatin : 1;
+    bool mbEmbedFontScriptAsian : 1;
+    bool mbEmbedFontScriptComplex : 1;
 
     std::unique_ptr<sc::IconSetBitmapMap> m_pIconSetBitmapMap;
 
@@ -535,8 +540,19 @@ private:
 public:
     bool                     IsCellInChangeTrack(const ScAddress &cell,Color *pColCellBorder);
     void                     GetCellChangeTrackNote(const ScAddress &cell, OUString &strTrackText, bool &pbLeftEdge);
-    bool                     IsUsingEmbededFonts() { return mbUseEmbedFonts; }
-    void                     SetIsUsingEmbededFonts( bool bUse ) { mbUseEmbedFonts = bUse; }
+
+    bool IsEmbedFonts() { return mbEmbedFonts; }
+    bool IsEmbedUsedFontsOnly() { return mbEmbedUsedFontsOnly; }
+    bool IsEmbedFontScriptLatin() { return mbEmbedFontScriptLatin; }
+    bool IsEmbedFontScriptAsian() { return mbEmbedFontScriptAsian; }
+    bool IsEmbedFontScriptComplex() { return mbEmbedFontScriptComplex; }
+
+    void SetEmbedFonts(bool bUse) { mbEmbedFonts = bUse; }
+    void SetEmbedUsedFontsOnly(bool bUse) { mbEmbedUsedFontsOnly = bUse; }
+    void SetEmbedFontScriptLatin(bool bUse) { mbEmbedFontScriptLatin = bUse; }
+    void SetEmbedFontScriptAsian(bool bUse) { mbEmbedFontScriptAsian = bUse; }
+    void SetEmbedFontScriptComplex(bool bUse) { mbEmbedFontScriptComplex = bUse; }
+
     SC_DLLPUBLIC sal_uLong   GetCellCount() const;       // all cells
     SC_DLLPUBLIC sal_uLong   GetFormulaGroupCount() const;       // all cells
     sal_uLong                GetCodeCount() const;       // RPN-Code in formulas
diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx
index 07d2864ed4fd..d90c4a510a3a 100644
--- a/sc/inc/unonames.hxx
+++ b/sc/inc/unonames.hxx
@@ -691,7 +691,11 @@
 // Named ranges
 #define SC_UNO_MODIFY_BROADCAST     "ModifyAndBroadcast"
 
-#define SC_UNO_EMBED_FONTS     "EmbedFonts"
+#define SC_UNO_EMBED_FONTS               "EmbedFonts"
+#define SC_UNO_EMBED_ONLY_USED_FONTS     "EmbedOnlyUsedFonts"
+#define SC_UNO_EMBED_FONT_SCRIPT_LATIN   "EmbedLatinScriptFonts"
+#define SC_UNO_EMBED_FONT_SCRIPT_ASIAN   "EmbedAsianScriptFonts"
+#define SC_UNO_EMBED_FONT_SCRIPT_COMPLEX "EmbedComplexScriptFonts"
 
 #define SC_UNO_ODS_LOCK_SOLAR_MUTEX "ODSLockSolarMutex"
 #define SC_UNO_ODS_IMPORT_STYLES    "ODSImportStyles"
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 6db74263c27b..826f846279f2 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -6521,7 +6521,11 @@ void Test::testEmptyCalcDocDefaults()
     CPPUNIT_ASSERT_EQUAL( false, m_pDoc->HasNotes() );
     CPPUNIT_ASSERT_EQUAL( false, m_pDoc->IsCutMode() );
 
-    CPPUNIT_ASSERT_EQUAL( false, m_pDoc->IsUsingEmbededFonts() );
+    CPPUNIT_ASSERT_EQUAL( false, m_pDoc->IsEmbedFonts() );
+    CPPUNIT_ASSERT_EQUAL( false, m_pDoc->IsEmbedUsedFontsOnly() );
+    CPPUNIT_ASSERT_EQUAL( true, m_pDoc->IsEmbedFontScriptLatin() );
+    CPPUNIT_ASSERT_EQUAL( true, m_pDoc->IsEmbedFontScriptAsian() );
+    CPPUNIT_ASSERT_EQUAL( true, m_pDoc->IsEmbedFontScriptComplex() );
     CPPUNIT_ASSERT_EQUAL( false, m_pDoc->IsEmbedded() );
 
     CPPUNIT_ASSERT_EQUAL( true, m_pDoc->IsDocEditable() );
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 81ce2170d02d..b39d0866be24 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -221,7 +221,11 @@ ScDocument::ScDocument( ScDocumentMode eMode, SfxObjectShell* pDocShell ) :
         mbStreamValidLocked( false ),
         mbUserInteractionEnabled(true),
         mnNamedRangesLockCount(0),
-        mbUseEmbedFonts(false),
+        mbEmbedFonts(false),
+        mbEmbedUsedFontsOnly(false),
+        mbEmbedFontScriptLatin(true),
+        mbEmbedFontScriptAsian(true),
+        mbEmbedFontScriptComplex(true),
         mbTrackFormulasPending(false),
         mbFinalTrackFormulas(false),
         mnMutationGuardFlags(0)
diff --git a/sc/source/filter/xml/xmlfonte.cxx b/sc/source/filter/xml/xmlfonte.cxx
index b8446e40606c..b4c7e7a8808c 100644
--- a/sc/source/filter/xml/xmlfonte.cxx
+++ b/sc/source/filter/xml/xmlfonte.cxx
@@ -39,7 +39,7 @@ private:
     void AddFontItems(const sal_uInt16* pWhichIds, sal_uInt8 nIdCount, const SfxItemPool* pItemPool, const bool bExportDefaults);
 
 public:
-    ScXMLFontAutoStylePool_Impl( ScXMLExport& rExport, bool bBlockFontEmbedding );
+    ScXMLFontAutoStylePool_Impl( ScXMLExport& rExport, bool bEmbedFonts);
     virtual ~ScXMLFontAutoStylePool_Impl() override;
 };
 
@@ -70,8 +70,8 @@ void ScXMLFontAutoStylePool_Impl::AddFontItems(const sal_uInt16* pWhichIds, sal_
     }
 }
 
-ScXMLFontAutoStylePool_Impl::ScXMLFontAutoStylePool_Impl(ScXMLExport& rExportP, bool bBlockFontEmbedding)
-    : XMLFontAutoStylePool(rExportP, bBlockFontEmbedding)
+ScXMLFontAutoStylePool_Impl::ScXMLFontAutoStylePool_Impl(ScXMLExport& rExportP, bool bEmbedFonts)
+    : XMLFontAutoStylePool(rExportP, bEmbedFonts)
     , mpEditEnginePool(nullptr)
 {
     sal_uInt16 const aWhichIds[]     { ATTR_FONT, ATTR_CJK_FONT,
@@ -88,6 +88,11 @@ ScXMLFontAutoStylePool_Impl::ScXMLFontAutoStylePool_Impl(ScXMLExport& rExportP,
 
     std::shared_ptr<SfxStyleSheetIterator> pItr = rExportP.GetDocument()->GetStyleSheetPool()->CreateIterator(SfxStyleFamily::Page, SfxStyleSearchBits::All);
 
+    m_bEmbedUsedOnly = rExportP.GetDocument()->IsEmbedUsedFontsOnly();
+    m_bEmbedLatinScript = rExportP.GetDocument()->IsEmbedFontScriptLatin();
+    m_bEmbedAsianScript = rExportP.GetDocument()->IsEmbedFontScriptAsian();
+    m_bEmbedComplexScript = rExportP.GetDocument()->IsEmbedFontScriptComplex();
+
     if(pItr)
     {
         SfxStyleSheetBase* pStyle(pItr->First());
@@ -157,7 +162,7 @@ XMLFontAutoStylePool* ScXMLExport::CreateFontAutoStylePool()
     // the embedding only in one of them.
     if(!( getExportFlags() & SvXMLExportFlags::CONTENT ))
         blockFontEmbedding = true;
-    if( !GetDocument()->IsUsingEmbededFonts())
+    if (!GetDocument()->IsEmbedFonts())
         blockFontEmbedding = true;
     return new ScXMLFontAutoStylePool_Impl( *this, !blockFontEmbedding );
 }
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index 36f3c3f8baa9..20ba58d3c216 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -2012,8 +2012,8 @@ const ScXMLEditAttributeMap& ScXMLImport::GetEditAttributeMap() const
 
 void ScXMLImport::NotifyEmbeddedFontRead()
 {
-    if ( pDoc )
-        pDoc->SetIsUsingEmbededFonts( true );
+    if (pDoc)
+        pDoc->SetEmbedFonts(true);
 }
 
 ScMyImpDetectiveOpArray* ScXMLImport::GetDetectiveOpArray()
diff --git a/sc/source/ui/unoobj/confuno.cxx b/sc/source/ui/unoobj/confuno.cxx
index 9e3ae551e22c..a7d6599aef6c 100644
--- a/sc/source/ui/unoobj/confuno.cxx
+++ b/sc/source/ui/unoobj/confuno.cxx
@@ -84,7 +84,11 @@ static const SfxItemPropertyMapEntry* lcl_GetConfigPropertyMap()
         {OUString(SC_UNO_LOADREADONLY), 0,  cppu::UnoType<bool>::get(),              0, 0},
         {OUString(SC_UNO_SHAREDOC),     0,  cppu::UnoType<bool>::get(),              0, 0},
         {OUString(SC_UNO_MODIFYPASSWORDINFO), 0,  cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get(),              0, 0},
-        {OUString(SC_UNO_EMBED_FONTS), 0,  cppu::UnoType<bool>::get(),              0, 0},
+        {OUString(SC_UNO_EMBED_FONTS),               0,  cppu::UnoType<bool>::get(), 0, 0},
+        {OUString(SC_UNO_EMBED_ONLY_USED_FONTS),     0,  cppu::UnoType<bool>::get(), 0, 0},
+        {OUString(SC_UNO_EMBED_FONT_SCRIPT_LATIN),   0,  cppu::UnoType<bool>::get(), 0, 0},
+        {OUString(SC_UNO_EMBED_FONT_SCRIPT_ASIAN),   0,  cppu::UnoType<bool>::get(), 0, 0},
+        {OUString(SC_UNO_EMBED_FONT_SCRIPT_COMPLEX), 0,  cppu::UnoType<bool>::get(), 0, 0},
         {OUString(SC_UNO_SYNTAXSTRINGREF), 0,  cppu::UnoType<sal_Int16>::get(),     0, 0},
         { OUString(), 0, css::uno::Type(), 0, 0 }
     };
@@ -337,13 +341,30 @@ void SAL_CALL ScDocumentConfiguration::setPropertyValue(
             throw beans::PropertyVetoException(
                 "The hash is not allowed to be changed now!" );
     }
-    else if ( aPropertyName == SC_UNO_EMBED_FONTS )
+    else if (aPropertyName == SC_UNO_EMBED_FONTS)
     {
-        bool bVal = false;
-        if ( aValue >>=bVal )
-        {
-            rDoc.SetIsUsingEmbededFonts(bVal);
-        }
+        bool bVal = aValue.has<bool>() && aValue.get<bool>();
+        rDoc.SetEmbedFonts(bVal);
+    }
+    else if (aPropertyName == SC_UNO_EMBED_ONLY_USED_FONTS)
+    {
+        bool bVal = aValue.has<bool>() && aValue.get<bool>();
+        rDoc.SetEmbedUsedFontsOnly(bVal);
+    }
+    else if (aPropertyName == SC_UNO_EMBED_FONT_SCRIPT_LATIN)
+    {
+        bool bVal = aValue.has<bool>() && aValue.get<bool>();
+        rDoc.SetEmbedFontScriptLatin(bVal);
+    }
+    else if (aPropertyName == SC_UNO_EMBED_FONT_SCRIPT_ASIAN)
+    {
+        bool bVal = aValue.has<bool>() && aValue.get<bool>();
+        rDoc.SetEmbedFontScriptAsian(bVal);
+    }
+    else if (aPropertyName == SC_UNO_EMBED_FONT_SCRIPT_COMPLEX)
+    {
+        bool bVal = aValue.has<bool>() && aValue.get<bool>();
+        rDoc.SetEmbedFontScriptComplex(bVal);
     }
     else if ( aPropertyName == SC_UNO_SYNTAXSTRINGREF )
     {
@@ -524,10 +545,16 @@ uno::Any SAL_CALL ScDocumentConfiguration::getPropertyValue( const OUString& aPr
     }
     else if ( aPropertyName == SC_UNO_MODIFYPASSWORDINFO )
         aRet <<= pDocShell->GetModifyPasswordInfo();
-    else if ( aPropertyName == SC_UNO_EMBED_FONTS )
-    {
-        aRet <<= rDoc.IsUsingEmbededFonts();
-    }
+    else if (aPropertyName == SC_UNO_EMBED_FONTS)
+        aRet <<= rDoc.IsEmbedFonts();
+    else if (aPropertyName == SC_UNO_EMBED_ONLY_USED_FONTS)
+        aRet <<= rDoc.IsEmbedUsedFontsOnly();
+    else if (aPropertyName == SC_UNO_EMBED_FONT_SCRIPT_LATIN)
+        aRet <<= rDoc.IsEmbedFontScriptLatin();
+    else if (aPropertyName == SC_UNO_EMBED_FONT_SCRIPT_ASIAN)
+        aRet <<= rDoc.IsEmbedFontScriptAsian();
+    else if (aPropertyName == SC_UNO_EMBED_FONT_SCRIPT_COMPLEX)
+        aRet <<= rDoc.IsEmbedFontScriptComplex();
     else if ( aPropertyName == SC_UNO_SYNTAXSTRINGREF )
     {
         ScCalcConfig aCalcConfig = rDoc.GetCalcConfig();
diff --git a/sd/inc/drawdoc.hxx b/sd/inc/drawdoc.hxx
index e576aa749eaa..23d7fbadff42 100644
--- a/sd/inc/drawdoc.hxx
+++ b/sd/inc/drawdoc.hxx
@@ -196,7 +196,12 @@ private:
 
     std::vector<css::uno::Reference< css::xml::dom::XNode> > maPresObjectInfo;
 
-    bool                mbUseEmbedFonts;
+    bool mbEmbedFonts : 1;
+    bool mbEmbedUsedFontsOnly : 1;
+    bool mbEmbedFontScriptLatin : 1;
+    bool mbEmbedFontScriptAsian : 1;
+    bool mbEmbedFontScriptComplex : 1;
+
 protected:
 
     SAL_DLLPRIVATE virtual css::uno::Reference< css::uno::XInterface > createUnoModel() override;
@@ -618,8 +623,17 @@ public:
 
     SAL_DLLPRIVATE sal_uInt16 GetAnnotationAuthorIndex( const OUString& rAuthor );
 
-    SAL_DLLPRIVATE bool IsUsingEmbededFonts() { return mbUseEmbedFonts; }
-    SAL_DLLPRIVATE void SetIsUsingEmbededFonts( bool bUse ) { mbUseEmbedFonts = bUse; }
+    SAL_DLLPRIVATE bool IsEmbedFonts() { return mbEmbedFonts; }
+    SAL_DLLPRIVATE bool IsEmbedUsedFontsOnly() { return mbEmbedUsedFontsOnly; }
+    SAL_DLLPRIVATE bool IsEmbedFontScriptLatin() { return mbEmbedFontScriptLatin; }
+    SAL_DLLPRIVATE bool IsEmbedFontScriptAsian() { return mbEmbedFontScriptAsian; }
+    SAL_DLLPRIVATE bool IsEmbedFontScriptComplex() { return mbEmbedFontScriptComplex; }
+
+    SAL_DLLPRIVATE void SetEmbedFonts(bool bUse) { mbEmbedFonts = bUse; }
+    SAL_DLLPRIVATE void SetEmbedUsedFontsOnly(bool bUse) { mbEmbedUsedFontsOnly = bUse; }
+    SAL_DLLPRIVATE void SetEmbedFontScriptLatin(bool bUse) { mbEmbedFontScriptLatin = bUse; }
+    SAL_DLLPRIVATE void SetEmbedFontScriptAsian(bool bUse) { mbEmbedFontScriptAsian = bUse; }
+    SAL_DLLPRIVATE void SetEmbedFontScriptComplex(bool bUse) { mbEmbedFontScriptComplex = bUse; }
 
     void dumpAsXml(struct _xmlTextWriter* pWriter) const override;
 
diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx
index c91d842a1374..dcd73dde1994 100644
--- a/sd/source/core/drawdoc.cxx
+++ b/sd/source/core/drawdoc.cxx
@@ -156,7 +156,11 @@ SdDrawDocument::SdDrawDocument(DocumentType eType, SfxObjectShell* pDrDocSh)
 , mbAllocDocSh(false)
 , meDocType(eType)
 , mpCharClass(nullptr)
-, mbUseEmbedFonts(false)
+, mbEmbedFonts(false)
+, mbEmbedUsedFontsOnly(false)
+, mbEmbedFontScriptLatin(true)
+, mbEmbedFontScriptAsian(true)
+, mbEmbedFontScriptComplex(true)
 {
     mpDrawPageListWatcher.reset(new ImpDrawPageListWatcher(*this));
     mpMasterPageListWatcher.reset(new ImpMasterPageListWatcher(*this));
diff --git a/sd/source/ui/unoidl/UnoDocumentSettings.cxx b/sd/source/ui/unoidl/UnoDocumentSettings.cxx
index c2ef28948604..31c8afae0a8d 100644
--- a/sd/source/ui/unoidl/UnoDocumentSettings.cxx
+++ b/sd/source/ui/unoidl/UnoDocumentSettings.cxx
@@ -141,7 +141,9 @@ enum SdDocumentSettingsPropertyHandles
     HANDLE_UPDATEFROMTEMPLATE, HANDLE_PRINTER_INDEPENDENT_LAYOUT
     // #i33095#
     ,HANDLE_LOAD_READONLY, HANDLE_MODIFY_PASSWD, HANDLE_SAVE_VERSION
-    ,HANDLE_SLIDESPERHANDOUT, HANDLE_HANDOUTHORIZONTAL, HANDLE_EMBED_FONTS
+    ,HANDLE_SLIDESPERHANDOUT, HANDLE_HANDOUTHORIZONTAL,
+    HANDLE_EMBED_FONTS, HANDLE_EMBED_USED_FONTS,
+    HANDLE_EMBED_LATIN_SCRIPT_FONTS, HANDLE_EMBED_ASIAN_SCRIPT_FONTS, HANDLE_EMBED_COMPLEX_SCRIPT_FONTS,
 };
 
 #define MID_PRINTER 1
@@ -205,7 +207,11 @@ enum SdDocumentSettingsPropertyHandles
             { OUString("LoadReadonly"),          HANDLE_LOAD_READONLY,       cppu::UnoType<bool>::get(),                0,  0 },
             { OUString("ModifyPasswordInfo"),    HANDLE_MODIFY_PASSWD,       cppu::UnoType<uno::Sequence < beans::PropertyValue >>::get(),  0,  0 },
             { OUString("SaveVersionOnClose"),    HANDLE_SAVE_VERSION,        cppu::UnoType<bool>::get(),                0,  0 },
-            { OUString("EmbedFonts"),            HANDLE_EMBED_FONTS,         cppu::UnoType<bool>::get(),                0,  0 },
+            { OUString("EmbedFonts"),              HANDLE_EMBED_FONTS,                cppu::UnoType<bool>::get(), 0,  0 },
+            { OUString("EmbedOnlyUsedFonts"),      HANDLE_EMBED_USED_FONTS,           cppu::UnoType<bool>::get(), 0,  0 },
+            { OUString("EmbedLatinScriptFonts"),   HANDLE_EMBED_LATIN_SCRIPT_FONTS,   cppu::UnoType<bool>::get(), 0,  0 },
+            { OUString("EmbedAsianScriptFonts"),   HANDLE_EMBED_ASIAN_SCRIPT_FONTS,   cppu::UnoType<bool>::get(), 0,  0 },
+            { OUString("EmbedComplexScriptFonts"), HANDLE_EMBED_COMPLEX_SCRIPT_FONTS, cppu::UnoType<bool>::get(), 0,  0 },
             { OUString(), 0, css::uno::Type(), 0, 0 }
         };
 
@@ -960,11 +966,59 @@ DocumentSettings::_setPropertyValues(const PropertyMapEntry** ppEntries,
 
             case HANDLE_EMBED_FONTS:
             {
-                bool bNewValue = false;
-                if ( *pValues >>= bNewValue )
+                if (pValues->has<bool>())
+                {
+                    bool bNewValue = pValues->get<bool>();
+                    bChanged = (pDoc->IsEmbedFonts() != bNewValue);
+                    pDoc->SetEmbedFonts(bNewValue);
+                    bOk = true;
+                }
+            }
+            break;
+
+            case HANDLE_EMBED_USED_FONTS:
+            {
+                if (pValues->has<bool>())
+                {
+                    bool bNewValue = pValues->get<bool>();
+                    bChanged = (pDoc->IsEmbedUsedFontsOnly() != bNewValue);
+                    pDoc->SetEmbedUsedFontsOnly(bNewValue);
+                    bOk = true;
+                }
+            }
+            break;
+
+            case HANDLE_EMBED_LATIN_SCRIPT_FONTS:
+            {
+                if (pValues->has<bool>())
+                {
+                    bool bNewValue = pValues->get<bool>();
+                    bChanged = (pDoc->IsEmbedFontScriptLatin() != bNewValue);
+                    pDoc->SetEmbedFontScriptLatin(bNewValue);
+                    bOk = true;
+                }
+            }
+            break;
+
+            case HANDLE_EMBED_ASIAN_SCRIPT_FONTS:
+            {
+                if (pValues->has<bool>())
                 {
-                    bChanged = ( pDoc->IsUsingEmbededFonts() != bNewValue );
-                    pDoc->SetIsUsingEmbededFonts( bNewValue );
+                    bool bNewValue = pValues->get<bool>();
+                    bChanged = (pDoc->IsEmbedFontScriptAsian() != bNewValue);
+                    pDoc->SetEmbedFontScriptAsian(bNewValue);
+                    bOk = true;
+                }
+            }
+            break;
+
+            case HANDLE_EMBED_COMPLEX_SCRIPT_FONTS:
+            {
+                if (pValues->has<bool>())
+                {
+                    bool bNewValue = pValues->get<bool>();
+                    bChanged = (pDoc->IsEmbedFontScriptComplex() != bNewValue);
+                    pDoc->SetEmbedFontScriptComplex(bNewValue);
                     bOk = true;
                 }
             }
@@ -1220,7 +1274,31 @@ DocumentSettings::_getPropertyValues(
 
             case HANDLE_EMBED_FONTS:
             {
-                *pValue <<= pDoc->IsUsingEmbededFonts();
+                *pValue <<= pDoc->IsEmbedFonts();
+            }
+            break;
+
+            case HANDLE_EMBED_USED_FONTS:
+            {
+                *pValue <<= pDoc->IsEmbedUsedFontsOnly();
+            }
+            break;
+
+            case HANDLE_EMBED_LATIN_SCRIPT_FONTS:
+            {
+                *pValue <<= pDoc->IsEmbedFontScriptLatin();
+            }
+            break;
+
+            case HANDLE_EMBED_ASIAN_SCRIPT_FONTS:
+            {
+                *pValue <<= pDoc->IsEmbedFontScriptAsian();
+            }
+            break;
+
+            case HANDLE_EMBED_COMPLEX_SCRIPT_FONTS:
+            {
+                *pValue <<= pDoc->IsEmbedFontScriptComplex();
             }
             break;
 
diff --git a/sfx2/source/dialog/documentfontsdialog.cxx b/sfx2/source/dialog/documentfontsdialog.cxx
index 7e5e7f51c6e9..3896f624fa49 100644
--- a/sfx2/source/dialog/documentfontsdialog.cxx
+++ b/sfx2/source/dialog/documentfontsdialog.cxx
@@ -31,6 +31,10 @@ VclPtr<SfxTabPage> SfxDocumentFontsPage::Create(TabPageParent pParent, const Sfx
 SfxDocumentFontsPage::SfxDocumentFontsPage(TabPageParent parent, const SfxItemSet& set)
     : SfxTabPage(parent, "sfx/ui/documentfontspage.ui", "DocumentFontsPage", &set)
     , embedFontsCheckbox(m_xBuilder->weld_check_button("embedFonts"))
+    , embedUsedFontsCheckbox(m_xBuilder->weld_check_button("embedUsedFonts"))
+    , embedLatinScriptFontsCheckbox(m_xBuilder->weld_check_button("embedLatinScriptFonts"))
+    , embedAsianScriptFontsCheckbox(m_xBuilder->weld_check_button("embedAsianScriptFonts"))
+    , embedComplexScriptFontsCheckbox(m_xBuilder->weld_check_button("embedComplexScriptFonts"))
 {
 }
 
@@ -40,26 +44,48 @@ SfxDocumentFontsPage::~SfxDocumentFontsPage()
 
 void SfxDocumentFontsPage::Reset( const SfxItemSet* )
 {
-    bool bVal = false;
+    bool bEmbedFonts = false;
+    bool bEmbedUsedFonts = false;
+
+    bool bEmbedLatinScriptFonts  = false;
+    bool bEmbedAsianScriptFonts  = false;
+    bool bEmbedComplexScriptFonts  = false;
+
     SfxObjectShell* pDocSh = SfxObjectShell::Current();
-    if ( pDocSh )
+    if (pDocSh)
     {
         try
         {
             uno::Reference< lang::XMultiServiceFactory > xFac( pDocSh->GetModel(), uno::UNO_QUERY_THROW );
             uno::Reference< beans::XPropertySet > xProps( xFac->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY_THROW );
-            xProps->getPropertyValue("EmbedFonts") >>= bVal;
+
+            xProps->getPropertyValue("EmbedFonts") >>= bEmbedFonts;
+            xProps->getPropertyValue("EmbedOnlyUsedFonts") >>= bEmbedUsedFonts;
+            xProps->getPropertyValue("EmbedLatinScriptFonts") >>= bEmbedLatinScriptFonts;
+            xProps->getPropertyValue("EmbedAsianScriptFonts") >>= bEmbedAsianScriptFonts;
+            xProps->getPropertyValue("EmbedComplexScriptFonts") >>= bEmbedComplexScriptFonts;
         }
         catch( uno::Exception& )
         {
         }
     }
-    embedFontsCheckbox->set_active(bVal);
+    embedFontsCheckbox->set_active(bEmbedFonts);
+    embedUsedFontsCheckbox->set_active(bEmbedUsedFonts);
+
+    embedLatinScriptFontsCheckbox->set_active(bEmbedLatinScriptFonts);
+    embedAsianScriptFontsCheckbox->set_active(bEmbedAsianScriptFonts);
+    embedComplexScriptFontsCheckbox->set_active(bEmbedComplexScriptFonts);
 }
 
 bool SfxDocumentFontsPage::FillItemSet( SfxItemSet* )
 {
-    bool bVal = embedFontsCheckbox->get_active();
+    bool bEmbedFonts = embedFontsCheckbox->get_active();
+    bool bEmbedUsedFonts = embedUsedFontsCheckbox->get_active();
+
+    bool bEmbedLatinScriptFonts  = embedLatinScriptFontsCheckbox->get_active();
+    bool bEmbedAsianScriptFonts  = embedAsianScriptFontsCheckbox->get_active();
+    bool bEmbedComplexScriptFonts  = embedComplexScriptFontsCheckbox->get_active();
+
     SfxObjectShell* pDocSh = SfxObjectShell::Current();
     if ( pDocSh )
     {
@@ -67,7 +93,11 @@ bool SfxDocumentFontsPage::FillItemSet( SfxItemSet* )
         {
             uno::Reference< lang::XMultiServiceFactory > xFac( pDocSh->GetModel(), uno::UNO_QUERY_THROW );
             uno::Reference< beans::XPropertySet > xProps( xFac->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY_THROW );
-            xProps->setPropertyValue("EmbedFonts", uno::makeAny( bVal ) );
+            xProps->setPropertyValue("EmbedFonts", uno::makeAny(bEmbedFonts));
+            xProps->setPropertyValue("EmbedOnlyUsedFonts", uno::makeAny(bEmbedUsedFonts));
+            xProps->setPropertyValue("EmbedLatinScriptFonts", uno::makeAny(bEmbedLatinScriptFonts));
+            xProps->setPropertyValue("EmbedAsianScriptFonts", uno::makeAny(bEmbedAsianScriptFonts));
+            xProps->setPropertyValue("EmbedComplexScriptFonts", uno::makeAny(bEmbedComplexScriptFonts));
         }
         catch( uno::Exception& )
         {
diff --git a/sfx2/source/inc/documentfontsdialog.hxx b/sfx2/source/inc/documentfontsdialog.hxx
index 1bb9830483dc..32ca1b5160fe 100644
--- a/sfx2/source/inc/documentfontsdialog.hxx
+++ b/sfx2/source/inc/documentfontsdialog.hxx
@@ -35,6 +35,10 @@ protected:
     virtual void Reset( const SfxItemSet* set ) override;
 private:
     std::unique_ptr<weld::CheckButton> embedFontsCheckbox;
+    std::unique_ptr<weld::CheckButton> embedUsedFontsCheckbox;
+    std::unique_ptr<weld::CheckButton> embedLatinScriptFontsCheckbox;
+    std::unique_ptr<weld::CheckButton> embedAsianScriptFontsCheckbox;
+    std::unique_ptr<weld::CheckButton> embedComplexScriptFontsCheckbox;
 };
 
 #endif
diff --git a/sfx2/uiconfig/ui/documentfontspage.ui b/sfx2/uiconfig/ui/documentfontspage.ui
index cec8f7848e82..a32fb1d4ed7f 100644
--- a/sfx2/uiconfig/ui/documentfontspage.ui
+++ b/sfx2/uiconfig/ui/documentfontspage.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.22.1 -->
 <interface domain="sfx">
   <requires lib="gtk+" version="3.18"/>
   <object class="GtkGrid" id="DocumentFontsPage">
@@ -21,14 +21,115 @@
             <property name="top_padding">6</property>
             <property name="left_padding">12</property>
             <child>
-              <object class="GtkCheckButton" id="embedFonts">
-                <property name="label" translatable="yes" context="documentfontspage|embedFonts">_Embed fonts in the document</property>
+              <object class="GtkGrid">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="use_underline">True</property>
-                <property name="xalign">0</property>
-                <property name="draw_indicator">True</property>
+                <property name="can_focus">False</property>
+                <child>
+                  <object class="GtkCheckButton" id="embedFonts">
+                    <property name="label" translatable="yes" context="documentfontspage|embedFonts">_Embed fonts in the document</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="use_underline">True</property>
+                    <property name="xalign">0</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkCheckButton" id="embedUsedFonts">
+                    <property name="label" translatable="yes" context="documentfontspage|embedUsedFonts">Only embed fonts that are used in documents</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="use_underline">True</property>
+                    <property name="xalign">0</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkFrame">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label_xalign">0</property>
+                    <child>
+                      <object class="GtkBox">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="orientation">vertical</property>
+                        <child>
+                          <object class="GtkCheckButton" id="embedLatinScriptFonts">
+                            <property name="label" translatable="yes" context="documentfontspage|embedLatinScriptFonts">Latin fonts</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">False</property>
+                            <property name="use_underline">True</property>
+                            <property name="xalign">0</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>
+                        <child>
+                          <object class="GtkCheckButton" id="embedAsianScriptFonts">
+                            <property name="label" translatable="yes" context="documentfontspage|embedAsianScriptFonts">Asian fonts</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">False</property>
+                            <property name="use_underline">True</property>
+                            <property name="xalign">0</property>
+                            <property name="draw_indicator">True</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkCheckButton" id="embedComplexScriptFonts">
+                            <property name="label" translatable="yes" context="documentfontspage|embedComplexScriptFonts">Complex fonts</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">False</property>
+                            <property name="use_underline">True</property>
+                            <property name="xalign">0</property>
+                            <property name="draw_indicator">True</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">2</property>
+                          </packing>
+                        </child>
+                      </object>
+                    </child>
+                    <child type="label">
+                      <object class="GtkLabel">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes" context="documentfontspage|fontScriptFrameLabel">Select font scripts to embed</property>
+                        <attributes>
+                          <attribute name="weight" value="bold"/>
+                        </attributes>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">2</property>
+                  </packing>
+                </child>
               </object>
             </child>
           </object>
diff --git a/sw/inc/IDocumentSettingAccess.hxx b/sw/inc/IDocumentSettingAccess.hxx
index a66f2367c22f..46f8c1568526 100644
--- a/sw/inc/IDocumentSettingAccess.hxx
+++ b/sw/inc/IDocumentSettingAccess.hxx
@@ -96,6 +96,10 @@ enum class DocumentSettingId
     STYLES_NODEFAULT,
     FLOATTABLE_NOMARGINS,
     EMBED_FONTS,
+    EMBED_USED_FONTS,
+    EMBED_LATIN_SCRIPT_FONTS,
+    EMBED_ASIAN_SCRIPT_FONTS,
+    EMBED_COMPLEX_SCRIPT_FONTS,
     EMBED_SYSTEM_FONTS,
     APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING,
 };
diff --git a/sw/source/core/doc/DocumentSettingManager.cxx b/sw/source/core/doc/DocumentSettingManager.cxx
index c900a985dee2..5e088e0fd0be 100644
--- a/sw/source/core/doc/DocumentSettingManager.cxx
+++ b/sw/source/core/doc/DocumentSettingManager.cxx
@@ -61,6 +61,10 @@ sw::DocumentSettingManager::DocumentSettingManager(SwDoc &rDoc)
     mbStylesNoDefault(false),
     mbFloattableNomargins(false),
     mEmbedFonts(false),
+    mEmbedUsedFonts(false),
+    mEmbedLatinScriptFonts(true),
+    mEmbedAsianScriptFonts(true),
+    mEmbedComplexScriptFonts(true),
     mEmbedSystemFonts(false),
     mbOldNumbering(false),
     mbIgnoreFirstLineIndentInNumbering(false),
@@ -204,6 +208,10 @@ bool sw::DocumentSettingManager::get(/*[in]*/ DocumentSettingId id) const
         case DocumentSettingId::STYLES_NODEFAULT: return mbStylesNoDefault;
         case DocumentSettingId::FLOATTABLE_NOMARGINS: return mbFloattableNomargins;
         case DocumentSettingId::EMBED_FONTS: return mEmbedFonts;
+        case DocumentSettingId::EMBED_USED_FONTS: return mEmbedUsedFonts;
+        case DocumentSettingId::EMBED_LATIN_SCRIPT_FONTS: return mEmbedLatinScriptFonts;
+        case DocumentSettingId::EMBED_ASIAN_SCRIPT_FONTS: return mEmbedAsianScriptFonts;
+        case DocumentSettingId::EMBED_COMPLEX_SCRIPT_FONTS: return mEmbedComplexScriptFonts;
         case DocumentSettingId::EMBED_SYSTEM_FONTS: return mEmbedSystemFonts;
         case DocumentSettingId::APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING: return mApplyParagraphMarkFormatToNumbering;
         case DocumentSettingId::DISABLE_OFF_PAGE_POSITIONING: return mbDisableOffPagePositioning;
@@ -416,6 +424,18 @@ void sw::DocumentSettingManager::set(/*[in]*/ DocumentSettingId id, /*[in]*/ boo
         case DocumentSettingId::EMBED_FONTS:
             mEmbedFonts = value;
             break;
+        case DocumentSettingId::EMBED_USED_FONTS:
+            mEmbedUsedFonts = value;
+            break;
+        case DocumentSettingId::EMBED_LATIN_SCRIPT_FONTS:
+            mEmbedLatinScriptFonts = value;
+            break;
+        case DocumentSettingId::EMBED_ASIAN_SCRIPT_FONTS:
+            mEmbedAsianScriptFonts = value;
+            break;
+        case DocumentSettingId::EMBED_COMPLEX_SCRIPT_FONTS:
+            mEmbedComplexScriptFonts = value;
+            break;
         case DocumentSettingId::EMBED_SYSTEM_FONTS:
             mEmbedSystemFonts = value;
             break;
diff --git a/sw/source/core/inc/DocumentSettingManager.hxx b/sw/source/core/inc/DocumentSettingManager.hxx
index 1cf9a9d9fea9..c8c5b0037978 100644
--- a/sw/source/core/inc/DocumentSettingManager.hxx
+++ b/sw/source/core/inc/DocumentSettingManager.hxx
@@ -122,7 +122,11 @@ class DocumentSettingManager :
     bool mbMathBaselineAlignment            : 1;    // TL  2010-10-29 #i972#
     bool mbStylesNoDefault                  : 1;
     bool mbFloattableNomargins              : 1; //< If paragraph margins next to a floating table should be ignored.
-    bool mEmbedFonts                        : 1;  //< Whether to embed fonts used by the document when saving.
+    bool mEmbedFonts                        : 1;  //< Whether to embed fonts when saving.
+    bool mEmbedUsedFonts                    : 1;  //< Whether to embed fonts that are used by the document when saving.
+    bool mEmbedLatinScriptFonts             : 1;  //< Whether to embed latin script fonts when saving.
+    bool mEmbedAsianScriptFonts             : 1;  //< Whether to embed asian script fonts when saving.
+    bool mEmbedComplexScriptFonts           : 1;  //< Whether to embed complex script fonts when saving.
     bool mEmbedSystemFonts                  : 1;  //< Whether to embed also system fonts.
 
     // non-ui-compatibility flags:
diff --git a/sw/source/filter/xml/xmlfonte.cxx b/sw/source/filter/xml/xmlfonte.cxx
index 7738d51ba50e..8c11072327f2 100644
--- a/sw/source/filter/xml/xmlfonte.cxx
+++ b/sw/source/filter/xml/xmlfonte.cxx
@@ -32,13 +32,12 @@ using namespace ::com::sun::star::text;
 
 class SwXMLFontAutoStylePool_Impl: public XMLFontAutoStylePool
 {
-    public:
-    SwXMLFontAutoStylePool_Impl( SwXMLExport& rExport, bool blockFontEmbedding );
+public:
+    SwXMLFontAutoStylePool_Impl(SwXMLExport& rExport, bool bFontEmbedding);
 };
 
-SwXMLFontAutoStylePool_Impl::SwXMLFontAutoStylePool_Impl(
-    SwXMLExport& _rExport, bool blockFontEmbedding ) :
-    XMLFontAutoStylePool( _rExport, blockFontEmbedding )
+SwXMLFontAutoStylePool_Impl::SwXMLFontAutoStylePool_Impl(SwXMLExport& _rExport, bool bFontEmbedding)
+    : XMLFontAutoStylePool(_rExport, bFontEmbedding)
 {
     sal_uInt16 const aWhichIds[3] = { RES_CHRATR_FONT, RES_CHRATR_CJK_FONT,
                                       RES_CHRATR_CTL_FONT };
@@ -65,6 +64,13 @@ SwXMLFontAutoStylePool_Impl::SwXMLFontAutoStylePool_Impl(
             }
         }
     }
+    auto const & pDocument = _rExport.getDoc();
+
+    m_bEmbedUsedOnly = pDocument->getIDocumentSettingAccess().get(DocumentSettingId::EMBED_USED_FONTS);
+    m_bEmbedLatinScript = pDocument->getIDocumentSettingAccess().get(DocumentSettingId::EMBED_LATIN_SCRIPT_FONTS);
+    m_bEmbedAsianScript = pDocument->getIDocumentSettingAccess().get(DocumentSettingId::EMBED_ASIAN_SCRIPT_FONTS);
+    m_bEmbedComplexScript = pDocument->getIDocumentSettingAccess().get(DocumentSettingId::EMBED_COMPLEX_SCRIPT_FONTS);
+
 }
 
 XMLFontAutoStylePool* SwXMLExport::CreateFontAutoStylePool()
@@ -87,4 +93,3 @@ void SwXMLImport::NotifyEmbeddedFontRead()
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-
diff --git a/sw/source/uibase/uno/SwXDocumentSettings.cxx b/sw/source/uibase/uno/SwXDocumentSettings.cxx
index a7690c7b1b88..8e5ae19a13f1 100644
--- a/sw/source/uibase/uno/SwXDocumentSettings.cxx
+++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx
@@ -128,6 +128,10 @@ enum SwDocumentSettingsPropertyHandles
     HANDLE_CLIPPED_PICTURES,
     HANDLE_BACKGROUND_PARA_OVER_DRAWINGS,
     HANDLE_EMBED_FONTS,
+    HANDLE_EMBED_USED_FONTS,
+    HANDLE_EMBED_LATIN_SCRIPT_FONTS,
+    HANDLE_EMBED_ASIAN_SCRIPT_FONTS,
+    HANDLE_EMBED_COMPLEX_SCRIPT_FONTS,
     HANDLE_EMBED_SYSTEM_FONTS,
     HANDLE_TAB_OVER_MARGIN,
     HANDLE_TREAT_SINGLE_COLUMN_BREAK_AS_PAGE_BREAK,
@@ -208,6 +212,10 @@ static MasterPropertySetInfo * lcl_createSettingsInfo()
         { OUString("ClippedPictures"), HANDLE_CLIPPED_PICTURES, cppu::UnoType<bool>::get(), 0},
         { OUString("BackgroundParaOverDrawings"), HANDLE_BACKGROUND_PARA_OVER_DRAWINGS, cppu::UnoType<bool>::get(), 0},
         { OUString("EmbedFonts"), HANDLE_EMBED_FONTS, cppu::UnoType<bool>::get(), 0},
+        { OUString("EmbedOnlyUsedFonts"), HANDLE_EMBED_USED_FONTS, cppu::UnoType<bool>::get(), 0},
+        { OUString("EmbedLatinScriptFonts"), HANDLE_EMBED_LATIN_SCRIPT_FONTS, cppu::UnoType<bool>::get(), 0},
+        { OUString("EmbedAsianScriptFonts"), HANDLE_EMBED_ASIAN_SCRIPT_FONTS, cppu::UnoType<bool>::get(), 0},
+        { OUString("EmbedComplexScriptFonts"), HANDLE_EMBED_COMPLEX_SCRIPT_FONTS, cppu::UnoType<bool>::get(), 0},
         { OUString("EmbedSystemFonts"), HANDLE_EMBED_SYSTEM_FONTS, cppu::UnoType<bool>::get(), 0},
         { OUString("TabOverMargin"), HANDLE_TAB_OVER_MARGIN, cppu::UnoType<bool>::get(), 0},
         { OUString("TreatSingleColumnBreakAsPageBreak"), HANDLE_TREAT_SINGLE_COLUMN_BREAK_AS_PAGE_BREAK, cppu::UnoType<bool>::get(), 0},
@@ -826,6 +834,30 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf
             mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::EMBED_FONTS, bTmp);
         }
         break;
+        case HANDLE_EMBED_USED_FONTS:
+        {
+            bool bTmp = *o3tl::doAccess<bool>(rValue);
+            mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::EMBED_USED_FONTS, bTmp);
+        }
+        break;
+        case HANDLE_EMBED_LATIN_SCRIPT_FONTS:
+        {
+            bool bTmp = *o3tl::doAccess<bool>(rValue);
+            mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::EMBED_LATIN_SCRIPT_FONTS, bTmp);
+        }
+        break;
+        case HANDLE_EMBED_ASIAN_SCRIPT_FONTS:
+        {
+            bool bTmp = *o3tl::doAccess<bool>(rValue);
+            mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::EMBED_ASIAN_SCRIPT_FONTS, bTmp);
+        }
+        break;
+        case HANDLE_EMBED_COMPLEX_SCRIPT_FONTS:
+        {
+            bool bTmp = *o3tl::doAccess<bool>(rValue);
+            mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::EMBED_COMPLEX_SCRIPT_FONTS, bTmp);
+        }
+        break;
         case HANDLE_EMBED_SYSTEM_FONTS:
         {
             bool bTmp = *o3tl::doAccess<bool>(rValue);
@@ -1287,6 +1319,26 @@ void SwXDocumentSettings::_getSingleValue( const comphelper::PropertyInfo & rInf
             rValue <<= mpDoc->getIDocumentSettingAccess().get( DocumentSettingId::EMBED_FONTS );
         }
         break;
+        case HANDLE_EMBED_USED_FONTS:
+        {
+            rValue <<= mpDoc->getIDocumentSettingAccess().get( DocumentSettingId::EMBED_USED_FONTS );
+        }
+        break;
+        case HANDLE_EMBED_LATIN_SCRIPT_FONTS:
+        {
+            rValue <<= mpDoc->getIDocumentSettingAccess().get( DocumentSettingId::EMBED_LATIN_SCRIPT_FONTS );
+        }
+        break;
+        case HANDLE_EMBED_ASIAN_SCRIPT_FONTS:
+        {
+            rValue <<= mpDoc->getIDocumentSettingAccess().get( DocumentSettingId::EMBED_ASIAN_SCRIPT_FONTS );
+        }
+        break;
+        case HANDLE_EMBED_COMPLEX_SCRIPT_FONTS:
+        {
+            rValue <<= mpDoc->getIDocumentSettingAccess().get( DocumentSettingId::EMBED_COMPLEX_SCRIPT_FONTS );
+        }
+        break;
         case HANDLE_EMBED_SYSTEM_FONTS:
         {
             rValue <<= mpDoc->getIDocumentSettingAccess().get( DocumentSettingId::EMBED_SYSTEM_FONTS );
diff --git a/xmloff/source/draw/sdxmlexp.cxx b/xmloff/source/draw/sdxmlexp.cxx
index 36c8ca93f117..859a8aea8c2e 100644
--- a/xmloff/source/draw/sdxmlexp.cxx
+++ b/xmloff/source/draw/sdxmlexp.cxx
@@ -2694,26 +2694,38 @@ SERVICE( XMLImpressClipboardExport, "com.sun.star.comp.Impress.XMLClipboardExpor
 XMLFontAutoStylePool* SdXMLExport::CreateFontAutoStylePool()
 {
     bool bEmbedFonts = false;
+    bool bEmbedUsedOnly = false;
+    bool bEmbedLatinScript = true;
+    bool bEmbedAsianScript = true;
+    bool bEmbedComplexScript = true;
+
     if (getExportFlags() & SvXMLExportFlags::CONTENT)
     {
         Reference< lang::XMultiServiceFactory > xFac( GetModel(), UNO_QUERY );
         if( xFac.is() )
         {
-            try
-            {
-                Reference<beans::XPropertySet> const xProps( xFac->createInstance(
-                             "com.sun.star.document.Settings"), UNO_QUERY_THROW );
-                xProps->getPropertyValue("EmbedFonts") >>= bEmbedFonts;
-            }
-            catch (...)
+            Reference<beans::XPropertySet> const xProps(xFac->createInstance("com.sun.star.document.Settings"), UNO_QUERY);
+            Reference<beans::XPropertySetInfo> const xInfo(xProps->getPropertySetInfo(), uno::UNO_QUERY);
+
+            if (xProps.is() && xInfo.is())
             {
-                // clipboard document doesn't have shell so throws from getPropertyValue
-                // gallery elements may not support com.sun.star.document.Settings so throws from createInstance
+                if (xInfo->hasPropertyByName("EmbedFonts"))
+                    xProps->getPropertyValue("EmbedFonts") >>= bEmbedFonts;
+                if (xInfo->hasPropertyByName("EmbedOnlyUsedFonts"))
+                    xProps->getPropertyValue("EmbedOnlyUsedFonts") >>= bEmbedUsedOnly;
+                if (xInfo->hasPropertyByName("EmbedLatinScriptFonts"))
+                    xProps->getPropertyValue("EmbedLatinScriptFonts") >>= bEmbedLatinScript;
+                if (xInfo->hasPropertyByName("EmbedAsianScriptFonts"))
+                    xProps->getPropertyValue("EmbedAsianScriptFonts") >>= bEmbedAsianScript;
+                if (xInfo->hasPropertyByName("EmbedComplexScriptFonts"))
+                    xProps->getPropertyValue("EmbedComplexScriptFonts") >>= bEmbedComplexScript;
             }
         }
     }
 
     XMLFontAutoStylePool *pPool = new XMLFontAutoStylePool( *this, bEmbedFonts );
+    pPool->setEmbedOnlyUsedFonts(bEmbedUsedOnly);
+    pPool->setEmbedFontScripts(bEmbedLatinScript, bEmbedAsianScript, bEmbedComplexScript);
 
     Reference< beans::XPropertySet > xProps( GetModel(), UNO_QUERY );
     if ( xProps.is() ) {
diff --git a/xmloff/source/style/XMLFontAutoStylePool.cxx b/xmloff/source/style/XMLFontAutoStylePool.cxx
index 1fb06598f841..c410624ee9ce 100644
--- a/xmloff/source/style/XMLFontAutoStylePool.cxx
+++ b/xmloff/source/style/XMLFontAutoStylePool.cxx
@@ -141,7 +141,11 @@ public:
 XMLFontAutoStylePool::XMLFontAutoStylePool(SvXMLExport& rExp, bool bTryToEmbedFonts) :
     rExport( rExp ),
     m_pFontAutoStylePool( new XMLFontAutoStylePool_Impl ),
-    m_bTryToEmbedFonts( bTryToEmbedFonts )
+    m_bTryToEmbedFonts( bTryToEmbedFonts ),
+    m_bEmbedUsedOnly(false),
+    m_bEmbedLatinScript(true),
+    m_bEmbedAsianScript(true),
+    m_bEmbedComplexScript(true)
 {
 }
 


More information about the Libreoffice-commits mailing list