On Wed, Apr 17, 2024 at 10:59:07PM +0200, Caspar Schutijser wrote:
> Hi,
> 
> At the end of the email is a diff that unbreaks and updates
> converters/k2pdfopt to 2.55.

Hi,

I spent some more time on it today and I have a new diff. Changes
compared to the last diff:
- using mupdf now works;
- ship a manual page, borrowed from Debian;
- sort dependencies in LIB_DEPENDS (I know it causes churn, but this
is already a noisy update anyway);
- improve comments in patches/patch-CMakeLists_txt;
- add another comment in patches/patch-k2pdfoptlib_k2pdfopt_h.

Feedback still welcome.

Caspar


Index: Makefile
===================================================================
RCS file: /cvs/ports/converters/k2pdfopt/Makefile,v
retrieving revision 1.12
diff -u -p -r1.12 Makefile
--- Makefile    13 Nov 2023 09:40:49 -0000      1.12
+++ Makefile    18 Apr 2024 15:11:48 -0000
@@ -1,76 +1,47 @@
-BROKEN =       k2pdfopt uses modified builds of MuPDF, Leptonica, Tesseract; 
at least some of these have been updated causing mods to fail
-
-BROKEN +=      also depends on graphics/opejpeg which no longer exists
-
-# Notes on updating:
-# - go to https://www.willus.com/k2pdfopt/k2pdfopt_version.txt;
-#   some of the dependencies need modifying by replacing source
-#   files with files from XXX_mod in k2pdfopt source; using the
-#   above file you can figure out which version of those libs
-#   is needed
-# - modify the port to:
-#   1. fetch those files
-#   2. move the files from XXX_mod/somefile to replace the relevant
-#      file in the library (you'll also need to figure out where in
-#      the library source that file is; they are dumped into the
-#      one XXX_mod dir per library)
-#   3. replicate the library build process (make them static)
-#   4. build k2pdfopt, pointed at the newly built libraries
-#
-# Alternatively you may get away with removing use of mupdf (there's
-# some fallback to ghostscript) and patching use of the libraries;
-# debian packaging takes this approach. It's still very fragile though.
-
 COMMENT =      optimizes PDF/DJVU files for mobile e-readers
 
-V =            2.42
+V =            2.55
 DISTNAME =     k2pdfopt_v${V}_src
 PKGNAME =      k2pdfopt-${V}
-SITES =                http://willus.com/k2pdfopt/src/
+SITES =                https://willus.com/k2pdfopt/src/
 EXTRACT_SUFX = .zip
-REVISION =     3
+
+SITES.deb =    ${SITE_DEBIAN:=main/k/k2pdfopt/}
+DISTFILES.deb =        k2pdfopt_${V}+ds-2.debian.tar.xz
 
 CATEGORIES =   converters
 
-HOMEPAGE =     http://willus.com/k2pdfopt/
-MAINTAINER =   Paul Irofti <p...@irofti.net>
+HOMEPAGE =     https://willus.com/k2pdfopt/
+MAINTAINER =   Caspar Schutijser <cas...@openbsd.org>
 
 # GPLv3
 PERMIT_PACKAGE =       Yes
 
 MODULES =      devel/cmake
 
-WANTLIB +=     ${COMPILER_LIBCXX} c freetype jbig2dec jpeg m png z \
-               djvulibre jasper lept mupdf openjpeg tesseract
+WANTLIB += c djvulibre freetype gsl gslcblas gumbo jasper jbig2dec
+WANTLIB += jpeg lcms leptonica m mupdf png pthread z
 
 COMPILER =             base-clang ports-gcc base-gcc
 
-BUILD_DEPENDS +=       textproc/mupdf:patch \
-                       graphics/leptonica:configure \
-                       graphics/tesseract/tesseract:patch
-
-LIB_DEPENDS += graphics/png \
-               graphics/jpeg \
-               graphics/jbig2dec \
-               textproc/mupdf \
+LIB_DEPENDS += devel/gsl \
                graphics/djvulibre \
+               graphics/jasper \
+               graphics/jpeg \
+               graphics/lcms \
                graphics/leptonica \
-               graphics/tesseract/tesseract
-
-# XXX we no longer have this port
-# LIB_DEPENDS +=       graphics/openjpeg
+               graphics/png \
+               textproc/mupdf \
+               www/gumbo
 
 RUN_DEPENDS += print/ghostscript/gnu
 
 WRKDIST =      ${WRKDIR}/k2pdfopt_v${V}
 
-post-extract:
-       ln -s ${WRKDIR}/graphics/leptonica/leptonica-* ${WRKSRC}/leptonica
-       ln -s ${WRKDIR}/graphics/tesseract/tesseract/tesseract-* \
-               ${WRKSRC}/tesseract
-       ln -s ${WRKDIR}/textproc/mupdf/mupdf-* ${WRKSRC}/mupdf
-
 pre-patch:
        @cd ${WRKSRC}; perl -i -pe 's/\r$$//' `find . -type f`
+
+post-install:
+       ${INSTALL_MAN} ${WRKDIR}/debian/k2pdfopt.1 ${PREFIX}/man/man1
 
 .include <bsd.port.mk>
Index: distinfo
===================================================================
RCS file: /cvs/ports/converters/k2pdfopt/distinfo,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 distinfo
--- distinfo    18 Aug 2017 12:07:51 -0000      1.1.1.1
+++ distinfo    18 Apr 2024 15:11:48 -0000
@@ -1,2 +1,4 @@
-SHA256 (k2pdfopt_v2.42_src.zip) = mqvWsZzhFbl/wM0xlclaMPO60FBl2LtHkfVynU2gOuk=
-SIZE (k2pdfopt_v2.42_src.zip) = 2829697
+SHA256 (k2pdfopt_2.55+ds-2.debian.tar.xz) = 
500cs10RualNV6sFM9SJbuMzcd5s7dME/39s68bVl34=
+SHA256 (k2pdfopt_v2.55_src.zip) = Pni0x91iJ/3hITj9JGjdE8DEW1JRWSpPCqxn/ROauVM=
+SIZE (k2pdfopt_2.55+ds-2.debian.tar.xz) = 34168
+SIZE (k2pdfopt_v2.55_src.zip) = 1364878
Index: patches/patch-CMakeLists_txt
===================================================================
RCS file: /cvs/ports/converters/k2pdfopt/patches/patch-CMakeLists_txt,v
retrieving revision 1.3
diff -u -p -r1.3 patch-CMakeLists_txt
--- patches/patch-CMakeLists_txt        11 Mar 2022 18:27:03 -0000      1.3
+++ patches/patch-CMakeLists_txt        18 Apr 2024 15:11:48 -0000
@@ -1,3 +1,20 @@
+Fix compilation with Jasper library.
+
+Patch from Debian: "do not detect ghostscript at compile time", see
+https://sources.debian.org/patches/k2pdfopt/2.55%2Bds-2/0003-CMakeLists.txt-do-not-detect-ghostscript-at-compile-.patch/
+
+Patch from Debian: "use system gsl", see
+https://sources.debian.org/patches/k2pdfopt/2.55%2Bds-2/0008-willuslib-gslpolyfit.c-use-system-gsl.patch/
+
+Find Freetype.
+
+Find MuPDF using find_library() since mupdf does not ship a pkg-config file.
+
+Remove check for Tesseract since it does not work for us (yet?).
+
+Patch from Debian: "add missing install command", see
+https://sources.debian.org/patches/k2pdfopt/2.55%2Bds-2/0001-CMakeLists.txt-add-missing-install-command.patch/
+
 Index: CMakeLists.txt
 --- CMakeLists.txt.orig
 +++ CMakeLists.txt
@@ -6,8 +23,8 @@ Index: CMakeLists.txt
 +project(k2pdfopt)
  cmake_minimum_required(VERSION 2.6)
  
- # ---- Test for packages
-@@ -52,6 +52,8 @@ endif(JPEG_FOUND)
+ #
+@@ -57,37 +57,40 @@ endif(JPEG_FOUND)
  include(FindJasper)
  if(JASPER_FOUND)
    set(HAVE_JASPER_LIB 1)
@@ -15,11 +32,34 @@ Index: CMakeLists.txt
 +  set(K2PDFOPT_LIB ${K2PDFOPT_LIB} ${JASPER_LIBRARY})
  endif(JASPER_FOUND)
  
- # paths from willuslib/wgs.c
-@@ -84,6 +86,22 @@ if(MUPDF_FOUND)
-   )
- endif(MUPDF_FOUND)
+-# paths from willuslib/wgs.c
+-find_program(GHOSTSCRIPT_EXECUTABLE gs
+-#  PATHS /usr/bin /usr/share/gs /usr/local/gs /opt/gs 
+-#    /usr/share/gs* /usr/local/gs* /opt/gs*
+-)
+-if(GHOSTSCRIPT_EXECUTABLE)
+-  set(HAVE_GHOSTSCRIPT 1)
+-  message(STATUS "Found ghostscript executable")
+-else()
+-  message(STATUS "Could NOT find ghostscript executable")
+-endif(GHOSTSCRIPT_EXECUTABLE)
++set(HAVE_GHOSTSCRIPT 1)
+ 
+-# willus.h
+-# HAVE_GSL_LIB
++pkg_check_modules(GSL gsl)
++if(GSL_FOUND)
++  set(HAVE_GSL_LIB 1)
++  include_directories(SYSTEM ${GSL_INCLUDEDIR})
++  set(K2PDFOPT_LIB ${K2PDFOPT_LIB} ${GSL_LDFLAGS})
++endif(GSL_FOUND)
+ 
  
