diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2018-09-14 03:34:50 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2018-09-14 03:34:50 +0000 |
commit | 00653d612add044de9f941c7b2c562bebe60d1e8 (patch) | |
tree | 46f2e9aa6440270f015d3e9d3d17f4d4ed709691 /Build/source | |
parent | fb833e57545c4b4d76e01406904fdfd83f057447 (diff) |
Cleanup. Remove duplicated code. Reorganize global variables. (S. Hirata)
git-svn-id: svn://tug.org/texlive/trunk@48663 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source')
72 files changed, 525 insertions, 1007 deletions
diff --git a/Build/source/texk/dvipdfm-x/ChangeLog b/Build/source/texk/dvipdfm-x/ChangeLog index 37bd482a5e4..509eec7ab2f 100644 --- a/Build/source/texk/dvipdfm-x/ChangeLog +++ b/Build/source/texk/dvipdfm-x/ChangeLog @@ -1,3 +1,17 @@ +2018-09-14 Shunsaku Hirata <shunsaku.hirata74@gmail.com> + + * agl.[ch], bmpimage.c, cid.[ch], cidtype0.[ch], cidtype2.[ch], + cmap.[ch], cmap_read.c, dpxconf.[ch], dpxfile.[ch], dvi.[ch], + dvipdfmx.[ch], epdf.c, fontmap.[ch], jp2image.c, jpegimage.c, + mpost.[ch], pdfcolor.[ch], pdfdev.[ch], pdfdoc.[ch], pdfdraw.c, + pdfencoding.[ch], pdfencrypt.[ch], pdffont.[ch], pdfobj.[ch], + pdfximage.[ch], pngimage.c, spc_pdfm.c, spc_util.[ch], + specials.[ch], subfont.[ch], t1_char.c, tfm.[ch], truetype.c, + tt_aux.[ch], tt_cmap.[ch], tt_gsub.[ch], type0.[ch], type1.c, + type1c.c, vf.[ch], xbb.c: Cleanup. Remove duplicated code. + Reorganize global variables. + * configure.ac: Version 20180914. + 2018-09-09 Karl Berry <karl@tug.org> * xdvipfm-bb.test: LC_ALL=LANGUAGE=C. diff --git a/Build/source/texk/dvipdfm-x/agl.c b/Build/source/texk/dvipdfm-x/agl.c index dc9f674fc48..ceaa2432322 100644 --- a/Build/source/texk/dvipdfm-x/agl.c +++ b/Build/source/texk/dvipdfm-x/agl.c @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2007-2016 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -40,10 +40,9 @@ #include "mfileio.h" #include "pdfparse.h" - +#include "dpxconf.h" /* Hash */ #include "dpxutil.h" - #include "dpxfile.h" #include "unicode.h" @@ -52,14 +51,6 @@ static int agl_load_listfile (const char *filename, int format); -static int verbose = 0; - -void -agl_set_verbose (void) -{ - verbose++; -} - static agl_name * agl_new_name (void) { @@ -408,7 +399,7 @@ agl_load_listfile (const char *filename, int is_predef) return -1; } - if (verbose) + if (dpx_conf.verbose_level > 0) MESG("<AGL:%s", filename); while ((p = mfgets(wbuf, WBUF_SIZE, fp)) != NULL) { @@ -478,7 +469,7 @@ agl_load_listfile (const char *filename, int is_predef) duplicate->alternate = agln; } - if (verbose > 3) { + if (dpx_conf.verbose_level > 5) { if (agln->suffix) MESG("agl: %s [%s.%s] -->", name, agln->name, agln->suffix); else @@ -498,7 +489,7 @@ agl_load_listfile (const char *filename, int is_predef) } DPXFCLOSE(fp); - if (verbose) + if (dpx_conf.verbose_level > 0) MESG(">"); return count; @@ -705,7 +696,7 @@ agl_sput_UTF16BE (const char *glyphstr, IS_PUA(agln1->unicodes[0]))) { agln0 = agl_normalized_name(name); if (agln0) { - if (verbose > 1 && agln0->suffix) { + if (dpx_conf.verbose_level > 1 && agln0->suffix) { WARN("agl: fix %s --> %s.%s", name, agln0->name, agln0->suffix); } @@ -718,7 +709,7 @@ agl_sput_UTF16BE (const char *glyphstr, len += UC_UTF16BE_encode_char(agln1->unicodes[i], dstpp, limptr); } } else { - if (verbose) { + if (dpx_conf.verbose_level > 0) { WARN("No Unicode mapping for glyph name \"%s\" found.", name); } count++; @@ -795,7 +786,7 @@ agl_get_unicodes (const char *glyphstr, IS_PUA(agln1->unicodes[0]))) { agln0 = agl_normalized_name(name); if (agln0) { - if (verbose > 1 && agln0->suffix) { + if (dpx_conf.verbose_level > 1 && agln0->suffix) { WARN("agl: fix %s --> %s.%s", name, agln0->name, agln0->suffix); } @@ -812,7 +803,7 @@ agl_get_unicodes (const char *glyphstr, unicodes[count++] = agln1->unicodes[i]; } } else { - if (verbose > 1) + if (dpx_conf.verbose_level > 1) WARN("No Unicode mapping for glyph name \"%s\" found.", name); RELEASE(name); return -1; diff --git a/Build/source/texk/dvipdfm-x/agl.h b/Build/source/texk/dvipdfm-x/agl.h index da94bd9d5a3..220a0aec9ae 100644 --- a/Build/source/texk/dvipdfm-x/agl.h +++ b/Build/source/texk/dvipdfm-x/agl.h @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2007-2016 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -58,7 +58,6 @@ extern agl_name *agl_lookup_list (const char *glyphname); extern int agl_select_listfile (const char *mapfile); #endif -extern void agl_set_verbose (void); extern void agl_init_map (void); extern void agl_close_map (void); diff --git a/Build/source/texk/dvipdfm-x/bmpimage.c b/Build/source/texk/dvipdfm-x/bmpimage.c index 2e6de52dc2d..143713631a7 100644 --- a/Build/source/texk/dvipdfm-x/bmpimage.c +++ b/Build/source/texk/dvipdfm-x/bmpimage.c @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002-2016 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2002-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -33,7 +33,8 @@ #include "error.h" #include "mem.h" -#include "dvipdfmx.h" /* only for "compat_mode" */ +#include "dpxconf.h" + #include "pdfobj.h" #include "bmpimage.h" @@ -87,7 +88,7 @@ check_for_bmp (FILE *fp) static void get_density (double *xdensity, double *ydensity, struct hdr_info *hdr) { - if (compat_mode) + if (dpx_conf.compat_mode == dpx_mode_compat_mode) *xdensity = *ydensity = 72.0 / 100.0; else if (hdr->x_pix_per_meter > 0 && hdr->y_pix_per_meter > 0) { /* 0 for undefined. FIXME */ *xdensity = 72.0 / (hdr->x_pix_per_meter * 0.0254); diff --git a/Build/source/texk/dvipdfm-x/cid.c b/Build/source/texk/dvipdfm-x/cid.c index 03b5557422e..517b21d22b6 100644 --- a/Build/source/texk/dvipdfm-x/cid.c +++ b/Build/source/texk/dvipdfm-x/cid.c @@ -33,6 +33,7 @@ #include "system.h" #include "mem.h" #include "error.h" +#include "dpxconf.h" #include "dpxutil.h" #include "pdfobj.h" @@ -115,16 +116,7 @@ static struct { static void release_opt (cid_opt *opt); static CIDSysInfo *get_cidsysinfo (const char *map_name, fontmap_opt *fmap_opt); -static int __verbose = 0; -static int cidoptflags = 0; - -void -CIDFont_set_verbose (void) -{ - CIDFont_type0_set_verbose(); - CIDFont_type2_set_verbose(); - __verbose++; -} +static int cidoptflags = 0; #if 0 int @@ -343,16 +335,16 @@ CIDFont_dofont (CIDFont *font) if (!font || !font->indirect) return; - if (__verbose) + if (dpx_conf.verbose_level > 0) MESG(":%s", font->ident); - if (__verbose > 1) { + if (dpx_conf.verbose_level > 1) { if (font->fontname) MESG("[%s]", font->fontname); } switch (font->subtype) { case CIDFONT_TYPE0: - if(__verbose) + if(dpx_conf.verbose_level > 0) MESG("[CIDFontType0]"); if (CIDFont_get_flag(font, CIDFONT_FLAG_TYPE1)) CIDFont_type0_t1dofont(font); @@ -362,7 +354,7 @@ CIDFont_dofont (CIDFont *font) CIDFont_type0_dofont(font); break; case CIDFONT_TYPE2: - if(__verbose) + if(dpx_conf.verbose_level > 0) MESG("[CIDFontType2]"); CIDFont_type2_dofont(font); break; @@ -670,7 +662,7 @@ CIDFont_cache_close (void) font = __cache->fonts[font_id]; - if (__verbose) + if (dpx_conf.verbose_level > 0) MESG("(CID"); CIDFont_dofont (font); @@ -679,7 +671,7 @@ CIDFont_cache_close (void) RELEASE(font); - if (__verbose) + if (dpx_conf.verbose_level > 0) MESG(")"); } RELEASE(__cache->fonts); diff --git a/Build/source/texk/dvipdfm-x/cid.h b/Build/source/texk/dvipdfm-x/cid.h index 47882b7e19f..77bed2011ab 100644 --- a/Build/source/texk/dvipdfm-x/cid.h +++ b/Build/source/texk/dvipdfm-x/cid.h @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002-2016 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2002-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. This program is free software; you can redistribute it and/or modify @@ -36,7 +36,6 @@ extern CIDSysInfo CSI_UNICODE; typedef struct CIDFont CIDFont; -extern void CIDFont_set_verbose (void); #if 0 extern int CIDFont_require_version (void); #endif diff --git a/Build/source/texk/dvipdfm-x/cidtype0.c b/Build/source/texk/dvipdfm-x/cidtype0.c index c6ddf2c17c1..648cb1757af 100644 --- a/Build/source/texk/dvipdfm-x/cidtype0.c +++ b/Build/source/texk/dvipdfm-x/cidtype0.c @@ -33,6 +33,7 @@ #include "numbers.h" #include "mem.h" #include "error.h" +#include "dpxconf.h" #include "dpxfile.h" @@ -70,16 +71,9 @@ #include "cmap_write.h" #include "fontmap.h" -static int verbose = 0; static int opt_flags = 0; void -CIDFont_type0_set_verbose (void) -{ - verbose++; -} - -void CIDFont_type0_set_flags (int flags) { opt_flags = flags; @@ -820,7 +814,7 @@ CIDFont_type0_dofont (CIDFont *font) CIDFontInfo_close(&info); - if (verbose > 1) + if (dpx_conf.verbose_level > 1) MESG("[%u/%u glyphs][%ld bytes]", num_glyphs, cs_count, destlen); CIDFont_type0_add_CIDSet(font, used_chars, last_cid); @@ -1264,7 +1258,7 @@ CIDFont_type0_t1cdofont (CIDFont *font) CIDFontInfo_close(&info); - if (verbose > 1) + if (dpx_conf.verbose_level > 1) MESG("[%u glyphs][%ld bytes]", num_glyphs, destlen); CIDFont_type0_add_CIDSet(font, used_chars, last_cid); diff --git a/Build/source/texk/dvipdfm-x/cidtype0.h b/Build/source/texk/dvipdfm-x/cidtype0.h index e9033eb4d6e..896496b6bf9 100644 --- a/Build/source/texk/dvipdfm-x/cidtype0.h +++ b/Build/source/texk/dvipdfm-x/cidtype0.h @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002-2016 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2002-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. This program is free software; you can redistribute it and/or modify @@ -25,7 +25,6 @@ #include "cid_p.h" #include "fontmap.h" -extern void CIDFont_type0_set_verbose (void); extern void CIDFont_type0_set_flags (int flags); extern int CIDFont_type0_open (CIDFont *font, const char *name, diff --git a/Build/source/texk/dvipdfm-x/cidtype2.c b/Build/source/texk/dvipdfm-x/cidtype2.c index 0c53848ddd7..90c360275a3 100644 --- a/Build/source/texk/dvipdfm-x/cidtype2.c +++ b/Build/source/texk/dvipdfm-x/cidtype2.c @@ -31,6 +31,7 @@ #include "numbers.h" #include "mem.h" #include "error.h" +#include "dpxconf.h" #include "dpxfile.h" #include "pdfobj.h" @@ -57,16 +58,9 @@ #include "cid_p.h" #include "cidtype2.h" -static int verbose = 0; static int opt_flags = 0; void -CIDFont_type2_set_verbose (void) -{ - verbose++; -} - -void CIDFont_type2_set_flags (int32_t flags) { opt_flags = flags; @@ -837,7 +831,7 @@ CIDFont_type2_dofont (CIDFont *font) if (CIDFont_get_embedding(font)) { if (tt_build_tables(sfont, glyphs) < 0) ERROR("Could not created FontFile stream."); - if (verbose > 1) + if (dpx_conf.verbose_level > 1) MESG("[%u glyphs (Max CID: %u)]", glyphs->num_glyphs, last_cid); } else { if (tt_get_metrics(sfont, glyphs) < 0) @@ -910,7 +904,7 @@ CIDFont_type2_dofont (CIDFont *font) if (!fontfile) ERROR("Could not created FontFile stream for \"%s\".", font->ident); - if (verbose > 1) { + if (dpx_conf.verbose_level > 1) { MESG("[%ld bytes]", pdf_stream_length(fontfile)); } diff --git a/Build/source/texk/dvipdfm-x/cidtype2.h b/Build/source/texk/dvipdfm-x/cidtype2.h index 86b076d107e..e9fa1176d93 100644 --- a/Build/source/texk/dvipdfm-x/cidtype2.h +++ b/Build/source/texk/dvipdfm-x/cidtype2.h @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002-2016 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2002-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. This program is free software; you can redistribute it and/or modify @@ -24,7 +24,6 @@ #include "cid.h" #include "cid_p.h" -extern void CIDFont_type2_set_verbose (void); extern void CIDFont_type2_set_flags (int flags); extern int CIDFont_type2_open (CIDFont *font, const char *name, diff --git a/Build/source/texk/dvipdfm-x/cmap.c b/Build/source/texk/dvipdfm-x/cmap.c index 5e53027af02..f235ee420fd 100644 --- a/Build/source/texk/dvipdfm-x/cmap.c +++ b/Build/source/texk/dvipdfm-x/cmap.c @@ -45,21 +45,15 @@ #include "system.h" #include "mem.h" #include "error.h" +#include "dpxconf.h" #include "dpxutil.h" #include "cmap_p.h" #include "cmap.h" -static int __verbose = 0; static int __silent = 0; void -CMap_set_verbose (void) -{ - __verbose++; -} - -void CMap_set_silent (int value) { __silent = value ? 1 : 0; @@ -932,7 +926,7 @@ CMap_cache_find (const char *cmap_name) return -1; } - if (__verbose) + if (dpx_conf.verbose_level > 0) MESG("(CMap:%s", cmap_name); if (__cache->num >= __cache->max) { @@ -948,7 +942,7 @@ CMap_cache_find (const char *cmap_name) DPXFCLOSE(fp); - if (__verbose) + if (dpx_conf.verbose_level > 0) MESG(")"); return id; diff --git a/Build/source/texk/dvipdfm-x/cmap.h b/Build/source/texk/dvipdfm-x/cmap.h index bbda82da3ee..c15c8cb0814 100644 --- a/Build/source/texk/dvipdfm-x/cmap.h +++ b/Build/source/texk/dvipdfm-x/cmap.h @@ -56,7 +56,6 @@ typedef struct CMap CMap; /************************** CMAP_MAIN **************************/ -extern void CMap_set_verbose (void); extern void CMap_set_silent (int value); extern CMap *CMap_new (void); diff --git a/Build/source/texk/dvipdfm-x/cmap_read.c b/Build/source/texk/dvipdfm-x/cmap_read.c index 94ad66bc37a..0eae0dab714 100644 --- a/Build/source/texk/dvipdfm-x/cmap_read.c +++ b/Build/source/texk/dvipdfm-x/cmap_read.c @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002-2016 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2002-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -30,6 +30,7 @@ #include "mem.h" #include "error.h" +#include "dpxconf.h" #include "dpxutil.h" #include "pst.h" @@ -38,8 +39,6 @@ #include "cmap_read.h" -static int __verbose = 0; - #define CMAP_PARSE_DEBUG_STR "CMap_parse:" #define CMAP_PARSE_DEBUG 3 @@ -97,8 +96,6 @@ ifreader_read (ifreader *reader, size_t size) ASSERT(reader); bytesrem = (size_t) reader->endptr - (size_t) reader->cursor; if (size > reader->max) { - if (__verbose) - MESG("\nExtending buffer (%ld bytes)...\n", size); reader->buf = RENEW(reader->buf, size+1, unsigned char); reader->max = size; } @@ -111,8 +108,6 @@ ifreader_read (ifreader *reader, size_t size) ERROR("Reading file failed."); reader->endptr += bytesread; reader->unread -= bytesread; - if (__verbose) - MESG("Reading more %ld bytes (%ld bytes remains in buffer)...\n", bytesread, bytesrem); } *reader->endptr = 0; diff --git a/Build/source/texk/dvipdfm-x/configure b/Build/source/texk/dvipdfm-x/configure index 14b08776497..22a7aaab08a 100755 --- a/Build/source/texk/dvipdfm-x/configure +++ b/Build/source/texk/dvipdfm-x/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for dvipdfm-x (TeX Live) 20180906. +# Generated by GNU Autoconf 2.69 for dvipdfm-x (TeX Live) 20180914. # # Report bugs to <tex-k@tug.org>. # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='dvipdfm-x (TeX Live)' PACKAGE_TARNAME='dvipdfm-x--tex-live-' -PACKAGE_VERSION='20180906' -PACKAGE_STRING='dvipdfm-x (TeX Live) 20180906' +PACKAGE_VERSION='20180914' +PACKAGE_STRING='dvipdfm-x (TeX Live) 20180914' PACKAGE_BUGREPORT='tex-k@tug.org' PACKAGE_URL='' @@ -1350,7 +1350,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures dvipdfm-x (TeX Live) 20180906 to adapt to many kinds of systems. +\`configure' configures dvipdfm-x (TeX Live) 20180914 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1421,7 +1421,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of dvipdfm-x (TeX Live) 20180906:";; + short | recursive ) echo "Configuration of dvipdfm-x (TeX Live) 20180914:";; esac cat <<\_ACEOF @@ -1551,7 +1551,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -dvipdfm-x (TeX Live) configure 20180906 +dvipdfm-x (TeX Live) configure 20180914 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2390,7 +2390,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by dvipdfm-x (TeX Live) $as_me 20180906, which was +It was created by dvipdfm-x (TeX Live) $as_me 20180914, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -8075,7 +8075,7 @@ fi # Define the identity of the package. PACKAGE='dvipdfm-x--tex-live-' - VERSION='20180906' + VERSION='20180914' cat >>confdefs.h <<_ACEOF @@ -14744,7 +14744,7 @@ Usage: $0 [OPTIONS] Report bugs to <bug-libtool@gnu.org>." lt_cl_version="\ -dvipdfm-x (TeX Live) config.lt 20180906 +dvipdfm-x (TeX Live) config.lt 20180914 configured by $0, generated by GNU Autoconf 2.69. Copyright (C) 2011 Free Software Foundation, Inc. @@ -16624,7 +16624,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by dvipdfm-x (TeX Live) $as_me 20180906, which was +This file was extended by dvipdfm-x (TeX Live) $as_me 20180914, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -16694,7 +16694,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -dvipdfm-x (TeX Live) config.status 20180906 +dvipdfm-x (TeX Live) config.status 20180914 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/Build/source/texk/dvipdfm-x/configure.ac b/Build/source/texk/dvipdfm-x/configure.ac index 329f75d782e..5ed24c5fb07 100644 --- a/Build/source/texk/dvipdfm-x/configure.ac +++ b/Build/source/texk/dvipdfm-x/configure.ac @@ -7,7 +7,7 @@ dnl This file is free software; the copyright holder dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl -AC_INIT([dvipdfm-x (TeX Live)], [20180906], [tex-k@tug.org]) +AC_INIT([dvipdfm-x (TeX Live)], [20180914], [tex-k@tug.org]) AC_PREREQ([2.65]) AC_CONFIG_SRCDIR([agl.c]) AC_CONFIG_AUX_DIR([../../build-aux]) diff --git a/Build/source/texk/dvipdfm-x/dpxconf.c b/Build/source/texk/dvipdfm-x/dpxconf.c index 20fc2de84ce..5b2f068d46a 100644 --- a/Build/source/texk/dvipdfm-x/dpxconf.c +++ b/Build/source/texk/dvipdfm-x/dpxconf.c @@ -1,6 +1,6 @@ /* This is DVIPDFMx, an eXtended version of DVIPDFM by Mark A. Wicks. - Copyright (C) 2002-2016 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2002-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -30,6 +30,8 @@ #include "dpxconf.h" +struct _dpx_conf dpx_conf = {0, dpx_mode_normal_mode, {0}}; + #ifndef HAVE_LIBPAPER const struct paper paperspecs[] = { {"letter", 612.00, 792.00}, diff --git a/Build/source/texk/dvipdfm-x/dpxconf.h b/Build/source/texk/dvipdfm-x/dpxconf.h index 702b44a3615..1b50fa0a575 100644 --- a/Build/source/texk/dvipdfm-x/dpxconf.h +++ b/Build/source/texk/dvipdfm-x/dpxconf.h @@ -1,6 +1,6 @@ /* This is DVIPDFMx, an eXtended version of DVIPDFM by Mark A. Wicks. - Copyright (C) 2002-2016 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2002-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -23,6 +23,21 @@ #ifndef _DPXCONF_H_ #define _DPXCONF_H_ +enum dpx_mode { + dpx_mode_normal_mode, + dpx_mode_compat_mode, + dpx_mode_xdv_mode, + dpx_mode_mpost_mode +}; + +extern struct _dpx_conf { + int verbose_level; + enum dpx_mode compat_mode; + struct { + int keep_cache; + } file; +} dpx_conf; + #ifdef HAVE_LIBPAPER #include <paper.h> #else diff --git a/Build/source/texk/dvipdfm-x/dpxfile.c b/Build/source/texk/dvipdfm-x/dpxfile.c index 3a3860412f9..856422cc1f5 100644 --- a/Build/source/texk/dvipdfm-x/dpxfile.c +++ b/Build/source/texk/dvipdfm-x/dpxfile.c @@ -36,6 +36,7 @@ #include "error.h" #include "mem.h" +#include "dpxconf.h" #include "dpxutil.h" #include "mfileio.h" @@ -70,16 +71,6 @@ #endif #endif /* MIKTEX || TESTCOMPILE */ -static int verbose = 0; -int keep_cache = 0; - -void -dpx_file_set_verbose (void) -{ - verbose++; -} - - /* Kpathsea library does not check file type. */ static int qcheck_filetype (const char *fqpn, dpx_res_type type); @@ -359,7 +350,7 @@ insistupdate (const char *filename, #else kpse_format_info_type *fif; kpse_format_info_type *fir; - if (verbose < 1) + if (dpx_conf.verbose_level < 1) return; fif = &kpse_format_info[foolformat]; fir = &kpse_format_info[realformat]; @@ -431,7 +422,7 @@ dpx_open_file (const char *filename, dpx_res_type type) switch (type) { case DPX_RES_TYPE_FONTMAP: fqpn = dpx_find_fontmap_file(filename); - if (verbose) { + if (dpx_conf.verbose_level > 0) { if (fqpn != NULL) MESG(fqpn); } @@ -969,7 +960,7 @@ dpx_delete_old_cache (int life) time_t limit; if (life == -2) { - keep_cache = -1; + dpx_conf.file.keep_cache = -1; return; } @@ -977,7 +968,7 @@ dpx_delete_old_cache (int life) pathname = NEW(strlen(dir)+1+strlen(PREFIX)+MAX_KEY_LEN*2 + 1, char); limit = time(NULL) - life * 60 * 60; - if (life >= 0) keep_cache = 1; + if (life >= 0) dpx_conf.file.keep_cache = 1; if ((dp = opendir(dir)) != NULL) { while((de = readdir(dp)) != NULL) { if (dpx_clear_cache_filter(de)) { @@ -1001,7 +992,7 @@ dpx_delete_temp_file (char *tmp, int force) { if (!tmp) return; - if (force || keep_cache != 1) remove (tmp); + if (force || dpx_conf.file.keep_cache != 1) remove (tmp); RELEASE(tmp); return; diff --git a/Build/source/texk/dvipdfm-x/dpxfile.h b/Build/source/texk/dvipdfm-x/dpxfile.h index 835e4182975..1ccea026007 100644 --- a/Build/source/texk/dvipdfm-x/dpxfile.h +++ b/Build/source/texk/dvipdfm-x/dpxfile.h @@ -56,8 +56,6 @@ extern char * dpx_find_dfont_file (const char *filename); #define DPXFOPEN(n,t) dpx_open_file((const char *)(n),(t)) #define DPXFCLOSE(f) MFCLOSE((f)) -extern void dpx_file_set_verbose (void); - extern int dpx_file_apply_filter (const char *cmdtmpl, const char *input, const char *output, int version); @@ -66,5 +64,4 @@ extern char *dpx_create_fix_temp_file (const char *filename); extern void dpx_delete_old_cache (int life); extern void dpx_delete_temp_file (char *tmp, int force); /* tmp freed here */ -extern int keep_cache; #endif /* _DPXFILE_H_ */ diff --git a/Build/source/texk/dvipdfm-x/dvi.c b/Build/source/texk/dvipdfm-x/dvi.c index 378582bdeec..25ba3ffd397 100644 --- a/Build/source/texk/dvipdfm-x/dvi.c +++ b/Build/source/texk/dvipdfm-x/dvi.c @@ -41,6 +41,7 @@ #include "error.h" #include "mfileio.h" #include "numbers.h" +#include "dpxconf.h" #include "pdfdev.h" #include "pdfdoc.h" @@ -195,7 +196,6 @@ static struct font_def static int num_def_fonts = 0, max_def_fonts = 0; static int compute_boxes = 0, link_annot = 1; -static int verbose = 0; #define DVI_PAGE_BUF_CHUNK 0x10000U /* 64K should be plenty for most pages */ @@ -292,16 +292,6 @@ static int32_t get_buffered_unsigned_num(unsigned char num) #define skip_bufferd_bytes(n) dvi_page_buf_index += n -void -dvi_set_verbose (void) -{ - verbose++; - subfont_set_verbose(); - tfm_set_verbose(); - vf_set_verbose (); - spc_set_verbose(); -} - unsigned int dvi_npages (void) { @@ -326,7 +316,7 @@ check_id_bytes (void) { static void need_XeTeX (int c) { - if (!is_xdv) + if (dpx_conf.compat_mode != dpx_mode_xdv_mode) ERROR ("DVI opcode %i only valid for XeTeX", c); } @@ -366,7 +356,8 @@ find_post (void) } post_id_byte = ch; - is_xdv = (ch == XDV_ID || ch == XDV_ID_OLD); + if (ch == XDV_ID || ch == XDV_ID_OLD) + dpx_conf.compat_mode = dpx_mode_xdv_mode; is_ptex = ch == DVIV_ID; /* Make sure post_post is really there */ @@ -411,7 +402,7 @@ get_page_info (int32_t post_location) if (num_pages == 0) { ERROR("Page count is 0!"); } - if (verbose > 2) { + if (dpx_conf.verbose_level > 2) { MESG("Page count:\t %4d\n", num_pages); } @@ -464,7 +455,7 @@ get_dvi_info (int32_t post_location) ERROR("Capacity exceeded."); } - if (verbose > 2) { + if (dpx_conf.verbose_level > 2) { MESG("DVI File Info\n"); MESG("Unit: %ld / %ld\n", dvi_info.unit_num, dvi_info.unit_den); MESG("Magnification: %ld\n", dvi_info.mag); @@ -493,7 +484,8 @@ get_preamble_dvi_info (void) } pre_id_byte = ch; - is_xdv = (ch == XDV_ID || ch == XDV_ID_OLD); + if (ch == XDV_ID || ch == XDV_ID_OLD) + dpx_conf.compat_mode = dpx_mode_xdv_mode; is_ptex = ch == DVI_ID; /* maybe */ dvi_info.unit_num = get_positive_quad(dvi_file, "DVI", "unit_num"); @@ -507,13 +499,13 @@ get_preamble_dvi_info (void) } dvi_info.comment[ch] = '\0'; - if (verbose > 2) { + if (dpx_conf.verbose_level > 2) { MESG("DVI File Info\n"); MESG("Unit: %ld / %ld\n", dvi_info.unit_num, dvi_info.unit_den); MESG("Magnification: %ld\n", dvi_info.mag); } - if (verbose) { + if (dpx_conf.verbose_level > 0) { MESG("DVI Comment: %s\n", dvi_info.comment); } @@ -651,7 +643,7 @@ get_dvi_fonts (int32_t post_location) ERROR(invalid_signature); } } - if (verbose > 2) { + if (dpx_conf.verbose_level > 2) { unsigned i; MESG("\n"); @@ -678,7 +670,7 @@ static void get_comment (void) ERROR(invalid_signature); } dvi_info.comment[length] = '\0'; - if (verbose) { + if (dpx_conf.verbose_level > 0) { MESG("DVI Comment: %s\n", dvi_info.comment); } } @@ -792,7 +784,7 @@ dvi_do_special (const void *buffer, int32_t size) mag = dvi_tell_mag(); if (spc_exec_special(p, size, x_user, y_user, mag) < 0) { - if (verbose) { + if (dpx_conf.verbose_level > 0) { dump(p, p + size); } } @@ -815,7 +807,7 @@ dvi_locate_font (const char *tfm_name, spt_t ptsize) int subfont_id = -1, font_id; /* VF or device font ID */ fontmap_rec *mrec; - if (verbose) + if (dpx_conf.verbose_level > 0) MESG("<%s@%.2fpt", tfm_name, ptsize * dvi2pts); need_more_fonts(1); @@ -861,7 +853,7 @@ dvi_locate_font (const char *tfm_name, spt_t ptsize) if (font_id >= 0) { loaded_fonts[cur_id].type = VIRTUAL; loaded_fonts[cur_id].font_id = font_id; - if (verbose) + if (dpx_conf.verbose_level > 0) MESG("(VF)>"); return cur_id; } @@ -891,7 +883,7 @@ dvi_locate_font (const char *tfm_name, spt_t ptsize) else { loaded_fonts[cur_id].type = VIRTUAL; loaded_fonts[cur_id].font_id = font_id; - if (verbose) + if (dpx_conf.verbose_level > 0) MESG("(OVF)>"); return cur_id; } @@ -940,7 +932,7 @@ dvi_locate_font (const char *tfm_name, spt_t ptsize) loaded_fonts[cur_id].type = PHYSICAL; loaded_fonts[cur_id].font_id = font_id; - if (verbose) + if (dpx_conf.verbose_level > 0) MESG(">"); return cur_id; @@ -966,7 +958,7 @@ dvi_locate_native_font (const char *filename, uint32_t index, struct tt_hhea_table *hhea; int is_dfont = 0, is_type1 = 0; - if (verbose) + if (dpx_conf.verbose_level > 0) MESG("<%s@%.2fpt", filename, ptsize * dvi2pts); if ((path = dpx_find_dfont_file(filename)) != NULL && @@ -1069,7 +1061,7 @@ dvi_locate_native_font (const char *filename, uint32_t index, loaded_fonts[cur_id].slant = mrec->opt.slant; loaded_fonts[cur_id].embolden = mrec->opt.bold; - if (verbose) + if (dpx_conf.verbose_level > 0) MESG(">"); return cur_id; @@ -1312,7 +1304,7 @@ dvi_rule (int32_t width, int32_t height) void dvi_dirchg (unsigned char dir) { - if (verbose) + if (dpx_conf.verbose_level > 0) fprintf(stderr, " > dvi_dirchg %d\n", dir); dvi_state.d = dir; pdf_dev_set_dirmode(dvi_state.d); /* 0: horizontal, 1,3: vertical */ diff --git a/Build/source/texk/dvipdfm-x/dvi.h b/Build/source/texk/dvipdfm-x/dvi.h index 77652ecd31e..efcaf69292e 100644 --- a/Build/source/texk/dvipdfm-x/dvi.h +++ b/Build/source/texk/dvipdfm-x/dvi.h @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002-2016 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2002-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -34,8 +34,6 @@ extern int landscape_mode; extern double get_origin (int x); -extern void dvi_set_verbose (void); - /* returns scale (dvi2pts) */ extern double dvi_init (char *dvi_filename, double mag); /* may append .dvi or .xdv to filename */ extern void dvi_close (void); /* Closes data structures created by dvi_open */ diff --git a/Build/source/texk/dvipdfm-x/dvipdfmx.c b/Build/source/texk/dvipdfm-x/dvipdfmx.c index 7bf7c9d3db1..5600d138b42 100644 --- a/Build/source/texk/dvipdfm-x/dvipdfmx.c +++ b/Build/source/texk/dvipdfm-x/dvipdfmx.c @@ -63,21 +63,14 @@ #include "error.h" -int is_xdv = 0; -int translate_origin = 0; - #if defined(LIBDPX) const char *my_name = "ApTeX"; #else const char *my_name; #endif /* LIBDPX */ -int compat_mode = 0; /* 0 = dvipdfmx, 1 = dvipdfm */ - static int verbose = 0; -static int mp_mode = 0; - static int opt_flags = 0; #define OPT_TPIC_TRANSPARENT_FILL (1 << 1) @@ -124,6 +117,8 @@ static char *psize_optarg = NULL; int always_embed = 0; /* always embed fonts, regardless of licensing flags */ +int translate_origin = 0; + char *dvi_filename = NULL, *pdf_filename = NULL; static void @@ -135,7 +130,7 @@ set_default_pdf_filename(void) const char *dvi_base; dvi_base = xbasename(dvi_filename); - if (mp_mode && + if (dpx_conf.compat_mode == dpx_mode_mpost_mode && strlen(dvi_base) > 4 && FILESTRCASEEQ(".mps", dvi_base + strlen(dvi_base) - 4)) { pdf_filename = NEW(strlen(dvi_base)+1, char); @@ -403,6 +398,59 @@ select_pages (const char *pagespec) return; } +/* Ask passwords for encryption */ +#ifdef WIN32 +/* Broken on mintty? */ +#include <conio.h> +#define getch _getch +static char * +getpass (const char *prompt) +{ + static char pwd_buf[128]; + size_t i; + + fputs(prompt, stderr); + fflush(stderr); + for (i = 0; i < sizeof(pwd_buf)-1; i++) { + pwd_buf[i] = getch(); + if (pwd_buf[i] == '\r' || pwd_buf[i] == '\n') + break; + fputs("*", stderr); + fflush(stderr); + } + pwd_buf[i] = '\0'; + fputs("\n", stderr); + return pwd_buf; +} +#else /* !WIN32 */ +#include <unistd.h> +#endif /* WIN32 */ + +static int +get_enc_password (char *uplain, char *oplain) +{ + char *retry_passwd; + + while (1) { + strncpy(uplain, getpass("Owner password: "), MAX_PWD_LEN); + retry_passwd = getpass("Re-enter owner password: "); + if (!strncmp(uplain, retry_passwd, MAX_PWD_LEN)) + break; + fputs("Password is not identical.\nTry again.\n", stderr); + fflush(stderr); + } + while (1) { + strncpy(oplain, getpass("User password: "), MAX_PWD_LEN); + retry_passwd = getpass("Re-enter user password: "); + if (!strncmp(oplain, retry_passwd, MAX_PWD_LEN)) + break; + fputs("Password is not identical.\nTry again.\n", stderr); + fflush(stderr); + } + + return 0; +} + static const char *optstrig = ":hD:r:m:g:x:y:o:s:p:clf:i:qtvV:z:d:I:K:P:O:MSC:Ee"; static struct option long_options[] = { @@ -459,14 +507,7 @@ do_early_args (int argc, char *argv[]) int i; for (i = 0; i < verbose; i++) { - dvi_set_verbose(); - pdf_dev_set_verbose(); - pdf_doc_set_verbose(); - pdf_enc_set_verbose(); - pdf_obj_set_verbose(); - pdf_fontmap_set_verbose(); - dpx_file_set_verbose(); - tt_aux_set_verbose(); + dpx_conf.verbose_level++; } } } @@ -495,7 +536,7 @@ do_args (int argc, char *argv[], const char *source, int unsafe) break; case 132: /* --dvipdfm */ - compat_mode = 1; + dpx_conf.compat_mode = dpx_mode_compat_mode; break; case 133: /* --kpathsea-debug */ @@ -645,7 +686,7 @@ do_args (int argc, char *argv[], const char *source, int unsafe) break; case 'M': - mp_mode = 1; + dpx_conf.compat_mode = dpx_mode_mpost_mode; break; case 'C': @@ -665,7 +706,7 @@ do_args (int argc, char *argv[], const char *source, int unsafe) break; case 'e': - if (compat_mode) { + if (dpx_conf.compat_mode == dpx_mode_compat_mode) { WARN("dvipdfm \"-e\" option not supported."); break; } /* else fall through */ @@ -806,8 +847,12 @@ error_cleanup (void) pdf_close_images(); /* delete temporary files */ pdf_error_cleanup(); if (pdf_filename) { - remove(pdf_filename); - fprintf(stderr, "\nOutput file removed.\n"); + if (pdf_get_output_file()) { + remove(pdf_filename); + fprintf(stderr, "\nOutput file removed.\n"); + } else { + fprintf(stderr, "\nNo output PDF file written.\n"); + } } } @@ -1021,11 +1066,11 @@ main (int argc, char *argv[]) } if (FILESTRCASEEQ (base, "ebb")) { my_name = "ebb"; - compat_mode = 1; + dpx_conf.compat_mode = dpx_mode_compat_mode; return extractbb (argc, argv); } if (FILESTRCASEEQ (base, "dvipdfm")) - compat_mode = 1; + dpx_conf.compat_mode = dpx_mode_compat_mode; if (FILESTRCASEEQ (base, "dvipdfmx")) my_name = "dvipdfmx"; else @@ -1073,13 +1118,15 @@ main (int argc, char *argv[]) pdf_enc_compute_id_string(dvi_filename, pdf_filename); if (do_encryption) { + char uplain[MAX_PWD_LEN], oplain[MAX_PWD_LEN]; if (key_bits > 40 && pdf_check_version(1, 4) < 0) ERROR("Chosen key length requires at least PDF 1.4. " "Use \"-V 4\" to change."); - pdf_enc_set_passwd(key_bits, permission, NULL, NULL); + get_enc_password(uplain, oplain); + pdf_enc_set_passwd(key_bits, permission, uplain, oplain); } - if (mp_mode) { + if (dpx_conf.compat_mode == dpx_mode_mpost_mode) { x_offset = 0.0; y_offset = 0.0; dvi2pts = 0.01; /* dvi2pts controls accuracy. */ @@ -1164,11 +1211,13 @@ main (int argc, char *argv[]) /* Please move this to spc_init_specials(). */ if (opt_flags & OPT_TPIC_TRANSPARENT_FILL) tpic_set_fill_mode(1); + if (translate_origin) + mps_set_translate_origin(1); if (opt_flags & OPT_PDFOBJ_NO_PREDICTOR) pdf_set_use_predictor(0); /* No prediction */ - if (mp_mode) { + if (dpx_conf.compat_mode == dpx_mode_mpost_mode) { do_mps_pages(); } else { do_dvi_pages(); @@ -1183,7 +1232,7 @@ main (int argc, char *argv[]) pdf_close_fontmaps(); /* pdf_font may depend on fontmap. */ - if (!mp_mode) + if (dpx_conf.compat_mode != dpx_mode_mpost_mode) dvi_close(); MESG("\n"); diff --git a/Build/source/texk/dvipdfm-x/dvipdfmx.h b/Build/source/texk/dvipdfm-x/dvipdfmx.h index c32800ae41d..f855e368870 100644 --- a/Build/source/texk/dvipdfm-x/dvipdfmx.h +++ b/Build/source/texk/dvipdfm-x/dvipdfmx.h @@ -1,6 +1,6 @@ /* DVIPDFMx, an eXtended version of DVIPDFM by Mark A. Wicks. - Copyright (C) 2002-2016 by Jin-Hwan Cho, Matthias Franz, and Shunsaku Hirata, + Copyright (C) 2002-2018 by Jin-Hwan Cho, Matthias Franz, and Shunsaku Hirata, the DVIPDFMx project team. Copyright (c) 2006 SIL. (xdvipdfmx extensions for XeTeX support) @@ -25,9 +25,6 @@ #ifndef _DVIPDFMX_H_ #define _DVIPDFMX_H_ -extern int compat_mode; -extern int is_xdv; -extern int translate_origin; extern const char *my_name; extern int extractbb(int argc, char *argv[]); diff --git a/Build/source/texk/dvipdfm-x/epdf.c b/Build/source/texk/dvipdfm-x/epdf.c index 0bc7d4593f4..c7ae614be8d 100644 --- a/Build/source/texk/dvipdfm-x/epdf.c +++ b/Build/source/texk/dvipdfm-x/epdf.c @@ -50,278 +50,8 @@ #include "epdf.h" -static int rect_equal (pdf_obj *rect1, pdf_obj *rect2); - -/* - * From PDFReference15_v6.pdf (p.119 and p.834) - * - * MediaBox rectangle (Required; inheritable) - * - * The media box defines the boundaries of the physical medium on which the - * page is to be printed. It may include any extended area surrounding the - * finished page for bleed, printing marks, or other such purposes. It may - * also include areas close to the edges of the medium that cannot be marked - * because of physical limitations of the output device. Content falling - * outside this boundary can safely be discarded without affecting the - * meaning of the PDF file. - * - * CropBox rectangle (Optional; inheritable) - * - * The crop box defines the region to which the contents of the page are to be - * clipped (cropped) when displayed or printed. Unlike the other boxes, the - * crop box has no defined meaning in terms of physical page geometry or - * intended use; it merely imposes clipping on the page contents. However, - * in the absence of additional information (such as imposition instructions - * specified in a JDF or PJTF job ticket), the crop box will determine how - * the page's contents are to be positioned on the output medium. The default - * value is the page's media box. - * - * BleedBox rectangle (Optional; PDF 1.3) - * - * The bleed box (PDF 1.3) defines the region to which the contents of the - * page should be clipped when output in a production environment. This may - * include any extra bleed area needed to accommodate the physical - * limitations of cutting, folding, and trimming equipment. The actual printed - * page may include printing marks that fall outside the bleed box. - * The default value is the page's crop box. - * - * TrimBox rectangle (Optional; PDF 1.3) - * - * The trim box (PDF 1.3) defines the intended dimensions of the finished page - * after trimming. It may be smaller than the media box, to allow for - * production-related content such as printing instructions, cut marks, or - * color bars. The default value is the page’s crop box. - * - * ArtBox rectangle (Optional; PDF 1.3) - * - * The art box (PDF 1.3) defines the extent of the page's meaningful content - * (including potential white space) as intended by the page's creator. - * The default value is the page's crop box. - * - * Rotate integer (Optional; inheritable) - * - * The number of degrees by which the page should be rotated clockwise when - * displayed or printed. The value must be a multiple of 90. Default value: 0. - */ - -static int -rect_equal (pdf_obj *rect1, pdf_obj *rect2) -{ - int i; - - if (!rect1 || !rect2) - return 0; - for (i = 0; i < 4; i++) { - if (pdf_number_value(pdf_get_array(rect1, i)) != - pdf_number_value(pdf_get_array(rect2, i))) - return 0; - } - - return 1; -} - -static pdf_obj* -pdf_get_page_obj (pdf_file *pf, int page_no, - pdf_obj **ret_bbox, pdf_obj **ret_resources) -{ - pdf_obj *page_tree; - pdf_obj *bbox = NULL, *resources = NULL, *rotate = NULL; - int page_idx; - - /* - * Get Page Tree. - */ - page_tree = NULL; - { - pdf_obj *trailer, *catalog; - pdf_obj *markinfo, *tmp; - - trailer = pdf_file_get_trailer(pf); - - if (pdf_lookup_dict(trailer, "Encrypt")) { - WARN("This PDF document is encrypted."); - pdf_release_obj(trailer); - return NULL; - } - - catalog = pdf_deref_obj(pdf_lookup_dict(trailer, "Root")); - if (!PDF_OBJ_DICTTYPE(catalog)) { - WARN("Can't read document catalog."); - pdf_release_obj(trailer); - if (catalog) - pdf_release_obj(catalog); - return NULL; - } - pdf_release_obj(trailer); - - markinfo = pdf_deref_obj(pdf_lookup_dict(catalog, "MarkInfo")); - if (markinfo) { - tmp = pdf_lookup_dict(markinfo, "Marked"); - if (PDF_OBJ_BOOLEANTYPE(tmp) && pdf_boolean_value(tmp)) - WARN("PDF file is tagged... Ignoring tags."); - pdf_release_obj(markinfo); - } - - page_tree = pdf_deref_obj(pdf_lookup_dict(catalog, "Pages")); - pdf_release_obj(catalog); - } - if (!page_tree) { - WARN("Page tree not found."); - return NULL; - } - - /* - * Negative page numbers are counted from the back. - */ - { - int count = pdf_number_value(pdf_lookup_dict(page_tree, "Count")); - page_idx = page_no + (page_no >= 0 ? -1 : count); - if (page_idx < 0 || page_idx >= count) { - WARN("Page %ld does not exist.", page_no); - pdf_release_obj(page_tree); - return NULL; - } - page_no = page_idx+1; - } - - /* - * Seek correct page. Get Media/Crop Box. - * Media box and resources can be inherited. - */ - { - pdf_obj *kids_ref, *kids; - pdf_obj *crop_box = NULL; - pdf_obj *tmp; - - tmp = pdf_lookup_dict(page_tree, "Resources"); - resources = tmp ? pdf_deref_obj(tmp) : pdf_new_dict(); - - while (1) { - int kids_length, i; - - if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "MediaBox")))) { - if (bbox) - pdf_release_obj(bbox); - bbox = tmp; - } - if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "BleedBox")))) { - if (!rect_equal(tmp, bbox)) { - if (bbox) - pdf_release_obj(bbox); - bbox = tmp; - } else { - pdf_release_obj(tmp); - } - } - if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "TrimBox")))) { - if (!rect_equal(tmp, bbox)) { - if (bbox) - pdf_release_obj(bbox); - bbox = tmp; - } else { - pdf_release_obj(tmp); - } - } - if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "ArtBox")))) { - if (!rect_equal(tmp, bbox)) { - if (bbox) - pdf_release_obj(bbox); - bbox = tmp; - } else { - pdf_release_obj(tmp); - } - } - if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "CropBox")))) { - if (crop_box) - pdf_release_obj(crop_box); - crop_box = tmp; - } - if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "Rotate")))) { - if (rotate) - pdf_release_obj(rotate); - rotate = tmp; - } - if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "Resources")))) { -#if 0 - pdf_merge_dict(tmp, resources); -#endif - if (resources) - pdf_release_obj(resources); - resources = tmp; - } - - kids_ref = pdf_lookup_dict(page_tree, "Kids"); - if (!kids_ref) - break; - kids = pdf_deref_obj(kids_ref); - kids_length = pdf_array_length(kids); - - for (i = 0; i < kids_length; i++) { - int count; - - pdf_release_obj(page_tree); - page_tree = pdf_deref_obj(pdf_get_array(kids, i)); - - tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "Count")); - if (tmp) { - /* Pages object */ - count = pdf_number_value(tmp); - pdf_release_obj(tmp); - } else { - /* Page object */ - count = 1; - } - if (page_idx < count) - break; - - page_idx -= count; - } - - pdf_release_obj(kids); - - if (i == kids_length) { - WARN("Page %ld not found! Broken PDF file?", page_no); - if (bbox) - pdf_release_obj(bbox); - if (crop_box) - pdf_release_obj(crop_box); - if (rotate) - pdf_release_obj(rotate); - pdf_release_obj(resources); - pdf_release_obj(page_tree); - return NULL; - } - } - if (crop_box) { - pdf_release_obj(bbox); - bbox = crop_box; - } - } - - if (!bbox) { - WARN("No BoundingBox information available."); - pdf_release_obj(page_tree); - pdf_release_obj(resources); - if (rotate) - pdf_release_obj(rotate); - return NULL; - } - - if (rotate) { - pdf_release_obj(rotate); - rotate = NULL; - } - - if (ret_bbox != NULL) - *ret_bbox = bbox; - if (ret_resources != NULL) - *ret_resources = resources; - - return page_tree; -} - static pdf_obj* -pdf_get_page_content (pdf_obj* page) +get_page_content (pdf_file *pf, pdf_obj* page) { pdf_obj *contents, *content_new; @@ -329,7 +59,7 @@ pdf_get_page_content (pdf_obj* page) if (!contents) return NULL; - if (pdf_obj_typeof(contents) == PDF_NULL) { + if (PDF_OBJ_NULLTYPE(contents)) { /* empty page */ pdf_release_obj(contents); /* TODO: better don't include anything if the page is empty */ @@ -339,29 +69,26 @@ pdf_get_page_content (pdf_obj* page) * Concatenate all content streams. */ pdf_obj *content_seg; - int idx = 0; + int i; content_new = pdf_new_stream(STREAM_COMPRESS); - for (;;) { - content_seg = pdf_deref_obj(pdf_get_array(contents, idx)); - if (!content_seg) - break; - else if (PDF_OBJ_NULLTYPE(content_seg)) { - /* Silently ignore. */ - } else if (!PDF_OBJ_STREAMTYPE(content_seg)) { - WARN("Page content not a stream object. Broken PDF file?"); - pdf_release_obj(content_seg); - pdf_release_obj(content_new); + for (i = 0; i < pdf_array_length(contents); i++) { + content_seg = pdf_deref_obj(pdf_get_array(contents, i)); + if (!content_seg) { + WARN("Could not read page content stream."); + pdf_release_obj(content_new); pdf_release_obj(contents); - return NULL; - } else if (pdf_concat_stream(content_new, content_seg) < 0) { - WARN("Could not handle content stream with multiple segments."); + return NULL; + } + if (PDF_OBJ_STREAMTYPE(content_seg)) { + pdf_concat_stream(content_new, content_seg); + } else if (!PDF_OBJ_NULLTYPE(content_seg)) { + WARN("Page content not a stream object. Broken PDF file?"); pdf_release_obj(content_seg); - pdf_release_obj(content_new); + pdf_release_obj(content_new); pdf_release_obj(contents); - return NULL; + return NULL; } pdf_release_obj(content_seg); - idx++; } pdf_release_obj(contents); contents = content_new; @@ -373,12 +100,7 @@ pdf_get_page_content (pdf_obj* page) } /* Flate the contents if necessary. */ content_new = pdf_new_stream(STREAM_COMPRESS); - if (pdf_concat_stream(content_new, contents) < 0) { - WARN("Could not handle a content stream."); - pdf_release_obj(contents); - pdf_release_obj(content_new); - return NULL; - } + pdf_concat_stream(content_new, contents); pdf_release_obj(contents); contents = content_new; } @@ -420,7 +142,7 @@ pdf_include_page (pdf_ximage *ximage, pdf_release_obj(markinfo); if (!PDF_OBJ_BOOLEANTYPE(tmp)) { if (tmp) - pdf_release_obj(tmp); + pdf_release_obj(tmp); goto error; } else if (pdf_boolean_value(tmp)) { WARN("PDF file is tagged... Ignoring tags."); @@ -428,52 +150,12 @@ pdf_include_page (pdf_ximage *ximage, pdf_release_obj(tmp); } - contents = pdf_deref_obj(pdf_lookup_dict(page, "Contents")); - pdf_release_obj(page); - page = NULL; - /* * Handle page content stream. */ - { - pdf_obj *content_new; - - if (!contents) { - /* - * Empty page - */ - content_new = pdf_new_stream(0); - /* TODO: better don't include anything if the page is empty */ - } else if (PDF_OBJ_STREAMTYPE(contents)) { - /* - * We must import the stream because its dictionary - * may contain indirect references. - */ - content_new = pdf_import_object(contents); - } else if (PDF_OBJ_ARRAYTYPE(contents)) { - /* - * Concatenate all content streams. - */ - int idx, len = pdf_array_length(contents); - content_new = pdf_new_stream(STREAM_COMPRESS); - for (idx = 0; idx < len; idx++) { - pdf_obj *content_seg = pdf_deref_obj(pdf_get_array(contents, idx)); - if (!PDF_OBJ_STREAMTYPE(content_seg) || - pdf_concat_stream(content_new, content_seg) < 0) { - pdf_release_obj(content_seg); - pdf_release_obj(content_new); - goto error; - } - pdf_release_obj(content_seg); - } - } else { - goto error; - } - - if (contents) - pdf_release_obj(contents); - contents = content_new; - } + contents = get_page_content(pf, page); + pdf_release_obj(page); + page = NULL; /* * Add entries to contents stream dictionary. @@ -604,13 +286,15 @@ static struct operator int pdf_copy_clip (FILE *image_file, int pageNo, double x_user, double y_user) { - pdf_obj *page_tree, *contents; - int depth = 0, top = -1; - const char *clip_path, *end_path; - char *save_path, *temp; - pdf_tmatrix M; - double stack[6]; - pdf_file *pf; + pdf_obj *page_tree, *contents; + int depth = 0, top = -1; + const char *clip_path, *end_path; + char *save_path, *temp; + pdf_tmatrix M; + double stack[6]; + pdf_rect bbox; + pdf_tmatrix mtrx; + pdf_file *pf; pf = pdf_open(NULL, image_file); if (!pf) @@ -619,13 +303,13 @@ pdf_copy_clip (FILE *image_file, int pageNo, double x_user, double y_user) pdf_dev_currentmatrix(&M); pdf_invertmatrix(&M); M.e += x_user; M.f += y_user; - page_tree = pdf_get_page_obj (pf, pageNo, NULL, NULL); + + page_tree = pdf_doc_get_page(pf, pageNo, 0, &bbox, &mtrx, NULL); if (!page_tree) { pdf_close(pf); return -1; } - - contents = pdf_get_page_content(page_tree); + contents = get_page_content(pf, page_tree); pdf_release_obj(page_tree); if (!contents) { pdf_close(pf); @@ -634,7 +318,7 @@ pdf_copy_clip (FILE *image_file, int pageNo, double x_user, double y_user) pdf_doc_add_page_content(" ", 1); - save_path = malloc(pdf_stream_length(contents) + 1); + save_path = NEW(pdf_stream_length(contents) + 1, char); strncpy(save_path, (const char *) pdf_stream_dataptr(contents), pdf_stream_length(contents)); clip_path = save_path; end_path = clip_path + pdf_stream_length(contents); @@ -839,7 +523,7 @@ pdf_copy_clip (FILE *image_file, int pageNo, double x_user, double y_user) } } } - free(save_path); + RELEASE(save_path); pdf_release_obj(contents); pdf_close(pf); diff --git a/Build/source/texk/dvipdfm-x/fontmap.c b/Build/source/texk/dvipdfm-x/fontmap.c index 06909a63ab7..92e6b7d8829 100644 --- a/Build/source/texk/dvipdfm-x/fontmap.c +++ b/Build/source/texk/dvipdfm-x/fontmap.c @@ -28,6 +28,7 @@ #include "mem.h" #include "error.h" +#include "dpxconf.h" #include "dpxfile.h" #include "dpxutil.h" @@ -38,14 +39,6 @@ /* CIDFont */ static char *strip_options (const char *map_name, fontmap_opt *opt); -static int verbose = 0; -void -pdf_fontmap_set_verbose (void) -{ - verbose++; -} - - void pdf_init_fontmap_record (fontmap_rec *mrec) { @@ -737,7 +730,7 @@ pdf_append_fontmap_record (const char *kp, const fontmap_rec *vp) return -1; } - if (verbose > 3) + if (dpx_conf.verbose_level > 3) MESG("fontmap>> append key=\"%s\"...", kp); fnt_name = chop_sfd_name(kp, &sfd_name); @@ -777,7 +770,7 @@ pdf_append_fontmap_record (const char *kp, const fontmap_rec *vp) } ht_insert_table(fontmap, kp, strlen(kp), mrec); } - if (verbose > 3) + if (dpx_conf.verbose_level > 3) MESG("\n"); return 0; @@ -791,7 +784,7 @@ pdf_remove_fontmap_record (const char *kp) if (!kp) return -1; - if (verbose > 3) + if (dpx_conf.verbose_level > 3) MESG("fontmap>> remove key=\"%s\"...", kp); fnt_name = chop_sfd_name(kp, &sfd_name); @@ -802,13 +795,13 @@ pdf_remove_fontmap_record (const char *kp) subfont_ids = sfd_get_subfont_ids(sfd_name, &n); if (!subfont_ids) return -1; - if (verbose > 3) + if (dpx_conf.verbose_level > 3) MESG("\nfontmap>> Expand @%s@:", sfd_name); while (n-- > 0) { tfm_name = make_subfont_name(kp, sfd_name, subfont_ids[n]); if (!tfm_name) continue; - if (verbose > 3) + if (dpx_conf.verbose_level > 3) MESG(" %s", tfm_name); ht_remove_table(fontmap, tfm_name, strlen(tfm_name)); RELEASE(tfm_name); @@ -819,7 +812,7 @@ pdf_remove_fontmap_record (const char *kp) ht_remove_table(fontmap, kp, strlen(kp)); - if (verbose > 3) + if (dpx_conf.verbose_level > 3) MESG("\n"); return 0; @@ -836,7 +829,7 @@ pdf_insert_fontmap_record (const char *kp, const fontmap_rec *vp) return NULL; } - if (verbose > 3) + if (dpx_conf.verbose_level > 3) MESG("fontmap>> insert key=\"%s\"...", kp); fnt_name = chop_sfd_name(kp, &sfd_name); @@ -851,13 +844,13 @@ pdf_insert_fontmap_record (const char *kp, const fontmap_rec *vp) WARN("Could not open SFD file: %s", sfd_name); return NULL; } - if (verbose > 3) + if (dpx_conf.verbose_level > 3) MESG("\nfontmap>> Expand @%s@:", sfd_name); while (n-- > 0) { tfm_name = make_subfont_name(kp, sfd_name, subfont_ids[n]); if (!tfm_name) continue; - if (verbose > 3) + if (dpx_conf.verbose_level > 3) MESG(" %s", tfm_name); mrec = NEW(1, fontmap_rec); pdf_init_fontmap_record(mrec); @@ -879,7 +872,7 @@ pdf_insert_fontmap_record (const char *kp, const fontmap_rec *vp) } ht_insert_table(fontmap, kp, strlen(kp), mrec); - if (verbose > 3) + if (dpx_conf.verbose_level > 3) MESG("\n"); return mrec; @@ -980,7 +973,7 @@ pdf_load_fontmap_file (const char *filename, int mode) ASSERT(filename); ASSERT(fontmap) ; - if (verbose) + if (dpx_conf.verbose_level > 0) MESG("<FONTMAP:"); fp = DPXFOPEN(filename, DPX_RES_TYPE_FONTMAP); /* outputs path if verbose */ if (!fp) { @@ -1038,7 +1031,7 @@ pdf_load_fontmap_file (const char *filename, int mode) } DPXFCLOSE(fp); - if (verbose) + if (dpx_conf.verbose_level > 0) MESG(">"); return error; @@ -1057,7 +1050,7 @@ pdf_insert_native_fontmap_record (const char *path, uint32_t index, fontmap_key = malloc(strlen(path) + 40); // CHECK sprintf(fontmap_key, "%s/%d/%c/%d/%d/%d", path, index, layout_dir == 0 ? 'H' : 'V', extend, slant, embolden); - if (verbose) + if (dpx_conf.verbose_level > 0) MESG("<NATIVE-FONTMAP:%s", fontmap_key); mrec = NEW(1, fontmap_rec); @@ -1081,7 +1074,7 @@ pdf_insert_native_fontmap_record (const char *path, uint32_t index, pdf_clear_fontmap_record(mrec); RELEASE(mrec); - if (verbose) + if (dpx_conf.verbose_level > 0) MESG(">"); return ret; diff --git a/Build/source/texk/dvipdfm-x/fontmap.h b/Build/source/texk/dvipdfm-x/fontmap.h index 568f2e6e38c..a144aa418c6 100644 --- a/Build/source/texk/dvipdfm-x/fontmap.h +++ b/Build/source/texk/dvipdfm-x/fontmap.h @@ -71,8 +71,6 @@ typedef struct fontmap_rec { fontmap_opt opt; } fontmap_rec; -extern void pdf_fontmap_set_verbose (void); - extern void pdf_init_fontmaps (void); #if 0 extern void pdf_clear_fontmaps (void); diff --git a/Build/source/texk/dvipdfm-x/jp2image.c b/Build/source/texk/dvipdfm-x/jp2image.c index 40435ba607f..4c798129e75 100644 --- a/Build/source/texk/dvipdfm-x/jp2image.c +++ b/Build/source/texk/dvipdfm-x/jp2image.c @@ -36,7 +36,7 @@ #include "error.h" #include "mem.h" -#include "dvipdfmx.h" +#include "dpxconf.h" #include "pdfobj.h" @@ -146,7 +146,7 @@ read_res__data (ximage_info *info, FILE *fp, unsigned int size) HR_D = get_unsigned_pair(fp); VR_E = get_unsigned_byte(fp); HR_E = get_unsigned_byte(fp); - if (compat_mode) + if (dpx_conf.compat_mode == dpx_mode_compat_mode) info->xdensity = info->ydensity = 72.0 / 100.0; else { info->xdensity = 72.0/(((double) HR_N / HR_D) * pow(10.0, HR_E) * 0.0254); diff --git a/Build/source/texk/dvipdfm-x/jpegimage.c b/Build/source/texk/dvipdfm-x/jpegimage.c index 18130a50809..98f20c1d7f5 100644 --- a/Build/source/texk/dvipdfm-x/jpegimage.c +++ b/Build/source/texk/dvipdfm-x/jpegimage.c @@ -59,7 +59,7 @@ #include "mfileio.h" #include "numbers.h" -#include "dvipdfmx.h" +#include "dpxconf.h" #include "pdfobj.h" @@ -363,7 +363,7 @@ jpeg_include_image (pdf_ximage *ximage, FILE *fp) static void jpeg_get_density (struct JPEG_info *j_info, double *xdensity, double *ydensity) { - if (compat_mode) { + if (dpx_conf.compat_mode == dpx_mode_compat_mode) { *xdensity = *ydensity = 72.0 / 100.0; return; } diff --git a/Build/source/texk/dvipdfm-x/mpost.c b/Build/source/texk/dvipdfm-x/mpost.c index 33b12f6f9af..b38c44b9fcf 100644 --- a/Build/source/texk/dvipdfm-x/mpost.c +++ b/Build/source/texk/dvipdfm-x/mpost.c @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2007-2016 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -33,6 +33,7 @@ #include "error.h" #include "mfileio.h" #include "numbers.h" +#include "dpxconf.h" #include "tfm.h" @@ -58,6 +59,12 @@ */ static double Xorigin, Yorigin; +static int translate_origin = 0; + +void +mps_set_translate_origin (int v) { + translate_origin = v; +} /* * In PDF, current path is not a part of graphics state parameter. diff --git a/Build/source/texk/dvipdfm-x/mpost.h b/Build/source/texk/dvipdfm-x/mpost.h index 10ad0132f96..711c9fe8c3e 100644 --- a/Build/source/texk/dvipdfm-x/mpost.h +++ b/Build/source/texk/dvipdfm-x/mpost.h @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002-2016 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2002-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -27,6 +27,8 @@ #include "pdfximage.h" #include "pdfdev.h" +extern void mps_set_translate_origin (int boolean_value); + extern int mps_scan_bbox (const char **pp, const char *endptr, pdf_rect *bbox); /* returns xobj_id */ diff --git a/Build/source/texk/dvipdfm-x/pdfcolor.c b/Build/source/texk/dvipdfm-x/pdfcolor.c index b5c67f3999a..139cabe16dd 100644 --- a/Build/source/texk/dvipdfm-x/pdfcolor.c +++ b/Build/source/texk/dvipdfm-x/pdfcolor.c @@ -31,6 +31,7 @@ #include "mem.h" #include "error.h" +#include "dpxconf.h" #include "dpxfile.h" #include "pdfdoc.h" @@ -38,13 +39,6 @@ #include "pdfcolor.h" -static int verbose = 0; -void -pdf_color_set_verbose (void) -{ - verbose++; -} - /* This function returns PDF_COLORSPACE_TYPE_GRAY, * PDF_COLORSPACE_TYPE_RGB, PDF_COLORSPACE_TYPE_CMYK or * PDF_COLORSPACE_TYPE_SPOT. @@ -1182,12 +1176,12 @@ iccp_load_profile (const char *ident, cspc_id = pdf_colorspace_findresource(ident, PDF_COLORSPACE_TYPE_ICCBASED, cdata); if (cspc_id >= 0) { - if (verbose) + if (dpx_conf.verbose_level > 0) MESG("(ICCP:[id=%d])", cspc_id); release_iccbased_cdata(cdata); return cspc_id; } - if (verbose > 1) { + if (dpx_conf.verbose_level > 1) { print_iccp_header(&icch, checksum); } @@ -1354,13 +1348,13 @@ pdf_colorspace_load_ICCBased (const char *ident, const char *filename) cspc_id = pdf_colorspace_findresource(ident, PDF_COLORSPACE_TYPE_ICCBASED, cdata); if (cspc_id >= 0) { - if (verbose) + if (dpx_conf.verbose_level > 0) MESG("(ICCP:[id=%d])", cspc_id); release_iccbased_cdata(cdata); pdf_release_obj(stream); return cspc_id; } - if (verbose > 1) { + if (dpx_conf.verbose_level > 1) { print_iccp_header(&icch, checksum); } @@ -1506,9 +1500,9 @@ pdf_colorspace_defineresource (const char *ident, colorspace->cdata = cdata; colorspace->resource = resource; - if (verbose) { + if (dpx_conf.verbose_level > 0) { MESG("(ColorSpace:%s", ident); - if (verbose > 1) { + if (dpx_conf.verbose_level > 1) { switch (subtype) { case PDF_COLORSPACE_TYPE_ICCBASED: MESG("[ICCBased]"); diff --git a/Build/source/texk/dvipdfm-x/pdfcolor.h b/Build/source/texk/dvipdfm-x/pdfcolor.h index abcd581c1a6..904a069f24a 100644 --- a/Build/source/texk/dvipdfm-x/pdfcolor.h +++ b/Build/source/texk/dvipdfm-x/pdfcolor.h @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002-2016 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2002-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -49,8 +49,6 @@ typedef struct double values[PDF_COLOR_COMPONENT_MAX]; } pdf_color; -extern void pdf_color_set_verbose (void); - extern int pdf_color_rgbcolor (pdf_color *color, double r, double g, double b); extern int pdf_color_cmykcolor (pdf_color *color, diff --git a/Build/source/texk/dvipdfm-x/pdfdev.c b/Build/source/texk/dvipdfm-x/pdfdev.c index 488d0bf47dd..8186e91896d 100644 --- a/Build/source/texk/dvipdfm-x/pdfdev.c +++ b/Build/source/texk/dvipdfm-x/pdfdev.c @@ -31,6 +31,7 @@ #include "system.h" #include "mem.h" #include "error.h" +#include "dpxconf.h" #include "mfileio.h" #include "numbers.h" @@ -52,14 +53,6 @@ #include "pdfdev.h" -static int verbose = 0; - -void -pdf_dev_set_verbose (void) -{ - verbose++; -} - /* Not working yet... */ double pdf_dev_scale (void) @@ -1469,7 +1462,7 @@ pdf_dev_locate_font (const char *font_name, spt_t ptsize) /* New font */ mrec = pdf_lookup_fontmap_record(font_name); - if (verbose > 1) + if (dpx_conf.verbose_level > 1) print_fontmap(font_name, mrec); font->font_id = pdf_font_findresource(font_name, ptsize * dev_unit.dvi2pts, mrec); diff --git a/Build/source/texk/dvipdfm-x/pdfdev.h b/Build/source/texk/dvipdfm-x/pdfdev.h index d1cca7b118d..5bd3db83f59 100644 --- a/Build/source/texk/dvipdfm-x/pdfdev.h +++ b/Build/source/texk/dvipdfm-x/pdfdev.h @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002-2016 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2002-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -71,9 +71,6 @@ typedef struct #define INFO_DO_HIDE (1 << 4) extern void transform_info_clear (transform_info *info); - -extern void pdf_dev_set_verbose (void); - /* Not in spt_t. */ extern int pdf_sprint_matrix (char *buf, const pdf_tmatrix *p); extern int pdf_sprint_rect (char *buf, const pdf_rect *p); diff --git a/Build/source/texk/dvipdfm-x/pdfdoc.c b/Build/source/texk/dvipdfm-x/pdfdoc.c index a46d1fcc95e..5826a006ee7 100644 --- a/Build/source/texk/dvipdfm-x/pdfdoc.c +++ b/Build/source/texk/dvipdfm-x/pdfdoc.c @@ -35,6 +35,7 @@ #include "mem.h" #include "error.h" #include "mfileio.h" +#include "dpxconf.h" #include "numbers.h" @@ -67,8 +68,6 @@ #define PDFDOC_ARTICLE_ALLOC_SIZE 16 #define PDFDOC_BEAD_ALLOC_SIZE 16 -static int verbose = 0; - static char manual_thumb_enabled = 0; static char *thumb_basename = NULL; @@ -113,14 +112,6 @@ read_thumbnail (const char *thumb_filename) return image_ref; } -void -pdf_doc_set_verbose (void) -{ - verbose++; - pdf_font_set_verbose(); - pdf_color_set_verbose(); - pdf_ximage_set_verbose(); -} typedef struct pdf_form { @@ -922,7 +913,7 @@ pdf_doc_get_page_count (pdf_file *pf) } static int -set_bounding_box (pdf_rect *bbox, int option, +set_bounding_box (pdf_rect *bbox, enum pdf_page_boundary opt_bbox, pdf_obj *media_box, pdf_obj *crop_box, pdf_obj *art_box, pdf_obj *trim_box, pdf_obj *bleed_box) { @@ -942,7 +933,7 @@ set_bounding_box (pdf_rect *bbox, int option, VALIDATE_BOX(trim_box); VALIDATE_BOX(bleed_box); - if (option == 0) { + if (opt_bbox == pdf_page_boundary__auto) { if (crop_box) box = pdf_link_obj(crop_box); else if (art_box) @@ -968,20 +959,20 @@ set_bounding_box (pdf_rect *bbox, int option, bleed_box = pdf_link_obj(crop_box); } /* At this point all boxes must be defined. */ - switch (option) { - case 1: /* crop box */ + switch (opt_bbox) { + case pdf_page_boundary_cropbox: box = pdf_link_obj(crop_box); break; - case 2: /* mdeia box */ + case pdf_page_boundary_mediabox: box = pdf_link_obj(media_box); break; - case 3: /* art box */ + case pdf_page_boundary_artbox: box = pdf_link_obj(art_box); break; - case 4: /* trim box */ + case pdf_page_boundary_trimbox: box = pdf_link_obj(trim_box); break; - case 5: /* bleen box */ + case pdf_page_boundary_bleedbox: box = pdf_link_obj(bleed_box); break; default: @@ -1016,7 +1007,8 @@ set_bounding_box (pdf_rect *bbox, int option, } /* New scheme only for XDV files */ - if (is_xdv || option) { + if (dpx_conf.compat_mode == dpx_mode_xdv_mode || + opt_bbox != pdf_page_boundary__auto) { for (i = 4; i--; ) { double x; pdf_obj *tmp = pdf_deref_obj(pdf_get_array(media_box, i)); @@ -1155,7 +1147,7 @@ set_transform_matrix (pdf_tmatrix *matrix, pdf_rect *bbox, pdf_obj *rotate) */ pdf_obj * pdf_doc_get_page (pdf_file *pf, - int page_no, int options, /* load options */ + int page_no, enum pdf_page_boundary opt_bbox, /* load options */ pdf_rect *bbox, pdf_tmatrix *matrix, /* returned value */ pdf_obj **resources_p /* returned values */ ) { @@ -1279,7 +1271,7 @@ pdf_doc_get_page (pdf_file *pf, *resources_p = pdf_link_obj(resources); /* Select page boundary box */ - error = set_bounding_box(bbox, options, media_box, crop_box, art_box, trim_box, bleed_box); + error = set_bounding_box(bbox, opt_bbox, media_box, crop_box, art_box, trim_box, bleed_box); if (error) goto error_exit; /* Set transformation matrix */ @@ -1801,7 +1793,7 @@ pdf_doc_close_names (pdf_doc *p) else { name_tree = pdf_names_create_tree(data, &count, &pdoc.gotos); - if (verbose && count < data->count) + if (dpx_conf.verbose_level > 0 && count < data->count) MESG("\nRemoved %ld unused PDF destinations\n", data->count-count); if (count < pdoc.gotos.count) diff --git a/Build/source/texk/dvipdfm-x/pdfdoc.h b/Build/source/texk/dvipdfm-x/pdfdoc.h index 2d5923eedf2..e3d81f46db4 100644 --- a/Build/source/texk/dvipdfm-x/pdfdoc.h +++ b/Build/source/texk/dvipdfm-x/pdfdoc.h @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2007-2017 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -26,9 +26,16 @@ #include "pdfobj.h" #include "pdfdev.h" -#define PDF_DOC_GRABBING_NEST_MAX 4 +enum pdf_page_boundary { + pdf_page_boundary__auto = 0, + pdf_page_boundary_mediabox, + pdf_page_boundary_cropbox, + pdf_page_boundary_artbox, + pdf_page_boundary_trimbox, + pdf_page_boundary_bleedbox +}; -extern void pdf_doc_set_verbose (void); +#define PDF_DOC_GRABBING_NEST_MAX 4 extern void pdf_open_document (const char *filename, int enable_encrypt, @@ -57,7 +64,7 @@ extern pdf_obj *pdf_doc_get_reference (const char *category); #define pdf_doc_this_page() pdf_doc_get_dictionary("@THISPAGE") extern int pdf_doc_get_page_count (pdf_file *pf); -extern pdf_obj *pdf_doc_get_page (pdf_file *pf, int page_no, int options, +extern pdf_obj *pdf_doc_get_page (pdf_file *pf, int page_no, enum pdf_page_boundary opt_bbox, pdf_rect *bbox, pdf_tmatrix *matrix, pdf_obj **resources_p); extern int pdf_doc_current_page_number (void); diff --git a/Build/source/texk/dvipdfm-x/pdfdraw.c b/Build/source/texk/dvipdfm-x/pdfdraw.c index 9582efb80eb..ae1ca11c835 100644 --- a/Build/source/texk/dvipdfm-x/pdfdraw.c +++ b/Build/source/texk/dvipdfm-x/pdfdraw.c @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002-2017 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2002-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -30,6 +30,7 @@ #include "error.h" #include "mem.h" #include "mfileio.h" +#include "dpxconf.h" #include "dpxutil.h" #include "numbers.h" diff --git a/Build/source/texk/dvipdfm-x/pdfencoding.c b/Build/source/texk/dvipdfm-x/pdfencoding.c index 0617d2c19dd..492e22ff976 100644 --- a/Build/source/texk/dvipdfm-x/pdfencoding.c +++ b/Build/source/texk/dvipdfm-x/pdfencoding.c @@ -29,6 +29,7 @@ #include "system.h" #include "mem.h" #include "error.h" +#include "dpxconf.h" #include "dpxutil.h" #include "pdfparse.h" @@ -42,8 +43,6 @@ static int is_similar_charset (char **encoding, const char **encoding2); static pdf_obj *make_encoding_differences (char **encoding, char **baseenc, const char *is_used); -static unsigned char verbose = 0; - static const char *MacRomanEncoding[256]; static const char *MacExpertEncoding[256]; static const char *WinAnsiEncoding[256]; @@ -52,12 +51,6 @@ static const char *StandardEncoding[256]; static const char *ISOLatin1Encoding[256]; #endif -void -pdf_encoding_set_verbose (void) -{ - verbose++; -} - /* * ident: File name, e.g., 8a.enc. * name: Name of encoding, StandardEncoding, TeXBase1Encoding, ... @@ -291,7 +284,7 @@ load_encoding_file (const char *filename) if (!filename) return -1; - if (verbose) { + if (dpx_conf.verbose_level > 0) { MESG("(Encoding:%s", filename); } @@ -340,13 +333,13 @@ load_encoding_file (const char *filename) filename, enc_vec, NULL, 0); if (enc_name) { - if (verbose > 1) + if (dpx_conf.verbose_level > 1) MESG("[%s]", pdf_name_value(enc_name)); pdf_release_obj(enc_name); } pdf_release_obj(encoding_array); - if (verbose) MESG(")"); + if (dpx_conf.verbose_level > 0) MESG(")"); return enc_id; } @@ -689,7 +682,7 @@ pdf_create_ToUnicode_CMap (const char *enc_name, } if (total_fail > 0) { - if (verbose) + if (dpx_conf.verbose_level > 0) WARN("Glyphs with no Unicode mapping found. Removing ToUnicode CMap."); } stream = total_fail > 0 ? NULL : CMap_create_stream(cmap); @@ -723,7 +716,7 @@ pdf_load_ToUnicode_stream (const char *ident) if (CMap_parse(cmap, fp) < 0) { WARN("Reading CMap file \"%s\" failed.", ident); } else { - if (verbose) { + if (dpx_conf.verbose_level > 0) { MESG("(CMap:%s)", ident); } stream = CMap_create_stream(cmap); diff --git a/Build/source/texk/dvipdfm-x/pdfencoding.h b/Build/source/texk/dvipdfm-x/pdfencoding.h index 13cf63abecc..4c51a479d3e 100644 --- a/Build/source/texk/dvipdfm-x/pdfencoding.h +++ b/Build/source/texk/dvipdfm-x/pdfencoding.h @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2007-2016 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -25,8 +25,6 @@ #include "pdfobj.h" -extern void pdf_encoding_set_verbose (void); - extern void pdf_init_encodings (void); extern void pdf_close_encodings (void); diff --git a/Build/source/texk/dvipdfm-x/pdfencrypt.c b/Build/source/texk/dvipdfm-x/pdfencrypt.c index e7d307bd801..23f4ea5c94b 100644 --- a/Build/source/texk/dvipdfm-x/pdfencrypt.c +++ b/Build/source/texk/dvipdfm-x/pdfencrypt.c @@ -27,17 +27,11 @@ #include <string.h> #include <time.h> -#ifdef WIN32 -#include <conio.h> -#define getch _getch -#else /* !WIN32 */ -#include <unistd.h> -#endif /* WIN32 */ - #include "system.h" #include "mem.h" #include "numbers.h" #include "error.h" +#include "dpxconf.h" #include "pdfobj.h" #include "unicode.h" #include "dpxcrypt.h" @@ -88,13 +82,6 @@ static const unsigned char padding_bytes[32] = { 0x2f, 0x0c, 0xa9, 0xfe, 0x64, 0x53, 0x69, 0x7a }; -static unsigned char verbose = 0; - -void pdf_enc_set_verbose (void) -{ - if (verbose < 255) verbose++; -} - static void pdf_enc_init (int use_aes, int encrypt_metadata) { @@ -439,29 +426,6 @@ compute_user_password_V5 (struct pdf_sec *p, const char *uplain) RELEASE(UE); } -#ifdef WIN32 -/* Broken on mintty? */ -static char * -getpass (const char *prompt) -{ - static char pwd_buf[128]; - size_t i; - - fputs(prompt, stderr); - fflush(stderr); - for (i = 0; i < sizeof(pwd_buf)-1; i++) { - pwd_buf[i] = getch(); - if (pwd_buf[i] == '\r' || pwd_buf[i] == '\n') - break; - fputs("*", stderr); - fflush(stderr); - } - pwd_buf[i] = '\0'; - fputs("\n", stderr); - return pwd_buf; -} -#endif - static void check_version (struct pdf_sec *p, int version) { @@ -558,9 +522,9 @@ pdf_enc_set_passwd (unsigned int bits, unsigned int perm, const char *oplain, const char *uplain) { struct pdf_sec *p = &sec_data; - char input[128], opasswd[128], upasswd[128]; - char *retry_passwd; + char opasswd[128], upasswd[128]; int version; + char empty_passwd[1] = "\0"; version = pdf_get_version(); @@ -612,31 +576,13 @@ pdf_enc_set_passwd (unsigned int bits, unsigned int perm, if (preproc_password(oplain, opasswd, p->V) < 0) WARN("Invaid UTF-8 string for password."); } else { - while (1) { - strncpy(input, getpass("Owner password: "), MAX_PWD_LEN); - retry_passwd = getpass("Re-enter owner password: "); - if (!strncmp(input, retry_passwd, MAX_PWD_LEN)) - break; - fputs("Password is not identical.\nTry again.\n", stderr); - fflush(stderr); - } - if (preproc_password(input, opasswd, p->V) < 0) - WARN("Invaid UTF-8 string for password."); + preproc_password(empty_passwd, opasswd, p->V); } if (uplain) { if (preproc_password(uplain, upasswd, p->V) < 0) WARN("Invalid UTF-8 string for passowrd."); } else { - while (1) { - strncpy(input, getpass("User password: "), MAX_PWD_LEN); - retry_passwd = getpass("Re-enter user password: "); - if (!strncmp(input, retry_passwd, MAX_PWD_LEN)) - break; - fputs("Password is not identical.\nTry again.\n", stderr); - fflush(stderr); - } - if (preproc_password(input, upasswd, p->V) < 0) - WARN("Invaid UTF-8 string for password."); + preproc_password(empty_passwd, upasswd, p->V); } if (p->R >= 3) diff --git a/Build/source/texk/dvipdfm-x/pdfencrypt.h b/Build/source/texk/dvipdfm-x/pdfencrypt.h index 024276dcc51..22f548279f1 100644 --- a/Build/source/texk/dvipdfm-x/pdfencrypt.h +++ b/Build/source/texk/dvipdfm-x/pdfencrypt.h @@ -2,7 +2,7 @@ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2007-2016 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. This program is free software; you can redistribute it and/or modify @@ -27,7 +27,6 @@ #define MAX_PWD_LEN 127 -extern void pdf_enc_set_verbose (void); extern pdf_obj *pdf_enc_id_array (void); extern void pdf_enc_compute_id_string (char *dviname, char *pdfname); extern void pdf_enc_set_label (unsigned label); diff --git a/Build/source/texk/dvipdfm-x/pdffont.c b/Build/source/texk/dvipdfm-x/pdffont.c index 8ea41ad471b..e50503e94ec 100644 --- a/Build/source/texk/dvipdfm-x/pdffont.c +++ b/Build/source/texk/dvipdfm-x/pdffont.c @@ -31,6 +31,7 @@ #include "error.h" #include "mem.h" +#include "dpxconf.h" #include "dpxfile.h" #include "dpxutil.h" @@ -53,29 +54,9 @@ #include "pdffont.h" -static int __verbose = 0; - #define MREC_HAS_TOUNICODE(m) ((m) && (m)->opt.tounicode) void -pdf_font_set_verbose (void) -{ - __verbose++; - CMap_set_verbose(); - Type0Font_set_verbose(); - CIDFont_set_verbose (); - pdf_encoding_set_verbose(); - agl_set_verbose(); - otf_cmap_set_verbose (); -} - -int -pdf_font_get_verbose (void) -{ - return __verbose; -} - -void pdf_font_set_dpi (int font_dpi) { PKFont_set_dpi(font_dpi); @@ -469,7 +450,7 @@ try_load_ToUnicode_CMap (pdf_font *font) pdf_add_dict(fontdict, pdf_new_name("ToUnicode"), pdf_ref_obj (tounicode)); /* _FIXME_ */ - if (__verbose) + if (dpx_conf.verbose_level > 0) MESG("pdf_font>> ToUnicode CMap \"%s\" attached to font id=\"%s\".\n", cmap_name, font->map_name); } @@ -490,18 +471,18 @@ pdf_close_fonts (void) font = GET_FONT(font_id); - if (__verbose) { + if (dpx_conf.verbose_level > 0) { if (font->subtype != PDF_FONT_FONTTYPE_TYPE0) { MESG("(%s", pdf_font_get_ident(font)); - if (__verbose > 2 && + if (dpx_conf.verbose_level > 2 && !pdf_font_get_flag(font, PDF_FONT_FLAG_NOEMBED)) { MESG("[%s+%s]", pdf_font_get_uniqueTag(font), pdf_font_get_fontname(font)); - } else if (__verbose > 1) { + } else if (dpx_conf.verbose_level > 1) { MESG("[%s]", pdf_font_get_fontname(font)); } - if (__verbose > 1) { + if (dpx_conf.verbose_level > 1) { if (pdf_font_get_encoding(font) >= 0) { MESG("[%s]", pdf_encoding_get_name(pdf_font_get_encoding(font))); } else { @@ -517,23 +498,23 @@ pdf_close_fonts (void) /* Type 0 is handled separately... */ switch (font->subtype) { case PDF_FONT_FONTTYPE_TYPE1: - if (__verbose) + if (dpx_conf.verbose_level > 0) MESG("[Type1]"); if (!pdf_font_get_flag(font, PDF_FONT_FLAG_BASEFONT)) pdf_font_load_type1(font); break; case PDF_FONT_FONTTYPE_TYPE1C: - if (__verbose) + if (dpx_conf.verbose_level > 0) MESG("[Type1C]"); pdf_font_load_type1c(font); break; case PDF_FONT_FONTTYPE_TRUETYPE: - if (__verbose) + if (dpx_conf.verbose_level > 0) MESG("[TrueType]"); pdf_font_load_truetype(font); break; case PDF_FONT_FONTTYPE_TYPE3: - if (__verbose) + if (dpx_conf.verbose_level > 0) MESG("[Type3/PK]"); pdf_font_load_pkfont (font); break; @@ -547,7 +528,7 @@ pdf_close_fonts (void) if (font->encoding_id >= 0 && font->subtype != PDF_FONT_FONTTYPE_TYPE0) pdf_encoding_add_usedchars(font->encoding_id, font->usedchars); - if (__verbose) { + if (dpx_conf.verbose_level > 0) { if (font->subtype != PDF_FONT_FONTTYPE_TYPE0) MESG(")"); } @@ -668,7 +649,7 @@ pdf_font_findresource (const char *tex_name, * Turn on map option. */ if (minbytes == 2 && mrec->opt.mapc < 0) { - if (__verbose) { + if (dpx_conf.verbose_level > 0) { MESG("\n"); MESG("pdf_font>> Input encoding \"%s\" requires at least 2 bytes.\n", CMap_get_name(cmap)); @@ -713,7 +694,7 @@ pdf_font_findresource (const char *tex_name, font->font_id == type0_id && font->encoding_id == cmap_id) { found = 1; - if (__verbose) { + if (dpx_conf.verbose_level > 0) { MESG("\npdf_font>> Type0 font \"%s\" (cmap_id=%d) found at font_id=%d.\n", mrec->font_name, cmap_id, font_id); } @@ -736,7 +717,7 @@ pdf_font_findresource (const char *tex_name, font_cache.count++; - if (__verbose) { + if (dpx_conf.verbose_level > 0) { MESG("\npdf_font>> Type0 font \"%s\"", fontname); MESG(" cmap_id=<%s,%d>", mrec->enc_name, font->encoding_id); MESG(" opened at font_id=<%s,%d>.\n", tex_name, font_id); @@ -787,7 +768,7 @@ pdf_font_findresource (const char *tex_name, } if (found) { - if (__verbose) { + if (dpx_conf.verbose_level > 0) { MESG("\npdf_font>> Simple font \"%s\" (enc_id=%d) found at id=%d.\n", fontname, encoding_id, font_id); } @@ -830,7 +811,7 @@ pdf_font_findresource (const char *tex_name, font_cache.count++; - if (__verbose) { + if (dpx_conf.verbose_level > 0) { MESG("\npdf_font>> Simple font \"%s\"", fontname); MESG(" enc_id=<%s,%d>", (mrec && mrec->enc_name) ? mrec->enc_name : "builtin", font->encoding_id); diff --git a/Build/source/texk/dvipdfm-x/pdffont.h b/Build/source/texk/dvipdfm-x/pdffont.h index e5a9ad6638e..0efcce44de5 100644 --- a/Build/source/texk/dvipdfm-x/pdffont.h +++ b/Build/source/texk/dvipdfm-x/pdffont.h @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002-2016 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2002-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -34,9 +34,6 @@ #define PDF_FONT_FONTTYPE_TYPE0 4 -extern void pdf_font_set_verbose (void); -extern int pdf_font_get_verbose (void); - extern void pdf_font_set_dpi (int font_dpi); #define PDF_FONT_FLAG_NOEMBED (1 << 0) diff --git a/Build/source/texk/dvipdfm-x/pdfobj.c b/Build/source/texk/dvipdfm-x/pdfobj.c index 1a08f64e578..54a6337848e 100644 --- a/Build/source/texk/dvipdfm-x/pdfobj.c +++ b/Build/source/texk/dvipdfm-x/pdfobj.c @@ -33,6 +33,7 @@ #include "mem.h" #include "error.h" #include "mfileio.h" +#include "dpxconf.h" #include "dpxutil.h" #include "pdflimits.h" #include "pdfencrypt.h" @@ -250,7 +251,6 @@ static void release_dict (pdf_dict *dict); static void write_stream (pdf_stream *stream, FILE *file); static void release_stream (pdf_stream *stream); -static int verbose = 0; static char compression_level = 9; static char compression_use_predictor = 1; @@ -274,6 +274,12 @@ pdf_set_compression (int level) return; } +FILE * +pdf_get_output_file (void) +{ + return pdf_output_file; +} + void pdf_set_use_predictor (int bval) { @@ -315,18 +321,6 @@ pdf_check_version (int major, int minor) return (pdf_version >= major*10+minor) ? 0 : -1; } -int -pdf_obj_get_verbose(void) -{ - return verbose; -} - -void -pdf_obj_set_verbose(void) -{ - verbose++; -} - static pdf_obj *current_objstm = NULL; static int do_objstm; @@ -537,7 +531,7 @@ pdf_out_flush (void) #if !defined(LIBDPX) MESG("\n"); #endif /* !LIBDPX */ - if (verbose) { + if (dpx_conf.verbose_level > 0) { if (compression_level > 0) { MESG("Compression saved %ld bytes%s\n", compression_saved, pdf_version < 15 ? ". Try \"-V 1.5\" for better compression" : ""); @@ -548,6 +542,7 @@ pdf_out_flush (void) #endif /* !LIBDPX */ MFCLOSE(pdf_output_file); + pdf_output_file = NULL; } #if defined(PDFOBJ_DEBUG) { @@ -579,6 +574,7 @@ pdf_error_cleanup (void) */ if (pdf_output_file) MFCLOSE(pdf_output_file); + pdf_output_file = NULL; } diff --git a/Build/source/texk/dvipdfm-x/pdfobj.h b/Build/source/texk/dvipdfm-x/pdfobj.h index 90f6da26aed..b8aea029fc6 100644 --- a/Build/source/texk/dvipdfm-x/pdfobj.h +++ b/Build/source/texk/dvipdfm-x/pdfobj.h @@ -51,11 +51,10 @@ typedef struct pdf_obj pdf_obj; typedef struct pdf_file pdf_file; /* External interface to pdf routines */ - -extern int pdf_obj_get_verbose (void); -extern void pdf_obj_set_verbose (void); extern void pdf_error_cleanup (void); +extern FILE *pdf_get_output_file (void); + extern void pdf_out_init (const char *filename, int enable_encrypt, int enable_objstm); extern void pdf_out_flush (void); diff --git a/Build/source/texk/dvipdfm-x/pdfximage.c b/Build/source/texk/dvipdfm-x/pdfximage.c index 9c249848591..e480190f7d8 100644 --- a/Build/source/texk/dvipdfm-x/pdfximage.c +++ b/Build/source/texk/dvipdfm-x/pdfximage.c @@ -28,6 +28,7 @@ #include "error.h" #include "mem.h" +#include "dpxconf.h" #include "dpxfile.h" #include "dpxutil.h" @@ -95,17 +96,13 @@ struct pdf_ximage_ /* verbose, verbose, verbose... */ struct opt_ { - int verbose; char *cmdtmpl; }; static struct opt_ _opts = { - 0, NULL + NULL }; -void pdf_ximage_set_verbose (void) { _opts.verbose++; } - - struct ic_ { int count, capacity; @@ -193,7 +190,8 @@ pdf_close_images (void) * We also use this to convert a PS file only once if multiple * pages are imported from that file. */ - if (_opts.verbose > 1 && keep_cache != 1) + if (dpx_conf.verbose_level > 1 && + dpx_conf.file.keep_cache != 1) MESG("pdf_image>> deleting temporary file \"%s\"\n", I->filename); dpx_delete_temp_file(I->filename, false); /* temporary filename freed here */ I->filename = NULL; @@ -282,14 +280,14 @@ load_image (const char *ident, const char *fullname, int format, FILE *fp, switch (format) { case IMAGE_TYPE_JPEG: - if (_opts.verbose) + if (dpx_conf.verbose_level > 0) MESG("[JPEG]"); if (jpeg_include_image(I, fp) < 0) goto error; I->subtype = PDF_XOBJECT_TYPE_IMAGE; break; case IMAGE_TYPE_JP2: - if (_opts.verbose) + if (dpx_conf.verbose_level > 0) MESG("[JP2]"); if (jp2_include_image(I, fp) < 0) goto error; @@ -297,7 +295,7 @@ load_image (const char *ident, const char *fullname, int format, FILE *fp, break; #ifdef HAVE_LIBPNG case IMAGE_TYPE_PNG: - if (_opts.verbose) + if (dpx_conf.verbose_level > 0) MESG("[PNG]"); if (png_include_image(I, fp) < 0) goto error; @@ -305,14 +303,14 @@ load_image (const char *ident, const char *fullname, int format, FILE *fp, break; #endif case IMAGE_TYPE_BMP: - if (_opts.verbose) + if (dpx_conf.verbose_level > 0) MESG("[BMP]"); if (bmp_include_image(I, fp) < 0) goto error; I->subtype = PDF_XOBJECT_TYPE_IMAGE; break; case IMAGE_TYPE_PDF: - if (_opts.verbose) + if (dpx_conf.verbose_level > 0) MESG("[PDF]"); { int result = pdf_include_page(I, fp, fullname, options); @@ -322,7 +320,7 @@ load_image (const char *ident, const char *fullname, int format, FILE *fp, if (result < 0) goto error; } - if (_opts.verbose) + if (dpx_conf.verbose_level > 0) MESG(",Page:%ld", I->attr.page_no); I->subtype = PDF_XOBJECT_TYPE_FORM; break; @@ -330,11 +328,11 @@ load_image (const char *ident, const char *fullname, int format, FILE *fp, case IMAGE_TYPE_EPS: */ default: - if (_opts.verbose) + if (dpx_conf.verbose_level > 0) MESG(format == IMAGE_TYPE_EPS ? "[PS]" : "[UNKNOWN]"); if (ps_include_page(I, fullname, options) < 0) goto error; - if (_opts.verbose) + if (dpx_conf.verbose_level > 0) MESG(",Page:%ld", I->attr.page_no); I->subtype = PDF_XOBJECT_TYPE_FORM; } @@ -409,16 +407,16 @@ pdf_ximage_findresource (const char *ident, load_options options) RELEASE(fullname); return -1; } - if (_opts.verbose) { + if (dpx_conf.verbose_level > 0) { MESG("(Image:%s", ident); - if (_opts.verbose > 1) + if (dpx_conf.verbose_level > 1) MESG("[%s]", fullname); } format = source_image_type(fp); switch (format) { case IMAGE_TYPE_MPS: - if (_opts.verbose) + if (dpx_conf.verbose_level > 0) MESG("[MPS]"); id = mps_include_page(ident, fp); if (id < 0) { @@ -435,7 +433,7 @@ pdf_ximage_findresource (const char *ident, load_options options) RELEASE(fullname); - if (_opts.verbose) + if (dpx_conf.verbose_level > 0) MESG(")"); if (id < 0) @@ -947,14 +945,15 @@ ps_include_page (pdf_ximage *ximage, const char *filename, load_options options) } #endif - if (keep_cache != -1 && stat(temp, &stat_t)==0 && stat(filename, &stat_o)==0 - && stat_t.st_mtime > stat_o.st_mtime) { + if (dpx_conf.file.keep_cache != -1 && + stat(temp, &stat_t)==0 && stat(filename, &stat_o)==0 && + stat_t.st_mtime > stat_o.st_mtime) { /* cache exist */ /*printf("\nLast file modification: %s", ctime(&stat_o.st_mtime)); printf("Last file modification: %s", ctime(&stat_t.st_mtime));*/ ; } else { - if (_opts.verbose > 1) { + if (dpx_conf.verbose_level > 1) { MESG("\n"); MESG("pdf_image>> Converting file \"%s\" --> \"%s\" via:\n", filename, temp); MESG("pdf_image>> %s\n", distiller_template); diff --git a/Build/source/texk/dvipdfm-x/pdfximage.h b/Build/source/texk/dvipdfm-x/pdfximage.h index 0d6dea0c407..b174c44655f 100644 --- a/Build/source/texk/dvipdfm-x/pdfximage.h +++ b/Build/source/texk/dvipdfm-x/pdfximage.h @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2007-2017 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -24,6 +24,7 @@ #define _PDFXIMAGE_H_ #include "pdfdev.h" +#include "pdfdoc.h" #define PDF_XOBJECT_TYPE_FORM 0 #define PDF_XOBJECT_TYPE_IMAGE 1 @@ -50,15 +51,13 @@ typedef struct { } xform_info; typedef struct { - int page_no; - int bbox_type; + int page_no; + enum pdf_page_boundary bbox_type; pdf_obj *dict; } load_options; typedef struct pdf_ximage_ pdf_ximage; -extern void pdf_ximage_set_verbose (void); - extern void pdf_init_images (void); extern void pdf_close_images (void); diff --git a/Build/source/texk/dvipdfm-x/pngimage.c b/Build/source/texk/dvipdfm-x/pngimage.c index e985b0fa85e..55ce4467564 100644 --- a/Build/source/texk/dvipdfm-x/pngimage.c +++ b/Build/source/texk/dvipdfm-x/pngimage.c @@ -41,7 +41,7 @@ #include "error.h" #include "mem.h" -#include "dvipdfmx.h" +#include "dpxconf.h" #include "pdfcolor.h" #include "pdfobj.h" @@ -219,7 +219,7 @@ png_include_image (pdf_ximage *ximage, FILE *png_file) info.height = height; info.bits_per_component = bpc; - if (compat_mode) + if (dpx_conf.compat_mode == dpx_mode_compat_mode) info.xdensity = info.ydensity = 72.0 / 100.0; else { @@ -1120,7 +1120,7 @@ png_get_bbox (FILE *png_file, uint32_t *width, uint32_t *height, *width = png_get_image_width (png_ptr, png_info_ptr); *height = png_get_image_height(png_ptr, png_info_ptr); - if (compat_mode) + if (dpx_conf.compat_mode == dpx_mode_compat_mode) *xdensity = *ydensity = 72.0 / 100.0; else { diff --git a/Build/source/texk/dvipdfm-x/spc_pdfm.c b/Build/source/texk/dvipdfm-x/spc_pdfm.c index 66501a16634..ead09a03bf5 100644 --- a/Build/source/texk/dvipdfm-x/spc_pdfm.c +++ b/Build/source/texk/dvipdfm-x/spc_pdfm.c @@ -36,6 +36,7 @@ #include "fontmap.h" #include "dpxfile.h" #include "dpxutil.h" +#include "dpxconf.h" #include "unicode.h" @@ -553,7 +554,7 @@ modstrings (pdf_obj *kp, pdf_obj *vp, void *dp) CMap *cmap = CMap_cache_get(cd->cmap_id); if (needreencode(kp, vp, cd)) r = reencodestring(cmap, vp); - } else if (is_xdv && cd && cd->taintkeys) { + } else if ((dpx_conf.compat_mode == dpx_mode_xdv_mode) && cd && cd->taintkeys) { /* Please fix this... PDF string object is not always a text string. * needreencode() is assumed to do a simple check if given string * object is actually a text string. @@ -581,7 +582,7 @@ parse_pdf_dict_with_tounicode (const char **pp, const char *endptr, struct touni pdf_obj *dict; /* disable this test for XDV files, as we do UTF8 reencoding with no cmap */ - if (!is_xdv && cd->cmap_id < 0) + if ((dpx_conf.compat_mode != dpx_mode_xdv_mode) && cd->cmap_id < 0) return parse_pdf_dict(pp, endptr, NULL); /* :( */ @@ -1077,7 +1078,7 @@ spc_handler_pdfm_image (struct spc_env *spe, struct spc_arg *args) pdf_dev_put_image(xobj_id, &ti, spe->x_user, spe->y_user); if (ident) { - if (compat_mode && + if ((dpx_conf.compat_mode == dpx_mode_compat_mode) && pdf_ximage_get_subtype(xobj_id) == PDF_XOBJECT_TYPE_IMAGE) pdf_ximage_set_attr(xobj_id, 1, 1, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0); addresource(sd, ident, xobj_id); @@ -1108,7 +1109,7 @@ spc_handler_pdfm_dest (struct spc_env *spe, struct spc_arg *args) } #if 0 - if (is_xdv && maybe_reencode_utf8(name) < 0) + if ((dpx_conf.compat_mode == dpx_mode_xdv_mode) && maybe_reencode_utf8(name) < 0) WARN("Failed to convert input string to UTF16..."); #endif diff --git a/Build/source/texk/dvipdfm-x/spc_util.c b/Build/source/texk/dvipdfm-x/spc_util.c index 4c34ce03f3c..07426a6171e 100644 --- a/Build/source/texk/dvipdfm-x/spc_util.c +++ b/Build/source/texk/dvipdfm-x/spc_util.c @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2007-2017 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -29,6 +29,7 @@ #include "error.h" #include "dpxutil.h" +#include "pdfdoc.h" #include "pdfdev.h" #include "pdfparse.h" #include "pdfcolor.h" @@ -718,7 +719,8 @@ spc_util_read_dimtrns (struct spc_env *spe, int spc_util_read_blahblah (struct spc_env *spe, - transform_info *p, int *page_no, int *bbox_type, + transform_info *p, int *page_no, + enum pdf_page_boundary *bbox_type, struct spc_arg *ap) { int has_scale, has_xscale, has_yscale, has_rotate, has_matrix; @@ -864,15 +866,15 @@ spc_util_read_blahblah (struct spc_env *spe, q = parse_c_ident (&ap->curptr, ap->endptr); if (q) { if (bbox_type) { - if (strcasecmp(q, "cropbox") == 0) *bbox_type = 1; - else if (strcasecmp(q, "mediabox") == 0) *bbox_type = 2; - else if (strcasecmp(q, "artbox") == 0) *bbox_type = 3; - else if (strcasecmp(q, "trimbox") == 0) *bbox_type = 4; - else if (strcasecmp(q, "bleedbox") == 0) *bbox_type = 5; + if (strcasecmp(q, "cropbox") == 0) *bbox_type = pdf_page_boundary_cropbox; + else if (strcasecmp(q, "mediabox") == 0) *bbox_type = pdf_page_boundary_mediabox; + else if (strcasecmp(q, "artbox") == 0) *bbox_type = pdf_page_boundary_artbox; + else if (strcasecmp(q, "trimbox") == 0) *bbox_type = pdf_page_boundary_trimbox; + else if (strcasecmp(q, "bleedbox") == 0) *bbox_type = pdf_page_boundary_bleedbox; } RELEASE(q); } else if (bbox_type) { - *bbox_type = 0; + *bbox_type = pdf_page_boundary__auto; } } break; diff --git a/Build/source/texk/dvipdfm-x/spc_util.h b/Build/source/texk/dvipdfm-x/spc_util.h index 8803cf7a270..0765247e636 100644 --- a/Build/source/texk/dvipdfm-x/spc_util.h +++ b/Build/source/texk/dvipdfm-x/spc_util.h @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002-2016 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2002-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -25,6 +25,7 @@ #include "pdfcolor.h" #include "pdfdev.h" +#include "pdfdoc.h" #include "specials.h" @@ -41,9 +42,9 @@ extern int spc_util_read_dimtrns (struct spc_env *spe, struct spc_arg *args, int syntax); extern int spc_util_read_blahblah (struct spc_env *spe, - transform_info *dimtrns, - int *page_no, - int *bbox_type, + transform_info *dimtrns, + int *page_no, + enum pdf_page_boundary *bbox_type, struct spc_arg *args); diff --git a/Build/source/texk/dvipdfm-x/specials.c b/Build/source/texk/dvipdfm-x/specials.c index e931fdb4eed..9d396ac5aeb 100644 --- a/Build/source/texk/dvipdfm-x/specials.c +++ b/Build/source/texk/dvipdfm-x/specials.c @@ -30,6 +30,7 @@ #include "mem.h" #include "error.h" #include "numbers.h" +#include "dpxconf.h" #include "dvi.h" @@ -52,14 +53,6 @@ #include "specials.h" -static int verbose = 0; -void -spc_set_verbose (void) -{ - verbose++; -} - - void spc_warn (struct spc_env *spe, const char *fmt, ...) { @@ -571,7 +564,8 @@ spc_exec_special (const char *buffer, int32_t size, struct spc_arg args; struct spc_handler special; - if (verbose > 3) { + if (dpx_conf.verbose_level > 3) { + MESG("Executing special command: "); dump(buffer, buffer + size); } diff --git a/Build/source/texk/dvipdfm-x/specials.h b/Build/source/texk/dvipdfm-x/specials.h index b58aaf6a398..0ce9785a314 100644 --- a/Build/source/texk/dvipdfm-x/specials.h +++ b/Build/source/texk/dvipdfm-x/specials.h @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2007-2016 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -44,8 +44,6 @@ struct spc_handler { spc_handler_fn_ptr exec; }; -/* This should not use pdf_. */ -extern void spc_set_verbose (void); #include <stdarg.h> extern void spc_warn (struct spc_env *spe, const char *fmt, ...); diff --git a/Build/source/texk/dvipdfm-x/subfont.c b/Build/source/texk/dvipdfm-x/subfont.c index f0b6fb84051..8834d36658b 100644 --- a/Build/source/texk/dvipdfm-x/subfont.c +++ b/Build/source/texk/dvipdfm-x/subfont.c @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002-2016 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2002-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. This program is free software; you can redistribute it and/or modify @@ -27,17 +27,11 @@ #include "system.h" #include "mem.h" #include "error.h" +#include "dpxconf.h" #include "dpxfile.h" #include "subfont.h" -static int verbose = 0; -void -subfont_set_verbose (void) -{ - verbose++; -} - /* Don't forget fontmap reading now requires information * from SFD files. You must initialize at least sfd_file_ * cache before starting loading of fontmaps. @@ -249,7 +243,7 @@ scan_sfd_file (struct sfd_file_ *sfd, FILE *fp) ASSERT( sfd && fp ); - if (verbose > 3) { + if (dpx_conf.verbose_level > 3) { MESG("\nsubfont>> Scanning SFD file \"%s\"...\n", sfd->ident); } @@ -270,7 +264,7 @@ scan_sfd_file (struct sfd_file_ *sfd, FILE *fp) sfd->sub_id = RENEW(sfd->sub_id, sfd->max_subfonts, char *); } - if (verbose > 3) { + if (dpx_conf.verbose_level > 3) { MESG("subfont>> id=\"%s\" at line=\"%d\"\n", id, lpos); } sfd->sub_id[sfd->num_subfonts] = id; @@ -282,7 +276,7 @@ scan_sfd_file (struct sfd_file_ *sfd, FILE *fp) sfd->rec_id[n] = -1; /* Not loaded yet. We do lazy loading of map definitions. */ } - if (verbose > 3) { + if (dpx_conf.verbose_level > 3) { MESG("subfont>> %d entries found in SFD file \"%s\".\n", sfd->num_subfonts, sfd->ident); } @@ -386,7 +380,7 @@ sfd_load_record (const char *sfd_name, const char *subfont_id) return sfd->rec_id[i]; } - if (verbose > 3) { + if (dpx_conf.verbose_level > 3) { MESG("\nsubfont>> Loading SFD mapping table for <%s,%s>...", sfd->ident, subfont_id); } @@ -429,7 +423,7 @@ sfd_load_record (const char *sfd_name, const char *subfont_id) sfd->rec_id[i] = rec_id; DPXFCLOSE(fp); - if (verbose > 3) { + if (dpx_conf.verbose_level > 3) { int __i; if (rec_id >= 0) { MESG(" at id=\"%d\"", rec_id); @@ -515,7 +509,7 @@ dump_table (const char *sfd_name, const char *sub_name, iconv_t cd) #ifdef HAVE_ICONV r = iconv(cd, &p, &inbufleft, &q, &outbufleft); if (r == -1) { - if (verbose) { + if (dpx_conf.verbose_level > 0) { WARN("Conversion to Unicode failed for subfont-id=\"%s\" code=\"0x%02x\"", sub_name, i); WARN(">> with: %s", strerror(errno)); diff --git a/Build/source/texk/dvipdfm-x/subfont.h b/Build/source/texk/dvipdfm-x/subfont.h index 340dc38a94d..29441361f15 100644 --- a/Build/source/texk/dvipdfm-x/subfont.h +++ b/Build/source/texk/dvipdfm-x/subfont.h @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002-2016 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2002-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. This program is free software; you can redistribute it and/or modify @@ -21,8 +21,6 @@ #ifndef _SUBFONT_H_ #define _SUBFONT_H_ -extern void subfont_set_verbose (void); - extern void release_sfd_record (void); extern unsigned short lookup_sfd_record(int rec_id, unsigned char code); diff --git a/Build/source/texk/dvipdfm-x/t1_char.c b/Build/source/texk/dvipdfm-x/t1_char.c index b60a7a4b69d..663a986aaec 100644 --- a/Build/source/texk/dvipdfm-x/t1_char.c +++ b/Build/source/texk/dvipdfm-x/t1_char.c @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002-2016 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2002-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -885,7 +885,7 @@ do_operator2 (t1_chardesc *cd, card8 **data, card8 *endptr) * (See, Adobe Technical Note #5177, Appendix C) */ if (!(cd->flags & T1_CS_FLAG_USE_HINTMASK)) { - if (__verbose > 1) + if (dpx_conf.verbose_level > 1) WARN("Obsolete Type 1 charstring operator \"dotsection\" not supported."); } #endif diff --git a/Build/source/texk/dvipdfm-x/tfm.c b/Build/source/texk/dvipdfm-x/tfm.c index 37f406698a9..5336e8d59e5 100644 --- a/Build/source/texk/dvipdfm-x/tfm.c +++ b/Build/source/texk/dvipdfm-x/tfm.c @@ -32,6 +32,7 @@ #include "error.h" #include "numbers.h" +#include "dpxconf.h" #include "dpxutil.h" #include "tfm.h" @@ -41,9 +42,6 @@ #define FWBASE ((double) (1<<20)) -static int verbose = 0; - - #ifndef WITHOUT_ASCII_PTEX /* * ID is 9 for vertical JFM file. @@ -328,13 +326,6 @@ fms_need (unsigned n) } } -void -tfm_set_verbose (void) -{ - verbose++; -} - - static int fread_fwords (fixword *words, int32_t nmemb, FILE *fp) { @@ -921,12 +912,12 @@ tfm_open (const char *tfm_name, int must_exist) ERROR("Could not open specified TFM/OFM file \"%s\".", tfm_name); } - if (verbose) { + if (dpx_conf.verbose_level > 0) { if (format == TFM_FORMAT) MESG("(TFM:%s", tfm_name); else if (format == OFM_FORMAT) MESG("(OFM:%s", tfm_name); - if (verbose > 1) + if (dpx_conf.verbose_level > 1) MESG("[%s]", file_name); } @@ -956,7 +947,7 @@ tfm_open (const char *tfm_name, int must_exist) fms[numfms].tex_name = NEW(strlen(tfm_name)+1, char); strcpy(fms[numfms].tex_name, tfm_name); - if (verbose) + if (dpx_conf.verbose_level > 0) MESG(")"); return numfms++; diff --git a/Build/source/texk/dvipdfm-x/tfm.h b/Build/source/texk/dvipdfm-x/tfm.h index 7621133412c..3f3b2379492 100644 --- a/Build/source/texk/dvipdfm-x/tfm.h +++ b/Build/source/texk/dvipdfm-x/tfm.h @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002-2016 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2002-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -25,8 +25,6 @@ #include "numbers.h" -extern void tfm_set_verbose (void); - extern int tfm_open (const char * tex_name, int must_exist); extern void tfm_close_all (void); diff --git a/Build/source/texk/dvipdfm-x/truetype.c b/Build/source/texk/dvipdfm-x/truetype.c index 64b5e5cc3fe..45b39159f80 100644 --- a/Build/source/texk/dvipdfm-x/truetype.c +++ b/Build/source/texk/dvipdfm-x/truetype.c @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2007-2016 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. This program is free software; you can redistribute it and/or modify @@ -28,6 +28,7 @@ #include "error.h" #include "mem.h" +#include "dpxconf.h" #include "dpxfile.h" #include "dpxutil.h" @@ -273,8 +274,6 @@ do_widths (pdf_font *font, double *widths) return; } -static int verbose = 0; - #define PDFUNIT(v) ((double) (ROUND(1000.0*(v)/(glyphs->emsize), 1))) /* @@ -314,7 +313,7 @@ do_builtin_encoding (pdf_font *font, const char *usedchars, sfnt *sfont) glyphs = tt_build_init(); - if (verbose > 2) + if (dpx_conf.verbose_level > 2) MESG("[glyphs:/.notdef"); count = 1; /* .notdef */ @@ -322,7 +321,7 @@ do_builtin_encoding (pdf_font *font, const char *usedchars, sfnt *sfont) if (!usedchars[code]) continue; - if (verbose > 2) + if (dpx_conf.verbose_level > 2) MESG("/.c0x%02x", code); gid = tt_cmap_lookup(ttcm, code); @@ -340,7 +339,7 @@ do_builtin_encoding (pdf_font *font, const char *usedchars, sfnt *sfont) } tt_cmap_release(ttcm); - if (verbose > 2) + if (dpx_conf.verbose_level > 2) MESG("]"); if (tt_build_tables(sfont, glyphs) < 0) { @@ -360,7 +359,7 @@ do_builtin_encoding (pdf_font *font, const char *usedchars, sfnt *sfont) } do_widths(font, widths); - if (verbose > 1) + if (dpx_conf.verbose_level > 1) MESG("[%d glyphs]", glyphs->num_glyphs); tt_build_finish(glyphs); @@ -424,7 +423,7 @@ select_gsub (const char *feat, struct glyph_mapper *gm) if (idx >= 0) return 0; - if (verbose > 1) + if (dpx_conf.verbose_level > 1) MESG("\ntrutype>> Try loading OTL GSUB for \"*.*.%s\"...", feat); error = otl_gsub_add_feat(gm->gsub, "*", "*", feat, gm->sfont); if (!error) { @@ -564,7 +563,7 @@ findposttable (const char *glyph_name, USHORT *gid, struct glyph_mapper *gm) *gid = tt_lookup_post_table(gm->nametogid, glyph_name); #if 0 - if (verbose > 1) + if (dpx_conf.verbose_level > 1) { if (*gid > 0) MESG("%s =post=> 0x%04X\n", glyph_name, *gid); @@ -648,11 +647,11 @@ findparanoiac (const char *glyphname, USHORT *gid, struct glyph_mapper *gm) if (agln->n_components == 1) idx = tt_cmap_lookup(gm->codetogid, agln->unicodes[0]); else if (agln->n_components > 1) { - if (verbose >= 0) /* give warning */ + if (dpx_conf.verbose_level >= 0) /* give warning */ WARN("Glyph \"%s\" looks like a composite glyph...", agln->name); error = composeuchar(agln->unicodes, agln->n_components, NULL, gm, &idx); - if (verbose >= 0) { + if (dpx_conf.verbose_level >= 0) { if (error) WARN("Not found..."); else { @@ -829,7 +828,7 @@ do_custom_encoding (pdf_font *font, WARN("Glyph \"%s\" not available in font \"%s\".", encoding[code], pdf_font_get_ident(font)); } else { - if (verbose > 1) + if (dpx_conf.verbose_level > 1) MESG("truetype>> Glyph glyph-name=\"%s\" found at glyph-id=\"%u\".\n", encoding[code], gid); } idx = tt_find_glyph(glyphs, gid); @@ -859,7 +858,7 @@ do_custom_encoding (pdf_font *font, } do_widths(font, widths); - if (verbose > 1) + if (dpx_conf.verbose_level > 1) MESG("[%d glyphs]", glyphs->num_glyphs); tt_build_finish(glyphs); @@ -889,8 +888,6 @@ pdf_font_load_truetype (pdf_font *font) if (!pdf_font_is_in_use(font)) return 0; - verbose = pdf_font_get_verbose(); - fp = DPXFOPEN(ident, DPX_RES_TYPE_TTFONT); if (!fp) { fp = DPXFOPEN(ident, DPX_RES_TYPE_DFONT); @@ -986,7 +983,7 @@ pdf_font_load_truetype (pdf_font *font) if (fp) DPXFCLOSE(fp); - if (verbose > 1) + if (dpx_conf.verbose_level > 1) MESG("[%ld bytes]", pdf_stream_length(fontfile)); pdf_add_dict(descriptor, diff --git a/Build/source/texk/dvipdfm-x/tt_aux.c b/Build/source/texk/dvipdfm-x/tt_aux.c index 3d28b3ace07..61cf6e2d36f 100644 --- a/Build/source/texk/dvipdfm-x/tt_aux.c +++ b/Build/source/texk/dvipdfm-x/tt_aux.c @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002-2016 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2002-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. This program is free software; you can redistribute it and/or modify @@ -26,6 +26,7 @@ #include "mem.h" #include "error.h" #include "numbers.h" +#include "dpxconf.h" #include "pdfobj.h" @@ -34,13 +35,6 @@ #include "tt_post.h" #include "tt_aux.h" -static int verbose = 0; - -void tt_aux_set_verbose(void) -{ - ++verbose; -} - ULONG ttc_read_offset (sfnt *sfont, int ttc_idx) { ULONG offset = 0, num_dirs = 0; @@ -181,17 +175,17 @@ pdf_obj *tt_get_fontdesc (sfnt *sfont, int *embed, int stemv, int type, const ch /* the least restrictive license granted takes precedence. */ *embed = 1; } else if (os2->fsType & 0x0004) { - if (verbose > 0) + if (dpx_conf.verbose_level > 0) WARN("Font \"%s\" permits \"Preview & Print\" embedding only **\n", fontname); *embed = 1; } else { if (always_embed) { - if (verbose > 0) + if (dpx_conf.verbose_level > 0) WARN("Font \"%s\" may be subject to embedding restrictions **\n", fontname); *embed = 1; } else { - if (verbose > 0) + if (dpx_conf.verbose_level > 0) WARN("Embedding of font \"%s\" disabled due to license restrictions", fontname); *embed = 0; } diff --git a/Build/source/texk/dvipdfm-x/tt_aux.h b/Build/source/texk/dvipdfm-x/tt_aux.h index f7373cf4f84..33e8e7c2d95 100644 --- a/Build/source/texk/dvipdfm-x/tt_aux.h +++ b/Build/source/texk/dvipdfm-x/tt_aux.h @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002-2016 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2002-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. This program is free software; you can redistribute it and/or modify @@ -26,8 +26,6 @@ extern int always_embed; /* flag declared in dvipdfmx.c */ -extern void tt_aux_set_verbose(void); - /* TTC (TrueType Collection) */ extern ULONG ttc_read_offset (sfnt *sfont, int ttc_idx); diff --git a/Build/source/texk/dvipdfm-x/tt_cmap.c b/Build/source/texk/dvipdfm-x/tt_cmap.c index 533480c58ac..32ffc1a8dba 100644 --- a/Build/source/texk/dvipdfm-x/tt_cmap.c +++ b/Build/source/texk/dvipdfm-x/tt_cmap.c @@ -29,6 +29,7 @@ #include "system.h" #include "mem.h" #include "error.h" +#include "dpxconf.h" #include "sfnt.h" @@ -54,13 +55,6 @@ #include "tt_cmap.h" #define VERBOSE_LEVEL_MIN 0 -static int verbose = 0; -void -otf_cmap_set_verbose (void) -{ - otl_gsub_set_verbose(); - verbose++; -} /* format 0: byte encoding table */ struct cmap0 @@ -927,7 +921,7 @@ handle_subst_glyphs (CMap *cmap, } #undef MAX_UNICODES if (unicode_count == -1) { - if(verbose > VERBOSE_LEVEL_MIN) { + if(dpx_conf.verbose_level > VERBOSE_LEVEL_MIN) { if (name) MESG("No Unicode mapping available: GID=%u, name=%s\n", gid, name); else @@ -964,7 +958,7 @@ handle_subst_glyphs (CMap *cmap, CMap_add_bfchar(cmap, wbuf, 2, wbuf + 2, len); count++; - if (verbose > VERBOSE_LEVEL_MIN) { + if (dpx_conf.verbose_level > VERBOSE_LEVEL_MIN) { int _i; MESG("otf_cmap>> Additional ToUnicode mapping: <%04X> <", gid); @@ -1183,12 +1177,11 @@ otf_create_ToUnicode_stream (const char *font_name, CMap *cmap_add; int cmap_add_id; tt_cmap *ttcmap; - char *normalized_font_name; char *cmap_name, *cmap_add_name; FILE *fp = NULL; sfnt *sfont; ULONG offset = 0; - int i, cmap_type; + int i; cmap_name = NEW(strlen(basefont)+strlen("-UTF16")+1, char); sprintf(cmap_name, "%s-UTF16", basefont); @@ -1200,7 +1193,7 @@ otf_create_ToUnicode_stream (const char *font_name, return cmap_ref; } - if (verbose > VERBOSE_LEVEL_MIN) { + if (dpx_conf.verbose_level > VERBOSE_LEVEL_MIN) { MESG("\n"); MESG("otf_cmap>> Creating ToUnicode CMap for \"%s\"...\n", font_name); } @@ -1261,7 +1254,7 @@ otf_create_ToUnicode_stream (const char *font_name, } } #if defined(LIBDPX) - if (cmap_obj == NULL && verbose > VERBOSE_LEVEL_MIN) + if (cmap_obj == NULL && dpx_conf.verbose_level > VERBOSE_LEVEL_MIN) #else if (cmap_obj == NULL) #endif /* LIBDPX */ @@ -1364,7 +1357,7 @@ otf_load_Unicode_CMap (const char *map_name, int ttc_index, /* 0 for non-TTC fon sprintf(cmap_name, "%s,%03d-UCS4-H", map_name, ttc_index); } } - if (verbose > VERBOSE_LEVEL_MIN) { + if (dpx_conf.verbose_level > VERBOSE_LEVEL_MIN) { MESG("\n"); MESG("otf_cmap>> Unicode charmap for font=\"%s\" layout=\"%s\"\n", map_name, (otl_tags ? otl_tags : "none")); @@ -1372,7 +1365,7 @@ otf_load_Unicode_CMap (const char *map_name, int ttc_index, /* 0 for non-TTC fon cmap_id = CMap_cache_find(cmap_name); if (cmap_id >= 0) { RELEASE(cmap_name); - if (verbose > VERBOSE_LEVEL_MIN) + if (dpx_conf.verbose_level > VERBOSE_LEVEL_MIN) MESG("otf_cmap>> Found at cmap_id=%d.\n", cmap_id); return cmap_id; @@ -1455,7 +1448,7 @@ otf_load_Unicode_CMap (const char *map_name, int ttc_index, /* 0 for non-TTC fon if (!ttcmap) { ttcmap = tt_cmap_read(sfont, 0, 3); /* Unicode 2.0 or later */ #if defined(LIBDPX) - if (!ttcmap && verbose > VERBOSE_LEVEL_MIN) { + if (!ttcmap && dpx_conf.verbose_level > VERBOSE_LEVEL_MIN) { #else if (!ttcmap) { #endif /* LIBDPX */ @@ -1542,7 +1535,7 @@ otf_try_load_GID_to_CID_map (const char *map_name, int ttc_index, int wmode) cmap_id = CMap_cache_find(cmap_name); if (cmap_id >= 0) { RELEASE(cmap_name); - if (verbose > VERBOSE_LEVEL_MIN) + if (dpx_conf.verbose_level > VERBOSE_LEVEL_MIN) MESG("otf_cmap>> GID-to-CID mapping found at cmap_id=%d.\n", cmap_id); return cmap_id; @@ -1600,12 +1593,13 @@ otf_try_load_GID_to_CID_map (const char *map_name, int ttc_index, int wmode) if (GIDToCIDMap) { CMap *cmap; int32_t gid; + const unsigned char csrange[4] = {0x00, 0x00, 0xff, 0xff}; cmap = CMap_new(); CMap_set_name (cmap, cmap_name); CMap_set_type (cmap, CMAP_TYPE_CODE_TO_CID); CMap_set_wmode(cmap, wmode); - CMap_add_codespacerange(cmap, "\x00\x00", "\xff\xff", 2); + CMap_add_codespacerange(cmap, &csrange[0], &csrange[2], 2); CMap_set_CIDSysInfo(cmap, &csi); for (gid = 0; gid < 65536; gid++) { @@ -1615,7 +1609,7 @@ otf_try_load_GID_to_CID_map (const char *map_name, int ttc_index, int wmode) CMap_add_bfchar(cmap, src, 2, &GIDToCIDMap[gid*2], 2); } cmap_id = CMap_cache_add(cmap); - if (verbose > VERBOSE_LEVEL_MIN) { + if (dpx_conf.verbose_level > VERBOSE_LEVEL_MIN) { MESG("\n"); MESG("otf_cmap>> Creating GID-to-CID mapping for font=\"%s\"\n", map_name); } diff --git a/Build/source/texk/dvipdfm-x/tt_cmap.h b/Build/source/texk/dvipdfm-x/tt_cmap.h index be1ed6a4545..08333d6afb5 100644 --- a/Build/source/texk/dvipdfm-x/tt_cmap.h +++ b/Build/source/texk/dvipdfm-x/tt_cmap.h @@ -23,8 +23,6 @@ #include "sfnt.h" -extern void otf_cmap_set_verbose (void); - /* TrueType cmap table */ typedef struct { diff --git a/Build/source/texk/dvipdfm-x/tt_gsub.c b/Build/source/texk/dvipdfm-x/tt_gsub.c index 518d6dc5f4f..25a7b89a5bc 100644 --- a/Build/source/texk/dvipdfm-x/tt_gsub.c +++ b/Build/source/texk/dvipdfm-x/tt_gsub.c @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002-2017 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2002-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. This program is free software; you can redistribute it and/or modify @@ -31,19 +31,14 @@ #include "error.h" #include "mem.h" #include "mfileio.h" +#include "dpxconf.h" #include "sfnt.h" #include "otl_opt.h" #include "tt_gsub.h" -#define VERBOSE_LEVEL_MIN 0 -static int verbose = 0; -void -otl_gsub_set_verbose (void) -{ - verbose++; -} +#define VERBOSE_LEVEL_MIN 2 typedef USHORT Offset; typedef USHORT GlyphID; @@ -888,7 +883,7 @@ otl_gsub_read_feat (struct otl_gsub_tab *gsub, sfnt *sfont) script_tab.DefaultLangSys != 0) { struct clt_langsys_table langsys_tab; - if(verbose > VERBOSE_LEVEL_MIN) { + if(dpx_conf.verbose_level > VERBOSE_LEVEL_MIN) { MESG("otl_gsub>> OTL script-language enabled: %c%c%c%c.dflt\n", script_list.record[script_idx].tag[0], script_list.record[script_idx].tag[1], @@ -918,7 +913,7 @@ otl_gsub_read_feat (struct otl_gsub_tab *gsub, sfnt *sfont) if (otl_match_optrule(language, langsys_rec->tag)) { struct clt_langsys_table langsys_tab; - if(verbose > VERBOSE_LEVEL_MIN) { + if(dpx_conf.verbose_level > VERBOSE_LEVEL_MIN) { MESG("otl_gsub>> OTL script-language enabled: %c%c%c%c.%c%c%c%c\n", script_list.record[script_idx].tag[0], script_list.record[script_idx].tag[1], @@ -956,7 +951,7 @@ otl_gsub_read_feat (struct otl_gsub_tab *gsub, sfnt *sfont) sfnt_seek_set(sfont, offset); clt_read_number_list(&lookup_list, sfont); - if(verbose > VERBOSE_LEVEL_MIN) { + if(dpx_conf.verbose_level > VERBOSE_LEVEL_MIN) { MESG("otl_gsub>> Reading OTL feature(s):"); } @@ -968,7 +963,7 @@ otl_gsub_read_feat (struct otl_gsub_tab *gsub, sfnt *sfont) struct clt_feature_table feature_table; int i; - if(verbose > VERBOSE_LEVEL_MIN) { + if(dpx_conf.verbose_level > VERBOSE_LEVEL_MIN) { MESG(" %c%c%c%c", feature_list.record[feat_idx].tag[0], feature_list.record[feat_idx].tag[1], @@ -1004,7 +999,7 @@ otl_gsub_read_feat (struct otl_gsub_tab *gsub, sfnt *sfont) lookup_table.LookupType != OTL_GSUB_TYPE_ALTERNATE && lookup_table.LookupType != OTL_GSUB_TYPE_LIGATURE && lookup_table.LookupType != OTL_GSUB_TYPE_ESUBST) { - if (verbose > VERBOSE_LEVEL_MIN) + if (dpx_conf.verbose_level > VERBOSE_LEVEL_MIN) WARN("Skipping unsupported GSUB subtable: LookupType=%d", lookup_table.LookupType); continue; } @@ -1028,7 +1023,7 @@ otl_gsub_read_feat (struct otl_gsub_tab *gsub, sfnt *sfont) if (r <= 0) WARN("Reading GSUB subtable (single) failed..."); else { - if(verbose > VERBOSE_LEVEL_MIN) { + if(dpx_conf.verbose_level > VERBOSE_LEVEL_MIN) { MESG("(single)"); } n_st++; @@ -1041,7 +1036,7 @@ otl_gsub_read_feat (struct otl_gsub_tab *gsub, sfnt *sfont) if (r <= 0) WARN("Reading GSUB subtable (alternate) failed..."); else { - if(verbose > VERBOSE_LEVEL_MIN) { + if(dpx_conf.verbose_level > VERBOSE_LEVEL_MIN) { MESG("(alternate)"); } n_st++; @@ -1054,7 +1049,7 @@ otl_gsub_read_feat (struct otl_gsub_tab *gsub, sfnt *sfont) if (r <= 0) WARN("Reading GSUB subtable (ligature) failed..."); else { - if(verbose > VERBOSE_LEVEL_MIN) { + if(dpx_conf.verbose_level > VERBOSE_LEVEL_MIN) { MESG("(ligature)"); } n_st++; @@ -1081,7 +1076,7 @@ otl_gsub_read_feat (struct otl_gsub_tab *gsub, sfnt *sfont) if (r <= 0) WARN("Reading GSUB subtable (ext:single) failed..."); else { - if(verbose > VERBOSE_LEVEL_MIN) { + if(dpx_conf.verbose_level > VERBOSE_LEVEL_MIN) { MESG("(ext:single)"); } n_st++; @@ -1094,7 +1089,7 @@ otl_gsub_read_feat (struct otl_gsub_tab *gsub, sfnt *sfont) if (r <= 0) WARN("Reading GSUB subtable (alternate) failed..."); else { - if(verbose > VERBOSE_LEVEL_MIN) { + if(dpx_conf.verbose_level > VERBOSE_LEVEL_MIN) { MESG("(alternate)"); } n_st++; @@ -1107,7 +1102,7 @@ otl_gsub_read_feat (struct otl_gsub_tab *gsub, sfnt *sfont) if (r <= 0) WARN("Reading GSUB subtable (ext:ligature) failed..."); else { - if(verbose > VERBOSE_LEVEL_MIN) { + if(dpx_conf.verbose_level > VERBOSE_LEVEL_MIN) { MESG("(ext:ligature)"); } n_st++; @@ -1129,7 +1124,7 @@ otl_gsub_read_feat (struct otl_gsub_tab *gsub, sfnt *sfont) } } - if(verbose > VERBOSE_LEVEL_MIN) { + if(dpx_conf.verbose_level > VERBOSE_LEVEL_MIN) { MESG("\n"); MESG("otl_gsub>> %ld subtable(s) read.\n", num_subtabs); } @@ -1338,7 +1333,7 @@ otl_gsub_add_feat (otl_gsub *gsub_list, gsub->feature = NEW(strlen(feature) +1, char); strcpy(gsub->feature, feature); - if(verbose > VERBOSE_LEVEL_MIN) { + if(dpx_conf.verbose_level > VERBOSE_LEVEL_MIN) { MESG("\n"); MESG("otl_gsub>> Reading \"%s.%s.%s\"...\n", script, language, feature); } @@ -1348,7 +1343,7 @@ otl_gsub_add_feat (otl_gsub *gsub_list, gsub_list->select = i; gsub_list->num_gsubs++; } else { - if(verbose > VERBOSE_LEVEL_MIN) { + if(dpx_conf.verbose_level > VERBOSE_LEVEL_MIN) { MESG("otl_gsub>> Failed\n"); } RELEASE(gsub->script); diff --git a/Build/source/texk/dvipdfm-x/tt_gsub.h b/Build/source/texk/dvipdfm-x/tt_gsub.h index 89377df470c..2fd85ee8a5d 100644 --- a/Build/source/texk/dvipdfm-x/tt_gsub.h +++ b/Build/source/texk/dvipdfm-x/tt_gsub.h @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002-2017 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2002-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. This program is free software; you can redistribute it and/or modify @@ -24,8 +24,6 @@ #include "sfnt.h" #include "otl_opt.h" -extern void otl_gsub_set_verbose (void); - typedef struct otl_gsub otl_gsub; /* LookupType for GSUB */ diff --git a/Build/source/texk/dvipdfm-x/type0.c b/Build/source/texk/dvipdfm-x/type0.c index 919ed06a3ea..28fe907127f 100644 --- a/Build/source/texk/dvipdfm-x/type0.c +++ b/Build/source/texk/dvipdfm-x/type0.c @@ -35,6 +35,7 @@ #include "system.h" #include "mem.h" #include "error.h" +#include "dpxconf.h" #include "dpxfile.h" #include "pdfobj.h" @@ -49,16 +50,8 @@ #define TYPE0FONT_DEBUG_STR "Type0" #define TYPE0FONT_DEBUG 3 -static int __verbose = 0; - static pdf_obj *pdf_read_ToUnicode_file (const char *cmap_name); -void -Type0Font_set_verbose(void) -{ - __verbose++; -} - /* * used_chars: * @@ -149,41 +142,37 @@ Type0Font_clean (Type0Font *font) /* PLEASE FIX THIS */ #include "tt_cmap.h" -static pdf_obj * -Type0Font_create_ToUnicode_stream(Type0Font *font) { - CIDFont *cidfont = font->descendant; - return otf_create_ToUnicode_stream(CIDFont_get_ident(cidfont), - CIDFont_get_opt_index(cidfont), - CIDFont_get_fontname(cidfont), - Type0Font_get_usedchars(font)); -} - /* Try to load ToUnicode CMap from file system first, if not found fallback to * font CMap reverse lookup. * CHANGED: CMap here is not always Unicode to CID mapping. Don't use reverse lookup. */ static pdf_obj * Type0Font_try_load_ToUnicode_stream(Type0Font *font, char *cmap_base) { - char *cmap_name = NEW(strlen(cmap_base) + strlen("-UTF-16"), char); pdf_obj *tounicode; + char *cmap_name; + cmap_name = NEW(strlen(cmap_base)+strlen("-UTF16")+1, char); sprintf(cmap_name, "%s-UTF16", cmap_base); tounicode = pdf_read_ToUnicode_file(cmap_name); if (!tounicode) { sprintf(cmap_name, "%s-UCS2", cmap_base); tounicode = pdf_read_ToUnicode_file(cmap_name); } - RELEASE(cmap_name); - if (!tounicode) - tounicode = Type0Font_create_ToUnicode_stream(font); + if (!tounicode) { + CIDFont *cidfont = font->descendant; + tounicode = otf_create_ToUnicode_stream(CIDFont_get_ident(cidfont), + CIDFont_get_opt_index(cidfont), + CIDFont_get_fontname(cidfont), + Type0Font_get_usedchars(font)); + } return tounicode; } static void -add_ToUnicode (Type0Font *font) +Type0Font_attach_ToUnicode_stream (Type0Font *font) { pdf_obj *tounicode; CIDFont *cidfont; @@ -224,21 +213,32 @@ add_ToUnicode (Type0Font *font) csi = CIDFont_get_CIDSysInfo(cidfont); fontname = CIDFont_get_fontname(cidfont); if (CIDFont_get_embedding(cidfont)) { - fontname += 7; /* FIXME */ + fontname += 7; /* FIXME: Skip pseudo unique tag... */ } - if (!strcmp(csi->registry, "Adobe") && - !strcmp(csi->ordering, "Identity")) { + if (!strcmp(csi->registry, "Adobe") && !strcmp(csi->ordering, "Identity")) { switch (CIDFont_get_subtype(cidfont)) { case CIDFONT_TYPE2: - /* PLEASE FIX THIS */ - tounicode = Type0Font_create_ToUnicode_stream(font); + /* PLEASE FIX THIS */ + { + CIDFont *cidfont = font->descendant; + tounicode = otf_create_ToUnicode_stream(CIDFont_get_ident(cidfont), + CIDFont_get_opt_index(cidfont), + CIDFont_get_fontname(cidfont), + Type0Font_get_usedchars(font)); + } break; default: - if (CIDFont_get_flag(cidfont, CIDFONT_FLAG_TYPE1C)) { /* FIXME */ - tounicode = Type0Font_create_ToUnicode_stream(font); - } else if (CIDFont_get_flag(cidfont, CIDFONT_FLAG_TYPE1)) { /* FIXME */ - /* Font loader will create ToUnicode and set. */ + if (CIDFont_get_flag(cidfont, CIDFONT_FLAG_TYPE1C)) { + CIDFont *cidfont = font->descendant; + tounicode = otf_create_ToUnicode_stream(CIDFont_get_ident(cidfont), + CIDFont_get_opt_index(cidfont), + CIDFont_get_fontname(cidfont), + Type0Font_get_usedchars(font)); + } else if (CIDFont_get_flag(cidfont, CIDFONT_FLAG_TYPE1)) { + /* FIXME: handled on very different timing. + * Font loader will create ToUnicode and set. + */ return; } else { tounicode = Type0Font_try_load_ToUnicode_stream(font, fontname); @@ -257,7 +257,7 @@ add_ToUnicode (Type0Font *font) pdf_new_name("ToUnicode"), tounicode); } else { #if defined(LIBDPX) - if (__verbose) + if (dpx_conf.verbose_level > 0) WARN("Failed to load ToUnicode CMap for font \"%s\"", fontname); #else WARN("Failed to load ToUnicode CMap for font \"%s\"", fontname); @@ -282,8 +282,9 @@ Type0Font_dofont (Type0Font *font) if (!font || !font->indirect) return; - if (!pdf_lookup_dict(font->fontdict, "ToUnicode")) { /* FIXME */ - add_ToUnicode(font); + /* FIXME: Should move to pdffont.c */ + if (!pdf_lookup_dict(font->fontdict, "ToUnicode")) { + Type0Font_attach_ToUnicode_stream(font); } } @@ -485,7 +486,7 @@ Type0Font_cache_find (const char *map_name, int cmap_id, fontmap_opt *fmap_opt) */ fontname = CIDFont_get_fontname(cidfont); - if (__verbose) { + if (dpx_conf.verbose_level > 0) { if (CIDFont_get_embedding(cidfont) && strlen(fontname) > 7) MESG("(CID:%s)", fontname+7); /* skip XXXXXX+ */ else diff --git a/Build/source/texk/dvipdfm-x/type0.h b/Build/source/texk/dvipdfm-x/type0.h index 11ab0064327..0b6cc62ef29 100644 --- a/Build/source/texk/dvipdfm-x/type0.h +++ b/Build/source/texk/dvipdfm-x/type0.h @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002-2016 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2002-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. This program is free software; you can redistribute it and/or modify @@ -28,8 +28,6 @@ typedef struct Type0Font Type0Font; -extern void Type0Font_set_verbose (void); - extern int Type0Font_get_wmode (Type0Font *font); #if 0 extern char *Type0Font_get_encoding (Type0Font *font); diff --git a/Build/source/texk/dvipdfm-x/type1.c b/Build/source/texk/dvipdfm-x/type1.c index b713c2b58a2..23ab1914d06 100644 --- a/Build/source/texk/dvipdfm-x/type1.c +++ b/Build/source/texk/dvipdfm-x/type1.c @@ -30,7 +30,7 @@ #include "system.h" #include "mem.h" #include "error.h" - +#include "dpxconf.h" #include "dpxfile.h" #include "numbers.h" @@ -524,7 +524,7 @@ pdf_font_load_type1 (pdf_font *font) card16 *GIDMap, num_glyphs = 0; FILE *fp; int offset; - int code, verbose; + int code; ASSERT(font); @@ -532,8 +532,6 @@ pdf_font_load_type1 (pdf_font *font) return 0; } - verbose = pdf_font_get_verbose(); - encoding_id = pdf_font_get_encoding (font); fontdict = pdf_font_get_resource (font); @@ -639,7 +637,7 @@ pdf_font_load_type1 (pdf_font *font) if (gid < 0) ERROR("Type 1 font with no \".notdef\" glyph???"); GIDMap[0] = (card16) gid; - if (verbose > 2) + if (dpx_conf.verbose_level > 2) MESG("[glyphs:/.notdef"); num_glyphs = 1; for (prev = -2, code = 0; code <= 0xff; code++) { @@ -686,7 +684,7 @@ pdf_font_load_type1 (pdf_font *font) prev = code; num_glyphs++; - if (verbose > 2) { + if (dpx_conf.verbose_level > 2) { MESG("/%s", glyph); } #if !defined(LIBDPX) @@ -775,7 +773,7 @@ pdf_font_load_type1 (pdf_font *font) break; } if (i == num_glyphs) { - if (verbose > 2) + if (dpx_conf.verbose_level > 2) MESG("/%s", achar_name); GIDMap[num_glyphs++] = achar_gid; charset->data.glyphs[charset->num_entries] = cff_get_seac_sid(cffont, achar_name); @@ -794,7 +792,7 @@ pdf_font_load_type1 (pdf_font *font) break; } if (i == num_glyphs) { - if (verbose > 2) + if (dpx_conf.verbose_level > 2) MESG("/%s", bchar_name); GIDMap[num_glyphs++] = bchar_gid; charset->data.glyphs[charset->num_entries] = cff_get_seac_sid(cffont, bchar_name); @@ -823,7 +821,7 @@ pdf_font_load_type1 (pdf_font *font) cff_release_charsets(cffont->charsets); cffont->charsets = charset; } - if (verbose > 2) + if (dpx_conf.verbose_level > 2) MESG("]"); /* Now we can update the String Index */ @@ -838,7 +836,7 @@ pdf_font_load_type1 (pdf_font *font) #else offset = write_fontfile(font, cffont, pdfcharset); #endif /* LIBDPX */ - if (verbose > 1) + if (dpx_conf.verbose_level > 1) MESG("[%u glyphs][%ld bytes]", num_glyphs, offset); #if !defined(LIBDPX) diff --git a/Build/source/texk/dvipdfm-x/type1c.c b/Build/source/texk/dvipdfm-x/type1c.c index 777ca53929b..fb45f9c9422 100644 --- a/Build/source/texk/dvipdfm-x/type1c.c +++ b/Build/source/texk/dvipdfm-x/type1c.c @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2008-2016 by Jin-Hwan Cho, Matthias Franz, and Shunsaku Hirata, + Copyright (C) 2008-2018 by Jin-Hwan Cho, Matthias Franz, and Shunsaku Hirata, the dvipdfmx project team. Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -41,7 +41,7 @@ #include "system.h" #include "mem.h" #include "error.h" - +#include "dpxconf.h" #include "dpxfile.h" #include "pdfobj.h" @@ -258,12 +258,9 @@ pdf_font_load_type1c (pdf_font *font) cs_ginfo ginfo; double nominal_width, default_width, notdef_width; double widths[256]; - int verbose; ASSERT(font); - verbose = pdf_font_get_verbose(); - if (!pdf_font_is_in_use(font)) { return 0; } @@ -437,7 +434,7 @@ pdf_font_load_type1c (pdf_font *font) /* First we add .notdef glyph. * All Type 1 font requires .notdef glyph to be present. */ - if (verbose > 2) { + if (dpx_conf.verbose_level > 2) { MESG("[glyphs:/.notdef"); } size = cs_idx->offset[1] - cs_idx->offset[0]; @@ -511,7 +508,7 @@ pdf_font_load_type1c (pdf_font *font) pdf_add_stream(pdfcharset, "/", 1); pdf_add_stream(pdfcharset, enc_vec[code], strlen(enc_vec[code])); - if (verbose > 2) { + if (dpx_conf.verbose_level > 2) { MESG("/%s", enc_vec[code]); } @@ -537,7 +534,7 @@ pdf_font_load_type1c (pdf_font *font) charset->num_entries += 1; num_glyphs++; } - if (verbose > 2) { + if (dpx_conf.verbose_level > 2) { MESG("]"); } RELEASE(data); @@ -725,7 +722,7 @@ pdf_font_load_type1c (pdf_font *font) if (fp) DPXFCLOSE(fp); - if (verbose > 1) { + if (dpx_conf.verbose_level > 1) { MESG("[%u/%u glyphs][%ld bytes]", num_glyphs, cs_count, offset); } diff --git a/Build/source/texk/dvipdfm-x/vf.c b/Build/source/texk/dvipdfm-x/vf.c index a2b1a60f26a..b046b665b56 100644 --- a/Build/source/texk/dvipdfm-x/vf.c +++ b/Build/source/texk/dvipdfm-x/vf.c @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2007-2016 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -28,7 +28,7 @@ #include "numbers.h" #include "error.h" #include "mem.h" - +#include "dpxconf.h" #include "dpxfile.h" /* pdfdev... */ #include "pdfdev.h" @@ -47,13 +47,6 @@ #define TEXPT2PT (72.0/72.27) #define FW2PT (TEXPT2PT/((double)(FIX_WORD_BASE))) -static unsigned char verbose = 0; - -void vf_set_verbose(void) -{ - if (verbose < 255) verbose++; -} - struct font_def { int32_t font_id /* id used internally in vf file */; uint32_t checksum, size, design_size; @@ -269,9 +262,9 @@ int vf_locate_font (const char *tex_name, spt_t ptsize) } if (full_vf_file_name && (vf_file = MFOPEN (full_vf_file_name, FOPEN_RBIN_MODE)) != NULL) { - if (verbose == 1) + if (dpx_conf.verbose_level == 1) fprintf (stderr, "(VF:%s", tex_name); - if (verbose > 1) + if (dpx_conf.verbose_level > 1) fprintf (stderr, "(VF:%s", full_vf_file_name); if (num_vf_fonts >= max_vf_fonts) { resize_vf_fonts (max_vf_fonts + VF_ALLOC_SIZE); @@ -287,7 +280,7 @@ int vf_locate_font (const char *tex_name, spt_t ptsize) } read_header(vf_file, thisfont); process_vf_file (vf_file, thisfont); - if (verbose) + if (dpx_conf.verbose_level > 0) fprintf (stderr, ")"); MFCLOSE (vf_file); } @@ -391,7 +384,7 @@ static void vf_xxx (int32_t len, unsigned char **start, unsigned char *end) * Warning message from virtual font. */ if (!memcmp((char *)p, "Warning:", 8)) { - if (verbose) + if (dpx_conf.verbose_level > 0) WARN("VF:%s", p+8); } else { dvi_do_special(buffer, len); diff --git a/Build/source/texk/dvipdfm-x/vf.h b/Build/source/texk/dvipdfm-x/vf.h index 8a9f9aee4b3..5c808fd63d3 100644 --- a/Build/source/texk/dvipdfm-x/vf.h +++ b/Build/source/texk/dvipdfm-x/vf.h @@ -1,6 +1,6 @@ /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002-2016 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2002-2018 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team. Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -25,7 +25,6 @@ #include "pdfdev.h" -extern void vf_set_verbose (void); extern int vf_locate_font (const char *tex_name, spt_t ptsize); extern void vf_set_char (int32_t ch, int vf_font); extern void vf_close_all_fonts(void); diff --git a/Build/source/texk/dvipdfm-x/xbb.c b/Build/source/texk/dvipdfm-x/xbb.c index 3541c8d1f20..04a0ed3dc9c 100644 --- a/Build/source/texk/dvipdfm-x/xbb.c +++ b/Build/source/texk/dvipdfm-x/xbb.c @@ -24,6 +24,7 @@ #include <time.h> #include <string.h> +#include "dpxconf.h" #include "dpxutil.h" #include "numbers.h" @@ -44,15 +45,7 @@ #include "dvipdfmx.h" #include "pdflimits.h" -static int PageBox = 0; -/* - PageBox=0 :default - PageBox=1 :cropbox - PageBox=2 :mediabox - PageBox=3 :artbox - PageBox=4 :trimbox - PageBox=5 :bleedbox -*/ +static enum pdf_page_boundary PageBox = pdf_page_boundary__auto; static int Include_Page = 1; @@ -90,8 +83,6 @@ static void usage(void) exit(1); } -static char verbose = 0; - static void do_time(FILE *file) { time_t current_time; @@ -133,7 +124,7 @@ static char *make_xbb_filename(const char *name) strncpy(result, name, strlen(name)-strlen(extensions[i])); result[strlen(name)-strlen(extensions[i])] = 0; } - strcat(result, (compat_mode ? ".bb" : ".xbb")); + strcat(result, ((dpx_conf.compat_mode == dpx_mode_compat_mode) ? ".bb" : ".xbb")); return result; } @@ -160,7 +151,7 @@ static void write_xbb(char *fname, #endif } - if (verbose) { + if (dpx_conf.verbose_level > 0) { MESG("Writing to %s: ", xbb_to_file ? outname : "stdout"); MESG("Bounding box: %d %d %d %d\n", bbllx, bblly, bburx, bbury); } @@ -169,7 +160,7 @@ static void write_xbb(char *fname, fprintf(fp, "%%%%Creator: extractbb %s\n", VERSION); fprintf(fp, "%%%%BoundingBox: %d %d %d %d\n", bbllx, bblly, bburx, bbury); - if (!compat_mode) { + if (dpx_conf.compat_mode != dpx_mode_compat_mode) { /* Note: * According to Adobe Technical Note #5644, the arguments to * "%%HiResBoundingBox:" must be of type real. And according @@ -326,11 +317,11 @@ int extractbb (int argc, char *argv[]) exit(0); case 'B': - if (strcasecmp (optarg, "cropbox") == 0) PageBox = 1; - else if (strcasecmp (optarg, "mediabox") == 0) PageBox = 2; - else if (strcasecmp (optarg, "artbox") == 0) PageBox = 3; - else if (strcasecmp (optarg, "trimbox") == 0) PageBox = 4; - else if (strcasecmp (optarg, "bleedbox") == 0) PageBox = 5; + if (strcasecmp (optarg, "cropbox") == 0) PageBox = pdf_page_boundary_cropbox; + else if (strcasecmp (optarg, "mediabox") == 0) PageBox = pdf_page_boundary_mediabox; + else if (strcasecmp (optarg, "artbox") == 0) PageBox = pdf_page_boundary_artbox; + else if (strcasecmp (optarg, "trimbox") == 0) PageBox = pdf_page_boundary_trimbox; + else if (strcasecmp (optarg, "bleedbox") == 0) PageBox = pdf_page_boundary_bleedbox; else { fprintf(stderr, "%s: Invalid argument \"-B %s\"", my_name, optarg); usage(); @@ -343,8 +334,11 @@ int extractbb (int argc, char *argv[]) Include_Page = 1; break; - case 'q': case 'v': - verbose = c == 'v'; + case 'q': + dpx_conf.verbose_level = 0; + break; + case 'v': + dpx_conf.verbose_level++; break; case 'O': @@ -352,8 +346,11 @@ int extractbb (int argc, char *argv[]) case 'b': /* Ignored for backward compatibility */ break; - case 'm': case 'x': - compat_mode = c == 'm'; + case 'm': + dpx_conf.compat_mode = dpx_mode_compat_mode; + break; + case 'x': + dpx_conf.compat_mode = dpx_mode_normal_mode; break; default: |