include/vcl/filter/PDFiumLibrary.hxx |    3 ++-
 vcl/source/pdf/PDFiumLibrary.cxx     |   14 ++++++++++----
 2 files changed, 12 insertions(+), 5 deletions(-)

New commits:
commit 7f0fc135ad44b3bc3701fb51fb7faf16150f05fd
Author:     Caolán McNamara <[email protected]>
AuthorDate: Wed Aug 20 12:31:34 2025 +0100
Commit:     Caolán McNamara <[email protected]>
CommitDate: Mon Oct 13 13:39:55 2025 +0200

    return the pdfium handle so we can identify unique fonts
    
    Change-Id: I4e164a3c25c3e3b3bfec26f817ffc958198aa61c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191370
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>
    (cherry picked from commit b8ad73eac969412c5b0aa86ecb5153d04950bfa0)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192268
    Reviewed-by: Caolán McNamara <[email protected]>
    Tested-by: Jenkins

diff --git a/include/vcl/filter/PDFiumLibrary.hxx 
b/include/vcl/filter/PDFiumLibrary.hxx
index 0fceef9d0b81..22add6f61e9c 100644
--- a/include/vcl/filter/PDFiumLibrary.hxx
+++ b/include/vcl/filter/PDFiumLibrary.hxx
@@ -158,7 +158,8 @@ public:
     virtual OUString getFontName() = 0;
     virtual OUString getBaseFontName() = 0;
     virtual int getFontAngle() = 0;
-    virtual bool getFontData(std::vector<uint8_t>& rData) = 0;
+    virtual PFDiumFont getFont() = 0;
+    virtual bool getFontData(PFDiumFont font, std::vector<uint8_t>& rData) = 0;
     virtual bool getFontProperties(FontWeight& weight) = 0;
     virtual PDFTextRenderMode getTextRenderMode() = 0;
     virtual Color getFillColor() = 0;
diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx
index 76bb12bcaa0e..a2880c328158 100644
--- a/vcl/source/pdf/PDFiumLibrary.cxx
+++ b/vcl/source/pdf/PDFiumLibrary.cxx
@@ -418,7 +418,8 @@ public:
     OUString getFontName() override;
     OUString getBaseFontName() override;
     int getFontAngle() override;
-    bool getFontData(std::vector<uint8_t>& rData) override;
+    PFDiumFont getFont() override;
+    bool getFontData(PFDiumFont font, std::vector<uint8_t>& rData) override;
     bool getFontProperties(FontWeight& weight) override;
     PDFTextRenderMode getTextRenderMode() override;
     Color getFillColor() override;
@@ -1179,9 +1180,11 @@ int PDFiumPageObjectImpl::getFontAngle()
     return nFontAngle;
 }
 
-bool PDFiumPageObjectImpl::getFontData(std::vector<uint8_t>& rData)
+PFDiumFont PDFiumPageObjectImpl::getFont() { return 
FPDFTextObj_GetFont(mpPageObject); }
+
+bool PDFiumPageObjectImpl::getFontData(PFDiumFont font, std::vector<uint8_t>& 
rData)
 {
-    FPDF_FONT pFontObject = FPDFTextObj_GetFont(mpPageObject);
+    FPDF_FONT pFontObject = static_cast<FPDF_FONT>(font);
     size_t buflen(0);
     bool bOk = FPDFFont_GetFontData(pFontObject, nullptr, 0, &buflen);
     if (!bOk)
@@ -1203,8 +1206,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.
+    PFDiumFont font = getFont();
+    if (!font)
+        return false;
     std::vector<uint8_t> aData;
-    if (!getFontData(aData))
+    if (!getFontData(font, aData))
         return false;
     if (!EmbeddedFontsManager::analyzeTTF(aData.data(), aData.size(), weight))
     {

Reply via email to