diff --git a/office/postscript/ghostscript/files/0001_No_output_visible_with_pdfwriter.diff b/office/postscript/ghostscript/files/0001_No_output_visible_with_pdfwriter.diff new file mode 100644 index 0000000000..2d178ac16f --- /dev/null +++ b/office/postscript/ghostscript/files/0001_No_output_visible_with_pdfwriter.diff @@ -0,0 +1,92 @@ +From e12b8487283979ab454a32888a3c37d4d9492480 Mon Sep 17 00:00:00 2001 +From: Ken Sharp +Date: Thu, 14 Mar 2024 13:08:38 +0000 +Subject: [PATCH] pdfwrite - more improvements for mesh shadings + +Bug #707655 "No output visible with pdfwriter" + +commit 3d6e3acbcda79a0096cd1ad73c7b9b1101a43187 to fix bug #06852 +unfortunately led to this regression. The problem is related to the +scaling of co-ordinates performed when a mesh shading has vertex +co-ordinates which are too large for Acrobat 5 (PDF 1.4). + +Acrobat 5 has a limit of =/-32767 on real numbers, which applies to the +/Decode array of a mesh shading. Because this is an Acrobat limit, not a +limit of the PDF specification we would ordinarily ignore it, but the +PDF/A-1 specification chose to carry the Acrobat limitations into the +PDF/A spec. + +This commit fixes the problem by correctly scaling the co-ordinate +values to the Decode array values when outputting to PDF 1.4 or less, +even if no actual co-ordinte scaling is required, and modifying the +/Matrix of the Pattern to scale up the Decode values to the real +co-ordinates. Crucially we must not scale the Tx and Ty values of the +CTM. +--- + devices/vector/gdevpdfv.c | 20 ++++++++++++-------- + 1 file changed, 12 insertions(+), 8 deletions(-) + +diff --git a/devices/vector/gdevpdfv.c b/devices/vector/gdevpdfv.c +index e880acafd..90a02158f 100644 +--- a/devices/vector/gdevpdfv.c ++++ b/devices/vector/gdevpdfv.c +@@ -42,8 +42,8 @@ extern const gx_device_color_type_t gx_dc_pattern2; + */ + #define ENCODE_VALUE(v, emax, vmin, vmax)\ + ( ((v) - (vmin)) * ((double)(emax) / ((vmax) - (vmin))) ) +-#define PDFA_MIN_MESH_COORDINATE (-0x800000 / 256.0) +-#define PDFA_MAX_MESH_COORDINATE ( 0x7fffff / 256.0) ++#define PDFA_MIN_MESH_COORDINATE (-0x400000 / 128.0) ++#define PDFA_MAX_MESH_COORDINATE ( 0x3fffff / 128.0) + #define PDFA_ENCODE_MESH_COORDINATE(v)\ + ENCODE_VALUE(v, 0xffffff, PDFA_MIN_MESH_COORDINATE, PDFA_MAX_MESH_COORDINATE) + #define MIN_MESH_COORDINATE (-0x800000 ) +@@ -690,6 +690,7 @@ typedef struct pdf_mesh_data_params_s { + int num_components; + bool is_indexed; + int rescale; /* If the co-ordinates won't fit into crappy Acrobat values, scale them here and in the pattern Matrix */ ++ bool old_pdf; + const float *Domain; /* iff Function */ + const gs_range_t *ranges; + } pdf_mesh_data_params_t; +@@ -713,7 +714,7 @@ put_clamped(byte *p, double v, int num_bytes) + static inline void + put_clamped_coord(byte *p, double v, int num_bytes, const pdf_mesh_data_params_t *pmdp) + { +- if (pmdp->rescale != 1.0) { ++ if (pmdp->rescale != 1.0 || pmdp->old_pdf) { + v = v / pmdp->rescale; + put_clamped(p, PDFA_ENCODE_MESH_COORDINATE(v), num_bytes); + } else +@@ -1027,7 +1028,9 @@ pdf_put_mesh_shading(gx_device_pdf *pdev, cos_stream_t *pscs, const gs_shading_t + if (z > *rescale) + *rescale = (int)z; + data_params.rescale = *rescale; +- } ++ data_params.old_pdf = 1; ++ } else ++ data_params.old_pdf = 0; + + switch (ShadingType(psh)) { + case shading_type_Free_form_Gouraud_triangle: { +@@ -1183,12 +1186,13 @@ pdf_put_pattern2(gx_device_pdf *pdev, const gs_gstate * pgs, const gx_drawing_co + yscale = 72.0 / pdev->HWResolution[1]; + } + +- if (rescale != 1) { +- xscale *= rescale; +- yscale *= rescale; +- } + smat.xx *= xscale, smat.yx *= xscale, smat.tx *= xscale; + smat.xy *= yscale, smat.yy *= yscale, smat.ty *= yscale; ++ ++ if (rescale != 1) { ++ smat.xx *= rescale, smat.yx *= rescale; ++ smat.xy *= rescale, smat.yy *= rescale; ++ } + } + + /* Bug #697451, if we emit a PDF with a type 2 Pattern where the +-- +2.34.1 + diff --git a/office/postscript/ghostscript/files/2010_add_build_timestamp_setting.patch b/office/postscript/ghostscript/files/2010_add_build_timestamp_setting.patch new file mode 100644 index 0000000000..1713685e0d --- /dev/null +++ b/office/postscript/ghostscript/files/2010_add_build_timestamp_setting.patch @@ -0,0 +1,119 @@ +Description: Allow the build timestamp to be externally set + In order to make Ghostscript output reproducible, we need a way to + set the build timestamp to other values than the current time. + We now consistently use gp_get_realtime() instead of directly calling + time() or gp_get_usertime() and make gp_get_realtime() use the value + found in the SOURCE_DATE_EPOCH environment variable if set. Also, + environment timezone is fixed to UTC if SOURCE_DATE_EPOCH is used to + avoid variations. +Author: Eduard Sanou +Author: Peter De Wachter +Bug-Debian: https://bugs.debian.org/794004 +Last-Update: 2015-07-30 +--- +This patch header follows DEP-3: https://dep.debian.net/deps/dep3/ +--- a/base/gp_unix.c ++++ b/base/gp_unix.c +@@ -19,6 +19,7 @@ + #ifdef __MINGW32__ + # include "windows_.h" + #endif ++#include "errno_.h" + #include "pipe_.h" + #include "string_.h" + #include "time_.h" +@@ -148,6 +149,7 @@ + gp_get_realtime(long *pdt) + { + struct timeval tp; ++ const char *env; + + #if gettimeofday_no_timezone /* older versions of SVR4 */ + { +@@ -167,6 +169,26 @@ + } + #endif + ++ env = getenv("SOURCE_DATE_EPOCH"); ++ if (env) { ++ char *end; ++ long timestamp; ++ ++ errno = 0; ++ timestamp = strtol(env, &end, 10); ++ if (env == end || *end || errno != 0) { ++ lprintf("Ghostscript: SOURCE_DATE_EPOCH is not a number!\n"); ++ timestamp = 0; ++ } ++ ++ tp.tv_sec = timestamp; ++ tp.tv_usec = 0; ++ ++ /* We need to fix the environment timezone to get reproducible */ ++ /* results when parsing the result of gp_get_realtime. */ ++ setenv("TZ", "UTC", 1); ++ } ++ + /* tp.tv_sec is #secs since Jan 1, 1970 */ + pdt[0] = tp.tv_sec; + +--- a/devices/vector/gdevpdf.c ++++ b/devices/vector/gdevpdf.c +@@ -427,6 +427,7 @@ + */ + { + struct tm tms; ++ long secs_ns[2]; + time_t t; + char buf[1+2+4+2+2+2+2+2+1+2+1+2+1+1+1]; /* (D:yyyymmddhhmmssZhh'mm')\0 */ + int timeoffset; +@@ -438,7 +439,8 @@ + timesign = 'Z'; + timeoffset = 0; + #else +- time(&t); ++ gp_get_realtime(secs_ns); ++ t = secs_ns[0]; + tms = *gmtime(&t); + tms.tm_isdst = -1; + timeoffset = (int)difftime(t, mktime(&tms)); /* tz+dst in seconds */ +--- a/devices/vector/gdevpdfe.c ++++ b/devices/vector/gdevpdfe.c +@@ -199,6 +199,7 @@ + { + /* We don't write a day time because we don't have a time zone. */ + struct tm tms; ++ long secs_ns[2]; + time_t t; + char buf1[4+1+2+1+2+1]; /* yyyy-mm-dd\0 */ + +@@ -206,7 +207,8 @@ + memset(&t, 0, sizeof(t)); + memset(&tms, 0, sizeof(tms)); + #else +- time(&t); ++ gp_get_realtime(secs_ns); ++ t = secs_ns[0]; + tms = *localtime(&t); + #endif + gs_sprintf(buf1, +--- a/devices/vector/gdevpsu.c ++++ b/devices/vector/gdevpsu.c +@@ -183,6 +183,7 @@ + fprintf(f, "%%%%Creator: %s %ld (%s)\n", gs_product, (long)gs_revision, + dev->dname); + { ++ long secs_ns[2]; + time_t t; + struct tm tms; + +@@ -190,7 +191,8 @@ + memset(&t, 0, sizeof(t)); + memset(&tms, 0, sizeof(tms)); + #else +- time(&t); ++ gp_get_realtime(secs_ns); ++ t = secs_ns[0]; + tms = *localtime(&t); + #endif + fprintf(f, "%%%%CreationDate: %d/%02d/%02d %02d:%02d:%02d\n", diff --git a/office/postscript/ghostscript/pspec.xml b/office/postscript/ghostscript/pspec.xml index 5d086d2c64..5fde0ada32 100644 --- a/office/postscript/ghostscript/pspec.xml +++ b/office/postscript/ghostscript/pspec.xml @@ -1,5 +1,5 @@ - + ghostscript @@ -13,7 +13,7 @@ library A PostScript interpreter and renderer ghostscript is a set of software that provides a PostScript interpreter, a set of C procedures and an interpreter for PDF files. ghostscript is normally used to display PostScript files and to print PostScript files to non-PostScript printers. - https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs10012/ghostscript-10.01.2.tar.gz + https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs10030/ghostscript-10.03.0.tar.gz cups-devel dbus-devel @@ -39,7 +39,9 @@ - fedora/ghostscript-sys-zlib.patch + 0001_No_output_visible_with_pdfwriter.diff + 2010_add_build_timestamp_setting.patch + @@ -54,6 +56,7 @@ libidn libX11 libpng + libgcc freetype libpaper openjpeg2 @@ -146,6 +149,13 @@ + + 2024-05-16 + 10.03.0 + Version bump + Kamil Atlı + suvari@pisilinux.org + 2023-07-29 10.01.2