sd/qa/unit/FontEmbeddingTest.cxx | 11 ----------- sd/source/filter/eppt/pptx-epptooxml.cxx | 23 +++++++++++++---------- 2 files changed, 13 insertions(+), 21 deletions(-)
New commits: commit ff4ff571defc5e62c469799a05a562012fc40ec7 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon May 26 14:27:18 2025 +0900 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed May 28 08:45:42 2025 +0200 sd: write embedded fonts with a more descriptive name If MSO writes the name of fonts with a generic name like "font1", this doesn't mean that we need to do the same thing. Use a better more descriptive names of the fonts that include the font family name and the font type (regular, bold, italic,...). Test assert needed to be removed - much harder to test this now, but not really that critical. Change-Id: I96b9f6ee9d34fa7a030fdf0496ef4078bd3dc946 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185763 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sd/qa/unit/FontEmbeddingTest.cxx b/sd/qa/unit/FontEmbeddingTest.cxx index 22ec352ceaf6..be1d91dfd1af 100644 --- a/sd/qa/unit/FontEmbeddingTest.cxx +++ b/sd/qa/unit/FontEmbeddingTest.cxx @@ -29,7 +29,6 @@ namespace constexpr OString xPath_Presentation = "/p:presentation"_ostr; constexpr OString xPath_EmbeddedFont = "/p:presentation/p:embeddedFontLst/p:embeddedFont/p:font"_ostr; -constexpr OString xPath_Relationship = "/rels:Relationships/rels:Relationship"_ostr; } CPPUNIT_TEST_FIXTURE(FontEmbeddingTest, testRoundtripEmbeddedFontsPPTX) @@ -132,16 +131,6 @@ CPPUNIT_TEST_FIXTURE(FontEmbeddingTest, testExportEmbeddedFontsPPTX) assertXPath(pXmlDoc, xPath_Presentation, "embedTrueTypeFonts", u"1"); assertXPath(pXmlDoc, xPath_EmbeddedFont + "[@typeface='DejaVu Sans']"); } - - // Check the relationships to the embedded fonts - { - xmlDocUniquePtr pXmlDoc = parseExport(u"ppt/_rels/presentation.xml.rels"_ustr); - - static constexpr auto sFontType - = u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/font"; - assertXPath(pXmlDoc, xPath_Relationship + "[@Target='fonts/font1.fntdata']", "Type", - sFontType); - } #endif } diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx index d3a55f5ae441..c21015b3a035 100644 --- a/sd/source/filter/eppt/pptx-epptooxml.cxx +++ b/sd/source/filter/eppt/pptx-epptooxml.cxx @@ -844,15 +844,26 @@ void PowerPointExport::WriteEmbeddedFontList() if (!aConverter.convert(rEOT)) continue; - OUString sFontFileName = "font" + OUString::number(nextFontId) + ".fntdata"; + OUString sFontType = u"Regular"_ustr; + if (eItalic == ITALIC_NONE && eWeight == WEIGHT_BOLD) + sFontType = u"Bold"_ustr; + else if (eItalic == ITALIC_NORMAL && eWeight == WEIGHT_NORMAL) + sFontType = u"Italic"_ustr; + else if (eItalic == ITALIC_NORMAL && eWeight == WEIGHT_BOLD) + sFontType = u"BoldItalic"_ustr; + + OUString sFontFileName = "Font_" + OUString::number(nextFontId) + "_" + + sFamilyName.replaceAll(" ", "_") + "_" + sFontType +".fntdata"; + OUString sArchivePath = "ppt/fonts/" + sFontFileName; + uno::Reference<css::io::XOutputStream> xOutStream = openFragmentStream(sArchivePath, u"application/x-fontdata"_ustr); xOutStream->writeBytes(uno::Sequence<sal_Int8>(reinterpret_cast<const sal_Int8*>(rEOT.data()), rEOT.size())); xOutStream->closeOutput(); OUString sRelID = addRelation(mPresentationFS->getOutputStream(), oox::getRelationship(Relationship::FONT), - Concat2View("fonts/font" + OUString::number(nextFontId) + ".fntdata")); + Concat2View("fonts/" + sFontFileName)); ++nextFontId; @@ -865,21 +876,13 @@ void PowerPointExport::WriteEmbeddedFontList() } if (eItalic == ITALIC_NONE && eWeight == WEIGHT_NORMAL) - { aInfo.aRegularRelID = uRelID; - } else if (eItalic == ITALIC_NONE && eWeight == WEIGHT_BOLD) - { aInfo.aBoldRelID = uRelID; - } else if (eItalic == ITALIC_NORMAL && eWeight == WEIGHT_NORMAL) - { aInfo.aItalicRelID = uRelID; - } else if (eItalic == ITALIC_NORMAL && eWeight == WEIGHT_BOLD) - { aInfo.aBoldItalicRelID = uRelID; - } } aEmbeddedFontInfo.push_back(aInfo);