+ # libfreetype6 (>= 2.3.9), libjbig2dec0, libjpeg8 (>= 8c), libx11-6, 
libxext6, zlib1g (>= 1:1.2.0)
+ # MUPDF_STATIC_LDFLAGS misses mupdf-js-none, and doubles libs ...
+ 
+-pkg_check_modules(MUPDF mupdf)
+-if(MUPDF_FOUND)
 +find_library(FREETYPE_LIB freetype PATHS /usr/X11R6/lib)
 +if(FREETYPE_LIB)
 +  include_directories(SYSTEM /usr/X11R6/include /usr/X11R6/include/freetype2)
@@ -29,54 +69,50 @@ Index: CMakeLists.txt
 +
 +find_library(MUPDF_LIB mupdf PATHS ${CMAKE_INSTALL_PREFIX}/lib)
 +if(MUPDF_LIB)
-+  set(HAVE_MUPDF_LIB 1) 
+   set(HAVE_MUPDF_LIB 1) 
+   # (includes jbig2dec, openjpeg, freetype)
+-  include_directories(SYSTEM ${MUPDF_INCLUDEDIR})
+-  message(STATUS "mupdf libraries: ${MUPDF_LDFLAGS}")
+-  set(K2PDFOPT_LIB ${K2PDFOPT_LIB} ${MUPDF_LDFLAGS} 
+-    -lmupdf-js-none -lopenjpeg -ljbig2dec -ljpeg -lfreetype -llcms -lgumbo
 +  include_directories(SYSTEM ${CMAKE_INSTALL_PREFIX}/include)
 +  message(STATUS "mupdf libraries: ${MUPDF_LIB}")
-+  set(K2PDFOPT_LIB ${K2PDFOPT_LIB} ${MUPDF_LIB} 
-+    -lopenjpeg -ljbig2dec -ljpeg)
-+endif()
-+
++  set(K2PDFOPT_LIB ${K2PDFOPT_LIB} ${MUPDF_LIB}
++    -lmupdf -ljpeg -llcms -lgumbo
+   )
+-endif(MUPDF_FOUND)
++endif(MUPDF_LIB)
+ 
  pkg_check_modules(DJVU ddjvuapi)
  if(DJVU_FOUND)
-   set(HAVE_DJVU_LIB 1)
-@@ -92,14 +110,30 @@ if(DJVU_FOUND)
- endif(DJVU_FOUND)
- 
- # HAVE_GOCR_LIB
--# HAVE_LEPTONICA_LIB
-+# LEPTONICA
-+find_library(LEPT_LIB lept PATHS ${CMAKE_INSTALL_PREFIX}/lib)
-+if(LEPT_LIB)
-+  set(HAVE_LEPTONICA_LIB 1) 
-+  include_directories(SYSTEM ${CMAKE_INSTALL_PREFIX}/include leptonica_mod)
-+  message(STATUS "leptonica libraries: ${LEPT_LIB}")
-+  set(K2PDFOPT_LIB ${K2PDFOPT_LIB} ${LEPT_LIB}) 
-+endif()
-+
- # HAVE_TESSERACT_LIB
-+find_library(TESSERACT_LIB tesseract PATHS ${CMAKE_INSTALL_PREFIX}/lib)
-+if(TESSERACT_LIB)
-+  set(HAVE_TESSERACT_LIB 1) 
-+  include_directories(SYSTEM ${CMAKE_INSTALL_PREFIX}/include)
-+  message(STATUS "tesseract libraries: ${TESSERACT_LIB}")
-+  set(K2PDFOPT_LIB ${K2PDFOPT_LIB} ${TESSERACT_LIB}) 
-+endif()
- 
-+
+@@ -105,13 +108,6 @@ if(LEPT_FOUND)
+   include_directories(SYSTEM ${LEPT_INCLUDEDIR})
+ endif(LEPT_FOUND)
+ 
+-pkg_check_modules(TESSERACT tesseract)
+-if(TESSERACT_FOUND)
+-  set(HAVE_TESSERACT_LIB 1)
+-  set(K2PDFOPT_LIB ${K2PDFOPT_LIB} ${TESSERACT_LDFLAGS})
+-  include_directories(SYSTEM ${TESSERACT_INCLUDEDIR})
+-endif(TESSERACT_FOUND)
+-
  # ---- Describe project
  
  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_CMAKE -Wall")
- 
--include_directories(. willuslib k2pdfoptlib)
-+include_directories(. ${PROJECT_BINARY_DIR} include_mod willuslib k2pdfoptlib)
- 
- configure_file (
+@@ -122,6 +118,7 @@ configure_file (
    "${PROJECT_SOURCE_DIR}/config.h.in"
-@@ -113,6 +147,7 @@ add_subdirectory(k2pdfoptlib)
+   "${PROJECT_BINARY_DIR}/config.h"
+ )
++include_directories(${PROJECT_BINARY_DIR})
+ 
+ add_subdirectory(willuslib)
+ add_subdirectory(k2pdfoptlib)
+@@ -129,6 +126,8 @@ add_subdirectory(k2pdfoptlib)
+ # ms
  add_executable(k2pdfopt k2pdfopt.c)
- target_link_libraries (k2pdfopt k2pdfoptlib willuslib ${K2PDFOPT_LIB})
-
-+install (TARGETS k2pdfopt RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
-
+ target_link_libraries (k2pdfopt k2pdfoptlib willuslib ${K2PDFOPT_LIB} pthread)
++
++install(TARGETS k2pdfopt RUNTIME DESTINATION bin)
+ 
+ 
  message("")
- message("-- Summary --")
Index: patches/patch-k2pdfoptlib_k2master_c
===================================================================
RCS file: patches/patch-k2pdfoptlib_k2master_c
diff -N patches/patch-k2pdfoptlib_k2master_c
--- patches/patch-k2pdfoptlib_k2master_c        11 Mar 2022 18:27:03 -0000      
1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,26 +0,0 @@
-Index: k2pdfoptlib/k2master.c
---- k2pdfoptlib/k2master.c.orig
-+++ k2pdfoptlib/k2master.c
-@@ -248,8 +248,10 @@ printf("masterinfo->landscape=%d\n",masterinfo->landsc
-             wfile_written_info("dewarp_image.png",stdout);
-             aprintf(TTEXT_NORMAL);
-             }
-+#ifdef HAVE_LEPTONICA_LIB
-         wlept_bmp_dewarp(dwbmp,src,srcgrey,white,k2settings->dewarp,
-                          k2settings->debug?"k2opt_dewarp_model.pdf":NULL);
-+#endif
-         if (k2settings->debug)
-             {
-             aprintf(TTEXT_BOLD);
-@@ -2681,7 +2683,11 @@ printf("@k2master_rows_color:  %d x %d\n",srcbmp->widt
-     /* Parse region into columns */
-     pageregions=&_pageregions;
-     pageregions_init(pageregions);
-+#ifdef HAVE_OCR_LIB
-     if (k2settings->ocr_max_columns==2 || k2settings->max_columns>1)
-+#else
-+    if (k2settings->max_columns>1)
-+#endif
-         maxlevels = 2;
-     else
-         maxlevels = 3;
Index: patches/patch-k2pdfoptlib_k2ocr_c
===================================================================
RCS file: patches/patch-k2pdfoptlib_k2ocr_c
diff -N patches/patch-k2pdfoptlib_k2ocr_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-k2pdfoptlib_k2ocr_c   18 Apr 2024 15:11:48 -0000
@@ -0,0 +1,55 @@
+Patch from Debian: "conditionally enable tesseract-related functions", see
+https://sources.debian.org/patches/k2pdfopt/2.55%2Bds-2/0007-k2pdfoptlib-k2ocr.c-conditionally-enable-tesseract-r.patch/
+
+Index: k2pdfoptlib/k2ocr.c
+--- k2pdfoptlib/k2ocr.c.orig
++++ k2pdfoptlib/k2ocr.c
+@@ -41,16 +41,16 @@ typedef struct
+     int ni;
+     char initstr[256];
+     } OCRTESSINITINFO;
+-#endif
+ static void k2ocr_show_envvar(char *buf,char *color,char *var);
+ static void k2ocr_status_line(char *buf,char *color,char *label,char *string);
+ static void k2ocr_tesslang_init(char *lang,int assume_yes);
++#endif
+ static void k2ocr_ocrwords_add_subregion_to_queue(MASTERINFO 
*masterinfo,OCRWORDS *words,
+                                         BMPREGION *region,K2PDFOPT_SETTINGS 
*k2settings);
+ #endif /* HAVE_OCR_LIB */
+ 
+ /* Functions to support extracting text from PDF using MuPDF lib */
+-#ifdef HAVE_MUPDF_LIB
++#if (defined(HAVE_MUPDF_LIB) || defined(HAVE_DJVU_LIB))
+ static void k2ocr_ocrwords_get_from_ocrlayer(MASTERINFO *masterinfo,OCRWORDS 
*words,
+                                              BMPREGION 
*region,K2PDFOPT_SETTINGS *k2settings);
+ static int ocrword_map_to_bitmap(OCRWORD *word,MASTERINFO 
*masterinfo,BMPREGION *region,
+@@ -425,6 +425,7 @@ static void *otinit(void *data)
+ void k2ocr_showlog(void)
+ 
+     {
++#ifdef HAVE_TESSERACT_LIB
+     static char *funcname="k2ocr_showlog";
+ 
+     if (k2ocr_tess_status<0 && k2ocr_logfile!=NULL && 
wfile_status(k2ocr_logfile)==1
+@@ -468,6 +469,7 @@ void k2ocr_showlog(void)
+         k2printf(header,divider,"End","\n");
+         willus_mem_free((double **)&bigbuf,funcname);
+         }
++#endif
+     }
+             
+ 
+@@ -724,9 +726,13 @@ printf("Done k2ocr_ocrwords_add_subregion_to_queue()\n
+ void k2ocr_multithreaded_ocr(OCRWORDS *words,K2PDFOPT_SETTINGS *k2settings)
+ 
+     {
++#ifdef HAVE_TESSERACT_LIB
+     ocr_cpu_time_secs += 
ocrwords_multithreaded_ocr(words,ocrtess_api,maxthreads,
+                                                     k2settings->dst_ocr,
+                                                     k2settings->ocr_dpi);
++#else
++    printf("k2ocr_multithreaded_ocr(): tesseract unsupported\n");
++#endif
+     }
+ 
+ 
Index: patches/patch-k2pdfoptlib_k2pdfopt_h
===================================================================
RCS file: /cvs/ports/converters/k2pdfopt/patches/patch-k2pdfoptlib_k2pdfopt_h,v
retrieving revision 1.2
diff -u -p -r1.2 patch-k2pdfoptlib_k2pdfopt_h
--- patches/patch-k2pdfoptlib_k2pdfopt_h        11 Mar 2022 18:27:03 -0000      
1.2
+++ patches/patch-k2pdfoptlib_k2pdfopt_h        18 Apr 2024 15:11:48 -0000
@@ -1,12 +1,26 @@
+Fix HAVE_MUPDF_LIB #define.
+
+Patch from Debian: "dst_ocr_visibility_flags workaround", see
+https://sources.debian.org/patches/k2pdfopt/2.55%2Bds-2/0006-k2pdfopt.h-dst_ocr_visibility_flags-workaround.patch/
+
 Index: k2pdfoptlib/k2pdfopt.h
 --- k2pdfoptlib/k2pdfopt.h.orig
 +++ k2pdfoptlib/k2pdfopt.h
-@@ -95,7 +95,7 @@
+@@ -107,7 +107,7 @@
  #endif
  */
  
--#if (defined(HAVE_MUPDF) || defined(HAVE_GOCR_LIB) || 
defined(HAVE_TESSERACT_LIB))
-+#if (defined(HAVE_MUPDF_LIB) || defined(HAVE_GOCR_LIB) || 
defined(HAVE_TESSERACT_LIB))
+-#if (defined(HAVE_MUPDF) || defined(HAVE_GOCR_LIB) || 
defined(HAVE_TESSERACT_LIB) || defined(HAVE_DJVU_LIB))
++#if (defined(HAVE_MUPDF_LIB) || defined(HAVE_GOCR_LIB) || 
defined(HAVE_TESSERACT_LIB) || defined(HAVE_DJVU_LIB))
  #if (!defined(HAVE_OCR_LIB))
  #define HAVE_OCR_LIB
  #endif
+@@ -267,7 +267,7 @@ typedef struct
+     int text_only; /* Do not send figures to output file */
+ 
+     /* OCR */
+-#ifdef HAVE_OCR_LIB
++#if 1
+     char ocrout[128];
+     int dst_ocr;
+     int ocrvbb;             /* New in v2.53 -ocrvbb option */
Index: patches/patch-k2pdfoptlib_textrows_c
===================================================================
RCS file: /cvs/ports/converters/k2pdfopt/patches/patch-k2pdfoptlib_textrows_c,v
retrieving revision 1.2
diff -u -p -r1.2 patch-k2pdfoptlib_textrows_c
--- patches/patch-k2pdfoptlib_textrows_c        11 Mar 2022 18:27:03 -0000      
1.2
+++ patches/patch-k2pdfoptlib_textrows_c        18 Apr 2024 15:11:48 -0000
@@ -1,7 +1,7 @@
 Index: k2pdfoptlib/textrows.c
 --- k2pdfoptlib/textrows.c.orig
 +++ k2pdfoptlib/textrows.c
-@@ -956,6 +956,11 @@ static int maxval(int *x,int n,int n0,int dx,int *inde
+@@ -996,6 +996,11 @@ static int maxval(int *x,int n,int n0,int dx,int *inde
          if (imax<0 || x[i]>x[imax])
              imax=i;
          }
Index: patches/patch-leptonica_mod_allheaders_h
===================================================================
RCS file: patches/patch-leptonica_mod_allheaders_h
diff -N patches/patch-leptonica_mod_allheaders_h
--- patches/patch-leptonica_mod_allheaders_h    11 Mar 2022 18:27:03 -0000      
1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,96 +0,0 @@
-Fix build with newer leptonica.
-
-Index: leptonica_mod/allheaders.h
---- leptonica_mod/allheaders.h.orig
-+++ leptonica_mod/allheaders.h
-@@ -2146,17 +2146,17 @@ LEPT_DLL extern PIX * pixReadMem ( const l_uint8 *data
- LEPT_DLL extern l_int32 pixReadHeaderMem ( const l_uint8 *data, size_t size, 
l_int32 *pformat, l_int32 *pw, l_int32 *ph, l_int32 *pbps, l_int32 *pspp, 
l_int32 *piscmap );
- LEPT_DLL extern l_int32 writeImageFileInfo ( const char *filename, FILE 
*fpout, l_int32 headeronly );
- LEPT_DLL extern l_int32 ioFormatTest ( const char *filename );
--LEPT_DLL extern L_RECOGA * recogaCreateFromRecog ( L_RECOG *recog );
--LEPT_DLL extern L_RECOGA * recogaCreateFromPixaa ( PIXAA *paa, l_int32 
scalew, l_int32 scaleh, l_int32 templ_type, l_int32 threshold, l_int32 
maxyshift );
--LEPT_DLL extern L_RECOGA * recogaCreate ( l_int32 n );
--LEPT_DLL extern void recogaDestroy ( L_RECOGA **precoga );
--LEPT_DLL extern l_int32 recogaAddRecog ( L_RECOGA *recoga, L_RECOG *recog );
-+LEPT_DLL extern L_RECOG * recogaCreateFromRecog ( L_RECOG *recog );
-+LEPT_DLL extern L_RECOG * recogaCreateFromPixaa ( PIXAA *paa, l_int32 scalew, 
l_int32 scaleh, l_int32 templ_type, l_int32 threshold, l_int32 maxyshift );
-+LEPT_DLL extern L_RECOG * recogaCreate ( l_int32 n );
-+LEPT_DLL extern void recogaDestroy ( L_RECOG **precoga );
-+LEPT_DLL extern l_int32 recogaAddRecog ( L_RECOG *recoga, L_RECOG *recog );
- LEPT_DLL extern l_int32 recogReplaceInRecoga ( L_RECOG **precog1, L_RECOG 
*recog2 );
--LEPT_DLL extern L_RECOG * recogaGetRecog ( L_RECOGA *recoga, l_int32 index );
--LEPT_DLL extern l_int32 recogaGetCount ( L_RECOGA *recoga );
-+LEPT_DLL extern L_RECOG * recogaGetRecog ( L_RECOG *recoga, l_int32 index );
-+LEPT_DLL extern l_int32 recogaGetCount ( L_RECOG *recoga );
- LEPT_DLL extern l_int32 recogGetCount ( L_RECOG *recog );
- LEPT_DLL extern l_int32 recogGetIndex ( L_RECOG *recog, l_int32 *pindex );
--LEPT_DLL extern L_RECOGA * recogGetParent ( L_RECOG *recog );
-+LEPT_DLL extern L_RECOG * recogGetParent ( L_RECOG *recog );
- LEPT_DLL extern l_int32 recogSetBootflag ( L_RECOG *recog );
- LEPT_DLL extern L_RECOG * recogCreateFromRecog ( L_RECOG *recs, l_int32 
scalew, l_int32 scaleh, l_int32 templ_type, l_int32 threshold, l_int32 
maxyshift );
- LEPT_DLL extern L_RECOG * recogCreateFromPixa ( PIXA *pixa, l_int32 scalew, 
l_int32 scaleh, l_int32 templ_type, l_int32 threshold, l_int32 maxyshift );
-@@ -2167,13 +2167,13 @@ LEPT_DLL extern l_int32 recogGetClassIndex ( L_RECOG *
- LEPT_DLL extern l_int32 recogStringToIndex ( L_RECOG *recog, char *text, 
l_int32 *pindex );
- LEPT_DLL extern l_int32 recogGetClassString ( L_RECOG *recog, l_int32 index, 
char **pcharstr );
- LEPT_DLL extern l_int32 l_convertCharstrToInt ( const char *str, l_int32 
*pval );
--LEPT_DLL extern L_RECOGA * recogaRead ( const char *filename );
--LEPT_DLL extern L_RECOGA * recogaReadStream ( FILE *fp );
--LEPT_DLL extern L_RECOGA * recogaReadMem ( const l_uint8 *data, size_t size );
--LEPT_DLL extern l_int32 recogaWrite ( const char *filename, L_RECOGA *recoga 
);
--LEPT_DLL extern l_int32 recogaWriteStream ( FILE *fp, L_RECOGA *recoga );
--LEPT_DLL extern l_int32 recogaWriteMem ( l_uint8 **pdata, size_t *psize, 
L_RECOGA *recoga );
--LEPT_DLL extern l_int32 recogaWritePixaa ( const char *filename, L_RECOGA 
*recoga );
-+LEPT_DLL extern L_RECOG * recogaRead ( const char *filename );
-+LEPT_DLL extern L_RECOG * recogaReadStream ( FILE *fp );
-+LEPT_DLL extern L_RECOG * recogaReadMem ( const l_uint8 *data, size_t size );
-+LEPT_DLL extern l_int32 recogaWrite ( const char *filename, L_RECOG *recoga );
-+LEPT_DLL extern l_int32 recogaWriteStream ( FILE *fp, L_RECOG *recoga );
-+LEPT_DLL extern l_int32 recogaWriteMem ( l_uint8 **pdata, size_t *psize, 
L_RECOG *recoga );
-+LEPT_DLL extern l_int32 recogaWritePixaa ( const char *filename, L_RECOG 
*recoga );
- LEPT_DLL extern L_RECOG * recogRead ( const char *filename );
- LEPT_DLL extern L_RECOG * recogReadStream ( FILE *fp );
- LEPT_DLL extern L_RECOG * recogReadMem ( const l_uint8 *data, size_t size );
-@@ -2189,11 +2189,11 @@ LEPT_DLL extern l_int32 recogDestroyDid ( L_RECOG *rec
- LEPT_DLL extern l_int32 recogDidExists ( L_RECOG *recog );
- LEPT_DLL extern L_RDID * recogGetDid ( L_RECOG *recog );
- LEPT_DLL extern l_int32 recogSetChannelParams ( L_RECOG *recog, l_int32 
nlevels );
--LEPT_DLL extern l_int32 recogaIdentifyMultiple ( L_RECOGA *recoga, PIX *pixs, 
l_int32 nitems, l_int32 minw, l_int32 minh, l_int32 skipsplit, BOXA **pboxa, 
PIXA **ppixa, PIX **ppixdb, l_int32 debugsplit );
-+LEPT_DLL extern l_int32 recogaIdentifyMultiple ( L_RECOG *recoga, PIX *pixs, 
l_int32 nitems, l_int32 minw, l_int32 minh, l_int32 skipsplit, BOXA **pboxa, 
PIXA **ppixa, PIX **ppixdb, l_int32 debugsplit );
- LEPT_DLL extern l_int32 recogSplitIntoCharacters ( L_RECOG *recog, PIX *pixs, 
l_int32 minw, l_int32 minh, l_int32 skipsplit, BOXA **pboxa, PIXA **ppixa, NUMA 
**pnaid, l_int32 debug );
- LEPT_DLL extern l_int32 recogCorrelationBestRow ( L_RECOG *recog, PIX *pixs, 
BOXA **pboxa, NUMA **pnascore, NUMA **pnaindex, SARRAY **psachar, l_int32 debug 
);
- LEPT_DLL extern l_int32 recogCorrelationBestChar ( L_RECOG *recog, PIX *pixs, 
BOX **pbox, l_float32 *pscore, l_int32 *pindex, char **pcharstr, PIX **ppixdb );
--LEPT_DLL extern l_int32 recogaIdentifyPixa ( L_RECOGA *recoga, PIXA *pixa, 
NUMA *naid, PIX **ppixdb );
-+LEPT_DLL extern l_int32 recogaIdentifyPixa ( L_RECOG *recoga, PIXA *pixa, 
NUMA *naid, PIX **ppixdb );
- LEPT_DLL extern l_int32 recogIdentifyPixa ( L_RECOG *recog, PIXA *pixa, NUMA 
*naid, PIX **ppixdb );
- LEPT_DLL extern l_int32 recogIdentifyPix ( L_RECOG *recog, PIX *pixs, PIX 
**ppixdb );
- LEPT_DLL extern l_int32 recogSkipIdentify ( L_RECOG *recog );
-@@ -2204,7 +2204,7 @@ LEPT_DLL extern l_int32 rchExtract ( L_RCH *rch, l_int
- LEPT_DLL extern PIX * recogProcessToIdentify ( L_RECOG *recog, PIX *pixs, 
l_int32 pad );
- LEPT_DLL extern PIX * recogPreSplittingFilter ( L_RECOG *recog, PIX *pixs, 
l_float32 maxasp, l_float32 minaf, l_int32 debug );
- LEPT_DLL extern l_int32 recogSplittingFilter ( L_RECOG *recog, PIX *pixs, 
l_float32 maxasp, l_float32 minaf, l_int32 *premove, l_int32 debug );
--LEPT_DLL extern SARRAY * recogaExtractNumbers ( L_RECOGA *recoga, BOXA 
*boxas, l_float32 scorethresh, l_int32 spacethresh, BOXAA **pbaa, NUMAA **pnaa 
);
-+LEPT_DLL extern SARRAY * recogaExtractNumbers ( L_RECOG *recoga, BOXA *boxas, 
l_float32 scorethresh, l_int32 spacethresh, BOXAA **pbaa, NUMAA **pnaa );
- LEPT_DLL extern l_int32 recogSetTemplateType ( L_RECOG *recog, l_int32 
templ_type );
- LEPT_DLL extern l_int32 recogSetScaling ( L_RECOG *recog, l_int32 scalew, 
l_int32 scaleh, l_int32 templ_type );
- LEPT_DLL extern l_int32 recogTrainLabelled ( L_RECOG *recog, PIX *pixs, BOX 
*box, char *text, l_int32 multflag, l_int32 debug );
-@@ -2216,16 +2216,16 @@ LEPT_DLL extern l_int32 recogAverageSamples ( L_RECOG 
- LEPT_DLL extern l_int32 pixaAccumulateSamples ( PIXA *pixa, PTA *pta, PIX 
**ppixd, l_float32 *px, l_float32 *py );
- LEPT_DLL extern l_int32 recogTrainingFinished ( L_RECOG *recog, l_int32 debug 
);
- LEPT_DLL extern l_int32 recogRemoveOutliers ( L_RECOG *recog, l_float32 
targetscore, l_float32 minfract, l_int32 debug );
--LEPT_DLL extern l_int32 recogaTrainingDone ( L_RECOGA *recoga, l_int32 *pdone 
);
--LEPT_DLL extern l_int32 recogaFinishAveraging ( L_RECOGA *recoga );
-+LEPT_DLL extern l_int32 recogaTrainingDone ( L_RECOG *recoga, l_int32 *pdone 
);
-+LEPT_DLL extern l_int32 recogaFinishAveraging ( L_RECOG *recoga );
- LEPT_DLL extern L_RECOG * recogTrainFromBoot ( PIXA *pixa, L_RECOG 
*recogboot, l_float32 minscore, l_int32 threshold, l_int32 scalew, l_int32 
scaleh, l_int32 templ_type, l_int32 debug );
- LEPT_DLL extern l_int32 recogTrainUnlabelled ( L_RECOG *recog, L_RECOG 
*recogboot, PIX *pixs, BOX *box, l_float32 minscore, l_int32 debug );
- LEPT_DLL extern l_int32 recogPadTrainingSet ( L_RECOG **precog, l_int32 debug 
);
--LEPT_DLL extern l_int32 recogBestCorrelForPadding ( L_RECOG *recog, L_RECOGA 
*recoga, NUMA **pnaset, NUMA **pnaindex, NUMA **pnascore, NUMA **pnasum, PIXA 
*pixadb );
-+LEPT_DLL extern l_int32 recogBestCorrelForPadding ( L_RECOG *recog, L_RECOG 
*recoga, NUMA **pnaset, NUMA **pnaindex, NUMA **pnascore, NUMA **pnasum, PIXA 
*pixadb );
- LEPT_DLL extern l_int32 recogCorrelAverages ( L_RECOG *recog1, L_RECOG 
*recog2, NUMA **pnaindex, NUMA **pnascore, PIXA *pixadb );
- LEPT_DLL extern l_int32 recogSetPadParams ( L_RECOG *recog, const char 
*bootdir, const char *bootpattern, const char *bootpath, l_int32 boot_iters, 
l_int32 type, l_int32 min_nopad, l_int32 max_afterpad, l_int32 min_samples );
- LEPT_DLL extern L_RECOG * recogMakeBootDigitRecog ( l_int32 templ_type, 
l_int32 maxyshift, l_int32 display );
--LEPT_DLL extern l_int32 recogaShowContent ( FILE *fp, L_RECOGA *recoga, 
l_int32 display );
-+LEPT_DLL extern l_int32 recogaShowContent ( FILE *fp, L_RECOG *recoga, 
l_int32 display );
- LEPT_DLL extern l_int32 recogShowContent ( FILE *fp, L_RECOG *recog, l_int32 
display );
- LEPT_DLL extern l_int32 recogDebugAverages ( L_RECOG *recog, l_int32 debug );
- LEPT_DLL extern l_int32 recogShowAverageTemplates ( L_RECOG *recog );
Index: patches/patch-mupdf_mod_font_c
===================================================================
RCS file: patches/patch-mupdf_mod_font_c
diff -N patches/patch-mupdf_mod_font_c
--- patches/patch-mupdf_mod_font_c      11 Mar 2022 18:27:03 -0000      1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,57 +0,0 @@
-Index: mupdf_mod/font.c
---- mupdf_mod/font.c.orig
-+++ mupdf_mod/font.c
-@@ -200,8 +200,8 @@ struct fz_font_context_s
-       int ctx_refs;
-       FT_Library ftlib;
-       int ftlib_refs;
--      fz_load_system_font_func load_font;
--      fz_load_system_cjk_font_func load_cjk_font;
-+      fz_load_system_font_fn load_font;
-+      fz_load_system_cjk_font_fn load_cjk_font;
- 
-       /* Cached fallback fonts */
-       struct { fz_font *serif, *sans; } fallback[256];
-@@ -258,7 +258,7 @@ void fz_drop_font_context(fz_context *ctx)
-       }
- }
- 
--void fz_install_load_system_font_funcs(fz_context *ctx, 
fz_load_system_font_func f, fz_load_system_cjk_font_func f_cjk)
-+void fz_install_load_system_font_funcs(fz_context *ctx, 
fz_load_system_font_fn f, fz_load_system_cjk_font_fn f_cjk, 
fz_load_system_fallback_font_fn f_fallback)
- {
-       ctx->font->load_font = f;
-       ctx->font->load_cjk_font = f_cjk;
-@@ -1354,27 +1354,27 @@ fz_render_t3_glyph_direct(fz_context *ctx, fz_device *
- void
- fz_print_font(fz_context *ctx, fz_output *out, fz_font *font)
- {
--      fz_printf(ctx, out, "font '%s' {\n", font->name);
-+      fz_write_printf(ctx, out, "font '%s' {\n", font->name);
- 
-       if (font->ft_face)
-       {
--              fz_printf(ctx, out, "\tfreetype face %p\n", font->ft_face);
-+              fz_write_printf(ctx, out, "\tfreetype face %p\n", 
font->ft_face);
-               if (font->flags.ft_substitute)
--                      fz_printf(ctx, out, "\tsubstitute font\n");
-+                      fz_write_printf(ctx, out, "\tsubstitute font\n");
-       }
- 
-       if (font->t3procs)
-       {
--              fz_printf(ctx, out, "\ttype3 matrix [%g %g %g %g]\n",
-+              fz_write_printf(ctx, out, "\ttype3 matrix [%g %g %g %g]\n",
-                       font->t3matrix.a, font->t3matrix.b,
-                       font->t3matrix.c, font->t3matrix.d);
- 
--              fz_printf(ctx, out, "\ttype3 bbox [%g %g %g %g]\n",
-+              fz_write_printf(ctx, out, "\ttype3 bbox [%g %g %g %g]\n",
-                       font->bbox.x0, font->bbox.y0,
-                       font->bbox.x1, font->bbox.y1);
-       }
- 
--      fz_printf(ctx, out, "}\n");
-+      fz_write_printf(ctx, out, "}\n");
- }
- 
- fz_rect *
Index: patches/patch-mupdf_mod_pdf-colorspace_c
===================================================================
RCS file: patches/patch-mupdf_mod_pdf-colorspace_c
diff -N patches/patch-mupdf_mod_pdf-colorspace_c
--- patches/patch-mupdf_mod_pdf-colorspace_c    11 Mar 2022 18:27:03 -0000      
1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,12 +0,0 @@
-Index: mupdf_mod/pdf-colorspace.c
---- mupdf_mod/pdf-colorspace.c.orig
-+++ mupdf_mod/pdf-colorspace.c
-@@ -109,7 +109,7 @@ load_separation(fz_context *ctx, pdf_document *doc, pd
-               sep->base = base;
-               sep->tint = tint;
- 
--              cs = fz_new_colorspace(ctx, n == 1 ? "Separation" : "DeviceN", 
n, separation_to_rgb, NULL, free_separation, sep,
-+              cs = fz_new_colorspace(ctx, n == 1 ? "Separation" : "DeviceN", 
0, n, separation_to_rgb, NULL, free_separation, sep,
-                       sizeof(struct separation) + (base ? base->size : 0) + 
fz_function_size(ctx, tint));
-       }
-       fz_catch(ctx)
Index: patches/patch-mupdf_mod_stext-device_c
===================================================================
RCS file: patches/patch-mupdf_mod_stext-device_c
diff -N patches/patch-mupdf_mod_stext-device_c
--- patches/patch-mupdf_mod_stext-device_c      11 Mar 2022 18:27:03 -0000      
1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,12 +0,0 @@
-Index: mupdf_mod/stext-device.c
---- mupdf_mod/stext-device.c.orig
-+++ mupdf_mod/stext-device.c
-@@ -1097,7 +1097,7 @@ fz_parse_stext_options(fz_context *ctx, fz_stext_optio
- fz_device *
- fz_new_stext_device(fz_context *ctx, fz_stext_sheet *sheet, fz_stext_page 
*page, const fz_stext_options *opts)
- {
--      fz_stext_device *dev = fz_new_device(ctx, sizeof *dev);
-+      fz_stext_device *dev = fz_new_derived_device(ctx, fz_stext_device);
- 
-       dev->super.hints = FZ_IGNORE_IMAGE | FZ_IGNORE_SHADE;
- 
Index: patches/patch-willuslib_CMakeLists_txt
===================================================================
RCS file: 
/cvs/ports/converters/k2pdfopt/patches/patch-willuslib_CMakeLists_txt,v
retrieving revision 1.2
diff -u -p -r1.2 patch-willuslib_CMakeLists_txt
--- patches/patch-willuslib_CMakeLists_txt      11 Mar 2022 18:27:03 -0000      
1.2
+++ patches/patch-willuslib_CMakeLists_txt      18 Apr 2024 15:11:48 -0000
@@ -1,78 +1,38 @@
+Patch from Debian: "conditionally add source files", see
+https://sources.debian.org/patches/k2pdfopt/2.55%2Bds-2/0012-willuslib-CMakeLists.txt-conditionally-add-source-fi.patch/
+
+Add ../mupdf_mod/font-win32.c to get the mupdf part to compile.
+
 Index: willuslib/CMakeLists.txt
 --- willuslib/CMakeLists.txt.orig
 +++ willuslib/CMakeLists.txt
-@@ -1,4 +1,4 @@
--project(k2pdfopt C)
-+project(k2pdfopt)
- cmake_minimum_required(VERSION 2.6)
- 
- include_directories(..)
-@@ -6,13 +6,37 @@ include_directories(..)
+@@ -9,14 +9,27 @@ include_directories(..)
  set(WILLUSLIB_SRC
      ansi.c array.c bmp.c bmpdjvu.c bmpmupdf.c dtcompress.c filelist.c
      fontdata.c fontrender.c gslpolyfit.c linux.c math.c mem.c ocr.c
--    ocrjocr.c ocrtess.c pdfwrite.c point2d.c render.c strbuf.c string.c
-+    ocrtess.c pdfwrite.c point2d.c render.c strbuf.c string.c
-     token.c wfile.c wgs.c wgui.c willusversion.c win.c winbmp.c
-     wincomdlg.c winmbox.c winshell.c wmupdf.c wmupdfinfo.c wpdf.c wsys.c
--    wzfile.c wleptonica.c
-+    wzfile.c
-+
-+    # mupdf mods
-+    ../mupdf_mod/font.c
+-    ocrgocr.c ocrtess.c ocrwords.c pdffonts.c pdfwrite.c point2d.c
+-    render.c strbuf.c string.c token.c wfile.c wgs.c wgui.c
++    ocrwords.c pdffonts.c pdfwrite.c point2d.c
++    render.c strbuf.c string.c token.c wfile.c wgui.c
+     willusversion.c win.c winbmp.c wincomdlg.c wininet.c winmbox.c
+     winshell.c winshellwapi.c wleptonica.c wmupdf.c wmupdfinfo.c wpdf.c
+     wpdfoutline.c wpdfutil.c wsys.c wzfile.c
 +    ../mupdf_mod/font-win32.c
-+    ../mupdf_mod/pdf-annot.c
-+    ../mupdf_mod/pdf-colorspace.c
-+    ../mupdf_mod/pdf-font.c
-+    ../mupdf_mod/pdf-parse.c
-+    ../mupdf_mod/pdf-type3.c
-+    ../mupdf_mod/stext-device.c
-+    ../mupdf_mod/string.c
-+
-+    # tesseract mods
-+    ../tesseract_mod/dawg.cpp
-+    ../tesseract_mod/imagedata.cpp
-+    ../tesseract_mod/tesscapi.cpp
-+    ../tesseract_mod/tessedit.cpp
-+    ../tesseract_mod/thresholder.cpp
-+
-+    # leptonica mods
-+    wleptonica.c
-+    ../leptonica_mod/dewarp2.c
  )
-+
  # ocr.c  
  # win.c  winbmp.c winmbox.c wincomdlg.c wgui.c winshell.c
-+# wleptonica.c
++
++if(HAVE_GHOSTSCRIPT)
++  set(WILLUSLIB_SRC ${WILLUSLIB_SRC} wgs.c)
++endif(HAVE_GHOSTSCRIPT)
++
++if(GOCR_FOUND)
++  set(WILLUSLIB_SRC ${WILLUSLIB_SRC} ocrgocr.c)
++endif(GOCR_FOUND)
++
++if(TESSERACT_FOUND)
++  set(WILLUSLIB_SRC ${WILLUSLIB_SRC} ocrtess.c)
++endif(TESSERACT_FOUND)
  
  if(DJVU_FOUND)
    set(WILLUSLIB_SRC ${WILLUSLIB_SRC} bmpdjvu.c)
-@@ -21,10 +45,28 @@ endif(DJVU_FOUND)
- if(MUPDF_FOUND)
-   set(WILLUSLIB_SRC ${WILLUSLIB_SRC} bmpmupdf.c wmupdf.c)
- endif(MUPDF_FOUND)
-+if(MUPDF_LIB)
-+  set(WILLUSLIB_SRC ${WILLUSLIB_SRC} bmpmupdf.c wmupdf.c)
-+  include_directories(SYSTEM ../mupdf/source/fitz)
-+endif(MUPDF_LIB)
- 
-+if(LEPT_LIB)
-+  include_directories(SYSTEM ../leptonica/src)
-+endif()
-+
-+if(TESSERACT_LIB)
-+  include_directories(SYSTEM ../tesseract/ccutil ../tesseract/api
-+      ../tesseract/ccmain ../tesseract/ccstruct ../tesseract/viewer
-+      ../tesseract/dict ../tesseract/textord ../tesseract/cutil 
-+      ../tesseract/wordrec ../tesseract/classify)
-+endif()
-+
- message("-- Willuslib sources: ${WILLUSLIB_SRC}")
- 
- add_library(willuslib ${WILLUSLIB_SRC})
-+if(MUPDF_LIB)
-+  target_link_libraries(willuslib ${MUPDF_LIB})
-+endif(MUPDF_LIB)
- 
- # HAVE_GOCR_LIB: ocrjocr.c
- # HAVE_TESSERACT_LIB: ocrtess.c 
Index: patches/patch-willuslib_bmpdjvu_c
===================================================================
RCS file: patches/patch-willuslib_bmpdjvu_c
diff -N patches/patch-willuslib_bmpdjvu_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-willuslib_bmpdjvu_c   18 Apr 2024 15:11:48 -0000
@@ -0,0 +1,15 @@
+Patch from Debian: "use system djvu", see
+https://sources.debian.org/patches/k2pdfopt/2.55%2Bds-2/0010-willuslib-use-system-djvu.patch/
+
+Index: willuslib/bmpdjvu.c
+--- willuslib/bmpdjvu.c.orig
++++ willuslib/bmpdjvu.c
+@@ -23,7 +23,7 @@
+ #include "willus.h"
+ 
+ #ifdef HAVE_DJVU_LIB
+-#include <djvu.h>
++#include <libdjvu/ddjvuapi.h>
+ 
+ static void handle(int wait,ddjvu_context_t *ctx);
+ static void djvu_add_page_info(char *buf,ddjvu_document_t *doc,int page,int 
npages);
Index: patches/patch-willuslib_gslpolyfit_c
===================================================================
RCS file: patches/patch-willuslib_gslpolyfit_c
diff -N patches/patch-willuslib_gslpolyfit_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-willuslib_gslpolyfit_c        18 Apr 2024 15:11:48 -0000
@@ -0,0 +1,15 @@
+Patch from Debian: "use system gsl", see
+https://sources.debian.org/patches/k2pdfopt/2.55%2Bds-2/0008-willuslib-gslpolyfit.c-use-system-gsl.patch/
+
+Index: willuslib/gslpolyfit.c
+--- willuslib/gslpolyfit.c.orig
++++ willuslib/gslpolyfit.c
+@@ -24,7 +24,7 @@
+ #include <stdlib.h>
+ #include "willus.h"
+ #ifdef HAVE_GSL_LIB
+-#include <gsl.h>
++#include <gsl/gsl_multifit.h>
+ #endif
+ 
+ void gslpolyfit(double *x,double *y0,int n,int d,double *c0)
Index: patches/patch-willuslib_ocrtess_c
===================================================================
RCS file: patches/patch-willuslib_ocrtess_c
diff -N patches/patch-willuslib_ocrtess_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-willuslib_ocrtess_c   18 Apr 2024 15:11:48 -0000
@@ -0,0 +1,16 @@
+Patch from Debian: "use system leptonica", see
+https://sources.debian.org/patches/k2pdfopt/2.55%2Bds-2/0005-willuslib-use-system-leptonica.patch/
+
+Index: willuslib/ocrtess.c
+--- willuslib/ocrtess.c.orig
++++ willuslib/ocrtess.c
+@@ -25,8 +25,7 @@
+ #include <string.h>
+ #include <ctype.h>
+ #include <locale.h>
+-#include <leptonica.h>
+-#include <tesseract.h>
++#include <leptonica/allheaders.h>
+ #include "willus.h"
+ 
+ char *ocrtess_langnames[] =
Index: patches/patch-willuslib_willus_h
===================================================================
RCS file: /cvs/ports/converters/k2pdfopt/patches/patch-willuslib_willus_h,v
retrieving revision 1.2
diff -u -p -r1.2 patch-willuslib_willus_h
--- patches/patch-willuslib_willus_h    11 Mar 2022 18:27:03 -0000      1.2
+++ patches/patch-willuslib_willus_h    18 Apr 2024 15:11:48 -0000
@@ -4,7 +4,7 @@
 Index: willuslib/willus.h
 --- willuslib/willus.h.orig
 +++ willuslib/willus.h
-@@ -107,7 +107,7 @@ typedef double  real;
+@@ -113,7 +113,7 @@ typedef double  real;
  #define MINGW
  #endif
  
@@ -13,7 +13,7 @@ Index: willuslib/willus.h
  #define UNIX
  #endif
  
-@@ -160,7 +160,8 @@ typedef double  real;
+@@ -166,7 +166,8 @@ typedef double  real;
  #define WILLUS_X86
  #endif
  
Index: patches/patch-willuslib_wleptonica_c
===================================================================
RCS file: patches/patch-willuslib_wleptonica_c
diff -N patches/patch-willuslib_wleptonica_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-willuslib_wleptonica_c        18 Apr 2024 15:11:48 -0000
@@ -0,0 +1,24 @@
+Patch from Debian: "use system leptonica", see
+https://sources.debian.org/patches/k2pdfopt/2.55%2Bds-2/0005-willuslib-use-system-leptonica.patch/
+
+Index: willuslib/wleptonica.c
+--- willuslib/wleptonica.c.orig
++++ willuslib/wleptonica.c
+@@ -23,7 +23,7 @@
+ #include "willus.h"
+ 
+ #ifdef HAVE_LEPTONICA_LIB
+-#include <leptonica.h>
++#include <leptonica/allheaders.h>
+ 
+ static void wlept_pix_from_bmp(PIX **pixptr,WILLUSBITMAP *bmp);
+ static void wlept_bmp_from_pix(WILLUSBITMAP *bmp,PIX *pix);
+@@ -135,7 +135,7 @@ pixWrite("pixb.png",pixb,IFF_PNG);
+     dew1=dewarpCreate(pixb,1);
+     pixDestroy(&pixb);
+     dewarpaInsertDewarp(dewa,dew1);
+-    dewarpBuildPageModel_ex(dew1,debug,fit_order);
++    dewarpBuildPageModel(dew1,debug);
+     if (bmp1!=NULL)
+         {
+         PIX *pix2,*pix2d;
Index: patches/patch-willuslib_wmupdf_c
===================================================================
RCS file: patches/patch-willuslib_wmupdf_c
diff -N patches/patch-willuslib_wmupdf_c
--- patches/patch-willuslib_wmupdf_c    11 Mar 2022 18:27:03 -0000      1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,21 +0,0 @@
-Index: willuslib/wmupdf.c
---- willuslib/wmupdf.c.orig
-+++ willuslib/wmupdf.c
-@@ -1051,7 +1051,7 @@ printf("    srcptr = %p\n",srcbuf->data);
- 
-         whitespace[0]=' ';
-         whitespace[1]='\0';
--        fz_write_buffer(ctx,dstbuf,whitespace,1);
-+        fz_append_data(ctx,dstbuf,whitespace,1);
-         }
-     /* mupdf 1.10a--replace write with append */
-     /*
-@@ -1153,7 +1153,7 @@ static int new_stream_object(pdf_document *xref,fz_con
-     pdf_update_object(ctx,xref,ref,obj);
-     pdf_drop_obj(ctx,obj);
-     fzbuf=fz_new_buffer(ctx,strlen(buf));
--    fz_write_buffer(ctx,fzbuf,(unsigned char *)buf,strlen(buf));
-+    fz_append_data(ctx,fzbuf,(unsigned char *)buf,strlen(buf));
-     wmupdf_update_stream(ctx,xref,ref,fzbuf);
-     fz_drop_buffer(ctx,fzbuf);
-     return(ref);
Index: patches/patch-willuslib_wmupdfinfo_c
===================================================================
RCS file: patches/patch-willuslib_wmupdfinfo_c
diff -N patches/patch-willuslib_wmupdfinfo_c
--- patches/patch-willuslib_wmupdfinfo_c        11 Mar 2022 18:27:03 -0000      
1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,293 +0,0 @@
-Index: willuslib/wmupdfinfo.c
---- willuslib/wmupdfinfo.c.orig
-+++ willuslib/wmupdfinfo.c
-@@ -227,7 +227,7 @@ static void showglobalinfo(fz_context *ctx, globals *g
-       fz_printf(ctx, out, "\nPages: %d\n\n", glo->pagecount);
- }
- */
--    fz_printf(ctx,out,"PDF VERSION:    
%d.%d\n",doc->version/10,doc->version%10);
-+    fz_write_printf(ctx,out,"PDF VERSION:    
%d.%d\n",doc->version/10,doc->version%10);
- 
-       obj = pdf_dict_gets(ctx,pdf_trailer(ctx,doc), "Info");
-       if (obj)
-@@ -241,7 +241,7 @@ static void showglobalinfo(fz_context *ctx, globals *g
-         buf=malloc(n+2);
-         if (buf==NULL)
-             {
--            fz_printf(ctx,out,"Info object (%d %d 
R):\n",pdf_to_num(ctx,obj),pdf_to_gen(ctx,obj));
-+            fz_write_printf(ctx,out,"Info object (%d %d 
R):\n",pdf_to_num(ctx,obj),pdf_to_gen(ctx,obj));
-                   pdf_print_obj(ctx,out,robj,1);
-             }
-         else
-@@ -263,18 +263,18 @@ static void showglobalinfo(fz_context *ctx, globals *g
-         sprintf(buf1,"PAGE SIZE:      %.2f x %.2f in\n",
-                 (glo->dim[0].u.dim.bbox->x1-glo->dim[0].u.dim.bbox->x0)/72.,
-                 (glo->dim[0].u.dim.bbox->y1-glo->dim[0].u.dim.bbox->y0)/72.);
--        fz_printf(ctx,out,"%s",buf1);
-+        fz_write_printf(ctx,out,"%s",buf1);
-         }
-     else
-         {
-         if (glo->dims>1)
--            fz_printf(ctx,out,"PAGE SIZE:      (varies)\n");
-+            fz_write_printf(ctx,out,"PAGE SIZE:      (varies)\n");
-         }
--      fz_printf(ctx,out, "PAGES:          %d\n\n", glo->pagecount);
-+      fz_write_printf(ctx,out, "PAGES:          %d\n\n", glo->pagecount);
-       obj = pdf_dict_gets(ctx,pdf_trailer(ctx,doc), "Encrypt");
-       if (obj)
-         {
--              fz_printf(ctx,out, "\nEncryption object (%d %d R):\n", 
pdf_to_num(ctx,obj), pdf_to_gen(ctx,obj));
-+              fz_write_printf(ctx,out, "\nEncryption object (%d %d R):\n", 
pdf_to_num(ctx,obj), pdf_to_gen(ctx,obj));
-               pdf_print_obj(ctx,out, pdf_resolve_indirect(ctx,obj), 1);
-         }
-     }
-@@ -302,15 +302,15 @@ static void display_pdf_field(fz_context *ctx,fz_outpu
-             int j;
-             for (j=i+lenfn+1;buf[j]!='\0' && buf[j]!=')';j++);
-             buf[j]='\0';
--            fz_printf(ctx,out,"%s",label3);
-+            fz_write_printf(ctx,out,"%s",label3);
-             if (in_string(fieldname,"date")>=0)
-                 {
-                 char newdate[128];
-                 date_convert(newdate,&buf[i+lenfn+1]);
--                fz_printf(ctx,out,"%s\n",newdate);
-+                fz_write_printf(ctx,out,"%s\n",newdate);
-                 }
-             else
--                fz_printf(ctx,out,"%s\n",&buf[i+lenfn+1]);
-+                fz_write_printf(ctx,out,"%s\n",&buf[i+lenfn+1]);
-             break;
-             }
-         }
-@@ -334,7 +334,7 @@ static void display_file_size(fz_context *ctx,fz_outpu
-     fclose(f);
-     str_format_int_grouped(sizecommas,sz);
-     sprintf(buf,"FILE SIZE:      %.1f kB (%s bytes)\n",sz/1024.,sizecommas);
--    fz_printf(ctx,out,"%s",buf);
-+    fz_write_printf(ctx,out,"%s",buf);
-     }
- 
- 
-@@ -819,7 +819,7 @@ static void gatherpageinfo(fz_context *ctx, globals *g
- 
-     if (page > glo->pagecount)
-         {
--        fz_printf(ctx,glo->out,"[Error:  Page %d not found.]\n",page);
-+        fz_write_printf(ctx,glo->out,"[Error:  Page %d not found.]\n",page);
-         return;
-         }
-       pageref = pdf_lookup_page_obj(ctx, glo->doc, page-1);
-@@ -845,7 +845,7 @@ printinfo(fz_context *ctx, globals *glo, char *filenam
- 
-       if (show & DIMENSIONS && glo->dims > 0)
-       {
--              fz_printf(ctx, out, "Mediaboxes (%d):\n", glo->dims);
-+              fz_write_printf(ctx, out, "Mediaboxes (%d):\n", glo->dims);
-               for (i = 0; i < glo->dims; i++)
-               {
-         char buf1[64];
-@@ -853,7 +853,7 @@ printinfo(fz_context *ctx, globals *glo, char *filenam
-         sprintf(buf1,"%.2f x %.2f",
-                 (glo->dim[i].u.dim.bbox->x1-glo->dim[i].u.dim.bbox->x0)/72.,
-                 (glo->dim[i].u.dim.bbox->y1-glo->dim[i].u.dim.bbox->y0)/72.);
--                      fz_printf(ctx, out, PAGE_FMT "[ %g %g %g %g ] (%s 
in)\n",
-+                      fz_write_printf(ctx, out, PAGE_FMT "[ %g %g %g %g ] (%s 
in)\n",
-                               glo->dim[i].page,
-                               pdf_to_num(ctx, glo->dim[i].pageref),
-                               pdf_to_gen(ctx, glo->dim[i].pageref),
-@@ -862,15 +862,15 @@ printinfo(fz_context *ctx, globals *glo, char *filenam
-                               glo->dim[i].u.dim.bbox->x1,
-                               glo->dim[i].u.dim.bbox->y1,buf1);
-               }
--              fz_printf(ctx, out, "\n");
-+              fz_write_printf(ctx, out, "\n");
-       }
- 
-       if (show & FONTS && glo->fonts > 0)
-       {
--              fz_printf(ctx, out, "Fonts (%d):\n", glo->fonts);
-+              fz_write_printf(ctx, out, "Fonts (%d):\n", glo->fonts);
-               for (i = 0; i < glo->fonts; i++)
-               {
--                      fz_printf(ctx, out, PAGE_FMT "%s '%s' (%d %d R)\n",
-+                      fz_write_printf(ctx, out, PAGE_FMT "%s '%s' (%d %d 
R)\n",
-                               glo->font[i].page,
-                               pdf_to_num(ctx, glo->font[i].pageref),
-                               pdf_to_gen(ctx, glo->font[i].pageref),
-@@ -879,18 +879,18 @@ printinfo(fz_context *ctx, globals *glo, char *filenam
-                               pdf_to_num(ctx, glo->font[i].u.font.obj),
-                               pdf_to_gen(ctx, glo->font[i].u.font.obj));
-               }
--              fz_printf(ctx, out, "\n");
-+              fz_write_printf(ctx, out, "\n");
-       }
- 
-       if (show & IMAGES && glo->images > 0)
-       {
--              fz_printf(ctx, out, "Images (%d):\n", glo->images);
-+              fz_write_printf(ctx, out, "Images (%d):\n", glo->images);
-               for (i = 0; i < glo->images; i++)
-               {
-                       char *cs = NULL;
-                       char *altcs = NULL;
- 
--                      fz_printf(ctx, out, PAGE_FMT "[ ",
-+                      fz_write_printf(ctx, out, PAGE_FMT "[ ",
-                               glo->image[i].page,
-                               pdf_to_num(ctx, glo->image[i].pageref),
-                               pdf_to_gen(ctx, glo->image[i].pageref));
-@@ -906,7 +906,7 @@ printinfo(fz_context *ctx, globals *glo, char *filenam
-                                       if (strstr(filter, "Decode"))
-                                               *(strstr(filter, "Decode")) = 
'\0';
- 
--                                      fz_printf(ctx, out, "%s%s",
-+                                      fz_write_printf(ctx, out, "%s%s",
-                                               filter,
-                                               j == pdf_array_len(ctx, 
glo->image[i].u.image.filter) - 1 ? "" : " ");
-                                       fz_free(ctx, filter);
-@@ -920,11 +920,11 @@ printinfo(fz_context *ctx, globals *glo, char *filenam
-                               if (strstr(filter, "Decode"))
-                                       *(strstr(filter, "Decode")) = '\0';
- 
--                              fz_printf(ctx, out, "%s", filter);
-+                              fz_write_printf(ctx, out, "%s", filter);
-                               fz_free(ctx, filter);
-                       }
-                       else
--                              fz_printf(ctx, out, "Raw");
-+                              fz_write_printf(ctx, out, "Raw");
- 
-                       if (glo->image[i].u.image.cs)
-                       {
-@@ -965,7 +965,7 @@ printinfo(fz_context *ctx, globals *glo, char *filenam
-                                       fz_strlcpy(altcs, "Sep", 4);
-                       }
- 
--                      fz_printf(ctx, out, " ] %dx%d %dbpc %s%s%s (%d %d R)\n",
-+                      fz_write_printf(ctx, out, " ] %dx%d %dbpc %s%s%s (%d %d 
R)\n",
-                               pdf_to_int(ctx, glo->image[i].u.image.width),
-                               pdf_to_int(ctx, glo->image[i].u.image.height),
-                               glo->image[i].u.image.bpc ? pdf_to_int(ctx, 
glo->image[i].u.image.bpc) : 1,
-@@ -978,12 +978,12 @@ printinfo(fz_context *ctx, globals *glo, char *filenam
-                       fz_free(ctx, cs);
-                       fz_free(ctx, altcs);
-               }
--              fz_printf(ctx, out, "\n");
-+              fz_write_printf(ctx, out, "\n");
-       }
- 
-       if (show & SHADINGS && glo->shadings > 0)
-       {
--              fz_printf(ctx, out, "Shading patterns (%d):\n", glo->shadings);
-+              fz_write_printf(ctx, out, "Shading patterns (%d):\n", 
glo->shadings);
-               for (i = 0; i < glo->shadings; i++)
-               {
-                       char *shadingtype[] =
-@@ -998,7 +998,7 @@ printinfo(fz_context *ctx, globals *glo, char *filenam
-                               "Tensor patch",
-                       };
- 
--                      fz_printf(ctx, out, PAGE_FMT "%s (%d %d R)\n",
-+                      fz_write_printf(ctx, out, PAGE_FMT "%s (%d %d R)\n",
-                               glo->shading[i].page,
-                               pdf_to_num(ctx, glo->shading[i].pageref),
-                               pdf_to_gen(ctx, glo->shading[i].pageref),
-@@ -1006,12 +1006,12 @@ printinfo(fz_context *ctx, globals *glo, char *filenam
-                               pdf_to_num(ctx, glo->shading[i].u.shading.obj),
-                               pdf_to_gen(ctx, glo->shading[i].u.shading.obj));
-               }
--              fz_printf(ctx, out, "\n");
-+              fz_write_printf(ctx, out, "\n");
-       }
- 
-       if (show & PATTERNS && glo->patterns > 0)
-       {
--              fz_printf(ctx, out, "Patterns (%d):\n", glo->patterns);
-+              fz_write_printf(ctx, out, "Patterns (%d):\n", glo->patterns);
-               for (i = 0; i < glo->patterns; i++)
-               {
-                       if (pdf_to_int(ctx, glo->pattern[i].u.pattern.type) == 
1)
-@@ -1030,7 +1030,7 @@ printinfo(fz_context *ctx, globals *glo, char *filenam
-                                       "Constant/fast tiling",
-                               };
- 
--                              fz_printf(ctx, out, PAGE_FMT "Tiling %s %s (%d 
%d R)\n",
-+                              fz_write_printf(ctx, out, PAGE_FMT "Tiling %s 
%s (%d %d R)\n",
-                                               glo->pattern[i].page,
-                                               pdf_to_num(ctx, 
glo->pattern[i].pageref),
-                                               pdf_to_gen(ctx, 
glo->pattern[i].pageref),
-@@ -1041,7 +1041,7 @@ printinfo(fz_context *ctx, globals *glo, char *filenam
-                       }
-                       else
-                       {
--                              fz_printf(ctx, out, PAGE_FMT "Shading %d %d R 
(%d %d R)\n",
-+                              fz_write_printf(ctx, out, PAGE_FMT "Shading %d 
%d R (%d %d R)\n",
-                                               glo->pattern[i].page,
-                                               pdf_to_num(ctx, 
glo->pattern[i].pageref),
-                                               pdf_to_gen(ctx, 
glo->pattern[i].pageref),
-@@ -1051,15 +1051,15 @@ printinfo(fz_context *ctx, globals *glo, char *filenam
-                                               pdf_to_gen(ctx, 
glo->pattern[i].u.pattern.obj));
-                       }
-               }
--              fz_printf(ctx, out, "\n");
-+              fz_write_printf(ctx, out, "\n");
-       }
- 
-       if (show & XOBJS && glo->forms > 0)
-       {
--              fz_printf(ctx, out, "Form xobjects (%d):\n", glo->forms);
-+              fz_write_printf(ctx, out, "Form xobjects (%d):\n", glo->forms);
-               for (i = 0; i < glo->forms; i++)
-               {
--                      fz_printf(ctx, out, PAGE_FMT "Form%s%s%s%s (%d %d R)\n",
-+                      fz_write_printf(ctx, out, PAGE_FMT "Form%s%s%s%s (%d %d 
R)\n",
-                               glo->form[i].page,
-                               pdf_to_num(ctx, glo->form[i].pageref),
-                               pdf_to_gen(ctx, glo->form[i].pageref),
-@@ -1070,22 +1070,22 @@ printinfo(fz_context *ctx, globals *glo, char *filenam
-                               pdf_to_num(ctx, glo->form[i].u.form.obj),
-                               pdf_to_gen(ctx, glo->form[i].u.form.obj));
-               }
--              fz_printf(ctx, out, "\n");
-+              fz_write_printf(ctx, out, "\n");
-       }
- 
-       if (show & XOBJS && glo->psobjs > 0)
-       {
--              fz_printf(ctx, out, "Postscript xobjects (%d):\n", glo->psobjs);
-+              fz_write_printf(ctx, out, "Postscript xobjects (%d):\n", 
glo->psobjs);
-               for (i = 0; i < glo->psobjs; i++)
-               {
--                      fz_printf(ctx, out, PAGE_FMT "(%d %d R)\n",
-+                      fz_write_printf(ctx, out, PAGE_FMT "(%d %d R)\n",
-                               glo->psobj[i].page,
-                               pdf_to_num(ctx, glo->psobj[i].pageref),
-                               pdf_to_gen(ctx, glo->psobj[i].pageref),
-                               pdf_to_num(ctx, glo->psobj[i].u.form.obj),
-                               pdf_to_gen(ctx, glo->psobj[i].u.form.obj));
-               }
--              fz_printf(ctx, out, "\n");
-+              fz_write_printf(ctx, out, "\n");
-       }
- }
- 
-@@ -1121,7 +1121,7 @@ static void pdfinfo_info(fz_context *ctx, fz_output *o
- 
-       glo.out = out;
-       glo.ctx = ctx;
--    fz_printf(ctx,out,"FILE:           %s\n",filename);
-+    fz_write_printf(ctx,out,"FILE:           %s\n",filename);
-       glo.doc = pdf_open_document(ctx,filename);
-       if (pdf_needs_password(ctx,glo.doc))
-               if (!pdf_authenticate_password(ctx, glo.doc, password))
-@@ -1129,7 +1129,7 @@ static void pdfinfo_info(fz_context *ctx, fz_output *o
-     glo.pagecount=pdf_count_pages(ctx,glo.doc);
-       gather_all_info(ctx,&glo,filename,show,pagelist);
-       showglobalinfo(ctx,&glo,filename);
--    fz_printf(ctx,glo.out,"       Page       Ref           Details\n");
-+    fz_write_printf(ctx,glo.out,"       Page       Ref           Details\n");
-     printinfo(ctx,&glo,filename,show);
-       closexref(ctx,&glo);
-     }
Index: pkg/PLIST
===================================================================
RCS file: /cvs/ports/converters/k2pdfopt/pkg/PLIST,v
retrieving revision 1.2
diff -u -p -r1.2 PLIST
--- pkg/PLIST   11 Mar 2022 18:27:03 -0000      1.2
+++ pkg/PLIST   18 Apr 2024 15:11:48 -0000
@@ -1 +1,2 @@
 @bin bin/k2pdfopt
+@man man/man1/k2pdfopt.1

Reply via email to