From 6721dd098a6875c5660943b3e560139c16ab7d4e Mon Sep 17 00:00:00 2001 From: Christian Schenk Date: Thu, 6 Feb 2025 11:50:09 +0100 Subject: [PATCH] dvipng 1.18 --- .../windows-x64/miktex-dvipng-bin-x64.tpm.in | 4 +- CHANGELOG.md | 1 + Programs/DviWare/dvipng/CMakeLists.txt | 152 +++++++++--------- Programs/DviWare/dvipng/component.cmake | 11 ++ Programs/DviWare/dvipng/config.h.cmake | 21 ++- Programs/DviWare/dvipng/dvipng-version.h | 26 --- Programs/DviWare/dvipng/dvipng.rc | 28 ---- .../DviWare/dvipng/miktex-dvipng-version.h.in | 22 +++ Programs/DviWare/dvipng/source/dvi.c | 8 +- Programs/DviWare/dvipng/source/dvipng.c | 2 +- Programs/DviWare/dvipng/source/dvipng.h | 10 +- Programs/DviWare/dvipng/source/ft.c | 2 +- Programs/DviWare/dvipng/source/misc.c | 4 +- Programs/DviWare/dvipng/source/set.c | 2 +- Programs/DviWare/dvipng/source/special.c | 138 ++++++++++------ Programs/DviWare/dvipng/version.cmake | 15 ++ .../dvipng/windows/miktex-dvipng.rc.in | 19 +++ 17 files changed, 257 insertions(+), 208 deletions(-) create mode 100644 Programs/DviWare/dvipng/component.cmake delete mode 100644 Programs/DviWare/dvipng/dvipng-version.h delete mode 100644 Programs/DviWare/dvipng/dvipng.rc create mode 100644 Programs/DviWare/dvipng/miktex-dvipng-version.h.in create mode 100644 Programs/DviWare/dvipng/version.cmake create mode 100644 Programs/DviWare/dvipng/windows/miktex-dvipng.rc.in diff --git a/Admin/TPM/windows-x64/miktex-dvipng-bin-x64.tpm.in b/Admin/TPM/windows-x64/miktex-dvipng-bin-x64.tpm.in index 9c6cfe64e0..cd2b0f632b 100644 --- a/Admin/TPM/windows-x64/miktex-dvipng-bin-x64.tpm.in +++ b/Admin/TPM/windows-x64/miktex-dvipng-bin-x64.tpm.in @@ -4,9 +4,9 @@ Dvipng win64 DVI-to-PNG Converter, Windows x64 - + - 1.17 + 1.18 windows-x64 @MIKTEX_DATETIME_STR@ diff --git a/CHANGELOG.md b/CHANGELOG.md index 12799c9614..21b144d698 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * chktex 1.7.9 * dvipdfmx 20250205 +* dvipng 1.18 * dvips 2024.1 * dvisvgm 3.4.3 * hitex 2.1 diff --git a/Programs/DviWare/dvipng/CMakeLists.txt b/Programs/DviWare/dvipng/CMakeLists.txt index 2eaf332019..f1da781320 100644 --- a/Programs/DviWare/dvipng/CMakeLists.txt +++ b/Programs/DviWare/dvipng/CMakeLists.txt @@ -1,21 +1,12 @@ -## CMakeLists.txt -*- CMake -*- +## CMakeLists.txt ## -## Copyright (C) 2006-2019 Christian Schenk +## Copyright (C) 2006-2025 Christian Schenk ## -## This file is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published -## by the Free Software Foundation; either version 2, or (at your -## option) any later version. -## -## This file is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this file; if not, write to the Free Software -## Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, -## USA. +## This file is free software; the copyright holder gives +## unlimited permission to copy and/or distribute it, with or +## without modifications, as long as this notice is preserved. + +include(component.cmake) set(MIKTEX_CURRENT_FOLDER "${MIKTEX_IDE_DVIWARE_FOLDER}/dvipng") @@ -44,72 +35,81 @@ set(PACKAGE_STRING "dvipng 1.16") set(PACKAGE_VERSION "1.16") configure_file( - config.h.cmake - ${CMAKE_CURRENT_BINARY_DIR}/config.h + miktex-dvipng-version.h.in + ${CMAKE_CURRENT_BINARY_DIR}/miktex-dvipng-version.h +) + +configure_file( + config.h.cmake + ${CMAKE_CURRENT_BINARY_DIR}/config.h ) include_directories(BEFORE - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} ) set(dvipng_c_sources - source/color.c - source/draw.c - source/dvi.c - source/dvipng.c - source/enc.c - source/font.c - source/fontmap.c - source/ft.c - source/misc.c - source/papersiz.c - source/pk.c - source/ppagelist.c - source/set.c - source/sfd.c - source/special.c - source/tfm.c - source/vf.c + source/color.c + source/draw.c + source/dvi.c + source/dvipng.c + source/enc.c + source/font.c + source/fontmap.c + source/ft.c + source/misc.c + source/papersiz.c + source/pk.c + source/ppagelist.c + source/set.c + source/sfd.c + source/special.c + source/tfm.c + source/vf.c ) set(dvipng_sources - ${CMAKE_CURRENT_BINARY_DIR}/config.h - ${MIKTEX_LIBRARY_WRAPPER} - ${dvipng_c_sources} - dvipng-version.h - source/commands.h - source/dvipng.h + ${CMAKE_CURRENT_BINARY_DIR}/config.h + ${CMAKE_CURRENT_BINARY_DIR}/miktex-dvipng-version.h + ${MIKTEX_LIBRARY_WRAPPER} + ${dvipng_c_sources} + source/commands.h + source/dvipng.h ) if(MIKTEX_NATIVE_WINDOWS) - add_definitions( - -D_UNICODE - -DUNICODE - ) + add_definitions( + -D_UNICODE + -DUNICODE + ) endif() if(MIKTEX_NATIVE_WINDOWS) - list(APPEND dvipng_sources - ${MIKTEX_COMMON_MANIFEST} - dvipng.rc - ) + configure_file( + windows/miktex-dvipng.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/miktex-dvipng.rc + ) + list(APPEND dvipng_sources + ${CMAKE_CURRENT_BINARY_DIR}/miktex-dvipng.rc + ${MIKTEX_COMMON_MANIFEST} + ) endif() if(DVIPNG_COMPILE_AS_CXX) - set_source_files_properties(${dvipng_c_sources} - PROPERTIES - LANGUAGE CXX - ) - set_source_files_properties(${MIKTEX_LIBRARY_WRAPPER} - PROPERTIES - COMPILE_FLAGS "-DCPLUSPLUSMAIN -DBEQUIET" - ) + set_source_files_properties(${dvipng_c_sources} + PROPERTIES + LANGUAGE CXX + ) + set_source_files_properties(${MIKTEX_LIBRARY_WRAPPER} + PROPERTIES + COMPILE_FLAGS "-DCPLUSPLUSMAIN -DBEQUIET" + ) else() - set_source_files_properties(${MIKTEX_LIBRARY_WRAPPER} - PROPERTIES - COMPILE_FLAGS "-DBEQUIET" - ) + set_source_files_properties(${MIKTEX_LIBRARY_WRAPPER} + PROPERTIES + COMPILE_FLAGS "-DBEQUIET" + ) endif() add_executable(${MIKTEX_PREFIX}dvipng ${dvipng_sources}) @@ -117,30 +117,30 @@ add_executable(${MIKTEX_PREFIX}dvipng ${dvipng_sources}) set_property(TARGET ${MIKTEX_PREFIX}dvipng PROPERTY FOLDER ${MIKTEX_CURRENT_FOLDER}) if(USE_SYSTEM_FREETYPE2) - target_link_libraries(${MIKTEX_PREFIX}dvipng MiKTeX::Imported::FREETYPE2) + target_link_libraries(${MIKTEX_PREFIX}dvipng MiKTeX::Imported::FREETYPE2) else() - target_link_libraries(${MIKTEX_PREFIX}dvipng ${freetype2_dll_name}) + target_link_libraries(${MIKTEX_PREFIX}dvipng ${freetype2_dll_name}) endif() if(USE_SYSTEM_GD) - target_link_libraries(${MIKTEX_PREFIX}dvipng MiKTeX::Imported::GD) + target_link_libraries(${MIKTEX_PREFIX}dvipng MiKTeX::Imported::GD) else() - target_link_libraries(${MIKTEX_PREFIX}dvipng ${gd_dll_name}) + target_link_libraries(${MIKTEX_PREFIX}dvipng ${gd_dll_name}) endif() target_link_libraries(${MIKTEX_PREFIX}dvipng - ${app_dll_name} - ${core_dll_name} - ${kpsemu_dll_name} - ${texmf_dll_name} + ${app_dll_name} + ${core_dll_name} + ${kpsemu_dll_name} + ${texmf_dll_name} ) if(MIKTEX_NATIVE_WINDOWS) - target_link_libraries(${MIKTEX_PREFIX}dvipng - ${getopt_dll_name} - ${unxemu_dll_name} - ${utf8wrap_dll_name} - ) + target_link_libraries(${MIKTEX_PREFIX}dvipng + ${getopt_dll_name} + ${unxemu_dll_name} + ${utf8wrap_dll_name} + ) endif() install(TARGETS ${MIKTEX_PREFIX}dvipng DESTINATION ${MIKTEX_BINARY_DESTINATION_DIR}) diff --git a/Programs/DviWare/dvipng/component.cmake b/Programs/DviWare/dvipng/component.cmake new file mode 100644 index 0000000000..a46ec603e5 --- /dev/null +++ b/Programs/DviWare/dvipng/component.cmake @@ -0,0 +1,11 @@ +## component.cmake +## +## Copyright (C) 2025 Christian Schenk +## +## This file is free software; the copyright holder gives +## unlimited permission to copy and/or distribute it, with or +## without modifications, as long as this notice is preserved. + +include(version.cmake) + +set(MIKTEX_COMP_DESCRIPTION "DVI-to-PNG Converter") diff --git a/Programs/DviWare/dvipng/config.h.cmake b/Programs/DviWare/dvipng/config.h.cmake index dc78a10213..947be94c62 100644 --- a/Programs/DviWare/dvipng/config.h.cmake +++ b/Programs/DviWare/dvipng/config.h.cmake @@ -87,9 +87,6 @@ /* Define to 1 if you have the `z' library (-lz). */ #cmakedefine HAVE_LIBZ 1 -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_MEMORY_H 1 - /* Define to 1 if you have the `memset' function. */ #cmakedefine HAVE_MEMSET 1 @@ -114,6 +111,9 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_STDINT_H 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDIO_H 1 + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_STDLIB_H 1 @@ -126,6 +126,9 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_STRING_H 1 +/* Define to 1 if you have the `strncasecmp' function. */ +#cmakedefine HAVE_STRNCASECMP 1 + /* Define to 1 if you have the `strrchr' function. */ #cmakedefine HAVE_STRRCHR 1 @@ -150,6 +153,9 @@ /* Define to 1 if you have that is POSIX.1 compatible. */ #cmakedefine HAVE_SYS_WAIT_H 1 +/* Define to 1 if you have the `texlive_gs_init' function. */ +#cmakedefine HAVE_TEXLIVE_GS_INIT 1 + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_UNISTD_H 1 @@ -189,12 +195,11 @@ /* Define to the version of this package. */ #cmakedefine PACKAGE_VERSION "${PACKAGE_VERSION}" -/* Define to 1 if you have the ANSI C header files. */ +/* Define to 1 if all of the C90 standard headers exist (not just the ones + required in a freestanding environment). This macro is provided for + backward compatibility; new code need not use it. */ #cmakedefine STDC_HEADERS 1 -/* Define to 1 if you can safely include both and . */ -#cmakedefine TIME_WITH_SYS_TIME 1 - /* Define as 1 to get execution time output. */ #cmakedefine TIMING 1 @@ -204,7 +209,7 @@ /* Define to `long long' if does not define it. */ #cmakedefine int64_t -/* Define to `int' if does not define. */ +/* Define as a signed integer type capable of holding a process identifier. */ #cmakedefine pid_t /* Define to `unsigned int' if does not define. */ diff --git a/Programs/DviWare/dvipng/dvipng-version.h b/Programs/DviWare/dvipng/dvipng-version.h deleted file mode 100644 index d3548bca95..0000000000 --- a/Programs/DviWare/dvipng/dvipng-version.h +++ /dev/null @@ -1,26 +0,0 @@ -/* dvipng-version.h: - - Copyright (C) 2004-2020 Christian Schenk - - This file is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 2, or (at your - option) any later version. - - This file is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this file; if not, write to the Free Software - Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ - -#define MIKTEX_COMP_J2000_VERSION 7330 - -#define MIKTEX_COMP_ORIG_VERSION_STR "1.17" - -#define MIKTEX_COMP_COPYRIGHT_STR "© 2002-2020 Jan-Ã…ke Larsson" - -#include diff --git a/Programs/DviWare/dvipng/dvipng.rc b/Programs/DviWare/dvipng/dvipng.rc deleted file mode 100644 index 93970724ce..0000000000 --- a/Programs/DviWare/dvipng/dvipng.rc +++ /dev/null @@ -1,28 +0,0 @@ -/* dvipng.rc: - - Copyright (C) 2004-2020 Christian Schenk - - This file is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 2, or (at your - option) any later version. - - This file is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this file; if not, write to the Free Software - Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ - -#pragma code_page(65001) - -#include "dvipng-version.h" - -#define VER_FILEDESCRIPTION_STR "DVI-to-PNG converter" -#define VER_INTERNALNAME_STR "dvipng" -#define VER_ORIGINALFILENAME_STR "miktex-dvipng.exe" - -#include "miktex/win/version.rc" diff --git a/Programs/DviWare/dvipng/miktex-dvipng-version.h.in b/Programs/DviWare/dvipng/miktex-dvipng-version.h.in new file mode 100644 index 0000000000..0fdac791d0 --- /dev/null +++ b/Programs/DviWare/dvipng/miktex-dvipng-version.h.in @@ -0,0 +1,22 @@ +/** + * @file miktex-dvipng-version.h + * @author Christian Schenk + * @brief Version number + * + * @copyright Copyright © 2025 Christian Schenk + * + * This file is free software; the copyright holder gives unlimited permission + * to copy and/or distribute it, with or without modifications, as long as this + * notice is preserved. + */ + +#define MIKTEX_COMP_MAJOR_VERSION @MIKTEX_COMP_MAJOR_VERSION@ +#define MIKTEX_COMP_MINOR_VERSION @MIKTEX_COMP_MINOR_VERSION@ +#define MIKTEX_COMP_PATCH_VERSION @MIKTEX_COMP_PATCH_VERSION@ + +#define MIKTEX_COMP_DESCRIPTION "@MIKTEX_COMP_DESCRIPTION@" + +#define MIKTEX_COMP_ORIG_VERSION_STR "@MIKTEX_COMP_ORIG_VERSION_STR@" +#define MIKTEX_COMP_COPYRIGHT_STR "@MIKTEX_COMP_COPYRIGHT_STR@" + +#include diff --git a/Programs/DviWare/dvipng/source/dvi.c b/Programs/DviWare/dvipng/source/dvi.c index f65e4517bc..3c18722293 100644 --- a/Programs/DviWare/dvipng/source/dvi.c +++ b/Programs/DviWare/dvipng/source/dvi.c @@ -18,7 +18,7 @@ License along with this program. If not, see . - Copyright (C) 2002-2015, 2019 Jan-Åke Larsson + Copyright (C) 2002-2015, 2019, 2025 Jan-Åke Larsson ************************************************************************/ @@ -87,15 +87,17 @@ static void DVIInit(struct dvi_data* dvi) dvi->den = UNumRead(pre+6, 4); DEBUG_PRINT(DEBUG_DVI,(" %d/%d",dvi->num,dvi->den)); dvi->mag = UNumRead(pre+10, 4); /*FIXME, see font.c*/ - DEBUG_PRINT(DEBUG_DVI,(" %d",dvi->mag)); + DEBUG_PRINT(DEBUG_DVI,(" %u",dvi->mag)); if ( usermag > 0 && usermag != dvi->mag ) { - Warning("DVI magnification of %d over-ridden by user (%ld)", + Warning("DVI magnification of %lu over-ridden by user (%lu)", (long)dvi->mag, usermag ); dvi->mag = usermag; } dvi->conv = (1.0/(((double)dvi->num / (double)dvi->den) * ((double)dvi->mag / 1000.0) * ((double)dpi*shrinkfactor/254000.0)))+0.5; + if ( dvi->conv==0 ) + Fatal("DVI magnification %u too large, override this by using the -x option",dvi->mag); DEBUG_PRINT(DEBUG_DVI,(" (%d)",dvi->conv)); k = UNumRead(pre+14,1); DEBUG_PRINT(DEBUG_DVI,(" '%.*s'",k,pre+15)); diff --git a/Programs/DviWare/dvipng/source/dvipng.c b/Programs/DviWare/dvipng/source/dvipng.c index 1681a1e86e..4db14a6f51 100644 --- a/Programs/DviWare/dvipng/source/dvipng.c +++ b/Programs/DviWare/dvipng/source/dvipng.c @@ -152,7 +152,7 @@ int main(int argc, char ** argv) ClearEncoding(); ClearSubfont(); if (libfreetype!=NULL && FT_Done_FreeType(libfreetype)) - Fatal("an error occured during freetype destruction"); + Fatal("an error occurred during freetype destruction"); libfreetype = NULL; #endif diff --git a/Programs/DviWare/dvipng/source/dvipng.h b/Programs/DviWare/dvipng/source/dvipng.h index aea86a13e3..709cd08866 100644 --- a/Programs/DviWare/dvipng/source/dvipng.h +++ b/Programs/DviWare/dvipng/source/dvipng.h @@ -437,16 +437,10 @@ EXTERN unsigned int debug INIT(0); /************************timing stuff*********************/ #ifdef TIMING -# ifdef TIME_WITH_SYS_TIME -# include -# include -# else # ifdef HAVE_SYS_TIME_H -# include -# else -# include +# include # endif -# endif +# include EXTERN double timer INIT(0); EXTERN double my_tic,my_toc INIT(0); EXTERN int ndone INIT(0); /* number of pages converted */ diff --git a/Programs/DviWare/dvipng/source/ft.c b/Programs/DviWare/dvipng/source/ft.c index 9609b10a10..91dc4f9c7a 100644 --- a/Programs/DviWare/dvipng/source/ft.c +++ b/Programs/DviWare/dvipng/source/ft.c @@ -88,7 +88,7 @@ bool InitFT(struct font_entry * tfontp) if (libfreetype==NULL) { if (FT_Init_FreeType( &libfreetype )) { - Warning("an error occured during freetype initialisation, disabling it"); + Warning("an error occurred during freetype initialisation, disabling it"); option_flags &= ~USE_FREETYPE; return(false); } diff --git a/Programs/DviWare/dvipng/source/misc.c b/Programs/DviWare/dvipng/source/misc.c index 6da79f3323..c776f78501 100644 --- a/Programs/DviWare/dvipng/source/misc.c +++ b/Programs/DviWare/dvipng/source/misc.c @@ -18,7 +18,7 @@ License along with this program. If not, see . - Copyright (C) 2002-2015, 2019 Jan-�ke Larsson + Copyright (C) 2002-2015, 2019 Jan-Ã…ke Larsson ************************************************************************/ @@ -500,7 +500,7 @@ bool DecodeArgs(int argc, char ** argv) puts(miktexBanner); } #else - puts(KPSEVERSION); + puts (KPSEVERSION); #endif #endif #ifdef HAVE_FT2 diff --git a/Programs/DviWare/dvipng/source/set.c b/Programs/DviWare/dvipng/source/set.c index 9f3ce99b05..5883db9140 100644 --- a/Programs/DviWare/dvipng/source/set.c +++ b/Programs/DviWare/dvipng/source/set.c @@ -150,7 +150,7 @@ void WriteImage(char *pngname, int pagenum) sprintf(freeme,pngname,pagenum); pngname = freeme; } else { - Fatal("unacceptible format spec in output file name"); + Fatal("unacceptable format spec in output file name"); } } #ifdef HAVE_GDIMAGEGIF diff --git a/Programs/DviWare/dvipng/source/special.c b/Programs/DviWare/dvipng/source/special.c index c326b4f295..2e138ec053 100644 --- a/Programs/DviWare/dvipng/source/special.c +++ b/Programs/DviWare/dvipng/source/special.c @@ -18,7 +18,7 @@ License along with this program. If not, see . - Copyright (C) 2002-2015 Jan-Åke Larsson + Copyright (C) 2002-2015, 2021, 2025 Jan-Åke Larsson ************************************************************************/ @@ -97,8 +97,6 @@ static void PSCodeInit(struct pscode *entry, char *special) #endif } - - void ClearPSHeaders(void) { struct pscode *temp=psheaderp; @@ -151,6 +149,32 @@ static void writepscode(FILE* psstream,struct pscode* pscodep) } } +static bool psisnotjustcomments(struct pscode* pscodep) +{ + while (pscodep!=NULL) { + if (pscodep->code!=NULL) { + const char* pos=pscodep->code; + while (*pos!='\0') { + while (*pos==' ' || *pos=='\t' || *pos=='\n' || *pos=='\r') pos++; /* skip whitespace */ + if (*pos=='%') { + while(*pos!='\0' && *pos!='\r' && *pos!='\n') pos++; /* skip comment */ + } else if (*pos=='/' && *(pos+1)=='*') { + pos+=2; + while(*pos!='\0' && *pos!='*' && *(pos+1)!='/') pos++; /* skip comment */ + } else if (*pos!='\0') + return(true); + } + } + if (pscodep->filename!=NULL) + return(true); + if (pscodep->fmmap.data!=NULL) + return(true); + if (pscodep->postcode!=NULL) + return(true); + pscodep=pscodep->next; + } + return(false); +} static gdImagePtr ps2png(struct pscode* pscodep, const char *device, int hresolution, int vresolution, @@ -450,7 +474,7 @@ void SetSpecial(char *start, char *end, int32_t hh, int32_t vv) char* psname = special+7; int llx=0,lly=0,urx=0,ury=0,rwi=0,rhi=0; bool clip=false; - int hresolution,vresolution; + int hresolution=0,vresolution=0; int pngheight,pngwidth; /* Remove quotation marks around filename. If no quotation marks, @@ -489,8 +513,8 @@ void SetSpecial(char *start, char *end, int32_t hh, int32_t vv) /* Calculate resolution, and use our base resolution as a fallback. */ /* The factor 10 is magic, the dvips graphicx driver needs this. */ - hresolution = ((dpi*rwi+urx-llx-1)/(urx - llx)+9)/10; - vresolution = ((dpi*rhi+ury-lly-1)/(ury - lly)+9)/10; + if (urx != llx) hresolution = ((dpi*rwi+urx-llx-1)/(urx - llx)+9)/10; + if (ury != lly) vresolution = ((dpi*rhi+ury-lly-1)/(ury - lly)+9)/10; if (vresolution==0) vresolution = hresolution; if (hresolution==0) hresolution = vresolution; if (hresolution==0) hresolution = vresolution = dpi; @@ -498,9 +522,9 @@ void SetSpecial(char *start, char *end, int32_t hh, int32_t vv) /* Convert from postscript 72 dpi resolution to our given resolution */ pngwidth = (dpi*rwi+719)/720; /* +719: round up */ pngheight = (dpi*rhi+719)/720; - if (pngwidth==0) + if (pngwidth==0 && ury != lly) pngwidth = ((dpi*rhi*(urx-llx)+ury-lly-1)/(ury-lly)+719)/720; - if (pngheight==0) + if (pngheight==0 && urx != llx) pngheight = ((dpi*rwi*(ury-lly)+urx-llx-1)/(urx-llx)+719)/720; if (pngheight==0) { pngwidth = (dpi*(urx-llx)+71)/72; @@ -515,6 +539,13 @@ void SetSpecial(char *start, char *end, int32_t hh, int32_t vv) PSCodeInit(&image, NULL); image.filename=kpse_find_file(psname,kpse_pict_format,0); + if (image.filename == NULL) { + Warning("Image file %s cannot be found, image will be left blank", + psname); + page_flags |= PAGE_GAVE_WARN; + free(buffer); + return; + } if (MmapFile(image.filename,&(image.fmmap)) || image.fmmap.size==0) { Warning("Image file %s unusable, image will be left blank", image.filename); @@ -739,6 +770,25 @@ void SetSpecial(char *start, char *end, int32_t hh, int32_t vv) return; } + if (strncmp(special,"papersize=",10)==0) { /* papersize spec, ignored */ + free(buffer); + return; + } + + if (special[0]=='!' || strncmp(special,"header=",7)==0) { /* PS header */ + newpsheader(special); + free(buffer); + return; + } + + if (strncmp(special,"src:",4)==0) { /* source special */ + if ( page_imagep != NULL ) + Message(BE_NONQUIET," at (%ld,%ld) source \\special{%s}", + hh, vv, special); + free(buffer); + return; + } + if (special[0]=='"' || strncmp(special,"ps:",3)==0) { /* Raw PostScript */ if (option_flags & NO_RAW_PS) { Warning("Raw PostScript rendering disallowed by --norawps" ); @@ -821,36 +871,38 @@ void SetSpecial(char *start, char *end, int32_t hh, int32_t vv) } PSCodeInit(tmp,special); /* Now, render image */ - if (option_flags & NO_GHOSTSCRIPT) - Warning("GhostScript calls disallowed by --nogs" ); - else { - /* Use alpha blending, and render transparent postscript - images. The alpha blending works correctly only from - libgd 2.0.12 upwards */ + if (psisnotjustcomments(pscodep)) { + if (option_flags & NO_GHOSTSCRIPT) + Warning("GhostScript calls disallowed by --nogs" ); + else { + /* Use alpha blending, and render transparent postscript + images. The alpha blending works correctly only from + libgd 2.0.12 upwards */ #ifdef HAVE_GDIMAGEPNGEX - if (page_imagep->trueColor) { - /* Render across the whole image */ - psimage = ps2png(pscodep, "-sDEVICE=pngalpha", - dpi,dpi, - -(hh+1)*72/dpi, - -(gdImageSY(page_imagep)-vv-1)*72/dpi, - (gdImageSX(page_imagep)-hh)*72/dpi, - (vv+1)*72/dpi, - 255,255,255); - if (psimage!=NULL) { - gdImageAlphaBlending(page_imagep,1); - gdImageCopy(page_imagep, psimage, - 0,0,0,0, - gdImageSX(psimage),gdImageSY(psimage)); - gdImageAlphaBlending(page_imagep,0); - gdImageDestroy(psimage); + if (page_imagep->trueColor) { + /* Render across the whole image */ + psimage = ps2png(pscodep, "-sDEVICE=pngalpha", + dpi,dpi, + -(hh+1)*72/dpi, + -(gdImageSY(page_imagep)-vv-1)*72/dpi, + (gdImageSX(page_imagep)-hh)*72/dpi, + (vv+1)*72/dpi, + 255,255,255); + if (psimage!=NULL) { + gdImageAlphaBlending(page_imagep,1); + gdImageCopy(page_imagep, psimage, + 0,0,0,0, + gdImageSX(psimage),gdImageSY(psimage)); + gdImageAlphaBlending(page_imagep,0); + gdImageDestroy(psimage); + } else + Warning("No image output from inclusion of raw PostScript"); } else - Warning("No image output from inclusion of raw PostScript"); - } else - Warning("Palette output, cannot include raw PostScript"); + Warning("Palette output, cannot include raw PostScript"); #else - Warning("Using libgd < 2.0.12, unable to include raw PostScript"); + Warning("Using libgd < 2.0.12, unable to include raw PostScript"); #endif + } } while(pscodep->next != NULL) { tmp=pscodep->next; @@ -872,24 +924,6 @@ void SetSpecial(char *start, char *end, int32_t hh, int32_t vv) return; } - if (strncmp(special,"papersize=",10)==0) { /* papersize spec, ignored */ - free(buffer); - return; - } - - if (special[0]=='!' || strncmp(special,"header=",7)==0) { /* PS header */ - newpsheader(special); - free(buffer); - return; - } - - if (strncmp(special,"src:",4)==0) { /* source special */ - if ( page_imagep != NULL ) - Message(BE_NONQUIET," at (%ld,%ld) source \\special{%s}", - hh, vv, special); - free(buffer); - return; - } if ( page_imagep != NULL ) { Warning("at (%ld,%ld) unimplemented \\special{%s}", hh, vv, special); diff --git a/Programs/DviWare/dvipng/version.cmake b/Programs/DviWare/dvipng/version.cmake new file mode 100644 index 0000000000..b2881b3380 --- /dev/null +++ b/Programs/DviWare/dvipng/version.cmake @@ -0,0 +1,15 @@ +## version.cmake +## +## Copyright (C) 2025 Christian Schenk +## +## This file is free software; the copyright holder gives +## unlimited permission to copy and/or distribute it, with or +## without modifications, as long as this notice is preserved. + +set(MIKTEX_COMP_MAJOR_VERSION 4) +set(MIKTEX_COMP_MINOR_VERSION 0) +set(MIKTEX_COMP_PATCH_VERSION 0) + +set(MIKTEX_COMP_ORIG_VERSION_STR "1.18") + +set(MIKTEX_COMP_COPYRIGHT_STR "© 2002-2025 Jan-Ã…ke Larsson") diff --git a/Programs/DviWare/dvipng/windows/miktex-dvipng.rc.in b/Programs/DviWare/dvipng/windows/miktex-dvipng.rc.in new file mode 100644 index 0000000000..2809e7ff33 --- /dev/null +++ b/Programs/DviWare/dvipng/windows/miktex-dvipng.rc.in @@ -0,0 +1,19 @@ +/** + * @file miktex-dvipng.rc + * @author Christian Schenk + * @brief Windows resources + * + * @copyright Copyright © 2004-2025 Christian Schenk + * + * This file is free software; the copyright holder gives unlimited permission + * to copy and/or distribute it, with or without modifications, as long as this + * notice is preserved. + */ + +#include "miktex-dvipng-version.h" + +#define VER_FILEDESCRIPTION_STR "@MIKTEX_COMP_DESCRIPTION@" +#define VER_INTERNALNAME_STR "dvipng" +#define VER_ORIGINALFILENAME_STR "miktex-dvipng.exe" + +#include "miktex/win/version.rc"