external/pdfium/UnpackedTarball_pdfium.mk | 1 external/pdfium/charcodetoglyphindex.patch.1 | 38 ++++++++++++++ include/vcl/filter/PDFiumLibrary.hxx | 24 +++++++-- svx/source/inc/svdpdf.hxx | 5 + svx/source/svdraw/svdpdf.cxx | 72 +++++++++++++++++---------- vcl/source/pdf/PDFiumLibrary.cxx | 64 ++++++++++++++++-------- 6 files changed, 152 insertions(+), 52 deletions(-)
New commits: commit 2e613609d41a4fb09087bc08967bf8958b67c0f2 Author: Caolán McNamara <[email protected]> AuthorDate: Thu Oct 23 16:36:34 2025 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Sun Oct 26 12:08:27 2025 +0100 use pdfium to map ToUnicode character codes to glyph indexes Seeing as these are not actually already glyph indexes, just seems to be common practice that they usually are, especially for subsets. Use pdfium's mapping for this instead. Change-Id: I6cd3d3c236b62c5014fa8e829cbb52ae4fa2d8ae Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192922 Reviewed-by: Mike Kaganski <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192992 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> diff --git a/external/pdfium/UnpackedTarball_pdfium.mk b/external/pdfium/UnpackedTarball_pdfium.mk index 8df29bbf3e6f..f3a3c9e8d62b 100644 --- a/external/pdfium/UnpackedTarball_pdfium.mk +++ b/external/pdfium/UnpackedTarball_pdfium.mk @@ -19,6 +19,7 @@ pdfium_patches += freebsd.patch pdfium_patches += system-abseil.diff # expose this mapping information pdfium_patches += tounicodeinfo.patch.1 +pdfium_patches += charcodetoglyphindex.patch.1 pdfium_patches += system-fast_float.diff diff --git a/external/pdfium/charcodetoglyphindex.patch.1 b/external/pdfium/charcodetoglyphindex.patch.1 new file mode 100644 index 000000000000..6115a92e0edc --- /dev/null +++ b/external/pdfium/charcodetoglyphindex.patch.1 @@ -0,0 +1,38 @@ +--- pdfium.orig/fpdfsdk/fpdf_edittext.cpp ++++ pdfium/fpdfsdk/fpdf_edittext.cpp +@@ -1173,6 +1173,21 @@ + return FPDFGlyphPathFromCFXPath(pPath); + } + ++FPDF_EXPORT uint32_t FPDF_CALLCONV ++FPDFFont_GetGlyphIndexFromCharCode(FPDF_FONT font, uint32_t char_code) { ++ auto* pFont = CPDFFontFromFPDFFont(font); ++ if (!pFont) ++ return 0; ++ ++#if BUILDFLAG(IS_APPLE) ++ uint32_t extGID = pFont->GlyphFromCharCodeExt(char_code); ++ if (extGID != static_cast<uint32_t>(-1)) ++ return extGID; ++#endif ++ ++ return pFont->GlyphFromCharCode(char_code, nullptr); ++} ++ + FPDF_EXPORT int FPDF_CALLCONV + FPDFGlyphPath_CountGlyphSegments(FPDF_GLYPHPATH glyphpath) { + auto* pPath = CFXPathFromFPDFGlyphPath(glyphpath); +--- pdfium.orig/public/fpdf_edit.h ++++ pdfium/public/fpdf_edit.h +@@ -1622,6 +1622,11 @@ + float font_size); + + // Experimental API. ++// Get glyph index of the PDF character code ++FPDF_EXPORT uint32_t FPDF_CALLCONV ++FPDFFont_GetGlyphIndexFromCharCode(FPDF_FONT font, uint32_t charcode); ++ ++// Experimental API. + // Get number of segments inside glyphpath. + // + // glyphpath - handle to a glyph path. diff --git a/include/vcl/filter/PDFiumLibrary.hxx b/include/vcl/filter/PDFiumLibrary.hxx index 4104eb53e1d0..8e17ee7b4144 100644 --- a/include/vcl/filter/PDFiumLibrary.hxx +++ b/include/vcl/filter/PDFiumLibrary.hxx @@ -63,6 +63,12 @@ public: virtual bool getFontToUnicode(std::vector<uint8_t>& rData) const = 0; virtual bool getIsEmbedded() const = 0; + // Get the index in the font of the glyph represented by the pdf "character + // code" of nCharCode. Which itself is what is mapped to unicode by a pdf's + // ToUnicode resource. + // A return of 0 represents not-found. + virtual sal_uInt32 getGlyphIndexFromCharCode(const sal_uInt32 nCharCode) const = 0; + virtual sal_Int64 getUniqueId() const = 0; }; diff --git a/svx/source/inc/svdpdf.hxx b/svx/source/inc/svdpdf.hxx index ac6c9bb1558c..e2bc3acf7895 100644 --- a/svx/source/inc/svdpdf.hxx +++ b/svx/source/inc/svdpdf.hxx @@ -189,7 +189,8 @@ class ImpSdrPdfImport final const OUString& fileUrl, const OUString& fontName, const OUString& baseFontName, std::u16string_view fontFileName, - const std::vector<uint8_t>& toUnicodeData); + const std::vector<uint8_t>& toUnicodeData, + const vcl::pdf::PDFiumFont& font); // Copy assignment is forbidden and not implemented. ImpSdrPdfImport(const ImpSdrPdfImport&) = delete; diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx index 776c9f4e93b3..fb94b2a3ea87 100644 --- a/svx/source/svdraw/svdpdf.cxx +++ b/svx/source/svdraw/svdpdf.cxx @@ -324,7 +324,7 @@ void ImpSdrPdfImport::CollectFonts() { EmbeddedFontInfo fontInfo = convertToOTF(getPrefix(), *pSubSetInfo, fileUrl, sFontName, - sPostScriptName, sFontFileName, aToUnicodeData); + sPostScriptName, sFontFileName, aToUnicodeData, *font); fileUrl = fontInfo.sFontFile; sFontName = fontInfo.sFontName; eFontWeight = fontInfo.eFontWeight; @@ -1223,7 +1223,6 @@ static bool toPfaCID(SubSetInfo& rSubSetInfo, const OUString& fileUrl, ## glyph[tag] {name,encoding} */ bNameKeyed = glyphTag == "{name,encoding}"; - if (bNameKeyed) { SAL_INFO("sd.filter", "convert to cid keyed"); @@ -1335,8 +1334,14 @@ struct ToUnicodeData std::vector<OString> bfcharlines; std::vector<OString> bfcharranges; + // one or the other of these + const vcl::pdf::PDFiumFont* pFont; + const std::map<int, int>* pNameIndexToGlyph; + // For the pdf provided mapping from the font to unicode - ToUnicodeData(const std::vector<uint8_t>& toUnicodeData) + ToUnicodeData(const std::vector<uint8_t>& toUnicodeData, const vcl::pdf::PDFiumFont& pdfFont) + : pFont(&pdfFont) + , pNameIndexToGlyph(nullptr) { SvMemoryStream aInCMap(const_cast<uint8_t*>(toUnicodeData.data()), toUnicodeData.size(), StreamMode::READ); @@ -1370,6 +1375,8 @@ struct ToUnicodeData // reverse map from the name indexes so we can forward // map to unicode ToUnicodeData(std::map<int, int>& nameIndexToGlyph) + : pFont(nullptr) + , pNameIndexToGlyph(&nameIndexToGlyph) { for (const auto & [ adobe, glyphid ] : nameIndexToGlyph) { @@ -1388,12 +1395,21 @@ struct ToUnicodeData bfcharlines.push_back(aBuffer.toString()); } } + + sal_uInt32 getGlyphIndexFromCharCode(sal_uInt32 nPDFCharCode) + { + if (pFont) + return pFont->getGlyphIndexFromCharCode(nPDFCharCode); + assert(pNameIndexToGlyph); + auto it = pNameIndexToGlyph->find(nPDFCharCode); + return it != pNameIndexToGlyph->end() ? it->second : 0; + } }; } static void buildCMapAndFeatures(const OUString& CMapUrl, SvFileStream& Features, - std::string_view FontName, ToUnicodeData& tud, bool bNameKeyed, - std::map<int, int>& nameIndexToGlyph, SubSetInfo& rSubSetInfo) + std::string_view FontName, ToUnicodeData& tud, + SubSetInfo& rSubSetInfo) { SvFileStream CMap(CMapUrl, StreamMode::READWRITE | StreamMode::TRUNC); @@ -1474,7 +1490,6 @@ static void buildCMapAndFeatures(const OUString& CMapUrl, SvFileStream& Features if (!cidranges.empty()) { // searching for real world examples where this occurs - assert(!bNameKeyed); OString beginline = OString::number(cidranges.size()) + " begincidrange"; CMap.WriteLine(beginline); for (const auto& rLine : cidranges) @@ -1492,9 +1507,8 @@ static void buildCMapAndFeatures(const OUString& CMapUrl, SvFileStream& Features assert(charline[0] == '<'); sal_Int32 nEnd = charline.indexOf('>', 1); assert(charline[nEnd] == '>'); - sal_Int32 nGlyphIndex = o3tl::toInt32(charline.subView(1, nEnd - 1), 16); - if (bNameKeyed) - nGlyphIndex = nameIndexToGlyph[nGlyphIndex]; + sal_Int32 nPDFCharCode = o3tl::toInt32(charline.subView(1, nEnd - 1), 16); + sal_Int32 nGlyphIndex = tud.getGlyphIndexFromCharCode(nPDFCharCode); OString sChars(o3tl::trim(charline.subView(nEnd + 1))); assert(sChars[0] == '<' && sChars[sChars.getLength() - 1] == '>'); OString sContents = sChars.copy(1, sChars.getLength() - 2); @@ -1598,7 +1612,7 @@ static EmbeddedFontInfo mergeFontSubsets(sal_Int64 prefix, const OUString& merge const OUString& longFontName, std::string_view Weight, const SubSetInfo& rSubSetInfo) { - SAL_WARN("sd.filter", "merging " << rSubSetInfo.aComponents.size() << " font subsets of " + SAL_INFO("sd.filter", "merging " << rSubSetInfo.aComponents.size() << " font subsets of " << postScriptName << " together to create: " << mergedFontUrl); std::vector<std::pair<OUString, OUString>> fonts; for (size_t i = 0; i < rSubSetInfo.aComponents.size(); ++i) @@ -1752,7 +1766,8 @@ EmbeddedFontInfo ImpSdrPdfImport::convertToOTF(sal_Int64 prefix, SubSetInfo& rSu const OUString& fileUrl, const OUString& fontName, const OUString& postScriptName, std::u16string_view fontFileName, - const std::vector<uint8_t>& toUnicodeData) + const std::vector<uint8_t>& toUnicodeData, + const vcl::pdf::PDFiumFont& font) { // Convert to Type 1 CID keyed std::map<int, int> nameIndexToGlyph; @@ -1774,16 +1789,14 @@ EmbeddedFontInfo ImpSdrPdfImport::convertToOTF(sal_Int64 prefix, SubSetInfo& rSu bool bCMap = true; if (!toUnicodeData.empty()) { - ToUnicodeData tud(toUnicodeData); - buildCMapAndFeatures(CMapUrl, Features, FontName, tud, bNameKeyed, nameIndexToGlyph, - rSubSetInfo); + ToUnicodeData tud(toUnicodeData, font); + buildCMapAndFeatures(CMapUrl, Features, FontName, tud, rSubSetInfo); } else if (bNameKeyed) { SAL_INFO("sd.filter", "There is no CMap, assuming Adobe Standard encoding."); ToUnicodeData tud(nameIndexToGlyph); - buildCMapAndFeatures(CMapUrl, Features, FontName, tud, bNameKeyed, nameIndexToGlyph, - rSubSetInfo); + buildCMapAndFeatures(CMapUrl, Features, FontName, tud, rSubSetInfo); } else { diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx index 0e82178bc6e2..8c709a7c1ff6 100644 --- a/vcl/source/pdf/PDFiumLibrary.cxx +++ b/vcl/source/pdf/PDFiumLibrary.cxx @@ -451,6 +451,8 @@ public: bool getFontToUnicode(std::vector<uint8_t>& rData) const override; bool getIsEmbedded() const override; + sal_uInt32 getGlyphIndexFromCharCode(const sal_uInt32 nCharCode) const override; + sal_Int64 getUniqueId() const override { return reinterpret_cast<sal_Int64>(mpFont); } }; @@ -1310,6 +1312,11 @@ bool PDFiumFontImpl::getFontToUnicode(std::vector<uint8_t>& rData) const bool PDFiumFontImpl::getIsEmbedded() const { return FPDFFont_GetIsEmbedded(mpFont) == 1; } +sal_uInt32 PDFiumFontImpl::getGlyphIndexFromCharCode(const sal_uInt32 nCharCode) const +{ + return FPDFFont_GetGlyphIndexFromCharCode(mpFont, nCharCode); +} + bool PDFiumPageObjectImpl::getFontProperties(FontWeight& weight) { // FPDFFont_GetWeight turns out not to be that useful. It seems to just commit f7c7ea2f67b71faad7410a6643cab0f069d9de0d Author: Caolán McNamara <[email protected]> AuthorDate: Thu Oct 23 15:21:46 2025 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Sun Oct 26 12:08:20 2025 +0100 make PDFiumFont a separate class Change-Id: I25c804bb9dee31cc26c18c8aa4038aeccd73f709 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192921 Reviewed-by: Mike Kaganski <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192991 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> diff --git a/include/vcl/filter/PDFiumLibrary.hxx b/include/vcl/filter/PDFiumLibrary.hxx index 36bfa8743ac7..4104eb53e1d0 100644 --- a/include/vcl/filter/PDFiumLibrary.hxx +++ b/include/vcl/filter/PDFiumLibrary.hxx @@ -53,7 +53,18 @@ inline constexpr OString constDictionaryKey_RichContent = "RC"_ostr; class PDFiumBitmap; class PDFiumDocument; class PDFiumPageObject; -typedef void* PDFiumFont; + +class PDFiumFont +{ +public: + virtual ~PDFiumFont() = default; + + virtual bool getFontData(std::vector<uint8_t>& rData) const = 0; + virtual bool getFontToUnicode(std::vector<uint8_t>& rData) const = 0; + virtual bool getIsEmbedded() const = 0; + + virtual sal_Int64 getUniqueId() const = 0; +}; class VCL_DLLPUBLIC PDFium { @@ -158,10 +169,7 @@ public: virtual OUString getFontName() = 0; virtual OUString getBaseFontName() = 0; virtual int getFontAngle() = 0; - virtual PDFiumFont getFont() = 0; - virtual bool getFontData(PDFiumFont font, std::vector<uint8_t>& rData) = 0; - virtual bool getFontToUnicode(PDFiumFont font, std::vector<uint8_t>& rData) = 0; - virtual bool getIsEmbedded(PDFiumFont font) = 0; + virtual std::unique_ptr<PDFiumFont> getFont() = 0; virtual bool getFontProperties(FontWeight& weight) = 0; virtual PDFTextRenderMode getTextRenderMode() = 0; virtual Color getFillColor() = 0; diff --git a/svx/source/inc/svdpdf.hxx b/svx/source/inc/svdpdf.hxx index c6a331adf044..ac6c9bb1558c 100644 --- a/svx/source/inc/svdpdf.hxx +++ b/svx/source/inc/svdpdf.hxx @@ -91,7 +91,7 @@ class ImpSdrPdfImport final { std::vector<rtl::Reference<SdrObject>> maTmpList; - std::map<vcl::pdf::PDFiumFont, OfficeFontInfo> maImportedFonts; + std::map<sal_Int64, OfficeFontInfo> maImportedFonts; std::map<OUString, SubSetInfo> maDifferentSubsetsForFont; // map of PostScriptName->Merged Font File for that font std::map<OUString, EmbeddedFontInfo> maEmbeddedFonts; diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx index c141794a86fd..776c9f4e93b3 100644 --- a/svx/source/svdraw/svdpdf.cxx +++ b/svx/source/svdraw/svdpdf.cxx @@ -250,11 +250,11 @@ void ImpSdrPdfImport::CollectFonts() const vcl::pdf::PDFPageObjectType ePageObjectType = pPageObject->getType(); if (ePageObjectType != vcl::pdf::PDFPageObjectType::Text) continue; - vcl::pdf::PDFiumFont font = pPageObject->getFont(); + std::unique_ptr<vcl::pdf::PDFiumFont> font = pPageObject->getFont(); if (!font) continue; - auto itImportedFont = maImportedFonts.find(font); + auto itImportedFont = maImportedFonts.find(font->getUniqueId()); if (itImportedFont == maImportedFonts.end()) { OUString sPostScriptName = GetPostScriptName(pPageObject->getBaseFontName()); @@ -272,17 +272,17 @@ void ImpSdrPdfImport::CollectFonts() << sFontName); } - if (!pPageObject->getIsEmbedded(font)) + if (!font->getIsEmbedded()) { SAL_WARN("sd.filter", "skipping not embedded font, map: " << sFontName << " to " << sPostScriptFontFamily); - maImportedFonts.emplace(font, + maImportedFonts.emplace(font->getUniqueId(), OfficeFontInfo{ sPostScriptFontFamily, eFontWeight }); continue; } std::vector<uint8_t> aFontData; - if (!pPageObject->getFontData(font, aFontData) || aFontData.empty()) + if (!font->getFontData(aFontData) || aFontData.empty()) { SAL_WARN("sd.filter", "that's worrying, skipping " << sFontName); continue; @@ -318,7 +318,7 @@ void ImpSdrPdfImport::CollectFonts() else SAL_INFO("sd.filter", "ttf written to: " << fileUrl); std::vector<uint8_t> aToUnicodeData; - if (!pPageObject->getFontToUnicode(font, aToUnicodeData)) + if (!font->getFontToUnicode(aToUnicodeData)) SAL_WARN("sd.filter", "that's maybe worrying"); if (!bTTF || !aToUnicodeData.empty()) { @@ -332,7 +332,8 @@ void ImpSdrPdfImport::CollectFonts() if (fileUrl.getLength()) { - maImportedFonts.emplace(font, OfficeFontInfo{ sFontName, eFontWeight }); + maImportedFonts.emplace(font->getUniqueId(), + OfficeFontInfo{ sFontName, eFontWeight }); maEmbeddedFonts[sPostScriptName] = EmbeddedFontInfo{ sFontName, fileUrl, eFontWeight }; } @@ -1875,7 +1876,9 @@ void ImpSdrPdfImport::ImportText(std::unique_ptr<vcl::pdf::PDFiumPageObject> con OUString sFontName; FontWeight eFontWeight(WEIGHT_DONTKNOW); - auto itImportedFont = maImportedFonts.find(pPageObject->getFont()); + auto xFont = pPageObject->getFont(); + auto itImportedFont + = xFont ? maImportedFonts.find(xFont->getUniqueId()) : maImportedFonts.end(); if (itImportedFont != maImportedFonts.end()) { // We expand a name like "Foo" with non-traditional styles like diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx index 1a60815ccf98..0e82178bc6e2 100644 --- a/vcl/source/pdf/PDFiumLibrary.cxx +++ b/vcl/source/pdf/PDFiumLibrary.cxx @@ -418,10 +418,7 @@ public: OUString getFontName() override; OUString getBaseFontName() override; int getFontAngle() override; - PDFiumFont getFont() override; - bool getFontData(PDFiumFont font, std::vector<uint8_t>& rData) override; - bool getFontToUnicode(PDFiumFont font, std::vector<uint8_t>& rData) override; - bool getIsEmbedded(PDFiumFont font) override; + std::unique_ptr<PDFiumFont> getFont() override; bool getFontProperties(FontWeight& weight) override; PDFTextRenderMode getTextRenderMode() override; Color getFillColor() override; @@ -439,6 +436,24 @@ public: bool getDrawMode(PDFFillMode& eFillMode, bool& bStroke) override; }; +class PDFiumFontImpl final : public PDFiumFont +{ +private: + FPDF_FONT mpFont; + + PDFiumFontImpl(const PDFiumFontImpl&) = delete; + PDFiumFontImpl& operator=(const PDFiumFontImpl&) = delete; + +public: + PDFiumFontImpl(FPDF_FONT pFont); + + bool getFontData(std::vector<uint8_t>& rData) const override; + bool getFontToUnicode(std::vector<uint8_t>& rData) const override; + bool getIsEmbedded() const override; + + sal_Int64 getUniqueId() const override { return reinterpret_cast<sal_Int64>(mpFont); } +}; + class PDFiumSearchHandleImpl final : public PDFiumSearchHandle { private: @@ -1250,46 +1265,50 @@ int PDFiumPageObjectImpl::getFontAngle() return nFontAngle; } -PDFiumFont PDFiumPageObjectImpl::getFont() { return FPDFTextObj_GetFont(mpPageObject); } +std::unique_ptr<PDFiumFont> PDFiumPageObjectImpl::getFont() +{ + std::unique_ptr<PDFiumFont> pPDFiumFont; + if (FPDF_FONT pFont = FPDFTextObj_GetFont(mpPageObject)) + pPDFiumFont = std::make_unique<PDFiumFontImpl>(pFont); + return pPDFiumFont; +} + +PDFiumFontImpl::PDFiumFontImpl(FPDF_FONT pFont) + : mpFont(pFont) +{ +} -bool PDFiumPageObjectImpl::getFontData(PDFiumFont font, std::vector<uint8_t>& rData) +bool PDFiumFontImpl::getFontData(std::vector<uint8_t>& rData) const { - FPDF_FONT pFontObject = static_cast<FPDF_FONT>(font); size_t buflen(0); - bool bOk = FPDFFont_GetFontData(pFontObject, nullptr, 0, &buflen); + bool bOk = FPDFFont_GetFontData(mpFont, nullptr, 0, &buflen); if (!bOk) { SAL_WARN("vcl.filter", "PDFiumImpl: failed to get font data"); return false; } rData.resize(buflen); - bOk = FPDFFont_GetFontData(pFontObject, rData.data(), rData.size(), &buflen); + bOk = FPDFFont_GetFontData(mpFont, rData.data(), rData.size(), &buflen); assert(bOk && rData.size() == buflen); return bOk; } -bool PDFiumPageObjectImpl::getFontToUnicode(PDFiumFont font, std::vector<uint8_t>& rData) +bool PDFiumFontImpl::getFontToUnicode(std::vector<uint8_t>& rData) const { - FPDF_FONT pFontObject = static_cast<FPDF_FONT>(font); - size_t buflen(0); - bool bOk = FPDFFont_GetToUnicodeContent(pFontObject, nullptr, 0, &buflen); + bool bOk = FPDFFont_GetToUnicodeContent(mpFont, nullptr, 0, &buflen); if (!bOk) { SAL_WARN("vcl.filter", "PDFiumImpl: failed to get font data"); return false; } rData.resize(buflen); - bOk = FPDFFont_GetToUnicodeContent(pFontObject, rData.data(), rData.size(), &buflen); + bOk = FPDFFont_GetToUnicodeContent(mpFont, rData.data(), rData.size(), &buflen); assert(bOk && rData.size() == buflen); return bOk; } -bool PDFiumPageObjectImpl::getIsEmbedded(PDFiumFont font) -{ - FPDF_FONT pFontObject = static_cast<FPDF_FONT>(font); - return FPDFFont_GetIsEmbedded(pFontObject) == 1; -} +bool PDFiumFontImpl::getIsEmbedded() const { return FPDFFont_GetIsEmbedded(mpFont) == 1; } bool PDFiumPageObjectImpl::getFontProperties(FontWeight& weight) { @@ -1299,11 +1318,11 @@ bool PDFiumPageObjectImpl::getFontProperties(FontWeight& weight) // So pull the font data and analyze it directly. Though the font might not // have an OS/2 table so we may end up eventually inferring the weight from // the style name. - PDFiumFont font = getFont(); + auto font = getFont(); if (!font) return false; std::vector<uint8_t> aData; - if (!getFontData(font, aData)) + if (!font->getFontData(aData)) return false; if (!EmbeddedFontsManager::analyzeTTF(aData.data(), aData.size(), weight)) { commit bf5a5f923869b3931c4558d9c638ab8638bcf4eb Author: Caolán McNamara <[email protected]> AuthorDate: Wed Oct 22 20:30:16 2025 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Sun Oct 26 12:08:12 2025 +0100 skip empty fonts Change-Id: I037ef2b00d62f1ca9bdd2acdadf88c649ec9235d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192879 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Mike Kaganski <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192990 Tested-by: Caolán McNamara <[email protected]> Reviewed-by: Caolán McNamara <[email protected]> diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx index 9b3f3132c1ed..c141794a86fd 100644 --- a/svx/source/svdraw/svdpdf.cxx +++ b/svx/source/svdraw/svdpdf.cxx @@ -281,6 +281,13 @@ void ImpSdrPdfImport::CollectFonts() continue; } + std::vector<uint8_t> aFontData; + if (!pPageObject->getFontData(font, aFontData) || aFontData.empty()) + { + SAL_WARN("sd.filter", "that's worrying, skipping " << sFontName); + continue; + } + SubSetInfo* pSubSetInfo; SAL_INFO("sd.filter", "importing font: " << font); @@ -301,9 +308,6 @@ void ImpSdrPdfImport::CollectFonts() = maDifferentSubsetsForFont.emplace(sPostScriptName, aSubSetInfo).first; pSubSetInfo = &result->second; } - std::vector<uint8_t> aFontData; - if (!pPageObject->getFontData(font, aFontData)) - SAL_WARN("sd.filter", "that's worrying"); bool bTTF = EmbeddedFontsManager::analyzeTTF(aFontData.data(), aFontData.size(), eFontWeight); SAL_INFO_IF(!bTTF, "sd.filter", "not ttf/otf, converting");
