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
|
407 | 407 | break; |
408 | 408 | case fontCIDType2: |
409 | 409 | case fontCIDType2OT: |
| 410 | #if POPPLER_CHECK_VERSION(25,2,0) |
| 411 | if (!gfxcid->getCIDToGID().empty()) { |
| 412 | #else |
410 | 413 | if (gfxcid->getCIDToGID()) { |
411 | 414 | n = gfxcid->getCIDToGIDLen(); |
412 | 415 | 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 |
414 | 421 | codeToGID.reserve(n); |
415 | 422 | codeToGID.insert(codeToGID.begin(), src, src + n); |
416 | 423 | } |
| 424 | #endif |
417 | 425 | } else { |
418 | 426 | #if POPPLER_CHECK_VERSION(22, 1, 0) |
419 | 427 | std::unique_ptr<FoFiTrueType> ff; |
… |
… |
CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref, FT_Li
|
429 | 437 | goto err2; |
430 | 438 | } |
431 | 439 | #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); |
433 | 441 | #else |
434 | | int *src = gfxcid->getCodeToGIDMap(ff, &n); |
| 442 | auto src = gfxcid->_POPPLER_GET_CODE_TO_GID_MAP(ff, &n); |
435 | 443 | #endif |
| 444 | |
| 445 | #if POPPLER_CHECK_VERSION(25,2,0) |
| 446 | codeToGID = std::move(src); |
| 447 | #else |
436 | 448 | codeToGID.reserve(n); |
437 | 449 | codeToGID.insert(codeToGID.begin(), src, src + n); |
438 | 450 | gfree(src); |
| 451 | #endif |
439 | 452 | } |
440 | 453 | /* Fall through */ |
441 | 454 | case fontTrueType: |
… |
… |
CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref, FT_Li
|
457 | 470 | /* This might be set already for the CIDType2 case */ |
458 | 471 | if (fontType == fontTrueType || fontType == fontTrueTypeOT) { |
459 | 472 | #if POPPLER_CHECK_VERSION(22, 1, 0) |
460 | | int *src = gfx8bit->getCodeToGIDMap(ff.get()); |
| 473 | auto src = gfx8bit->getCodeToGIDMap(ff.get()); |
461 | 474 | #else |
462 | | int *src = gfx8bit->getCodeToGIDMap(ff); |
| 475 | auto src = gfx8bit->getCodeToGIDMap(ff); |
463 | 476 | #endif |
| 477 | #if POPPLER_CHECK_VERSION(25,2,0) |
| 478 | codeToGID = std::move(src); |
| 479 | #else |
464 | 480 | codeToGID.reserve(256); |
465 | 481 | codeToGID.insert(codeToGID.begin(), src, src + 256); |
466 | 482 | gfree(src); |
| 483 | #endif |
467 | 484 | } |
468 | 485 | font_face = getFreeTypeFontFace(fontEngine, lib, fileName, std::move(font_data)); |
469 | 486 | if (!font_face) { |
… |
… |
CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref, FT_Li
|
481 | 498 | ff1c = FoFiType1C::load(fileName.c_str()); |
482 | 499 | } |
483 | 500 | 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 |
485 | 505 | codeToGID.reserve(n); |
486 | 506 | codeToGID.insert(codeToGID.begin(), src, src + n); |
487 | 507 | gfree(src); |
| 508 | #endif |
488 | 509 | delete ff1c; |
489 | 510 | } |
490 | 511 | } |
… |
… |
CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref, FT_Li
|
497 | 518 | break; |
498 | 519 | |
499 | 520 | case fontCIDType0COT: |
| 521 | #if POPPLER_CHECK_VERSION(25,2,0) |
| 522 | if (!gfxcid->getCIDToGID().empty()) { |
| 523 | #else |
500 | 524 | if (gfxcid->getCIDToGID()) { |
501 | 525 | n = gfxcid->getCIDToGIDLen(); |
502 | 526 | 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 |
504 | 532 | codeToGID.reserve(n); |
505 | 533 | codeToGID.insert(codeToGID.begin(), src, src + n); |
506 | 534 | } |
| 535 | #endif |
507 | 536 | } |
508 | 537 | |
509 | 538 | if (codeToGID.empty()) { |
… |
… |
CairoFreeTypeFont *CairoFreeTypeFont::create(GfxFont *gfxFont, XRef *xref, FT_Li
|
520 | 549 | } |
521 | 550 | if (ff) { |
522 | 551 | 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 |
524 | 556 | codeToGID.reserve(n); |
525 | 557 | codeToGID.insert(codeToGID.begin(), src, src + n); |
526 | 558 | gfree(src); |
| 559 | #endif |
527 | 560 | } |
528 | 561 | } |
529 | 562 | } |
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
|
|
15 | 15 | #include <glib/poppler-features.h> |
16 | 16 | #include <poppler/UTF.h> |
17 | 17 | |
| 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 | |
18 | 34 | #if POPPLER_CHECK_VERSION(24, 10, 0) |
19 | 35 | #define _POPPLER_CONSUME_UNIQPTR_ARG(value) std::move(value) |
20 | 36 | #else |
… |
… |
|
39 | 55 | #define _POPPLER_FUNCTION_TYPE_STITCHING 3 |
40 | 56 | #endif |
41 | 57 | |
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 | | |
48 | 58 | #if POPPLER_CHECK_VERSION(22, 4, 0) |
49 | 59 | #define _POPPLER_FONTPTR_TO_GFX8(font_ptr) ((Gfx8BitFont *)font_ptr.get()) |
50 | 60 | #else |