Ticket #21050: 0001-Fix-building-with-poppler-25.02.0_final.patch

File 0001-Fix-building-with-poppler-25.02.0_final.patch, 7.0 KB (added by Bruce Dubbs, 6 weeks ago)
  • TabularUnified src/extension/internal/pdfinput/poppler-cairo-font-engine.cpp

    From eec175c9338e84b7748fe1f7e8d510c629dde10f Mon Sep 17 00:00:00 2001
    From: KrIr17 <elendil.krir17@gmail.com>
    Date: Sun, 9 Feb 2025 18:35:50 +0530
    Subject: [PATCH] Fix building with poppler 25.02.0
    
    1. `getCodeToGIDMap`, `getCIDToGID`, `getCIDToGIDMap` are now `std::vector`
    
    2. `pdfDocEncodingToUTF16` returns an `std::string`
    ---
     .../pdfinput/poppler-cairo-font-engine.cpp    | 49 ++++++++++++++++---
     .../pdfinput/poppler-transition-api.h         | 22 ++++++---
     2 files changed, 57 insertions(+), 14 deletions(-)
    
    diff --git a/src/extension/internal/pdfinput/poppler-cairo-font-engine.cpp b/src/extension/internal/pdfinput/poppler-cairo-font-engine.cpp
    index 02c55fda58..245c39bfbf 100644
    a b CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref, FT_Li  
    407407            break;
    408408        case fontCIDType2:
    409409        case fontCIDType2OT:
     410#if POPPLER_CHECK_VERSION(25,2,0)
     411            if (!gfxcid->getCIDToGID().empty()) {
     412#else
    410413            if (gfxcid->getCIDToGID()) {
    411414                n = gfxcid->getCIDToGIDLen();
    412415                if (n) {
    413                     const int *src = gfxcid->getCIDToGID();
     416#endif
     417                    const auto src = gfxcid->getCIDToGID();
     418#if POPPLER_CHECK_VERSION(25,2,0)
     419                    codeToGID = std::move(src);
     420#else
    414421                    codeToGID.reserve(n);
    415422                    codeToGID.insert(codeToGID.begin(), src, src + n);
    416423                }
     424#endif
    417425            } else {
    418426#if POPPLER_CHECK_VERSION(22, 1, 0)
    419427                std::unique_ptr<FoFiTrueType> ff;
    CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref, FT_Li  
    429437                    goto err2;
    430438                }
    431439#if POPPLER_CHECK_VERSION(22, 1, 0)
    432                 int *src = gfxcid->getCodeToGIDMap(ff.get(), &n);
     440                auto src = gfxcid->_POPPLER_GET_CODE_TO_GID_MAP(ff.get(), &n);
    433441#else
    434                 int *src = gfxcid->getCodeToGIDMap(ff, &n);
     442                auto src = gfxcid->_POPPLER_GET_CODE_TO_GID_MAP(ff, &n);
    435443#endif
     444
     445#if POPPLER_CHECK_VERSION(25,2,0)
     446                codeToGID = std::move(src);
     447#else
    436448                codeToGID.reserve(n);
    437449                codeToGID.insert(codeToGID.begin(), src, src + n);
    438450                gfree(src);
     451#endif
    439452            }
    440453            /* Fall through */
    441454        case fontTrueType:
    CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref, FT_Li  
    457470            /* This might be set already for the CIDType2 case */
    458471            if (fontType == fontTrueType || fontType == fontTrueTypeOT) {
    459472#if POPPLER_CHECK_VERSION(22, 1, 0)
    460                 int *src = gfx8bit->getCodeToGIDMap(ff.get());
     473                auto src = gfx8bit->getCodeToGIDMap(ff.get());
    461474#else
    462                 int *src = gfx8bit->getCodeToGIDMap(ff);
     475                auto src = gfx8bit->getCodeToGIDMap(ff);
    463476#endif
     477#if POPPLER_CHECK_VERSION(25,2,0)
     478                codeToGID = std::move(src);
     479#else
    464480                codeToGID.reserve(256);
    465481                codeToGID.insert(codeToGID.begin(), src, src + 256);
    466482                gfree(src);
     483#endif
    467484            }
    468485            font_face = getFreeTypeFontFace(fontEngine, lib, fileName, std::move(font_data));
    469486            if (!font_face) {
    CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref, FT_Li  
    481498                    ff1c = FoFiType1C::load(fileName.c_str());
    482499                }
    483500                if (ff1c) {
    484                     int *src = ff1c->getCIDToGIDMap(&n);
     501                    auto src = ff1c->_POPPLER_GET_CID_TO_GID_MAP(&n);
     502#if POPPLER_CHECK_VERSION(25,2,0)
     503                    codeToGID = std::move(src);
     504#else
    485505                    codeToGID.reserve(n);
    486506                    codeToGID.insert(codeToGID.begin(), src, src + n);
    487507                    gfree(src);
     508#endif
    488509                    delete ff1c;
    489510                }
    490511            }
    CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref, FT_Li  
    497518            break;
    498519
    499520        case fontCIDType0COT:
     521#if POPPLER_CHECK_VERSION(25,2,0)
     522            if (!gfxcid->getCIDToGID().empty()) {
     523#else
    500524            if (gfxcid->getCIDToGID()) {
    501525                n = gfxcid->getCIDToGIDLen();
    502526                if (n) {
    503                     const int *src = gfxcid->getCIDToGID();
     527#endif
     528                    const auto src = gfxcid->getCIDToGID();
     529#if POPPLER_CHECK_VERSION(25,2,0)
     530                    codeToGID = std::move(src);
     531#else
    504532                    codeToGID.reserve(n);
    505533                    codeToGID.insert(codeToGID.begin(), src, src + n);
    506534                }
     535#endif
    507536            }
    508537
    509538            if (codeToGID.empty()) {
    CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref, FT_Li  
    520549                    }
    521550                    if (ff) {
    522551                        if (ff->isOpenTypeCFF()) {
    523                             int *src = ff->getCIDToGIDMap(&n);
     552                            auto src = ff1c->_POPPLER_GET_CID_TO_GID_MAP(&n);
     553#if POPPLER_CHECK_VERSION(25,2,0)
     554                            codeToGID = std::move(src);
     555#else
    524556                            codeToGID.reserve(n);
    525557                            codeToGID.insert(codeToGID.begin(), src, src + n);
    526558                            gfree(src);
     559#endif
    527560                        }
    528561                    }
    529562                }
  • TabularUnified src/extension/internal/pdfinput/poppler-transition-api.h

    diff --git a/src/extension/internal/pdfinput/poppler-transition-api.h b/src/extension/internal/pdfinput/poppler-transition-api.h
    index b7a54828e7..6f8c8e246f 100644
    a b  
    1515#include <glib/poppler-features.h>
    1616#include <poppler/UTF.h>
    1717
     18#if POPPLER_CHECK_VERSION(25,2,0)
     19#define _POPPLER_GET_CODE_TO_GID_MAP(ff, len) getCodeToGIDMap(ff)
     20#define _POPPLER_GET_CID_TO_GID_MAP(len) getCIDToGIDMap()
     21#define _POPPLER_PDF_DOC_ENCODING_TO_UTF16(str, strlen) pdfDocEncodingToUTF16(str).c_str()
     22#else
     23#define _POPPLER_GET_CODE_TO_GID_MAP(ff, len) getCodeToGIDMap(ff, len)
     24#define _POPPLER_GET_CID_TO_GID_MAP(len) getCIDToGIDMap(len)
     25#define _POPPLER_PDF_DOC_ENCODING_TO_UTF16(str, strlen) pdfDocEncodingToUTF16(str, strlen)
     26#endif
     27
     28#if POPPLER_CHECK_VERSION(24,12,0)
     29#define _POPPLER_GET_IMAGE_PARAMS(bits, csMode, hasAlpha) getImageParams(bits, csMode, hasAlpha)
     30#else
     31#define _POPPLER_GET_IMAGE_PARAMS(bits, csMode, hasAlpha) getImageParams(bits, csMode)
     32#endif
     33
    1834#if POPPLER_CHECK_VERSION(24, 10, 0)
    1935#define _POPPLER_CONSUME_UNIQPTR_ARG(value) std::move(value)
    2036#else
     
    3955#define _POPPLER_FUNCTION_TYPE_STITCHING 3
    4056#endif
    4157
    42 #if POPPLER_CHECK_VERSION(24,12,0)
    43 #define _POPPLER_GET_IMAGE_PARAMS(bits, csMode, hasAlpha) getImageParams(bits, csMode, hasAlpha)
    44 #else
    45 #define _POPPLER_GET_IMAGE_PARAMS(bits, csMode, hasAlpha) getImageParams(bits, csMode)
    46 #endif
    47 
    4858#if POPPLER_CHECK_VERSION(22, 4, 0)
    4959#define _POPPLER_FONTPTR_TO_GFX8(font_ptr) ((Gfx8BitFont *)font_ptr.get())
    5060#else