summaryrefslogtreecommitdiff
path: root/Build/source/texk
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk')
-rw-r--r--Build/source/texk/README3
-rw-r--r--Build/source/texk/dvipdfmx/ChangeLog263
-rwxr-xr-xBuild/source/texk/dvipdfmx/configure16
-rw-r--r--Build/source/texk/dvipdfmx/configure.in3
-rw-r--r--Build/source/texk/dvipdfmx/data/Makefile.am2
-rw-r--r--Build/source/texk/dvipdfmx/data/Makefile.in2
-rw-r--r--Build/source/texk/dvipdfmx/data/dvipdfmx.cfg31
-rw-r--r--Build/source/texk/dvipdfmx/src/Makefile.am13
-rw-r--r--Build/source/texk/dvipdfmx/src/Makefile.in169
-rw-r--r--Build/source/texk/dvipdfmx/src/cid.c7
-rw-r--r--Build/source/texk/dvipdfmx/src/cid_p.h3
-rw-r--r--Build/source/texk/dvipdfmx/src/cidtype0.c26
-rw-r--r--Build/source/texk/dvipdfmx/src/cidtype2.c36
-rw-r--r--Build/source/texk/dvipdfmx/src/cmap.c21
-rw-r--r--Build/source/texk/dvipdfmx/src/cmap_read.c11
-rw-r--r--Build/source/texk/dvipdfmx/src/dpxfile.c125
-rw-r--r--Build/source/texk/dvipdfmx/src/dpxfile.h8
-rw-r--r--Build/source/texk/dvipdfmx/src/dvipdfmx.c130
-rw-r--r--Build/source/texk/dvipdfmx/src/epdf.c301
-rw-r--r--Build/source/texk/dvipdfmx/src/fontmap.c197
-rw-r--r--Build/source/texk/dvipdfmx/src/fontmap.h9
-rw-r--r--Build/source/texk/dvipdfmx/src/mem.c201
-rw-r--r--Build/source/texk/dvipdfmx/src/mem.h49
-rw-r--r--Build/source/texk/dvipdfmx/src/mpost.c101
-rw-r--r--Build/source/texk/dvipdfmx/src/otl_conf.c26
-rw-r--r--Build/source/texk/dvipdfmx/src/pdfcolor.c210
-rw-r--r--Build/source/texk/dvipdfmx/src/pdfcolor.h16
-rw-r--r--Build/source/texk/dvipdfmx/src/pdfdev.c188
-rw-r--r--Build/source/texk/dvipdfmx/src/pdfdev.h9
-rw-r--r--Build/source/texk/dvipdfmx/src/pdfdoc.c121
-rw-r--r--Build/source/texk/dvipdfmx/src/pdfdoc.h8
-rw-r--r--Build/source/texk/dvipdfmx/src/pdfdraw.c335
-rw-r--r--Build/source/texk/dvipdfmx/src/pdfencoding.c21
-rw-r--r--Build/source/texk/dvipdfmx/src/pdfencrypt.c14
-rw-r--r--Build/source/texk/dvipdfmx/src/pdffont.c35
-rw-r--r--Build/source/texk/dvipdfmx/src/pdffont.h8
-rw-r--r--Build/source/texk/dvipdfmx/src/pdfobj.c1217
-rw-r--r--Build/source/texk/dvipdfmx/src/pdfobj.h20
-rw-r--r--Build/source/texk/dvipdfmx/src/pdfparse.c51
-rw-r--r--Build/source/texk/dvipdfmx/src/pdfparse.h8
-rw-r--r--Build/source/texk/dvipdfmx/src/pdfximage.c97
-rw-r--r--Build/source/texk/dvipdfmx/src/pdfximage.h7
-rw-r--r--Build/source/texk/dvipdfmx/src/pst.c5
-rw-r--r--Build/source/texk/dvipdfmx/src/pst_obj.c178
-rw-r--r--Build/source/texk/dvipdfmx/src/sfnt.c63
-rw-r--r--Build/source/texk/dvipdfmx/src/sfnt.h5
-rw-r--r--Build/source/texk/dvipdfmx/src/spc_color.c18
-rw-r--r--Build/source/texk/dvipdfmx/src/spc_dvips.c8
-rw-r--r--Build/source/texk/dvipdfmx/src/spc_html.c4
-rw-r--r--Build/source/texk/dvipdfmx/src/spc_misc.c4
-rw-r--r--Build/source/texk/dvipdfmx/src/spc_pdfm.c132
-rw-r--r--Build/source/texk/dvipdfmx/src/spc_util.c44
-rw-r--r--Build/source/texk/dvipdfmx/src/spc_util.h4
-rw-r--r--Build/source/texk/dvipdfmx/src/subfont.c4
-rw-r--r--Build/source/texk/dvipdfmx/src/system.h6
-rw-r--r--Build/source/texk/dvipdfmx/src/t1_load.c5
-rw-r--r--Build/source/texk/dvipdfmx/src/tfm.c4
-rw-r--r--Build/source/texk/dvipdfmx/src/truetype.c96
-rw-r--r--Build/source/texk/dvipdfmx/src/tt_aux.c17
-rw-r--r--Build/source/texk/dvipdfmx/src/tt_aux.h4
-rw-r--r--Build/source/texk/dvipdfmx/src/tt_cmap.c19
-rw-r--r--Build/source/texk/dvipdfmx/src/tt_glyf.c8
-rw-r--r--Build/source/texk/dvipdfmx/src/tt_table.c106
-rw-r--r--Build/source/texk/dvipdfmx/src/type1.c45
-rw-r--r--Build/source/texk/dvipdfmx/src/type1c.c34
-rw-r--r--Build/source/texk/dvipdfmx/src/vf.c4
-rw-r--r--Build/source/texk/dvipdfmx/src/xbb.c359
-rw-r--r--Build/source/texk/dvipdfmx/src/xbb.h31
68 files changed, 2971 insertions, 2354 deletions
diff --git a/Build/source/texk/README b/Build/source/texk/README
index f3f66ab1557..7e6312ccba7 100644
--- a/Build/source/texk/README
+++ b/Build/source/texk/README
@@ -39,9 +39,8 @@ dviljk - Joachim Schrod
dvipdfm - now moribund, but until dvipdfmx is a 100% replacement we
cannot drop it.
-dvipdfmx 20070518 - ok 21apr08
+dvipdfmx 20080520 - ok 21may08
http://project.ktug.or.kr/dvipdfmx/snapshot/current/
- -> http://www.ctan.org/tex-archive/dviware/dvipdfmx/
dvipdfmx@project.ktug.or.kr (ChoF, Hirata, Matthias)
dvipng 1.11 - ok 15may08
diff --git a/Build/source/texk/dvipdfmx/ChangeLog b/Build/source/texk/dvipdfmx/ChangeLog
index 1bb32cc4c8c..febf3a6fdd7 100644
--- a/Build/source/texk/dvipdfmx/ChangeLog
+++ b/Build/source/texk/dvipdfmx/ChangeLog
@@ -1,35 +1,258 @@
-$Header: /home/cvsroot/dvipdfmx/ChangeLog,v 1.162 2007/11/15 17:08:52 chofchof Exp $
+$Header: /home/cvsroot/dvipdfmx/ChangeLog,v 1.201 2008/05/20 13:05:14 matthias Exp $
+
ChangeLog: Changes for dvipdfmx
===============================
-2008-04-26 Vladimir Volovich <vvv@vsu.ru>
+2008-05-20 Matthias Franz
+
+ * dvipdfmx.c, pdfdoc.c, pdfdoc.h, pdfobj.c, pdfobj.h:
+ Polished object stream code; removed command line option flag
+ 0x10 (no object streams).
+
+2008-05-20 Jin-Hwan Cho <chofchof@ktug.or.kr>
+
+ * contrib/latex/dvipdfmx.def.sample:
+ Fix ithe problem when including a PDF image with bounding box
+ having nonzero llx or nonzero lly.
+
+2008-05-18 Jin-Hwan Cho <chofchof@ktug.or.kr>
+
+ * pdffont.c, pdffont.h, type1.c, type1c.c, truetype.c:
+ Fix the problem with MusiXTeX's Type1 fonts. Some characters
+ of these fonts have different widths from the corresponding
+ TFM files; reported by Yasuhiro Okazaki and Jean-Pierre Coulon.
+ DVIPDFMx now reads character width from TFM if found.
+ Otherwise, the information comes from the font file.
+ However, Type0 fonts (not simple fonts) do not refer to TFM.
+
+2008-05-18 Matthias Franz
+
+ * epdf.c, pdfobj.c, pdfobj.h, xbb.c:
+ Added PDF 1.5 parsing. Note that many PDF 1.5 files have
+ compressed xref streams with DecodeParms entry. Since we
+ don't support this, we cannot read these files.
+
+ * epdf.c:
+ Allow page import from tagged PDF files. Tags are ignored.
+
+2008-05-18 Jin-Hwan Cho <chofchof@ktug.or.kr>
+
+ * dvipdfmx.c, dpxfile.c, dpxfile.h, otl_conf.c, spc_pdfm.c, system.h:
+ Arranged MiKTeX related codes according to MiKTeX SVN repository.
+
+ * fontmap.c, fontmap.h, pdfdev.c, pdffont.c:
+ Ignore obsolete remap option -r in DVIPDFM fontmaps.
+
+2008-05-17 Jin-Hwan Cho <chofchof@ktug.or.kr>
+
+ * dvipdfmx.c, xbb.c, xbb.h, src/Makefile.am, src/Makefile.in, contrib/latex/dvipdfmx.def.sample:
+ DVIPDFMx now extracts bounding box information.
+ The binary dvipdfmx can be linked as extractbb, ebb, xbb, and
+ it works as same as the linked name. (extractbb == xbb)
+ This idea was suggested by Karl Berry.
+
+2008-05-17 Jin-Hwan Cho <chofchof@ktug.or.kr>
+
+ * Makefile.in, aclocal.m4:
+ Remove acinclude.m4. Give a new tag DVIPDFMX-20080517.
+
+ * cid.c, cidtype0.c, cid_p.h, truetype.c, cidtype2.c, fontmap.c, fontmap.h, tt_aux.c, tt_aux.h, type1c.c:
+ New fontmap option '-v' to give StemV value explicitly;
+ especially for Chinese truetype fonts, e.g., Simsun;
+ this feature was suggested by Yue Wang.
+
+ * dvipdfmx.def:
+ Support automatic generation of .xbb if -shell-escape is given.
+ Don't forget to replace $TEXMF/tex/latex/dvipdfmx/dvipdfmx.def
+ to contrib/latex/dvipdfmx.def.sample.
+
+ * mpost.c:
+ Support MPS files generated by MetaFun.
+
+ * pdfximage.c:
+ Try distiller specified in the configuration file
+ if interpreting MPS file fails.
+
+2008-05-16 Matthias Franz
+
+ * pdfobj.c:
+ Fixed incorrect size entry in xref stream dictionary.
+
+ * pdfparse.c:
+ Fixed a bug in hex string parsing.
+
+2008-05-16 Jin-Hwan Cho <chofchof@ktug.or.kr>
+
+ * dvipdfmx.c, spc_pdfm.c, dpxfile.c, otl_conf.c:
+ Restore the application name from "dvipdfm" to "dvidpfmx".
+ Notice that "dvipdfmx.cfg" must be located in "$TEXMF/dvipdfmx".
+
+ * dvipdfmx.c, fontmap.c, fontmap.h, spc_pdfm.c:
+ Support font mapping files with DVIPS/pdfTeX format.
+
+2008-05-13 Matthias Franz
+
+ * cid.c, dvipdfmx.c, epdf.c, mpost.c, pdfencoding.c, pdfobj.c, pdfobj.h, pdfparse.c, pdfparse.h, pdfximage.c, pdfximage.h, spc_pdfm.c, xbb.c:
+ Changed code for PDF import so that objects are not duplicated
+ if they are imported through several pages of the same file.
+ Some PDF parsing functions now take an additional argument
+ of type pdf_file. If this is NULL, them indirect references
+ are not accepted.
+
+2008-05-10 Jin-Hwan Cho <chofchof@ktug.or.kr>
+
+ * dpxfile.c, pdffont.c:
+ Support Mac OS X Resource Fork Font (/rsrc) with TrueType outlines.
+
+2008-05-09 Jin-Hwan Cho <chofchof@ktug.or.kr>
+
+ * truetype.c, cidtype0.c, cidtype2.c, pdffont.c, pdffont.h, sfnt.c, sfnt.h, tt_glyf.c, tt_cmap.c, tt_table.c, tt_aux.c, dpxfile.c, dpxfile.h:
+ Support Mac OS X Data Fork Font (.dfont) with TrueType outlines.
+
+2008-05-08 Jin-Hwan Cho <chofchof@ktug.or.kr>
- * src/pdfencoding.c,
- * src/pdfobj.c: no declarations after statements.
+ * cidtype0.c, cidtype2.c, tt_aux.c, tt_table.c:
+ Support Mac TrueType fonts without OS/2 table.
-2008-04-26 Karl Berry <karl@tug.org>
+2008-04-28 Matthias Franz
- * src/Makefile.am: xbb needs zlib too.
+ * src/pdfencoding.c, src/pdfobj.c:
+ No declarations after statements allowed in C89.
+ (contributed by Vladimir Volovich <vvv at vsu.ru> via Karl Berry)
-2008-04-07 Peter Breitenlohner <peb@mppmu.mpg.de>
+ * src/Makefile.am:
+ xbb needs zlib too.
+ (contributed by Karl Berry <karl at tug.org>)
- * m4/maw-kpse.m4, maw-libs.m4 (removed): renamed ...
- * m4/chi-kpse.m4, cho-libs.m4 (new): ... into these; these
- files are the same as in ../xdvipdfmx.
- * configure.in: use new names.
+ * m4/maw-kpse.m4, maw-libs.m4 (removed):
+ Renamed ...
+ * m4/chi-kpse.m4, cho-libs.m4 (new):
+ ... into these.
+ * Makefile.am:
+ Added `ACLOCAL_AMFLAGS -I m4'.
+ * configure.in:
+ Use new names; respect library dependencies; moved macro
+ definitions ...
+ * m4/maw-time.m4 (new):
+ ... to here.
+ * acinclude.m4 (removed):
+ Moved macro definitions ...
+ * m4/maw-kpse.m4, maw-libs.m4 (both new):
+ ... to here.
+ (all contributed by Peter Breitenlohner <peb at mppmu.mpg.de>
+ via Karl Berry)
-2008-04-06 Peter Breitenlohner <peb@mppmu.mpg.de>
+2008-03-01 Matthias Franz
- * configure.in: respect library dependencies.
+ * dvipdfmx.def:
+ Write bounding box information only if necessary.
-2008-03-04 Peter Breitenlohner <peb@mppmu.mpg.de>
+ * dvipdfmx.def, spc_util.c:
+ New 'clip' parameter for 'pdf:epdf' and 'pdf:image'
+ specials. 'clip 1' enables clipping (default),
+ 'clip 0' disables it.
+
+2008-02-13 Matthias Franz
+
+ * dvipdfmx.def, epdf.c, pdfdoc.c, pdfximage.c, pdfximage.h, spc_dvips.c, spc_html.c, spc_misc.c, spc_pdfm.c, spc_util.c, spc_util.h:
+ Added new 'page' parameter to PDF and PS inclusion. This
+ can be used with the graphicx package and the (experimental)
+ graphics driver dvipdfmx.def (see contrib/latex). Example:
+
+ \includegraphics[page=4]{a.pdf}
+
+ Page numbers can also be negative; the last page is -1.
+
+ Remarks:
+ 1) Currently PDF objects may be duplicated in the output
+ if several pages are included from the same file.
+ -- done (2008-05-13)
+ 2) The graphicx package currently uses the same bounding
+ box information (that of the first page) for all pages.
+
+2008-02-13 Jin-Hwan Cho <chofchof@ktug.or.kr>
+
+ * acinclude.m4, aclocal.m4, configure.in, configure:
+ Karl Berry reports configure fixes for TeXLive.
+
+ * pdfencoding.c, pdffont.c:
+ Fix an encoding bug by the MinionPro package;
+ reported by Juho Lee.
+
+2008-02-12 Matthias Franz
+
+ * pdfencrypt.c:
+ Encrypted PDF files with key lengths strictly between
+ 40 and 128 bits could not be opened. Changed code to
+ meet Adobe Reader's behaviour for revision 3 (PDF 1.4)
+ encryption.
+
+2008-02-08 Matthias Franz
+
+ * epdf.c, pdfobj.c:
+ Improved PDF document parsing: pages without contents,
+ undefined indirect references and media boxes with
+ indirect references are now allowed. (Undefined
+ indirect references are needed for documents with
+ several cross-reference tables if the trailer contains
+ a reference to an object outside the part of the
+ xref table seen so far.)
+
+2008-01-11 Matthias Franz
+
+ * dvipdfmx.c:
+ Fixed a bug in processing DVI comments.
+
+ * cmap_read.c, pst.c, pst_obj.c , t1_load.c:
+ Fixed a bug in postscript number parsing; reported
+ by Ulrike Fischer.
+
+2008-01-06 Matthias Franz
+
+ * type1.c, type1c.c:
+ Fixed a bug in the computation of glyph width arrays
+ for Type1 and Type1C font dictionaries; reported by
+ Ulrike Fischer.
+
+2007-12-05 Jin-Hwan Cho <chofchof@ktug.or.kr>
+
+ * spc_pdfm.c:
+ Fixed a memory deallocation problem in the ConTeXt sample of
+ Francesco Pretto.
+
+2007-12-03 Jin-Hwan Cho <chofchof@ktug.or.kr>
+
+ * cmap.c:
+ Code mappings in CMap may overlap, but succeeding maps
+ superceded preceding maps; reported and patched by Luo Jie.
+
+2007-11-27 Jin-Hwan Cho <chofchof@ktug.or.kr>
+
+ * pdfdev.c:
+ Restored the DVIPDFM code for calculation of kerns;
+ reported by Keiichirou Shikano.
+
+2007-11-22 Jin-Hwan Cho <chofchof@ktug.or.kr>
+
+ * pdfdev.c:
+ Fixed a bug related to calculate kern; reported by
+ Keiichirou Shikano.
+
+ * spc_util.c:
+ Fixed a memory deallocation bug.
+
+2007-11-18 Matthias Franz
+
+ * vf.c:
+ Fixed small memory leak.
+
+2007-11-17 Matthias Franz
+
+ * pdfobj.c:
+ Suppress unnecessary white-space in PDF arrays.
- * Makefile.am: added `ACLOCAL_AMFLAGS -I m4'
- * configure.in: moved macro definitions ...
- * m4/maw-time.m4 (new): ... to here
- * acinclude.m4 (removed): moved macro definitions ...
- * m4/maw-kpse.m4, maw-libs.m4 (both new): ... to here; these
- files are the same as in ../xdvipdfmx.
+ * dpxfile.c, dvipdfmx.c, mem.c, mem.h, tfm.c, xbb.c:
+ Fixed some small memory leaks.
2007-11-15 Jin-Hwan Cho <chofchof@ktug.or.kr>
diff --git a/Build/source/texk/dvipdfmx/configure b/Build/source/texk/dvipdfmx/configure
index 701c6114da5..9cb49f2eec6 100755
--- a/Build/source/texk/dvipdfmx/configure
+++ b/Build/source/texk/dvipdfmx/configure
@@ -2198,7 +2198,7 @@ fi
# Define the identity of the package.
PACKAGE=dvipdfmx
- VERSION=20071115
+ VERSION=20080520
cat >>confdefs.h <<_ACEOF
@@ -3601,6 +3601,20 @@ if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" != yes"; then
fi
+# FIXME: we rely on the cache variable name because
+# there is no other way.
+set dummy $CC
+ac_cc=`echo $2 | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'`
+if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" != yes"; then
+ # Losing compiler, so override with the script.
+ # FIXME: It is wrong to rewrite CC.
+ # But if we don't then we get into trouble of one sort or another.
+ # A longer-term fix would be to have automake use am__CC in this case,
+ # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
+ CC="$am_aux_dir/compile $CC"
+fi
+
+
# Find a good install program. We prefer a C program (faster),
# so one script is as good as another. But avoid the broken or
# incompatible versions:
diff --git a/Build/source/texk/dvipdfmx/configure.in b/Build/source/texk/dvipdfmx/configure.in
index 80a1c6a7fd7..cc308538956 100644
--- a/Build/source/texk/dvipdfmx/configure.in
+++ b/Build/source/texk/dvipdfmx/configure.in
@@ -1,12 +1,13 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(src/dvipdfmx.c)
-AM_INIT_AUTOMAKE(dvipdfmx, 20071115)
+AM_INIT_AUTOMAKE(dvipdfmx, 20080520)
AM_CONFIG_HEADER(config.h)
AM_MAINTAINER_MODE
dnl Checks for programs.
AC_PROG_CC
AM_PROG_CC_C_O
+AM_PROG_CC_C_O
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
diff --git a/Build/source/texk/dvipdfmx/data/Makefile.am b/Build/source/texk/dvipdfmx/data/Makefile.am
index d0f7dba3753..fdc28c47d7e 100644
--- a/Build/source/texk/dvipdfmx/data/Makefile.am
+++ b/Build/source/texk/dvipdfmx/data/Makefile.am
@@ -1,4 +1,4 @@
-configdatadir = $(datadir)/texmf/dvipdfm
+configdatadir = $(datadir)/texmf/dvipdfmx
dist_configdata_DATA = \
$(srcdir)/dvipdfmx.cfg
diff --git a/Build/source/texk/dvipdfmx/data/Makefile.in b/Build/source/texk/dvipdfmx/data/Makefile.in
index 96b615d127a..8baab556fde 100644
--- a/Build/source/texk/dvipdfmx/data/Makefile.in
+++ b/Build/source/texk/dvipdfmx/data/Makefile.in
@@ -159,7 +159,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-configdatadir = $(datadir)/texmf/dvipdfm
+configdatadir = $(datadir)/texmf/dvipdfmx
dist_configdata_DATA = \
$(srcdir)/dvipdfmx.cfg
diff --git a/Build/source/texk/dvipdfmx/data/dvipdfmx.cfg b/Build/source/texk/dvipdfmx/data/dvipdfmx.cfg
index 1b960e60cee..9b884bbff3a 100644
--- a/Build/source/texk/dvipdfmx/data/dvipdfmx.cfg
+++ b/Build/source/texk/dvipdfmx/data/dvipdfmx.cfg
@@ -37,7 +37,6 @@
%%
%% papersize-spec is 'paper-format' or length-pair, e.g., 'a4', 'letter',
%% '20cm,30cm'. Recognized unit is 'cm', 'mm', 'bp', 'pt', 'in'.
-%%
p a4
@@ -49,7 +48,9 @@ p a4
%% TeX macro packages set the annotation bounding box equal to the TeX box
%% that encloses the material. That's not always what you want.
%% Annotations created by pdf:bannot/pdf:eannot is also affected.
-%%
+
+%g 1
+
%% Bookmark Open Level:
%%
%% O integer
@@ -58,10 +59,8 @@ p a4
%% of that item (from root node) is less than or equal to the integer
%% specified with this option.
-g 1
O 0
-%%
%% PDF Security (Encryption) Setting
%%
%% Those options won't take effects unless you use flag 'S'.
@@ -101,7 +100,6 @@ K 40
P 0x003C
-%%
%% Image Handler
%%
%% Command-line template for a-to-b conversion:
@@ -116,7 +114,7 @@ P 0x003C
%% %b The "base" name of the input file, e.g., "foo" instead of
%% "foo.eps".
%% %% Replaced with single '%'.
-
+%%
%% *Examples* for GhostScript (PS-to-PDF)
%%
%% The following example decode all DCT (i.e., JPEG) encoded images
@@ -131,6 +129,9 @@ P 0x003C
%% prevent gs from clipping PS figure at some papersize. (A0 above
%% simply means large size paper)
%%
+%% If you have figures even larger than A0, and their llx=lly=0, you can
+%% use -dEPSCrop instead of -sPAPERSIZE=a0
+%%
%% GhostScript (Unix/Linux):
D "gs -q -dNOPAUSE -dBATCH -sPAPERSIZE=a0 -sDEVICE=pdfwrite -dCompatibilityLevel=1.3 -dAutoFilterGrayImages=false -dGrayImageFilter=/FlateEncode -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode -dUseFlateCompression=true -sOutputFile=%o %i -c quit"
@@ -173,23 +174,17 @@ D "gs -q -dNOPAUSE -dBATCH -sPAPERSIZE=a0 -sDEVICE=pdfwrite -dCompatibilityLeve
%d 5
-%%
%% Font Map Files
%%
+%% teTeX 2.x and TeXLive using updmap (pdfTeX format)
+f pdftex.map
-% For correct searching / text extraction of ligatures, etc., of cm
-% fonts, which are given without an encoding in the map files. However,
-% if the latin modern fonts are desired/used instead of bluesky, this
-% won't be needed and should be removed.
-%f cm-dvipdfm-fix.map
-
-%% teTeX 2.x using updmap
-
-f dvipdfm.map
+%% teTeX 2.x and TeXLive using updmap (DVIPDFM format)
+%f dvipdfm.map
+%% teTeX 2.x and TeXLive using updmap (DVIPS format)
%% MiKTeX 2.2 and 2.3
-
%f psfonts.map
-%% Put additonal fontmap files here
+%% Put additonal fontmap files here (usually for Type0 fonts)
f cid-x.map
diff --git a/Build/source/texk/dvipdfmx/src/Makefile.am b/Build/source/texk/dvipdfmx/src/Makefile.am
index 2f013ef2fc7..32b870d7584 100644
--- a/Build/source/texk/dvipdfmx/src/Makefile.am
+++ b/Build/source/texk/dvipdfmx/src/Makefile.am
@@ -1,4 +1,4 @@
-bin_PROGRAMS = dvipdfmx xbb
+bin_PROGRAMS = dvipdfmx
dvipdfmx_SOURCES = agl.c bmpimage.c cff.c cff_dict.c cid.c cidtype0.c cidtype2.c \
cmap.c cmap_read.c cmap_write.c cs_type2.c \
dpxconf.c dpxcrypt.c dpxfile.c dpxutil.c \
@@ -10,7 +10,7 @@ spc_color.c spc_dvips.c spc_html.c spc_misc.c spc_pdfm.c spc_tpic.c spc_util.c s
subfont.c tfm.c \
tt_aux.c tt_cmap.c tt_glyf.c tt_gsub.c tt_post.c tt_table.c truetype.c \
type0.c t1_char.c t1_load.c type1.c type1c.c \
-unicode.c vf.c \
+unicode.c vf.c xbb.c \
agl.h bmpimage.h cff.h cff_dict.h cff_limits.h cff_stdstr.h cff_types.h \
cid.h cid_basefont.h cid_p.h cidtype0.h cidtype2.h cmap.h cmap_p.h cmap_read.h cmap_write.h \
cs_type2.h dpxconf.h dpxcrypt.h dpxutil.h dpxfile.h dvi.h dvicodes.h epdf.h error.h fontmap.h \
@@ -21,9 +21,7 @@ spc_color.h spc_dvips.h spc_html.h spc_misc.h spc_pdfm.h spc_tpic.h spc_util.h s
subfont.h system.h tfm.h \
tt_aux.h tt_cmap.h tt_glyf.h tt_gsub.h tt_post.h tt_table.h truetype.h \
type0.h t1_char.h t1_load.h type1.h type1c.h \
-unicode.h vf.h
-
-xbb_SOURCES = xbb.c pdfobj.c pdfparse.c dpxfile.c dpxutil.c error.c mem.c mfileio.c numbers.c pdfobj.h pdfparse.h dpxfile.h dpxutil.h error.h mem.h mfileio.h numbers.h
+unicode.h vf.h xbb.h
LIBPNGDIR=$(top_builddir)/../../libs/libpng
LIBPNGSRCDIR=$(srcdir)/$(LIBPNGDIR)
@@ -39,8 +37,3 @@ dvipdfmx_CPPFLAGS = @LIBPNGCPPFLAGS@ @ZLIBCPPFLAGS@
dvipdfmx_LDADD = $(LDADD) $(LDLIBPNG) $(LDZLIB)
dvipdfmx_DEPENDENCIES = $(ZLIBDEP) $(LIBPNGDEP)
dvipdfmx_LDFLAGS = @dvipdfmx_LDFLAGS@
-
-xbb_CPPFLAGS = @LIBPNGCPPFLAGS@ @ZLIBCPPFLAGS@
-xbb_LDADD = $(LDADD) $(LDLIBPNG) $(LDZLIB)
-xbb_DEPENDENCIES = $(LIBPNGDEP) $(ZLIBDEP)
-xbb_LDFLAGS = @dvipdfmx_LDFLAGS@
diff --git a/Build/source/texk/dvipdfmx/src/Makefile.in b/Build/source/texk/dvipdfmx/src/Makefile.in
index 3808e133f48..8468219cea8 100644
--- a/Build/source/texk/dvipdfmx/src/Makefile.in
+++ b/Build/source/texk/dvipdfmx/src/Makefile.in
@@ -30,7 +30,7 @@ POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
-bin_PROGRAMS = dvipdfmx$(EXEEXT) xbb$(EXEEXT)
+bin_PROGRAMS = dvipdfmx$(EXEEXT)
subdir = src
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -83,18 +83,11 @@ am_dvipdfmx_OBJECTS = dvipdfmx-agl.$(OBJEXT) \
dvipdfmx-type0.$(OBJEXT) dvipdfmx-t1_char.$(OBJEXT) \
dvipdfmx-t1_load.$(OBJEXT) dvipdfmx-type1.$(OBJEXT) \
dvipdfmx-type1c.$(OBJEXT) dvipdfmx-unicode.$(OBJEXT) \
- dvipdfmx-vf.$(OBJEXT)
+ dvipdfmx-vf.$(OBJEXT) dvipdfmx-xbb.$(OBJEXT)
dvipdfmx_OBJECTS = $(am_dvipdfmx_OBJECTS)
am__DEPENDENCIES_1 =
dvipdfmx_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(dvipdfmx_LDFLAGS) \
$(LDFLAGS) -o $@
-am_xbb_OBJECTS = xbb-xbb.$(OBJEXT) xbb-pdfobj.$(OBJEXT) \
- xbb-pdfparse.$(OBJEXT) xbb-dpxfile.$(OBJEXT) \
- xbb-dpxutil.$(OBJEXT) xbb-error.$(OBJEXT) xbb-mem.$(OBJEXT) \
- xbb-mfileio.$(OBJEXT) xbb-numbers.$(OBJEXT)
-xbb_OBJECTS = $(am_xbb_OBJECTS)
-xbb_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(xbb_LDFLAGS) $(LDFLAGS) -o \
- $@
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
@@ -102,8 +95,8 @@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
-SOURCES = $(dvipdfmx_SOURCES) $(xbb_SOURCES)
-DIST_SOURCES = $(dvipdfmx_SOURCES) $(xbb_SOURCES)
+SOURCES = $(dvipdfmx_SOURCES)
+DIST_SOURCES = $(dvipdfmx_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -212,7 +205,7 @@ spc_color.c spc_dvips.c spc_html.c spc_misc.c spc_pdfm.c spc_tpic.c spc_util.c s
subfont.c tfm.c \
tt_aux.c tt_cmap.c tt_glyf.c tt_gsub.c tt_post.c tt_table.c truetype.c \
type0.c t1_char.c t1_load.c type1.c type1c.c \
-unicode.c vf.c \
+unicode.c vf.c xbb.c \
agl.h bmpimage.h cff.h cff_dict.h cff_limits.h cff_stdstr.h cff_types.h \
cid.h cid_basefont.h cid_p.h cidtype0.h cidtype2.h cmap.h cmap_p.h cmap_read.h cmap_write.h \
cs_type2.h dpxconf.h dpxcrypt.h dpxutil.h dpxfile.h dvi.h dvicodes.h epdf.h error.h fontmap.h \
@@ -223,9 +216,8 @@ spc_color.h spc_dvips.h spc_html.h spc_misc.h spc_pdfm.h spc_tpic.h spc_util.h s
subfont.h system.h tfm.h \
tt_aux.h tt_cmap.h tt_glyf.h tt_gsub.h tt_post.h tt_table.h truetype.h \
type0.h t1_char.h t1_load.h type1.h type1c.h \
-unicode.h vf.h
+unicode.h vf.h xbb.h
-xbb_SOURCES = xbb.c pdfobj.c pdfparse.c dpxfile.c dpxutil.c error.c mem.c mfileio.c numbers.c pdfobj.h pdfparse.h dpxfile.h dpxutil.h error.h mem.h mfileio.h numbers.h
LIBPNGDIR = $(top_builddir)/../../libs/libpng
LIBPNGSRCDIR = $(srcdir)/$(LIBPNGDIR)
ZLIBDIR = $(top_builddir)/../../libs/zlib
@@ -233,10 +225,6 @@ ZLIBSRCDIR = $(srcdir)/$(ZLIBDIR)
dvipdfmx_CPPFLAGS = @LIBPNGCPPFLAGS@ @ZLIBCPPFLAGS@
dvipdfmx_LDADD = $(LDADD) $(LDLIBPNG) $(LDZLIB)
dvipdfmx_DEPENDENCIES = $(ZLIBDEP) $(LIBPNGDEP)
-xbb_CPPFLAGS = @LIBPNGCPPFLAGS@ @ZLIBCPPFLAGS@
-xbb_LDADD = $(LDADD) $(LDLIBPNG) $(LDZLIB)
-xbb_DEPENDENCIES = $(LIBPNGDEP) $(ZLIBDEP)
-xbb_LDFLAGS = @dvipdfmx_LDFLAGS@
all: all-am
.SUFFIXES:
@@ -296,9 +284,6 @@ clean-binPROGRAMS:
dvipdfmx$(EXEEXT): $(dvipdfmx_OBJECTS) $(dvipdfmx_DEPENDENCIES)
@rm -f dvipdfmx$(EXEEXT)
$(dvipdfmx_LINK) $(dvipdfmx_OBJECTS) $(dvipdfmx_LDADD) $(LIBS)
-xbb$(EXEEXT): $(xbb_OBJECTS) $(xbb_DEPENDENCIES)
- @rm -f xbb$(EXEEXT)
- $(xbb_LINK) $(xbb_OBJECTS) $(xbb_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@@ -374,15 +359,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dvipdfmx-type1c.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dvipdfmx-unicode.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dvipdfmx-vf.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbb-dpxfile.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbb-dpxutil.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbb-error.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbb-mem.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbb-mfileio.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbb-numbers.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbb-pdfobj.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbb-pdfparse.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbb-xbb.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dvipdfmx-xbb.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -1350,131 +1327,19 @@ dvipdfmx-vf.obj: vf.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(dvipdfmx_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o dvipdfmx-vf.obj `if test -f 'vf.c'; then $(CYGPATH_W) 'vf.c'; else $(CYGPATH_W) '$(srcdir)/vf.c'; fi`
-xbb-xbb.o: xbb.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT xbb-xbb.o -MD -MP -MF $(DEPDIR)/xbb-xbb.Tpo -c -o xbb-xbb.o `test -f 'xbb.c' || echo '$(srcdir)/'`xbb.c
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xbb-xbb.Tpo $(DEPDIR)/xbb-xbb.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='xbb.c' object='xbb-xbb.o' libtool=no @AMDEPBACKSLASH@
+dvipdfmx-xbb.o: xbb.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(dvipdfmx_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT dvipdfmx-xbb.o -MD -MP -MF $(DEPDIR)/dvipdfmx-xbb.Tpo -c -o dvipdfmx-xbb.o `test -f 'xbb.c' || echo '$(srcdir)/'`xbb.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/dvipdfmx-xbb.Tpo $(DEPDIR)/dvipdfmx-xbb.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='xbb.c' object='dvipdfmx-xbb.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o xbb-xbb.o `test -f 'xbb.c' || echo '$(srcdir)/'`xbb.c
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(dvipdfmx_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o dvipdfmx-xbb.o `test -f 'xbb.c' || echo '$(srcdir)/'`xbb.c
-xbb-xbb.obj: xbb.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT xbb-xbb.obj -MD -MP -MF $(DEPDIR)/xbb-xbb.Tpo -c -o xbb-xbb.obj `if test -f 'xbb.c'; then $(CYGPATH_W) 'xbb.c'; else $(CYGPATH_W) '$(srcdir)/xbb.c'; fi`
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xbb-xbb.Tpo $(DEPDIR)/xbb-xbb.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='xbb.c' object='xbb-xbb.obj' libtool=no @AMDEPBACKSLASH@
+dvipdfmx-xbb.obj: xbb.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(dvipdfmx_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT dvipdfmx-xbb.obj -MD -MP -MF $(DEPDIR)/dvipdfmx-xbb.Tpo -c -o dvipdfmx-xbb.obj `if test -f 'xbb.c'; then $(CYGPATH_W) 'xbb.c'; else $(CYGPATH_W) '$(srcdir)/xbb.c'; fi`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/dvipdfmx-xbb.Tpo $(DEPDIR)/dvipdfmx-xbb.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='xbb.c' object='dvipdfmx-xbb.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o xbb-xbb.obj `if test -f 'xbb.c'; then $(CYGPATH_W) 'xbb.c'; else $(CYGPATH_W) '$(srcdir)/xbb.c'; fi`
-
-xbb-pdfobj.o: pdfobj.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT xbb-pdfobj.o -MD -MP -MF $(DEPDIR)/xbb-pdfobj.Tpo -c -o xbb-pdfobj.o `test -f 'pdfobj.c' || echo '$(srcdir)/'`pdfobj.c
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xbb-pdfobj.Tpo $(DEPDIR)/xbb-pdfobj.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfobj.c' object='xbb-pdfobj.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o xbb-pdfobj.o `test -f 'pdfobj.c' || echo '$(srcdir)/'`pdfobj.c
-
-xbb-pdfobj.obj: pdfobj.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT xbb-pdfobj.obj -MD -MP -MF $(DEPDIR)/xbb-pdfobj.Tpo -c -o xbb-pdfobj.obj `if test -f 'pdfobj.c'; then $(CYGPATH_W) 'pdfobj.c'; else $(CYGPATH_W) '$(srcdir)/pdfobj.c'; fi`
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xbb-pdfobj.Tpo $(DEPDIR)/xbb-pdfobj.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfobj.c' object='xbb-pdfobj.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o xbb-pdfobj.obj `if test -f 'pdfobj.c'; then $(CYGPATH_W) 'pdfobj.c'; else $(CYGPATH_W) '$(srcdir)/pdfobj.c'; fi`
-
-xbb-pdfparse.o: pdfparse.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT xbb-pdfparse.o -MD -MP -MF $(DEPDIR)/xbb-pdfparse.Tpo -c -o xbb-pdfparse.o `test -f 'pdfparse.c' || echo '$(srcdir)/'`pdfparse.c
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xbb-pdfparse.Tpo $(DEPDIR)/xbb-pdfparse.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfparse.c' object='xbb-pdfparse.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o xbb-pdfparse.o `test -f 'pdfparse.c' || echo '$(srcdir)/'`pdfparse.c
-
-xbb-pdfparse.obj: pdfparse.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT xbb-pdfparse.obj -MD -MP -MF $(DEPDIR)/xbb-pdfparse.Tpo -c -o xbb-pdfparse.obj `if test -f 'pdfparse.c'; then $(CYGPATH_W) 'pdfparse.c'; else $(CYGPATH_W) '$(srcdir)/pdfparse.c'; fi`
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xbb-pdfparse.Tpo $(DEPDIR)/xbb-pdfparse.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pdfparse.c' object='xbb-pdfparse.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o xbb-pdfparse.obj `if test -f 'pdfparse.c'; then $(CYGPATH_W) 'pdfparse.c'; else $(CYGPATH_W) '$(srcdir)/pdfparse.c'; fi`
-
-xbb-dpxfile.o: dpxfile.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT xbb-dpxfile.o -MD -MP -MF $(DEPDIR)/xbb-dpxfile.Tpo -c -o xbb-dpxfile.o `test -f 'dpxfile.c' || echo '$(srcdir)/'`dpxfile.c
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xbb-dpxfile.Tpo $(DEPDIR)/xbb-dpxfile.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='dpxfile.c' object='xbb-dpxfile.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o xbb-dpxfile.o `test -f 'dpxfile.c' || echo '$(srcdir)/'`dpxfile.c
-
-xbb-dpxfile.obj: dpxfile.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT xbb-dpxfile.obj -MD -MP -MF $(DEPDIR)/xbb-dpxfile.Tpo -c -o xbb-dpxfile.obj `if test -f 'dpxfile.c'; then $(CYGPATH_W) 'dpxfile.c'; else $(CYGPATH_W) '$(srcdir)/dpxfile.c'; fi`
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xbb-dpxfile.Tpo $(DEPDIR)/xbb-dpxfile.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='dpxfile.c' object='xbb-dpxfile.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o xbb-dpxfile.obj `if test -f 'dpxfile.c'; then $(CYGPATH_W) 'dpxfile.c'; else $(CYGPATH_W) '$(srcdir)/dpxfile.c'; fi`
-
-xbb-dpxutil.o: dpxutil.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT xbb-dpxutil.o -MD -MP -MF $(DEPDIR)/xbb-dpxutil.Tpo -c -o xbb-dpxutil.o `test -f 'dpxutil.c' || echo '$(srcdir)/'`dpxutil.c
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xbb-dpxutil.Tpo $(DEPDIR)/xbb-dpxutil.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='dpxutil.c' object='xbb-dpxutil.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o xbb-dpxutil.o `test -f 'dpxutil.c' || echo '$(srcdir)/'`dpxutil.c
-
-xbb-dpxutil.obj: dpxutil.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT xbb-dpxutil.obj -MD -MP -MF $(DEPDIR)/xbb-dpxutil.Tpo -c -o xbb-dpxutil.obj `if test -f 'dpxutil.c'; then $(CYGPATH_W) 'dpxutil.c'; else $(CYGPATH_W) '$(srcdir)/dpxutil.c'; fi`
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xbb-dpxutil.Tpo $(DEPDIR)/xbb-dpxutil.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='dpxutil.c' object='xbb-dpxutil.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o xbb-dpxutil.obj `if test -f 'dpxutil.c'; then $(CYGPATH_W) 'dpxutil.c'; else $(CYGPATH_W) '$(srcdir)/dpxutil.c'; fi`
-
-xbb-error.o: error.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT xbb-error.o -MD -MP -MF $(DEPDIR)/xbb-error.Tpo -c -o xbb-error.o `test -f 'error.c' || echo '$(srcdir)/'`error.c
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xbb-error.Tpo $(DEPDIR)/xbb-error.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='error.c' object='xbb-error.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o xbb-error.o `test -f 'error.c' || echo '$(srcdir)/'`error.c
-
-xbb-error.obj: error.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT xbb-error.obj -MD -MP -MF $(DEPDIR)/xbb-error.Tpo -c -o xbb-error.obj `if test -f 'error.c'; then $(CYGPATH_W) 'error.c'; else $(CYGPATH_W) '$(srcdir)/error.c'; fi`
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xbb-error.Tpo $(DEPDIR)/xbb-error.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='error.c' object='xbb-error.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o xbb-error.obj `if test -f 'error.c'; then $(CYGPATH_W) 'error.c'; else $(CYGPATH_W) '$(srcdir)/error.c'; fi`
-
-xbb-mem.o: mem.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT xbb-mem.o -MD -MP -MF $(DEPDIR)/xbb-mem.Tpo -c -o xbb-mem.o `test -f 'mem.c' || echo '$(srcdir)/'`mem.c
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xbb-mem.Tpo $(DEPDIR)/xbb-mem.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mem.c' object='xbb-mem.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o xbb-mem.o `test -f 'mem.c' || echo '$(srcdir)/'`mem.c
-
-xbb-mem.obj: mem.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT xbb-mem.obj -MD -MP -MF $(DEPDIR)/xbb-mem.Tpo -c -o xbb-mem.obj `if test -f 'mem.c'; then $(CYGPATH_W) 'mem.c'; else $(CYGPATH_W) '$(srcdir)/mem.c'; fi`
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xbb-mem.Tpo $(DEPDIR)/xbb-mem.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mem.c' object='xbb-mem.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o xbb-mem.obj `if test -f 'mem.c'; then $(CYGPATH_W) 'mem.c'; else $(CYGPATH_W) '$(srcdir)/mem.c'; fi`
-
-xbb-mfileio.o: mfileio.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT xbb-mfileio.o -MD -MP -MF $(DEPDIR)/xbb-mfileio.Tpo -c -o xbb-mfileio.o `test -f 'mfileio.c' || echo '$(srcdir)/'`mfileio.c
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xbb-mfileio.Tpo $(DEPDIR)/xbb-mfileio.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mfileio.c' object='xbb-mfileio.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o xbb-mfileio.o `test -f 'mfileio.c' || echo '$(srcdir)/'`mfileio.c
-
-xbb-mfileio.obj: mfileio.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT xbb-mfileio.obj -MD -MP -MF $(DEPDIR)/xbb-mfileio.Tpo -c -o xbb-mfileio.obj `if test -f 'mfileio.c'; then $(CYGPATH_W) 'mfileio.c'; else $(CYGPATH_W) '$(srcdir)/mfileio.c'; fi`
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xbb-mfileio.Tpo $(DEPDIR)/xbb-mfileio.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mfileio.c' object='xbb-mfileio.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o xbb-mfileio.obj `if test -f 'mfileio.c'; then $(CYGPATH_W) 'mfileio.c'; else $(CYGPATH_W) '$(srcdir)/mfileio.c'; fi`
-
-xbb-numbers.o: numbers.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT xbb-numbers.o -MD -MP -MF $(DEPDIR)/xbb-numbers.Tpo -c -o xbb-numbers.o `test -f 'numbers.c' || echo '$(srcdir)/'`numbers.c
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xbb-numbers.Tpo $(DEPDIR)/xbb-numbers.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='numbers.c' object='xbb-numbers.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o xbb-numbers.o `test -f 'numbers.c' || echo '$(srcdir)/'`numbers.c
-
-xbb-numbers.obj: numbers.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT xbb-numbers.obj -MD -MP -MF $(DEPDIR)/xbb-numbers.Tpo -c -o xbb-numbers.obj `if test -f 'numbers.c'; then $(CYGPATH_W) 'numbers.c'; else $(CYGPATH_W) '$(srcdir)/numbers.c'; fi`
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xbb-numbers.Tpo $(DEPDIR)/xbb-numbers.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='numbers.c' object='xbb-numbers.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(xbb_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o xbb-numbers.obj `if test -f 'numbers.c'; then $(CYGPATH_W) 'numbers.c'; else $(CYGPATH_W) '$(srcdir)/numbers.c'; fi`
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(dvipdfmx_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o dvipdfmx-xbb.obj `if test -f 'xbb.c'; then $(CYGPATH_W) 'xbb.c'; else $(CYGPATH_W) '$(srcdir)/xbb.c'; fi`
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
diff --git a/Build/source/texk/dvipdfmx/src/cid.c b/Build/source/texk/dvipdfmx/src/cid.c
index 425659f2fb5..9e22650194f 100644
--- a/Build/source/texk/dvipdfmx/src/cid.c
+++ b/Build/source/texk/dvipdfmx/src/cid.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/cid.c,v 1.29 2005/07/30 11:44:18 hirata Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/cid.c,v 1.31 2008/05/17 04:18:47 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -424,10 +424,10 @@ CIDFont_base_open (CIDFont *font, const char *name, CIDSysInfo *cmap_csi, cid_op
start = cid_basefont[idx].fontdict;
end = start + strlen(start);
- fontdict = parse_pdf_dict((char **)&start, (char *)end);
+ fontdict = parse_pdf_dict((char **)&start, (char *)end, NULL);
start = cid_basefont[idx].descriptor;
end = start + strlen(start);
- descriptor = parse_pdf_dict((char **)&start, (char *)end);
+ descriptor = parse_pdf_dict((char **)&start, (char *)end, NULL);
ASSERT(fontdict && descriptor);
}
@@ -562,6 +562,7 @@ CIDFont_cache_find (const char *map_name,
opt->embed = (fmap_opt->flags & FONTMAP_OPT_NOEMBED) ? 0 : 1;
opt->name = NULL;
opt->csi = get_cidsysinfo(map_name, fmap_opt);
+ opt->stemv = fmap_opt->stemv;
if (!opt->csi && cmap_csi) {
/*
diff --git a/Build/source/texk/dvipdfmx/src/cid_p.h b/Build/source/texk/dvipdfmx/src/cid_p.h
index e0dc5089f53..f6952abd231 100644
--- a/Build/source/texk/dvipdfmx/src/cid_p.h
+++ b/Build/source/texk/dvipdfmx/src/cid_p.h
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/cid_p.h,v 1.8 2004/09/11 14:50:28 hirata Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/cid_p.h,v 1.9 2008/05/17 04:18:47 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -43,6 +43,7 @@ typedef struct
int index;
int style;
int embed;
+ int stemv;
} cid_opt;
struct CIDFont
diff --git a/Build/source/texk/dvipdfmx/src/cidtype0.c b/Build/source/texk/dvipdfmx/src/cidtype0.c
index f070cd2fe43..4987b4f52d6 100644
--- a/Build/source/texk/dvipdfmx/src/cidtype0.c
+++ b/Build/source/texk/dvipdfmx/src/cidtype0.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/cidtype0.c,v 1.36 2007/06/30 01:18:13 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/cidtype0.c,v 1.38 2008/05/17 04:18:47 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -163,7 +163,6 @@ add_CIDVMetrics (sfnt *sfont, pdf_obj *fontdict,
pdf_obj *w2_array, *an_array = NULL;
long cid, prev, start;
struct tt_VORG_table *vorg;
- struct tt_os2__table *os2;
struct tt_vhea_table *vhea = NULL;
struct tt_longMetrics *vmtx = NULL;
double defaultAdvanceHeight, defaultVertOriginY;
@@ -184,13 +183,18 @@ add_CIDVMetrics (sfnt *sfont, pdf_obj *fontdict,
sfnt_locate_table(sfont, "vmtx");
vmtx = tt_read_longMetrics(sfont, maxp->numGlyphs, vhea->numOfLongVerMetrics, vhea->numOfExSideBearings);
}
- /*
- * OpenType font must have OS/2 table.
- */
- os2 = tt_read_os2__table(sfont);
- defaultVertOriginY = PDFUNIT(os2->sTypoAscender);
- defaultAdvanceHeight = PDFUNIT(os2->sTypoAscender - os2->sTypoDescender);
- RELEASE(os2);
+
+ if (sfnt_find_table_pos(sfont, "OS/2") <= 0) {
+ struct tt_os2__table *os2;
+ /* OpenType font must have OS/2 table. */
+ os2 = tt_read_os2__table(sfont);
+ defaultVertOriginY = PDFUNIT(os2->sTypoAscender);
+ defaultAdvanceHeight = PDFUNIT(os2->sTypoAscender - os2->sTypoDescender);
+ RELEASE(os2);
+ } else {
+ /* Some TrueType fonts used in Macintosh does not have OS/2 table. */
+ defaultAdvanceHeight = 1000;
+ }
w2_array = pdf_new_array();
start = prev = 0;
@@ -814,7 +818,7 @@ CIDFont_type0_open (CIDFont *font, const char *name,
/* getting font info. from TrueType tables */
if ((font->descriptor
- = tt_get_fontdesc(sfont, &(opt->embed), 0)) == NULL)
+ = tt_get_fontdesc(sfont, &(opt->embed), opt->stemv, 0)) == NULL)
ERROR("Could not obtain neccesary font info.");
if (opt->embed) {
@@ -1213,7 +1217,7 @@ CIDFont_type0_t1copen (CIDFont *font, const char *name,
/* getting font info. from TrueType tables */
if ((font->descriptor
- = tt_get_fontdesc(sfont, &(opt->embed), 0)) == NULL)
+ = tt_get_fontdesc(sfont, &(opt->embed), opt->stemv, 0)) == NULL)
ERROR("Could not obtain neccesary font info.");
if (opt->embed) {
diff --git a/Build/source/texk/dvipdfmx/src/cidtype2.c b/Build/source/texk/dvipdfmx/src/cidtype2.c
index eea45946db2..f5560682e13 100644
--- a/Build/source/texk/dvipdfmx/src/cidtype2.c
+++ b/Build/source/texk/dvipdfmx/src/cidtype2.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/cidtype2.c,v 1.33 2005/07/17 09:53:38 hirata Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/cidtype2.c,v 1.36 2008/05/17 04:18:47 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -101,7 +101,7 @@ static struct
const char *name;
int must_exist;
} required_table[] = {
- {"OS/2", 1}, {"head", 1}, {"hhea", 1}, {"loca", 1}, {"maxp", 1},
+ {"OS/2", 0}, {"head", 1}, {"hhea", 1}, {"loca", 1}, {"maxp", 1},
{"name", 1}, {"glyf", 1}, {"hmtx", 1}, {"fpgm", 0}, {"cvt ", 0},
{"prep", 0}, {NULL, 0}
};
@@ -159,7 +159,7 @@ validate_name (char *fontname, int len)
*/
#define WIN_UCS_INDEX_MAX 1
-#define KNOWN_ENCODINGS_MAX 8
+#define KNOWN_ENCODINGS_MAX 9
static struct
{
unsigned short platform;
@@ -530,10 +530,14 @@ CIDFont_type2_dofont (CIDFont *font)
}
fp = DPXFOPEN(font->ident, DPX_RES_TYPE_TTFONT);
- if (!fp)
- ERROR("Could not open TTF file: %s", font->ident);
+ if (!fp) {
+ fp = DPXFOPEN(font->ident, DPX_RES_TYPE_DFONT);
+ if (!fp) ERROR("Could not open TTF/dfont file: %s", font->ident);
+ sfont = dfont_open(fp, font->options->index);
+ } else {
+ sfont = sfnt_open(fp);
+ }
- sfont = sfnt_open(fp);
if (!sfont) {
ERROR("Could not open TTF file: %s", font->ident);
}
@@ -549,6 +553,9 @@ CIDFont_type2_dofont (CIDFont *font)
ERROR("Found TrueType font file while expecting TTC file (%s).", font->ident);
offset = 0;
break;
+ case SFNT_TYPE_DFONT:
+ offset = sfont->offset;
+ break;
default:
ERROR("Not a TrueType/TTC font (%s)?", font->ident);
break;
@@ -849,7 +856,7 @@ CIDFont_type2_dofont (CIDFont *font)
if (sfnt_require_table(sfont,
required_table[i].name,
required_table[i].must_exist) < 0) {
- ERROR("Some required TrueType table does not exist.");
+ ERROR("Some required TrueType table (%s) does not exist.", required_table[i].name);
}
}
@@ -917,10 +924,14 @@ CIDFont_type2_open (CIDFont *font, const char *name,
ASSERT(font && opt);
fp = DPXFOPEN(name, DPX_RES_TYPE_TTFONT);
- if (!fp)
- return -1;
+ if (!fp) {
+ fp = DPXFOPEN(name, DPX_RES_TYPE_DFONT);
+ if (!fp) return -1;
+ sfont = dfont_open(fp, opt->index);
+ } else {
+ sfont = sfnt_open(fp);
+ }
- sfont = sfnt_open(fp);
if (!sfont) {
DPXFCLOSE(fp);
return -1;
@@ -937,6 +948,9 @@ CIDFont_type2_open (CIDFont *font, const char *name,
offset = 0;
}
break;
+ case SFNT_TYPE_DFONT:
+ offset = sfont->offset;
+ break;
default:
sfnt_close(sfont);
DPXFCLOSE(fp);
@@ -1036,7 +1050,7 @@ CIDFont_type2_open (CIDFont *font, const char *name,
pdf_new_name("Subtype"),
pdf_new_name("CIDFontType2"));
- font->descriptor = tt_get_fontdesc(sfont, &(opt->embed), 0);
+ font->descriptor = tt_get_fontdesc(sfont, &(opt->embed), opt->stemv, 0);
if (!font->descriptor) {
ERROR("Could not obtain neccesary font info.");
}
diff --git a/Build/source/texk/dvipdfmx/src/cmap.c b/Build/source/texk/dvipdfmx/src/cmap.c
index b0a2f160daf..2df1917707f 100644
--- a/Build/source/texk/dvipdfmx/src/cmap.c
+++ b/Build/source/texk/dvipdfmx/src/cmap.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/cmap.c,v 1.28 2004/09/05 13:30:05 hirata Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/cmap.c,v 1.29 2007/12/03 03:10:43 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -616,7 +616,7 @@ CMap_add_bfrange (CMap *cmap,
if (check_range(cmap, srclo, srchi, srcdim, base, dstdim) < 0)
return -1;
- if (cmap->mapTbl == NULL )
+ if (cmap->mapTbl == NULL)
cmap->mapTbl = mapDef_new();
cur = cmap->mapTbl;
@@ -624,12 +624,15 @@ CMap_add_bfrange (CMap *cmap,
return -1;
for (c = srclo[srcdim-1]; c <= srchi[srcdim-1]; c++) {
- if (MAP_DEFINED(cur[c].flag)) {
- if (!__silent)
- WARN("Trying to redefine already defined code mapping. (ignored)");
- continue;
+ /* According to 5014.CIDFont_Spec.pdf (p.52),
+ * Code mappings (unlike codespace ranges) may overlap,
+ * but succeeding maps superceded preceding maps.
+ * (reported and patched by Luo Jie on 2007/12/2)
+ */
+ if (!MAP_DEFINED(cur[c].flag) || cur[c].len < dstdim) {
+ cur[c].flag = (MAP_LOOKUP_END|MAP_IS_CODE);
+ cur[c].code = get_mem(cmap, dstdim);
}
-
/*
* We assume restriction to code ranges also applied here.
* Addition <00FF> + 1 is undefined.
@@ -638,9 +641,7 @@ CMap_add_bfrange (CMap *cmap,
*
* Should be treated as <0100> in Acrobat's "ToUnicode" CMap.
*/
- cur[c].flag = (MAP_LOOKUP_END|MAP_IS_CODE);
- cur[c].code = get_mem(cmap, dstdim);
- cur[c].len = dstdim;
+ cur[c].len = dstdim;
memcpy(cur[c].code, base, dstdim);
last_byte = c - srclo[srcdim-1] + base[dstdim-1];
diff --git a/Build/source/texk/dvipdfmx/src/cmap_read.c b/Build/source/texk/dvipdfmx/src/cmap_read.c
index c40652da08d..f927b40de77 100644
--- a/Build/source/texk/dvipdfmx/src/cmap_read.c
+++ b/Build/source/texk/dvipdfmx/src/cmap_read.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/cmap_read.c,v 1.2 2005/06/08 11:18:37 hirata Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/cmap_read.c,v 1.3 2008/01/11 18:04:15 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -66,12 +66,13 @@ ifreader_create (FILE *fp, long size, long bufsize)
ifreader *reader;
reader = NEW(1, ifreader);
- reader->buf = NEW(bufsize, unsigned char);
+ reader->buf = NEW(bufsize+1, unsigned char);
reader->max = bufsize;
reader->fp = fp;
reader->unread = size;
reader->cursor = reader->endptr = reader->buf;
+ *reader->endptr = 0;
return reader;
}
@@ -96,7 +97,7 @@ ifreader_read (ifreader *reader, long size)
if (size > reader->max) {
if (__verbose)
MESG("\nExtending buffer (%ld bytes)...\n", size);
- reader->buf = RENEW(reader->buf, size, unsigned char);
+ reader->buf = RENEW(reader->buf, size+1, unsigned char);
reader->max = size;
}
if (reader->unread > 0 && bytesrem < size) {
@@ -112,6 +113,8 @@ ifreader_read (ifreader *reader, long size)
MESG("Reading more %ld bytes (%ld bytes remains in buffer)...\n", bytesread, bytesrem);
}
+ *reader->endptr = 0;
+
return bytesread + bytesrem;
}
#define ifreader_need(f,s) ifreader_read((f),(s))
@@ -527,7 +530,7 @@ CMap_parse (CMap *cmap, FILE *fp)
ASSERT(cmap && fp);
- input = ifreader_create(fp, file_size(fp), INPUT_BUF_SIZE);
+ input = ifreader_create(fp, file_size(fp), INPUT_BUF_SIZE-1);
while (status >= 0) {
tok1 = tok2 = NULL;
diff --git a/Build/source/texk/dvipdfmx/src/dpxfile.c b/Build/source/texk/dvipdfmx/src/dpxfile.c
index 195bb4faa8c..682db495135 100644
--- a/Build/source/texk/dvipdfmx/src/dpxfile.c
+++ b/Build/source/texk/dvipdfmx/src/dpxfile.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/dpxfile.c,v 1.16 2007/11/14 03:36:01 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/dpxfile.c,v 1.23 2008/05/18 14:12:20 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -88,7 +88,7 @@ miktex_find_app_input_file (const char *progname, const char *filename, char *bu
kpse_reset_program_name(progname);
fqpn = kpse_find_file (filename, kpse_program_text_format, false);
- kpse_reset_program_name("dvipdfm");
+ kpse_reset_program_name(PACKAGE);
if (!fqpn)
return 0;
@@ -133,7 +133,8 @@ miktex_find_psheader_file (const char *filename, char *buf)
static char _tmpbuf[_MAX_PATH+1];
#endif /* MIKTEX */
-#if 1
+
+/* ensuresuffix() returns a copy of basename if sfx is "". */
static char *
ensuresuffix (const char *basename, const char *sfx)
{
@@ -147,7 +148,6 @@ ensuresuffix (const char *basename, const char *sfx)
return p;
}
-#endif
#ifdef MIKTEX
static char *
@@ -159,9 +159,9 @@ dpx_find__app__xyz (const char *filename,
char *q;
q = ensuresuffix(filename, suffix);
- r = miktex_find_app_input_file("dvipdfm", q, _tmpbuf);
+ r = miktex_find_app_input_file(PACKAGE, q, _tmpbuf);
if (!r && strcmp(q, filename))
- r = miktex_find_app_input_file("dvipdfm", filename, _tmpbuf);
+ r = miktex_find_app_input_file(PACKAGE, filename, _tmpbuf);
if (r) {
fqpn = NEW(strlen(_tmpbuf) + 1, char);
strcpy(fqpn, _tmpbuf);
@@ -249,7 +249,7 @@ dpx_foolsearch (const char *foolname,
kpse_program_text_format :
kpse_program_binary_format),
false);
- kpse_reset_program_name("dvipdfm");
+ kpse_reset_program_name(PACKAGE);
return fqpn;
}
@@ -264,22 +264,7 @@ static char *dpx_find_opentype_file (const char *filename);
static char *dpx_find_truetype_file (const char *filename);
static char *dpx_find_type1_file (const char *filename);
static char *dpx_find_iccp_file (const char *filename);
-
-#if 0
-static char *dpx_find_fonts_map (const char *filename);
-
-static char *dpx_find_fonts_enc (const char *filename);
-static char *dpx_find_fonts_cmap (const char *filename);
-
-static char *dpx_find_fonts_type1 (const char *filename);
-static char *dpx_find_fonts_truetype (const char *filename);
-static char *dpx_find_fonts_opentype (const char *filename);
-
-static char *dpx_find_unicode_agl (const char *filename);
-static char *dpx_find_unicode_cmap (const char *filename);
-
-static char *dpx_find_color_icc (const char *filename);
-#endif
+static char *dpx_find_dfont_file (const char *filename);
FILE *
dpx_open_file (const char *filename, int type)
@@ -317,19 +302,28 @@ dpx_open_file (const char *filename, int type)
case DPX_RES_TYPE_ICCPROFILE:
fqpn = dpx_find_iccp_file(filename);
break;
+ case DPX_RES_TYPE_DFONT:
+ fqpn = dpx_find_dfont_file(filename);
+ break;
+ case DPX_RES_TYPE_BINARY:
+ fqpn = dpx_find__app__xyz(filename, "", 0);
+ break;
+ case DPX_RES_TYPE_TEXT:
+ fqpn = dpx_find__app__xyz(filename, "", 1);
+ break;
default:
ERROR("Unknown resource type: %d", type);
break;
}
if (fqpn) {
fp = MFOPEN(fqpn, FOPEN_RBIN_MODE);
- free(fqpn); /* no RELEASE because not allocated by NEW */
+ RELEASE(fqpn);
}
return fp;
}
-/* color/icc ? */
+
static char *
dpx_find_iccp_file (const char *filename)
{
@@ -364,7 +358,7 @@ dpx_find_fontmap_file (const char *filename)
fqpn = dpx_find__app__xyz(q, ".map", 1);
#if defined(__TDS_VERSION__) && __TDS_VERSION__ >= 0x200406L
if (fqpn)
- insistupdate(q, fqpn, "dvipdfm",
+ insistupdate(q, fqpn, PACKAGE,
kpse_program_text_format, kpse_fontmap_format);
#endif
}
@@ -390,7 +384,7 @@ dpx_find_agl_file (const char *filename)
fqpn = dpx_find__app__xyz(q, ".txt", 1);
#if defined(__TDS_VERSION__) && __TDS_VERSION__ >= 0x200406L
if (fqpn)
- insistupdate(q, fqpn, "dvipdfm",
+ insistupdate(q, fqpn, PACKAGE,
kpse_program_text_format, kpse_fontmap_format);
#endif
}
@@ -407,7 +401,7 @@ dpx_find_cmap_file (const char *filename)
{
char *fqpn = NULL;
static const char *fools[] = {
- "cmap", "dvipdfm", "tex", NULL
+ "cmap", "tex", NULL
};
int i;
@@ -467,6 +461,7 @@ dpx_find_cmap_file (const char *filename)
return fqpn;
}
+
/* Search order:
* SFDFONTS (TDS 1.1)
* ttf2pk (text file)
@@ -479,7 +474,7 @@ dpx_find_sfd_file (const char *filename)
char *fqpn = NULL;
char *q;
static const char *fools[] = {
- "ttf2pk", "ttf2tfm", "dvipdfm", NULL
+ "ttf2pk", "ttf2tfm", NULL
};
int i;
@@ -505,13 +500,14 @@ dpx_find_sfd_file (const char *filename)
return fqpn;
}
+
static char *
dpx_find_enc_file (const char *filename)
{
char *fqpn = NULL;
char *q;
static const char *fools[] = {
- "dvips", "dvipdfm", NULL
+ "dvips", NULL
};
int i;
@@ -544,6 +540,7 @@ dpx_find_enc_file (const char *filename)
return fqpn;
}
+
static char *
dpx_find_type1_file (const char *filename)
{
@@ -551,7 +548,6 @@ dpx_find_type1_file (const char *filename)
fqpn = kpse_find_file(filename, kpse_type1_format, 0);
if (fqpn && !qcheck_filetype(fqpn, DPX_RES_TYPE_T1FONT)) {
- WARN("Found file \"%s\" for PFB font but it doesn't look like a PFB...", fqpn);
RELEASE(fqpn);
fqpn = NULL;
}
@@ -559,6 +555,7 @@ dpx_find_type1_file (const char *filename)
return fqpn;
}
+
static char *
dpx_find_truetype_file (const char *filename)
{
@@ -566,7 +563,6 @@ dpx_find_truetype_file (const char *filename)
fqpn = kpse_find_file(filename, kpse_truetype_format, 0);
if (fqpn && !qcheck_filetype(fqpn, DPX_RES_TYPE_TTFONT)) {
- WARN("Found file \"%s\" for TrueType font but it doesn't look like a TrueType...", fqpn);
RELEASE(fqpn);
fqpn = NULL;
}
@@ -580,35 +576,27 @@ dpx_find_opentype_file (const char *filename)
{
char *fqpn = NULL;
char *q;
- static const char *fools[] = {
- "dvipdfm", NULL
- };
- int i;
q = ensuresuffix(filename, ".otf");
#ifndef MIKTEX
#if defined(__TDS_VERSION__) && __TDS_VERSION__ >= 0x200406L
fqpn = kpse_find_file(q, kpse_opentype_format, 0);
+ if (!fqpn) {
#endif
#endif
-
- for (i = 0; !fqpn && fools[i]; i++) {
- fqpn = dpx_foolsearch(fools[i], q, 0);
+ fqpn = dpx_foolsearch(PACKAGE, q, 0);
#ifndef MIKTEX
#if defined(__TDS_VERSION__) && __TDS_VERSION__ >= 0x200406L
if (fqpn)
- insistupdate(filename, fqpn, fools[i],
+ insistupdate(filename, fqpn, PACKAGE,
kpse_program_binary_format, kpse_opentype_format);
+ }
#endif
#endif
- }
RELEASE(q);
/* *We* use "opentype" for ".otf" (CFF). */
if (fqpn && !qcheck_filetype(fqpn, DPX_RES_TYPE_OTFONT)) {
-#if 0
- WARN("Found file \"%s\" for OpenType font but it doesn't look like a .otf...", fqpn);
-#endif
RELEASE(fqpn);
fqpn = NULL;
}
@@ -616,7 +604,28 @@ dpx_find_opentype_file (const char *filename)
return fqpn;
}
+
+static char *
+dpx_find_dfont_file (const char *filename)
+{
+ char *fqpn = NULL;
+
+ fqpn = kpse_find_file(filename, kpse_truetype_format, 0);
+ if (fqpn) {
+ int len = strlen(fqpn);
+ if (len > 6 && strncmp(fqpn+len-6, ".dfont", 6)) {
+ RENEW(fqpn, len+6, char);
+ strcat(fqpn, "/rsrc");
+ }
+ }
+ if (!qcheck_filetype(fqpn, DPX_RES_TYPE_DFONT)) {
+ RELEASE(fqpn);
+ fqpn = NULL;
+ }
+ return fqpn;
+}
+
#ifdef HAVE_MKSTEMP
# include <stdlib.h>
/* extern int mkstemp(const char *); */
@@ -634,7 +643,7 @@ dpx_create_temp_file (void)
#if defined(MIKTEX)
{
tmp = NEW(_MAX_PATH + 1, char);
- miktex_create_temp_file(tmp); /* FIXME_FIXME */
+ miktex_create_temp_file_name(tmp); /* FIXME_FIXME */
}
#elif defined(HAVE_MKSTEMP)
# define __TMPDIR "/tmp"
@@ -772,7 +781,6 @@ dpx_file_apply_filter (const char *cmdtmpl, const char *input, const char *outpu
}
#endif /* HAVE_SYSTEM */
-#if 1
static char _sbuf[128];
/*
* SFNT type sigs:
@@ -867,6 +875,26 @@ ispscmap (FILE *fp)
return 0;
}
+static int
+isdfont (FILE *fp)
+{
+ int i, n;
+ unsigned long pos;
+
+ rewind(fp);
+
+ get_unsigned_quad(fp);
+ seek_absolute(fp, (pos = get_unsigned_quad(fp)) + 0x18);
+ seek_absolute(fp, pos + get_unsigned_pair(fp));
+ n = get_unsigned_pair(fp);
+ for (i = 0; i <= n; i++) {
+ if (get_unsigned_quad(fp) == 0x73666e74UL) /* "sfnt" */
+ return 1;
+ get_unsigned_quad(fp);
+ }
+ return 0;
+}
+
/* This actually opens files. */
static int
qcheck_filetype (const char *fqpn, int type)
@@ -895,11 +923,12 @@ qcheck_filetype (const char *fqpn, int type)
case DPX_RES_TYPE_CMAP:
r = ispscmap(fp);
break;
+ case DPX_RES_TYPE_DFONT:
+ r = isdfont(fp);
+ break;
}
MFCLOSE(fp);
return r;
}
-#endif /* 1 */
-
diff --git a/Build/source/texk/dvipdfmx/src/dpxfile.h b/Build/source/texk/dvipdfmx/src/dpxfile.h
index 706f5816228..fd6d8e17a2d 100644
--- a/Build/source/texk/dvipdfmx/src/dpxfile.h
+++ b/Build/source/texk/dvipdfmx/src/dpxfile.h
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/dpxfile.h,v 1.6 2005/07/20 10:41:54 hirata Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/dpxfile.h,v 1.8 2008/05/18 12:05:22 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -25,12 +25,15 @@
#ifndef _DPXFILE_H_
#define _DPXFILE_H_
+#define DPX_CONFIG_FILE "dvipdfmx.cfg"
+
#define DPX_RES_TYPE_FONTMAP 0x00
#define DPX_RES_TYPE_T1FONT 0x10
#define DPX_RES_TYPE_TTFONT 0x11
#define DPX_RES_TYPE_OTFONT 0x12
#define DPX_RES_TYPE_PKFONT 0x13
+#define DPX_RES_TYPE_DFONT 0x14
#define DPX_RES_TYPE_ENC 0x20
#define DPX_RES_TYPE_CMAP 0x21
@@ -39,6 +42,9 @@
#define DPX_RES_TYPE_ICCPROFILE 0x30
+#define DPX_RES_TYPE_BINARY 0x40
+#define DPX_RES_TYPE_TEXT 0x41
+
#include "mfileio.h"
extern FILE *dpx_open_file (const char *filename, int type);
diff --git a/Build/source/texk/dvipdfmx/src/dvipdfmx.c b/Build/source/texk/dvipdfmx/src/dvipdfmx.c
index 3c9e043c4a7..3886310f908 100644
--- a/Build/source/texk/dvipdfmx/src/dvipdfmx.c
+++ b/Build/source/texk/dvipdfmx/src/dvipdfmx.c
@@ -1,8 +1,8 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/dvipdfmx.c,v 1.53 2007/11/14 03:36:01 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/dvipdfmx.c,v 1.63 2008/05/20 13:05:14 matthias Exp $
This is DVIPDFMx, an eXtended version of DVIPDFM by Mark A. Wicks.
- Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata,
+ Copyright (C) 2008 by Jin-Hwan Cho, Matthias Franz, and Shunsaku Hirata,
the DVIPDFMx project team <dvipdfmx@project.ktug.or.kr>
Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu>
@@ -55,6 +55,8 @@
#include "pdfximage.h"
#include "cid.h"
+#include "xbb.h"
+
extern void error_cleanup (void);
static int verbose = 0;
@@ -62,12 +64,10 @@ static int verbose = 0;
static int mp_mode = 0;
static long opt_flags = 0;
+
#define OPT_TPIC_TRANSPARENT_FILL (1 << 1)
#define OPT_CIDFONT_FIXEDPITCH (1 << 2)
#define OPT_FONTMAP_FIRST_MATCH (1 << 3)
-#define OPT_NO_OBJSTM (1 << 4)
-
-static int do_objstm;
static char ignore_colors = 0;
static double annot_grow = 0.0;
@@ -126,7 +126,7 @@ usage (void)
{
fprintf (stdout, "\nThis is %s-%s by the DVIPDFMx project team,\n", PACKAGE, VERSION);
fprintf (stdout, "an extended version of dvipdfm-0.13.2c developed by Mark A. Wicks.\n");
- fprintf (stdout, "\nCopyright (C) 2002-2007 by the DVIPDFMx project team\n");
+ fprintf (stdout, "\nCopyright (C) 2002-2008 by the DVIPDFMx project team\n");
fprintf (stdout, "\nThis is free software; you can redistribute it and/or modify\n");
fprintf (stdout, "it under the terms of the GNU General Public License as published by\n");
fprintf (stdout, "the Free Software Foundation; either version 2 of the License, or\n");
@@ -134,11 +134,7 @@ usage (void)
fprintf (stdout, "\nUsage: dvipdfmx [options] dvifile\n");
fprintf (stdout, "-c \t\tIgnore color specials (for B&W printing)\n");
fprintf (stdout, "-d number\tSet PDF decimal digits (0-5) [2]\n");
-#if 0
- /* Not supported */
- fprintf (stdout, "-e \t\tDisable partial font embedding [default is enabled]\n");
-#endif
- fprintf (stdout, "-f filename\tSet font map file name [t1fonts.map]\n");
+ fprintf (stdout, "-f filename\tSet font map file name [cid-x.map]\n");
fprintf (stdout, "-g dimension\tAnnotation \"grow\" amount [0.0in]\n");
fprintf (stdout, "-l \t\tLandscape mode\n");
fprintf (stdout, "-m number\tSet additional magnification\n");
@@ -147,9 +143,7 @@ usage (void)
fprintf (stdout, "-q \t\tBe quiet\n");
fprintf (stdout, "-r resolution\tSet resolution (in DPI) for raster fonts [600]\n");
fprintf (stdout, "-s pages\tSelect page ranges (-)\n");
-#ifndef NO_THUMBNAIL
- fprintf (stdout, "-t \t\tEmbed thumbnail images\n");
-#endif /* !NO_THUMBNAIL */
+ fprintf (stdout, "-t \t\tEmbed thumbnail images of PNG format [dvifile.1] \n");
fprintf (stdout, "-x dimension\tSet horizontal offset [1.0in]\n");
fprintf (stdout, "-y dimension\tSet vertical offset [1.0in]\n");
fprintf (stdout, "-z number \tSet zlib compression level (0-9) [9]\n");
@@ -162,18 +156,13 @@ usage (void)
fprintf (stdout, "\t\t\t instead of opaque gray color. (requires PDF 1.4)\n");
fprintf (stdout, "\t\t 0x0004 Treat all CIDFont as fixed-pitch font.\n");
fprintf (stdout, "\t\t 0x0008 Do not replace duplicate fontmap entries.\n");
- fprintf (stdout, "\t\t 0x0010 Do not create object streams.\n");
fprintf (stdout, "\t\tPositive values are always ORed with previously given flags.\n");
fprintf (stdout, "\t\tAnd negative values replace old values.\n");
fprintf (stdout, "-D template\tPS->PDF conversion command line template [none]\n");
fprintf (stdout, "-K number\tEncryption key bits [40]\n");
- fprintf (stdout, "-M \t\tExperimental mps-to-pdf mode\n");
fprintf (stdout, "-O number\tSet maximum depth of open bookmark items [0]\n");
fprintf (stdout, "-P number\tSet permission flags for PDF encryption [0x003C]\n");
fprintf (stdout, "-S \t\tEnable PDF encryption\n");
-#ifndef NO_THUMBNAIL
- fprintf (stdout, "-T \t\tEmbed thumbnail images. Remove images files when finished.\n");
-#endif /* !NO_THUMBNAIL */
fprintf (stdout, "-V number\tSet PDF minor version [4]\n");
fprintf (stdout, "\nAll dimensions entered on the command line are \"true\" TeX dimensions.\n");
fprintf (stdout, "Argument of \"-s\" lists physical page ranges separated by commas, e.g., \"-s 1-3,5-6\"\n");
@@ -325,6 +314,37 @@ select_pages (const char *pagespec)
}
static void
+set_verbose (int argc, char *argv[])
+{
+ while (argc > 0 && *argv[0] == '-') {
+ char *flag, *nextptr;
+
+ for (flag = argv[0] + 1; *flag != 0; flag++) {
+ if (*flag == 'q')
+ really_quiet = 1;
+ if (*flag == 'v')
+ verbose++;
+ }
+ POP_ARG();
+ }
+
+ if (!really_quiet) {
+ 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();
+ }
+ }
+}
+
+
+static void
do_args (int argc, char *argv[])
{
while (argc > 0 && *argv[0] == '-') {
@@ -380,14 +400,9 @@ do_args (int argc, char *argv[])
select_pages(argv[1]);
POP_ARG();
break;
-#ifndef NO_THUMBNAIL
- case 'T':
- pdf_doc_enable_thumbnails(1); /* remove after... */
- break;
case 't':
- pdf_doc_enable_thumbnails(0);
+ pdf_doc_enable_manual_thumbnails();
break;
-#endif /* !NO_THUMBNAIL */
case 'p':
CHECK_ARG(1, "paper format/size");
select_paper(argv[1]);
@@ -410,11 +425,7 @@ do_args (int argc, char *argv[])
case 'e':
WARN("dvipdfm \"-e\" option not supported.");
break;
- case 'q':
- really_quiet = 1;
- break;
- case 'v':
- verbose++;
+ case 'q': case 'v':
break;
case 'V':
{
@@ -510,20 +521,6 @@ do_args (int argc, char *argv[])
POP_ARG();
}
- if (!really_quiet) {
- int i;
-
- for (i = 0; i < verbose; i++) {
- dvi_set_verbose();
- pdf_fontmap_set_verbose();
- pdf_dev_set_verbose();
- pdf_doc_set_verbose();
- pdf_enc_set_verbose();
- pdf_obj_set_verbose();
- dpx_file_set_verbose();
- }
- }
-
if (argc > 1) {
fprintf(stderr, "Multiple dvi filenames?");
usage();
@@ -555,25 +552,15 @@ cleanup (void)
RELEASE(page_ranges);
}
-static const char *default_config_file = "dvipdfmx.cfg";
-
static void
read_config_file (const char *config)
{
- char *fullname;
char *start, *end, *option;
FILE *fp;
-#ifdef MIKTEX
- if (!miktex_find_app_input_file("dvipdfm", config, fullname = work_buffer))
- return;
-#else
- if ((fullname = kpse_find_file(config, kpse_program_text_format, 1)) == NULL)
- return;
-#endif
-
- if (!(fp = MFOPEN (fullname, FOPEN_R_MODE))) {
- WARN("Could not open config file \"%s\".", fullname);
+ fp = DPXFOPEN(config, DPX_RES_TYPE_TEXT);
+ if (!fp) {
+ WARN("Could not open config file \"%s\".", config);
return;
}
while ((start = mfgets (work_buffer, WORK_BUFFER_SIZE, fp)) != NULL) {
@@ -779,11 +766,19 @@ do_mps_pages (void)
/* TODO: MetaPost mode */
+#if defined(MIKTEX)
+# define main Main
+#endif
int CDECL
main (int argc, char *argv[])
{
double dvi2pts;
+ if (strcmp(argv[0], "ebb") == 0)
+ return extractbb(argc, argv, EBB_OUTPUT);
+ else if (strcmp(argv[0], "xbb") == 0 || strcmp(argv[0], "extractbb") == 0)
+ return extractbb(argc, argv, XBB_OUTPUT);
+
mem_debug_init();
if (argc < 2) {
@@ -795,7 +790,7 @@ main (int argc, char *argv[])
#ifdef MIKTEX
miktex_initialize();
#else
- kpse_set_program_name(argv[0], "dvipdfm");
+ kpse_set_program_name(argv[0], PACKAGE);
#endif
paperinit();
@@ -804,12 +799,11 @@ main (int argc, char *argv[])
argv+=1;
argc-=1;
+ set_verbose(argc, argv);
+
pdf_init_fontmaps(); /* This must come before parsing options... */
- /* Process config file, if any */
- if (default_config_file) {
- read_config_file(default_config_file);
- }
+ read_config_file(DPX_CONFIG_FILE);
do_args (argc, argv);
@@ -840,10 +834,6 @@ main (int argc, char *argv[])
pdf_set_version(4);
}
- do_objstm = !(opt_flags & OPT_NO_OBJSTM);
-
- pdf_doc_set_creator(dvi_comment());
-
if (mp_mode) {
x_offset = 0.0;
y_offset = 0.0;
@@ -854,17 +844,21 @@ main (int argc, char *argv[])
if (dvi2pts == 0.0)
ERROR("dvi_init() failed!");
+ pdf_doc_set_creator(dvi_comment());
+
dvi_scan_paper_size(0, &paper_width, &paper_height, &x_offset, &y_offset, &landscape_mode);
if (landscape_mode) {
SWAP(paper_width, paper_height);
}
}
+ pdf_files_init();
+
/* Set default paper size here so that all page's can inherite it.
* annot_grow: Margin of annotation.
* bookmark_open: Miximal depth of open bookmarks.
*/
- pdf_open_document(pdf_filename, do_encryption, do_objstm,
+ pdf_open_document(pdf_filename, do_encryption,
paper_width, paper_height, annot_grow, bookmark_open);
/* Ignore_colors placed here since
@@ -885,6 +879,8 @@ main (int argc, char *argv[])
do_dvi_pages();
}
+ pdf_files_close();
+
/* Order of close... */
pdf_close_device ();
/* pdf_close_document flushes XObject (image) and other resources. */
diff --git a/Build/source/texk/dvipdfmx/src/epdf.c b/Build/source/texk/dvipdfmx/src/epdf.c
index 1cb621a4149..2471f4a6152 100644
--- a/Build/source/texk/dvipdfmx/src/epdf.c
+++ b/Build/source/texk/dvipdfmx/src/epdf.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/epdf.c,v 1.16 2007/11/14 03:12:21 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/epdf.c,v 1.22 2008/05/18 14:31:06 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -40,10 +40,6 @@
#include "mfileio.h"
#include "error.h"
-#if HAVE_ZLIB
-#include <zlib.h>
-#endif
-
#include "pdfobj.h"
#include "pdfdev.h"
@@ -51,10 +47,6 @@
#include "epdf.h"
-#if HAVE_ZLIB
-static int add_stream_flate (pdf_obj *dst, const void *data, long len);
-#endif
-static int concat_stream (pdf_obj *dst, pdf_obj *src);
static void print_bbox_info (pdf_obj *rect, const char *type, pdf_obj *crop_box);
static int rect_equal (pdf_obj *rect1, pdf_obj *rect2);
@@ -145,10 +137,13 @@ print_bbox_info (pdf_obj *rect, const char *type, pdf_obj *crop_box)
int
pdf_include_page (pdf_ximage *ximage, FILE *image_file)
{
+ char *ident = pdf_ximage_get_ident(ximage);
+ pdf_file *pf;
xform_info info;
- pdf_obj *contents, *contents_ref, *contents_dict;
+ pdf_obj *contents, *contents_dict;
pdf_obj *page_tree;
- pdf_obj *bbox, *resources, *rotate, *matrix;
+ pdf_obj *bbox = NULL, *resources = NULL, *rotate = NULL, *matrix;
+ long page_no, page_idx;
pdf_ximage_init_form_info(&info);
/*
@@ -159,24 +154,26 @@ pdf_include_page (pdf_ximage *ximage, FILE *image_file)
pdf_obj *trailer, *catalog;
pdf_obj *markinfo, *tmp;
- trailer = pdf_open(image_file);
- if (!trailer) {
- WARN("Trailer not found! Corrupt PDF file?");
- pdf_close();
+ pf = pdf_open(ident, image_file);
+ if (!pf)
return -1;
- }
+
+ trailer = pdf_file_get_trailer(pf);
if (pdf_lookup_dict(trailer, "Encrypt")) {
WARN("This PDF document is encrypted.");
pdf_release_obj(trailer);
- pdf_close();
+ pdf_close(pf);
return -1;
}
catalog = pdf_deref_obj(pdf_lookup_dict(trailer, "Root"));
- if (!catalog) {
- WARN("Catalog isn't where I expect it.");
- pdf_close();
+ if (!PDF_OBJ_DICTTYPE(catalog)) {
+ WARN("Can't read document catalog.");
+ pdf_release_obj(trailer);
+ if (catalog)
+ pdf_release_obj(catalog);
+ pdf_close(pf);
return -1;
}
pdf_release_obj(trailer);
@@ -184,13 +181,9 @@ pdf_include_page (pdf_ximage *ximage, FILE *image_file)
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("File contains tagged PDF. Ignoring tags.");
pdf_release_obj(markinfo);
- if (tmp && pdf_boolean_value(tmp)) {
- WARN("Tagged PDF not supported.");
- pdf_release_obj(catalog);
- pdf_close();
- return -1;
- }
}
page_tree = pdf_deref_obj(pdf_lookup_dict(catalog, "Pages"));
@@ -198,35 +191,42 @@ pdf_include_page (pdf_ximage *ximage, FILE *image_file)
}
if (!page_tree) {
WARN("Page tree not found.");
- pdf_close();
+ pdf_close(pf);
return -1;
}
/*
- * Seek first page. Get Media/Crop Box.
+ * Negative page numbers are counted from the back.
+ */
+ {
+ long count = pdf_number_value(pdf_lookup_dict(page_tree, "Count"));
+ page_no = pdf_ximage_get_page(ximage);
+ 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);
+ pdf_close(pf);
+ return -1;
+ }
+ page_no = page_idx+1;
+ pdf_ximage_set_page(ximage, page_no, count);
+ }
+
+ /*
+ * Seek correct page. Get Media/Crop Box.
* Media box and resources can be inherited.
*/
{
pdf_obj *kids_ref, *kids;
- pdf_obj *crop_box;
+ pdf_obj *crop_box = NULL;
pdf_obj *tmp;
- tmp = pdf_lookup_dict(page_tree, "MediaBox");
- bbox = tmp ? pdf_deref_obj(tmp) : NULL;
- tmp = pdf_lookup_dict(page_tree, "CropBox");
- crop_box = tmp ? pdf_deref_obj(tmp) : NULL;
- tmp = pdf_lookup_dict(page_tree, "Rotate");
- rotate = tmp ? pdf_deref_obj(tmp) : NULL;
-
tmp = pdf_lookup_dict(page_tree, "Resources");
resources = tmp ? pdf_deref_obj(tmp) : pdf_new_dict();
- while ((kids_ref = pdf_lookup_dict(page_tree, "Kids")) != NULL) {
- kids = pdf_deref_obj(kids_ref);
- pdf_release_obj(page_tree);
- page_tree = pdf_deref_obj(pdf_get_array(kids, 0));
- pdf_release_obj(kids);
-
+ while (1) {
+ long kids_length, i;
+
if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "MediaBox")))) {
if (bbox)
pdf_release_obj(bbox);
@@ -237,21 +237,24 @@ pdf_include_page (pdf_ximage *ximage, FILE *image_file)
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)
@@ -271,6 +274,49 @@ pdf_include_page (pdf_ximage *ximage, FILE *image_file)
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++) {
+ long 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);
+ pdf_close(pf);
+ return -1;
+ }
}
if (crop_box) {
pdf_release_obj(bbox);
@@ -284,7 +330,7 @@ pdf_include_page (pdf_ximage *ximage, FILE *image_file)
pdf_release_obj(resources);
if (rotate)
pdf_release_obj(rotate);
- pdf_close();
+ pdf_close(pf);
return -1;
}
@@ -295,29 +341,41 @@ pdf_include_page (pdf_ximage *ximage, FILE *image_file)
rotate = NULL;
}
- info.bbox.llx = pdf_number_value(pdf_get_array(bbox, 0));
- info.bbox.lly = pdf_number_value(pdf_get_array(bbox, 1));
- info.bbox.urx = pdf_number_value(pdf_get_array(bbox, 2));
- info.bbox.ury = pdf_number_value(pdf_get_array(bbox, 3));
+ {
+ pdf_obj *tmp;
+
+ tmp = pdf_deref_obj(pdf_get_array(bbox, 0));
+ info.bbox.llx = pdf_number_value(tmp);
+ pdf_release_obj(tmp);
+ tmp = pdf_deref_obj(pdf_get_array(bbox, 1));
+ info.bbox.lly = pdf_number_value(tmp);
+ pdf_release_obj(tmp);
+ tmp = pdf_deref_obj(pdf_get_array(bbox, 2));
+ info.bbox.urx = pdf_number_value(tmp);
+ pdf_release_obj(tmp);
+ tmp = pdf_deref_obj(pdf_get_array(bbox, 3));
+ info.bbox.ury = pdf_number_value(tmp);
+ pdf_release_obj(tmp);
+ }
/*
* Handle page content stream.
- * page_tree is now set to the first page.
+ * page_tree is now set to the correct page.
*/
- contents_ref = contents = NULL;
{
contents = pdf_deref_obj(pdf_lookup_dict(page_tree, "Contents"));
pdf_release_obj(page_tree);
- if (!contents) {
- pdf_release_obj(bbox);
- pdf_close();
- return -1;
- }
- /*
- * Concatinate all content streams.
- */
- if (PDF_OBJ_ARRAYTYPE(contents)) {
+ if (!contents) {
+ /* empty page */
+ if (contents)
+ pdf_release_obj(contents);
+ /* TODO: better don't include anything if the page is empty */
+ contents = pdf_new_stream(0);
+ } else if (PDF_OBJ_ARRAYTYPE(contents)) {
+ /*
+ * Concatenate all content streams.
+ */
pdf_obj *content_seg, *content_new;
int idx = 0;
content_new = pdf_new_stream(STREAM_COMPRESS);
@@ -325,19 +383,17 @@ pdf_include_page (pdf_ximage *ximage, FILE *image_file)
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)) {
+ else if (!PDF_OBJ_STREAMTYPE(content_seg)) {
WARN("Page content not a stream object. Broken PDF file?");
pdf_release_obj(content_new);
pdf_release_obj(bbox);
- pdf_close();
+ pdf_close(pf);
return -1;
- } else if (concat_stream(content_new, content_seg) < 0) {
+ } else if (pdf_concat_stream(content_new, content_seg) < 0) {
WARN("Could not handle content stream with multiple segment.");
pdf_release_obj(content_new);
pdf_release_obj(bbox);
- pdf_close();
+ pdf_close(pf);
return -1;
}
pdf_release_obj(content_seg);
@@ -345,10 +401,11 @@ pdf_include_page (pdf_ximage *ximage, FILE *image_file)
}
pdf_release_obj(contents);
contents = content_new;
- }
- if (!contents) {
+ } else if (pdf_obj_typeof(contents) != PDF_STREAM) {
+ WARN("Page content not a stream object.");
+ pdf_release_obj(contents);
pdf_release_obj(bbox);
- pdf_close();
+ pdf_close(pf);
return -1;
}
}
@@ -359,9 +416,12 @@ pdf_include_page (pdf_ximage *ximage, FILE *image_file)
tmp = pdf_import_object(resources);
pdf_release_obj(resources);
resources = tmp;
+ tmp = pdf_import_object(bbox);
+ pdf_release_obj(bbox);
+ bbox = tmp;
}
- pdf_close();
+ pdf_close(pf);
contents_dict = pdf_stream_dict(contents);
pdf_add_dict(contents_dict,
@@ -392,102 +452,3 @@ pdf_include_page (pdf_ximage *ximage, FILE *image_file)
return 0;
}
-
-#define WBUF_SIZE 4096
-#if HAVE_ZLIB
-static int
-add_stream_flate (pdf_obj *dst, const void *data, long len)
-{
- z_stream z;
- Bytef wbuf[WBUF_SIZE];
-
- z.zalloc = Z_NULL; z.zfree = Z_NULL; z.opaque = Z_NULL;
-
- z.next_in = (Bytef *) data; z.avail_in = len;
- z.next_out = (Bytef *) wbuf; z.avail_out = WBUF_SIZE;
-
- if (inflateInit(&z) != Z_OK) {
- WARN("inflateInit() failed.");
- return -1;
- }
-
- for (;;) {
- int status;
- status = inflate(&z, Z_NO_FLUSH);
- if (status == Z_STREAM_END)
- break;
- else if (status != Z_OK) {
- WARN("inflate() failed. Broken PDF file?");
- inflateEnd(&z);
- return -1;
- }
-
- if (z.avail_out == 0) {
- pdf_add_stream(dst, wbuf, WBUF_SIZE);
- z.next_out = wbuf;
- z.avail_out = WBUF_SIZE;
- }
- }
-
- if (WBUF_SIZE - z.avail_out > 0)
- pdf_add_stream(dst, wbuf, WBUF_SIZE - z.avail_out);
-
- return (inflateEnd(&z) == Z_OK ? 0 : -1);
-}
-#endif
-
-static int
-concat_stream (pdf_obj *dst, pdf_obj *src)
-{
- const char *stream_data;
- long stream_length;
- pdf_obj *stream_dict;
- pdf_obj *filter;
-
- if (!PDF_OBJ_STREAMTYPE(dst) || !PDF_OBJ_STREAMTYPE(src))
- ERROR("Invalid type.");
-
- stream_data = pdf_stream_dataptr(src);
- stream_length = pdf_stream_length (src);
- stream_dict = pdf_stream_dict (src);
-
- if (pdf_lookup_dict(stream_dict, "DecodeParms")) {
- WARN("DecodeParams not supported.");
- return -1;
- }
-
- filter = pdf_lookup_dict(stream_dict, "Filter");
- if (!filter) {
- pdf_add_stream(dst, stream_data, stream_length);
- return 0;
-#if HAVE_ZLIB
- } else {
- char *filter_name;
- if (PDF_OBJ_NAMETYPE(filter)) {
- filter_name = pdf_name_value(filter);
- if (filter_name && !strcmp(filter_name, "FlateDecode"))
- return add_stream_flate(dst, stream_data, stream_length);
- else {
- WARN("DecodeFilter \"%s\" not supported.", filter_name);
- return -1;
- }
- } else if (PDF_OBJ_ARRAYTYPE(filter)) {
- if (pdf_array_length(filter) > 1) {
- WARN("Multiple DecodeFilter not supported.");
- return -1;
- } else {
- filter_name = pdf_name_value(pdf_get_array(filter, 0));
- if (filter_name && !strcmp(filter_name, "FlateDecode"))
- return add_stream_flate(dst, stream_data, stream_length);
- else {
- WARN("DecodeFilter \"%s\" not supported.", filter_name);
- return -1;
- }
- }
- } else
- ERROR("Broken PDF file?");
-#endif /* HAVE_ZLIB */
- }
-
- return -1;
-}
diff --git a/Build/source/texk/dvipdfmx/src/fontmap.c b/Build/source/texk/dvipdfmx/src/fontmap.c
index f55e4a9a738..9b573419a03 100644
--- a/Build/source/texk/dvipdfmx/src/fontmap.c
+++ b/Build/source/texk/dvipdfmx/src/fontmap.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/fontmap.c,v 1.36 2007/11/14 03:36:01 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/fontmap.c,v 1.39 2008/05/18 08:09:09 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -77,6 +77,7 @@ pdf_init_fontmap_record (fontmap_rec *mrec)
mrec->opt.index = 0;
mrec->opt.charcoll = NULL;
mrec->opt.style = FONTMAP_STYLE_NONE;
+ mrec->opt.stemv = -1; /* not given explicitly by an option */
}
void
@@ -141,6 +142,7 @@ pdf_copy_fontmap_record (fontmap_rec *dst, const fontmap_rec *src)
dst->opt.index = src->opt.index;
dst->opt.charcoll = mstrdup(src->opt.charcoll);
dst->opt.style = src->opt.style;
+ dst->opt.stemv = src->opt.stemv;
}
@@ -305,8 +307,8 @@ parse_integer_value (char **pp, char *endptr, int base)
}
static int
-fontmap_parse_mapdef (fontmap_rec *mrec,
- const char *mapdef, char *endptr)
+fontmap_parse_mapdef_dpm (fontmap_rec *mrec,
+ const char *mapdef, char *endptr)
{
char *p = (char *) mapdef;
@@ -366,6 +368,7 @@ fontmap_parse_mapdef (fontmap_rec *mrec,
mrec->opt.slant = atof(q);
RELEASE(q);
break;
+
case 'e': /* Extend option */
q = parse_float_decimal(&p, endptr);
if (!q) {
@@ -379,6 +382,7 @@ fontmap_parse_mapdef (fontmap_rec *mrec,
}
RELEASE(q);
break;
+
case 'b': /* Fake-bold option */
q = parse_float_decimal(&p, endptr);
if (!q) {
@@ -393,11 +397,9 @@ fontmap_parse_mapdef (fontmap_rec *mrec,
RELEASE(q);
break;
- case 'r': /* Remap option */
- mrec->opt.flags |= FONTMAP_OPT_REMAP;
+ case 'r': /* Remap option; obsolete; just ignore */
break;
-#if 1
case 'i': /* TTC index */
q = parse_integer_value(&p, endptr, 10);
if (!q) {
@@ -436,7 +438,16 @@ fontmap_parse_mapdef (fontmap_rec *mrec,
return -1;
}
break;
-#endif
+
+ case 'v': /* StemV */
+ q = parse_integer_value(&p, endptr, 10);
+ if (!q) {
+ WARN("Missing a number for 'v' option.");
+ return -1;
+ }
+ mrec->opt.stemv = strtol(q, NULL, 0);
+ RELEASE(q);
+ break;
/* Omega uses both single-byte and double-byte set_char command
* even for double-byte OFMs. This confuses CMap decoder.
@@ -504,7 +515,6 @@ fontmap_parse_mapdef (fontmap_rec *mrec,
}
break;
-#if 1
case 'w': /* Writing mode (for unicode encoding) */
if (!mrec->enc_name ||
strcmp(mrec->enc_name, "unicode")) {
@@ -525,7 +535,6 @@ fontmap_parse_mapdef (fontmap_rec *mrec,
}
RELEASE(q);
break;
-#endif
default:
WARN("Unrecognized font map option: '%c'", mopt);
@@ -544,6 +553,84 @@ fontmap_parse_mapdef (fontmap_rec *mrec,
}
+/* Parse record line in map file of DVIPS/pdfTeX format. */
+static int
+fontmap_parse_mapdef_dps (fontmap_rec *mrec,
+ const char *mapdef, char *endptr)
+{
+ char *p = (char *)mapdef, *q;
+
+ skip_blank(&p, endptr);
+
+ /* The first field (after TFM name) must be PostScript name. */
+ if (p < endptr) {
+ q = parse_string_value(&p, endptr);
+ if (q) RELEASE(q);
+ skip_blank(&p, endptr);
+ } else {
+ WARN("Missing a PostScript font name.");
+ return -1;
+ }
+
+ if (p >= endptr) return 0;
+
+ /* Parse any remaining arguments */
+ while (p < endptr && *p != '\r' && *p != '\n' && (*p == '<' || *p == '"')) {
+ switch (*p) {
+ case '<': /* encoding or fontfile field */
+ if (++p < endptr && *p == '[') p++; /*skip */
+ skip_blank(&p, endptr);
+ if (q = parse_string_value(&p, endptr)) {
+ int n = strlen(q);
+ if (n > 4 && strncmp(q+n-4, ".enc", 4) == 0)
+ mrec->enc_name = q;
+ else
+ mrec->font_name = q;
+ }
+ skip_blank(&p, endptr);
+ break;
+
+ case '"': /* Options */
+ if (q = parse_string_value(&p, endptr)) {
+ char *r = q, *e = q+strlen(q), *s, *t;
+ skip_blank(&r, e);
+ while (r < e) {
+ if (s = parse_float_decimal(&r, e)) {
+ skip_blank(&r, e);
+ if (t = parse_string_value(&r, e)) {
+ if (strcmp(t, "SlantFont") == 0)
+ mrec->opt.slant = atof(s);
+ else if (strcmp(r, "ExtendFont") == 0)
+ mrec->opt.extend = atof(s);
+ RELEASE(t);
+ }
+ RELEASE(s);
+ } else if (s = parse_string_value(&r, e)) { /* skip */
+ RELEASE(s);
+ }
+ skip_blank(&r, e);
+ }
+ RELEASE(q);
+ }
+ skip_blank(&p, endptr);
+ break;
+
+ default:
+ WARN("Found an invalid entry: %s", p);
+ return -1;
+ break;
+ }
+ skip_blank(&p, endptr);
+ }
+
+ if (p < endptr && *p != '\r' && *p != '\n') {
+ WARN("Invalid char in fontmap line: %c", *p);
+ return -1;
+ }
+
+ return 0;
+}
+
static struct ht_table *fontmap = NULL;
@@ -779,12 +866,11 @@ pdf_insert_fontmap_record (const char *kp, const fontmap_rec *vp)
int
-pdf_read_fontmap_line (fontmap_rec *mrec, const char *mline, long mline_len)
+pdf_read_fontmap_line (fontmap_rec *mrec, const char *mline, long mline_len, int format)
{
int error;
char *q, *p, *endptr;
-
ASSERT(mrec);
p = (char *) mline;
@@ -798,7 +884,10 @@ pdf_read_fontmap_line (fontmap_rec *mrec, const char *mline, long mline_len)
if (!q)
return -1;
- error = fontmap_parse_mapdef(mrec, p, endptr);
+ if (format > 0) /* DVIPDFM format */
+ error = fontmap_parse_mapdef_dpm(mrec, p, endptr);
+ else /* DVIPS/pdfTeX format */
+ error = fontmap_parse_mapdef_dps(mrec, p, endptr);
if (!error) {
char *fnt_name, *sfd_name = NULL;
fnt_name = chop_sfd_name(q, &sfd_name);
@@ -823,43 +912,38 @@ pdf_read_fontmap_line (fontmap_rec *mrec, const char *mline, long mline_len)
return error;
}
-/* Dvips format:
- * String enclosed by '"' --> PostScript code(!)
- * '<' or '<<' followed by *.enc, *.pfb, or *.pfa
+/* DVIPS/pdfTeX fontmap line if one of the following three cases found:
+ *
+ * (1) any line including the character '"'
+ * (2) any line including the character '<'
+ * (3) if the line consists of two entries (tfmname and psname)
+ *
+ * DVIPDFM fontmap line otherwise.
*/
-static int
+int
is_pdfm_mapline (const char *mline) /* NULL terminated. */
{
- int r = 1;
- char *q, *p, *endptr;
+ int n = 0;
+ char *p, *endptr;
+
+ if (strchr(mline, '"') || strchr(mline, '<'))
+ return -1; /* DVIPS/pdfTeX format */
p = (char *) mline;
endptr = p + strlen(mline);
skip_blank(&p, endptr);
- /* Break if '-' preceeded by blanks is found. */
- while (r && p < endptr && *p != '-') {
- switch (p[0]) {
- case '"':
- q = parse_c_string(&p, endptr); /* wrong */
- if (q) {
- if (strstr(q, "SlantFont") ||
- strstr(q, "ExtendFont") ||
- strstr(q, "ReEncodeFont")) {
- r = 0;
- }
- RELEASE(q);
- }
- break;
- case '<':
- r = 0;
- break;
- }
- for ( ; p < endptr && !ISBLANK(*p); p++);
+
+ while (p < endptr) {
+ /* Break if '-' preceeded by blanks is found. (DVIPDFM format) */
+ if (*p == '-') return 1;
+ for (n++; p < endptr && !ISBLANK(*p); p++);
skip_blank(&p, endptr);
}
- return r;
+ /* Two entries: TFM_NAME PS_NAME only (DVIPS format)
+ * Otherwise (DVIPDFM format) */
+ return (n == 2 ? 0 : 1);
}
static void
@@ -889,7 +973,7 @@ pdf_load_fontmap_file (const char *filename, int mode)
FILE *fp;
char *p = NULL, *endptr;
long llen, lpos = 0;
- int error = 0;
+ int error = 0, format = 0;
ASSERT(filename);
ASSERT(fontmap) ;
@@ -905,6 +989,7 @@ pdf_load_fontmap_file (const char *filename, int mode)
while (!error &&
(p = readline(work_buffer, WORK_BUFFER_SIZE, fp)) != NULL) {
+ int m;
lpos++;
llen = strlen(work_buffer);
@@ -914,26 +999,26 @@ pdf_load_fontmap_file (const char *filename, int mode)
if (p == endptr)
continue;
- if (!is_pdfm_mapline(p)) {
- WARN("This .map file looks like a dvips format fontmap file.");
- WARN("-- Current input buffer is: %s", p);
- WARN("-- Reading fontmap file stopped at: file=\"%s\", line=%d.",
- filename, lpos);
- rewind(fp);
- delete_records(fp, lpos - 1);
- break;
- }
+ m = is_pdfm_mapline(p);
+
+ if (format * m < 0) { /* mismatch */
+ WARN("Found a mismatched fontmap line %d from %s.", lpos, filename);
+ WARN("-- Ignore the current input buffer: %s", p);
+ continue;
+ } else
+ format += m;
mrec = NEW(1, fontmap_rec);
pdf_init_fontmap_record(mrec);
- error = pdf_read_fontmap_line(mrec, p, llen);
+
+ /* format > 0: DVIPDFM, format <= 0: DVIPS/pdfTeX */
+ error = pdf_read_fontmap_line(mrec, p, llen, format);
if (error) {
- WARN("Invalid map record in fontmap file.");
- WARN("-- Current input buffer is: %s", p);
- WARN("-- Reading fontmap file stopped at: file=\"%s\", line=%d.",
- filename, lpos);
- rewind(fp);
- delete_records(fp, lpos - 1);
+ WARN("Invalid map record in fontmap line %d from %s.", lpos, filename);
+ WARN("-- Ignore the current input buffer: %s", p);
+ pdf_clear_fontmap_record(mrec);
+ RELEASE(mrec);
+ continue;
} else {
switch (mode) {
case FONTMAP_RMODE_REPLACE:
@@ -1186,8 +1271,6 @@ dump_fontmap_rec (const char *key, const fontmap_rec *mrec)
fprintf(stdout, " tounicode=\"%s\"", opt->tounicode);
if (opt->index != 0)
fprintf(stdout, " ttc-index=\"%d\"", opt->index);
- if (opt->flags & FONTMAP_OPT_REMAP)
- fprintf(stdout, " remap=\"true\"");
if (opt->flags & FONTMAP_OPT_NOEMBED)
fprintf(stdout, " embedding=\"no\"");
if (opt->mapc >= 0) {
diff --git a/Build/source/texk/dvipdfmx/src/fontmap.h b/Build/source/texk/dvipdfmx/src/fontmap.h
index cda7ac9e38a..b8314ab8f71 100644
--- a/Build/source/texk/dvipdfmx/src/fontmap.h
+++ b/Build/source/texk/dvipdfmx/src/fontmap.h
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/fontmap.h,v 1.19 2005/07/30 11:44:18 hirata Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/fontmap.h,v 1.22 2008/05/18 08:09:09 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -29,7 +29,6 @@
#define FONTMAP_RMODE_APPEND '+'
#define FONTMAP_RMODE_REMOVE '-'
-#define FONTMAP_OPT_REMAP (1 << 0)
#define FONTMAP_OPT_NOEMBED (1 << 1)
#define FONTMAP_OPT_VERT (1 << 2)
@@ -53,6 +52,7 @@ typedef struct fontmap_opt {
char *charcoll; /* Adobe-Japan1-4, etc. */
int index; /* TTC index */
int style; /* ,Bold, etc. */
+ int stemv; /* StemV value especially for CJK fonts */
} fontmap_opt;
typedef struct fontmap_rec {
@@ -82,12 +82,13 @@ extern void pdf_init_fontmap_record (fontmap_rec *mrec);
extern void pdf_clear_fontmap_record (fontmap_rec *mrec);
extern int pdf_load_fontmap_file (const char *filename, int mode);
-extern int pdf_read_fontmap_line (fontmap_rec *mrec,
- const char *mline, long mline_strlen);
+extern int pdf_read_fontmap_line (fontmap_rec *mrec, const char *mline, long mline_strlen, int format);
extern int pdf_append_fontmap_record (const char *kp, const fontmap_rec *mrec);
extern int pdf_remove_fontmap_record (const char *kp);
extern int pdf_insert_fontmap_record (const char *kp, const fontmap_rec *mrec);
extern fontmap_rec *pdf_lookup_fontmap_record (const char *kp);
+extern int is_pdfm_mapline (const char *mline);
+
#endif /* _FONTMAP_H_ */
diff --git a/Build/source/texk/dvipdfmx/src/mem.c b/Build/source/texk/dvipdfmx/src/mem.c
index ecc42c6321c..e474f407e6d 100644
--- a/Build/source/texk/dvipdfmx/src/mem.c
+++ b/Build/source/texk/dvipdfmx/src/mem.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/mem.c,v 1.4 2007/11/14 03:36:01 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/mem.c,v 1.5 2007/11/17 18:08:58 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -25,35 +25,31 @@
#include <stdio.h>
#include <stdlib.h>
-#include "dpxutil.h"
#include "mem.h"
-
-static long int mem_count = 0;
-static int mem_internal = 0;
-static struct ht_table *mem_ht = NULL;
+#include "error.h"
#ifdef MEM_DEBUG
+#include "dpxutil.h"
+
#define MEM_LINE 128
-long int mem_event = 0;
+static struct ht_table *mem_ht;
+static long int mem_event;
+static int mem_internal;
+char *mem_str;
-static void
-mem_noop (void *vp)
-{
-}
-
-static void
-mem_error (void *vp)
+void mem_debug_init(void)
{
- fprintf(stderr, "pointer %p released, but not allocated\n", vp);
+ mem_event = 0;
+ mem_internal = 0;
+ mem_ht = malloc(sizeof(struct ht_table));
+ ht_init_table(mem_ht);
+ fprintf(stderr, "*** Memory debugging started ***\n");
}
-#endif /* MEM_DEBUG */
-
void mem_debug_check(void)
{
-#ifdef MEM_DEBUG
struct ht_iter iter;
fprintf(stderr, "*** Memory still in use ***\n");
@@ -61,7 +57,7 @@ void mem_debug_check(void)
if (ht_set_iter(mem_ht, &iter) == 0) {
do {
int pl;
- void *p = ht_iter_getkey(&iter, &pl);
+ void *p = *((void **) ht_iter_getkey(&iter, &pl));
char *s = ht_iter_getval(&iter);
fprintf(stderr, "%p %s\n", p, s);
@@ -70,133 +66,112 @@ void mem_debug_check(void)
ht_clear_iter(&iter);
fprintf(stderr, "*** End of used memory ***\n");
-#endif /* MEM_DEBUG */
-
- if (mem_count)
- fprintf(stderr, "*** WARNING: %ld memory objects still allocated\n", mem_count);
}
-void mem_debug_init(void)
+static void
+mem_noop (void *vp)
{
-#ifdef MEM_DEBUG
- mem_ht = malloc(sizeof(struct ht_table));
- ht_init_table(mem_ht);
- fprintf(stderr, "*** Memory debugging started ***\n");
-#else
- mem_ht = (struct ht_table *) &mem_count; /* just any non-null value */
-#endif /* MEM_DEBUG */
}
-void *new (size_t size, const char *file, const char *function, int line)
+static void
+mem_error (void *vp)
{
- void *result;
- if ((result = malloc (size)) == NULL) {
- fprintf (stderr, "Out of memory in %s:%d\n", function, line);
- fprintf (stderr, "Asked for %lu\n", (unsigned long) size);
- exit (1);
- }
+ ERROR("Internal memory debugging error\n1: %s\n2: %s\n",
+ vp, (char *) vp, mem_str);
+}
- if (!mem_internal) {
- mem_count++;
-#ifdef MEM_DEBUG
+void *mem_add(void *ptr, const char *file, const char *function, int line) {
+ if (ptr && !mem_internal) {
mem_internal = 1;
- char *s = malloc(MEM_LINE), **p = malloc(sizeof(result));
- *p = result;
- snprintf(s, MEM_LINE, "(0x%08lx) %s (%s, %d)"
+ mem_str = malloc(MEM_LINE);
+ char **p = malloc(sizeof(ptr));
+ *p = ptr;
+ snprintf(mem_str, MEM_LINE, "(0x%08lx) %s (%s, %d)"
#ifdef __GNUC__
- ", called from %p"
+ ", %p" //" %p"
#endif
, ++mem_event, function, file, line
#ifdef __GNUC__
- , __builtin_return_address(1)
+ , __builtin_return_address(1) //, __builtin_return_address(2)
#endif
);
- ht_insert_table(mem_ht, p, sizeof(result), s, mem_error);
+ ht_insert_table(mem_ht, p, sizeof(ptr), mem_str, mem_error);
mem_internal = 0;
-#endif /* MEM_DEBUG */
}
- return result;
+ return ptr;
}
-void *renew (void *mem, size_t size, const char *file, const char *function, int line)
-{
- void *result;
-
- if (!mem_internal) {
- if (!mem)
- mem_count++;
-#ifdef MEM_DEBUG
- else {
- mem_internal = 1;
- if (!(mem_ht && ht_remove_table(mem_ht, &mem, sizeof(mem), mem_noop))) {
- fprintf(stderr, "*** ERROR: Trying to re-allocate non-allocated memory\n");
- fprintf(stderr, "%p %s (%s, %d)"
+void *mem_remove(void *ptr, const char *file, const char *function, int line) {
+ if (ptr && !mem_internal) {
+ mem_internal = 1;
+ if (!(mem_ht && ht_remove_table(mem_ht, &ptr, sizeof(ptr), mem_noop))) {
+ WARN("Trying to free non-allocated memory\n"
+ "%p %s (%s, %d)"
#ifdef __GNUC__
- ", called from %p"
+ ", called from %p"
#endif
- "\n", mem, function, file, line
+ "\n", ptr, function, file, line
#ifdef __GNUC__
- , __builtin_return_address(1)
+ , __builtin_return_address(1)
#endif
- );
- exit(1);
- }
- mem_internal = 0;
+ );
}
-#endif /* MEM_DEBUG */
+ mem_internal = 0;
}
- if ((result = realloc (mem, size)) == NULL) {
- fprintf (stderr, "Out of memory!\n");
- exit (1);
- }
+ return ptr;
+}
-#ifdef MEM_DEBUG
- if (!mem_internal) {
- mem_internal = 1;
- char *s = malloc(MEM_LINE), **p = malloc(sizeof(result));
- *p = result;
- snprintf(s, MEM_LINE, "(0x%08lx) %s (%s, %d)"
-#ifdef __GNUC__
- ", called from %p"
-#endif
- , ++mem_event, function, file, line
-#ifdef __GNUC__
- , __builtin_return_address(1)
-#endif
- );
- ht_insert_table(mem_ht, p, sizeof(result), s, mem_error);
- mem_internal = 0;
- }
-#endif /* MEM_DEBUG */
- return result;
+#else /* ! MEM_DEBUG */
+
+static long int mem_count;
+
+void mem_debug_init(void)
+{
+ mem_count = 0;
}
-void release (void *mem, const char *file, const char *function, int line)
+void mem_debug_check(void)
{
+ if (mem_count)
+ WARN("%ld memory objects still allocated\n", mem_count);
+}
+
+void *mem_add(void *ptr) {
+ if (ptr)
+ mem_count++;
+
+ return ptr;
+}
+
+void *mem_remove(void *ptr) {
+ if (ptr)
+ mem_count--;
+
+ return ptr;
+}
- if (mem && !mem_internal) {
- mem_count--;
-#ifdef MEM_DEBUG
- mem_internal = 1;
- if (!(mem_ht && ht_remove_table(mem_ht, &mem, sizeof(mem), mem_noop))) {
- fprintf(stderr, "*** ERROR: Trying to free non-allocated memory\n");
- fprintf(stderr, "%p %s (%s, %d)"
-#ifdef __GNUC__
- ", called from %p"
-#endif
- "\n", mem, function, file, line
-#ifdef __GNUC__
- , __builtin_return_address(1)
-#endif
- );
- exit(1);
- }
- mem_internal = 0;
#endif /* MEM_DEBUG */
+
+
+void *new (size_t size)
+{
+ void *result = malloc (size);
+ if (!result) {
+ ERROR("Out of memory - asked for %lu bytes\n", (unsigned long) size);
+ }
+
+ return result;
+}
+
+void *renew (void *mem, size_t size)
+{
+ void *result = realloc (mem, size);
+ if (!result) {
+ ERROR("Out of memory - asked for %lu bytes\n", (unsigned long) size);
}
- free (mem);
+ return result;
}
diff --git a/Build/source/texk/dvipdfmx/src/mem.h b/Build/source/texk/dvipdfmx/src/mem.h
index 90e9db7da7a..6380e9e9125 100644
--- a/Build/source/texk/dvipdfmx/src/mem.h
+++ b/Build/source/texk/dvipdfmx/src/mem.h
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/mem.h,v 1.4 2007/11/14 03:36:01 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/mem.h,v 1.5 2007/11/17 18:08:58 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -25,31 +25,42 @@
#ifndef _MEM_H_
#define _MEM_H_
-#undef MEM_DEBUG
-
#include <stdlib.h>
-extern void *new (size_t size, const char *file, const char *function, int line);
-extern void *renew (void *p, size_t size, const char *file, const char *function, int line);
-extern void release (void *mem, const char *file, const char *function, int line);
+extern void *new (size_t size);
+extern void *renew (void *p, size_t size);
extern void mem_debug_init(void);
extern void mem_debug_check(void);
+#undef MEM_DEBUG
+
#ifdef MEM_DEBUG
-#include <stdio.h>
-extern long int mem_event;
-#define NEW(n,type) (type *)(new (((size_t) (n))*sizeof(type),__FILE__,__FUNCTION__,__LINE__))
-#define RENEW(p,n,type) (type *)(renew ((p),(n)*sizeof(type),__FILE__,__FUNCTION__,__LINE__))
-#define RELEASE(p) release ((p),__FILE__,__FUNCTION__,__LINE__)
-#define MEM_START {mem_debug_init();fprintf (stderr, "Entered %s\n", __FUNCTION__);}
-#define MEM_END fprintf (stderr, "Leaving %s\n", __FUNCTION__);
-#else /* MEM_DEBUG */
-#define MEM_START
-#define MEM_END
-#define NEW(n,type) (type *)(new (((size_t) (n))*sizeof(type),NULL,NULL,0))
-#define RENEW(p,n,type) (type *)(renew ((p),(n)*sizeof(type),NULL,NULL,0))
-#define RELEASE(p) release ((p),NULL,NULL,0)
+
+extern void *mem_add (void *ptr,
+ const char *file, const char *function, int line);
+extern void *mem_remove (void *ptr,
+ const char *file, const char *function, int line);
+#define MEM_ADD(p) mem_add(p, __FILE__, __FUNCTION__, __LINE__)
+#define MEM_REMOVE(p) mem_remove(p, __FILE__, __FUNCTION__, __LINE__)
+
+#else /* ! MEM_DEBUG */
+
+extern void *mem_add (void *ptr);
+extern void *mem_remove (void *ptr);
+#define MEM_ADD(p) mem_add(p)
+#define MEM_REMOVE(p) mem_remove(p)
+
#endif /* MEM_DEBUG */
+
+#define NEW(n,type) (type *) MEM_ADD(new(((size_t)(n))*sizeof(type)))
+#define RENEW(p,n,type) (type *) MEM_ADD(renew(MEM_REMOVE(p),(n)*sizeof(type)))
+#define RELEASE(p) free(MEM_REMOVE(p))
+
+/* wrappers for functions from kpathsea */
+#define kpse_path_search(x,y,z) (char *) MEM_ADD(kpse_path_search(x,y,z))
+#define kpse_find_file(x,y,z) (char *) MEM_ADD(kpse_find_file(x,y,z))
+#define kpse_find_glyph(x,y,z,w) (char *) MEM_ADD(kpse_find_glyph(x,y,z,w))
+
#endif /* _MEM_H_ */
diff --git a/Build/source/texk/dvipdfmx/src/mpost.c b/Build/source/texk/dvipdfmx/src/mpost.c
index c3bb35410a5..841a357e699 100644
--- a/Build/source/texk/dvipdfmx/src/mpost.c
+++ b/Build/source/texk/dvipdfmx/src/mpost.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/mpost.c,v 1.37 2007/11/03 05:31:20 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/mpost.c,v 1.40 2008/05/17 01:17:27 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -348,6 +348,10 @@ skip_prolog (char **start, char *end)
#define FSHOW 1001
#define STEXFIG 1002
#define ETEXFIG 1003
+#define HLW 1004
+#define VLW 1005
+#define RD 1006
+#define B 1007
static struct operators
{
@@ -417,9 +421,34 @@ static struct operators
};
static struct operators mps_operators[] = {
- {"fshow", FSHOW},
+ {"fshow", FSHOW}, /* exch findfont exch scalefont setfont show */
{"startTexFig", STEXFIG},
- {"endTexFig", ETEXFIG}
+ {"endTexFig", ETEXFIG},
+ {"hlw", HLW}, /* 0 dtransform exch truncate exch idtransform pop setlinewidth */
+ {"vlw", VLW}, /* 0 exch dtransform truncate idtransform pop setlinewidth pop */
+ {"l", LINETO},
+ {"r", RLINETO},
+ {"c", CURVETO},
+ {"m", MOVETO},
+ {"p", CLOSEPATH},
+ {"n", NEWPATH},
+ {"C", SETCMYKCOLOR},
+ {"G", SETGRAY},
+ {"R", SETRGBCOLOR},
+ {"lj", SETLINEJOIN},
+ {"ml", SETMITERLIMIT},
+ {"lc", SETLINECAP},
+ {"S", STROKE},
+ {"F", FILL},
+ {"q", GSAVE},
+ {"Q", GRESTORE},
+ {"s", SCALE},
+ {"t", CONCAT},
+ {"sd", SETDASH},
+ {"rd", RD}, /* [] 0 setdash */
+ {"P", SHOWPAGE},
+ {"B", B}, /* gsave fill grestore */
+ {"W", CLIP}
};
#define NUM_PS_OPERATORS (sizeof(ps_operators)/sizeof(ps_operators[0]))
@@ -800,19 +829,13 @@ do_show (void)
return 0;
}
-static const char *ps_code_fshow = "exch findfont exch scalefont setfont show";
-/*
- * string tfmname scale fshow -
- *
- * exch findfont exch scalefont setfont show
- */
static int
-do_mpost_fshow (int opcode, double x_user, double y_user)
+do_mpost_bind_def (const char *ps_code, double x_user, double y_user)
{
int error = 0;
char *start, *end;
- start = (char *) ps_code_fshow;
+ start = (char *) ps_code;
end = start + strlen(start);
error = mp_parse_body(&start, end, x_user, y_user);
@@ -1190,8 +1213,7 @@ do_operator (const char *token, double x_user, double y_user)
pdf_color_cmykcolor(&color,
values[0], values[1],
values[2], values[3]);
- pdf_dev_setcolor(&color, 0);
- pdf_dev_setcolor(&color, 1);
+ pdf_dev_set_color(&color);
}
break;
case SETGRAY:
@@ -1199,8 +1221,7 @@ do_operator (const char *token, double x_user, double y_user)
error = pop_get_numbers(values, 1);
if (!error) {
pdf_color_graycolor(&color, values[0]);
- pdf_dev_setcolor(&color, 0);
- pdf_dev_setcolor(&color, 1);
+ pdf_dev_set_color(&color);
}
break;
case SETRGBCOLOR:
@@ -1208,8 +1229,7 @@ do_operator (const char *token, double x_user, double y_user)
if (!error) {
pdf_color_rgbcolor(&color,
values[0], values[1], values[2]);
- pdf_dev_setcolor(&color, 0);
- pdf_dev_setcolor(&color, 1);
+ pdf_dev_set_color(&color);
}
break;
@@ -1331,13 +1351,24 @@ do_operator (const char *token, double x_user, double y_user)
/* Extensions */
case FSHOW:
- error = do_mpost_fshow(opcode, x_user, y_user);
- /* Treat fshow as a path terminator of sorts */
+ error = do_mpost_bind_def("exch findfont exch scalefont setfont show", x_user, y_user);
break;
case STEXFIG:
case ETEXFIG:
error = do_texfig_operator(opcode, x_user, y_user);
break;
+ case HLW:
+ error = do_mpost_bind_def("0 dtransform exch truncate exch idtransform pop setlinewidth", x_user, y_user);
+ break;
+ case VLW:
+ error = do_mpost_bind_def("0 exch dtransform truncate idtransform setlinewidth pop", x_user, y_user);
+ break;
+ case RD:
+ error = do_mpost_bind_def("[] 0 setdash", x_user, y_user);
+ break;
+ case B:
+ error = do_mpost_bind_def("gsave fill grestore", x_user, y_user);
+ break;
case DEF:
tmp = POP_STACK();
@@ -1391,33 +1422,19 @@ mp_parse_body (char **start, char *end, double x_user, double y_user)
* This shouldn't use parse_pdf_array().
*/
} else if (**start == '[' &&
- (obj = parse_pdf_array(start, end))) {
+ (obj = parse_pdf_array(start, end, NULL))) {
PUSH(obj);
/* This cannot handle ASCII85 string. */
} else if (*start < end - 1 &&
(**start == '<' && *(*start+1) == '<') &&
- (obj = parse_pdf_dict(start, end))) {
+ (obj = parse_pdf_dict(start, end, NULL))) {
PUSH(obj);
} else if ((**start == '(' || **start == '<') &&
(obj = parse_pdf_string (start, end))) {
PUSH(obj);
} else if (**start == '/' &&
(obj = parse_pdf_name(start, end))) {
- /* Temporary implementation for mps files generated by mptopdf:
- * Just ignore the following command:
- * /fshow {exch findfont exch scalefont setfont show} bind def
- */
- if (strcmp(pdf_name_value(obj), "fshow") == 0) {
- while (*start < end - 3) {
- if (**start == 'd' && *(*start+1) == 'e' && *(*start+2) == 'f') {
- *start += 3;
- break;
- }
- (*start)++;
- }
- } else {
- PUSH(obj);
- }
+ PUSH(obj);
} else {
token = parse_ident(start, end);
if (!token)
@@ -1463,7 +1480,7 @@ mps_exec_inline (char **p, char *endptr,
autorotate = pdf_dev_get_param(PDF_DEV_PARAM_AUTOROTATE);
pdf_dev_set_param(PDF_DEV_PARAM_AUTOROTATE, 0);
- pdf_color_push(); /* ... */
+ //pdf_color_push(); /* ... */
/* Comment in dvipdfm:
* Remember that x_user and y_user are off by 0.02 %
@@ -1471,7 +1488,7 @@ mps_exec_inline (char **p, char *endptr,
pdf_dev_moveto(x_user, y_user);
error = mp_parse_body(p, endptr, x_user, y_user);
- pdf_color_pop(); /* ... */
+ //pdf_color_pop(); /* ... */
pdf_dev_set_param(PDF_DEV_PARAM_AUTOROTATE, autorotate);
pdf_dev_set_dirmode(dirmode);
@@ -1536,7 +1553,7 @@ mps_include_page (const char *ident, FILE *fp)
dirmode = pdf_dev_get_dirmode();
autorotate = pdf_dev_get_param(PDF_DEV_PARAM_AUTOROTATE);
pdf_dev_set_param(PDF_DEV_PARAM_AUTOROTATE, 0);
- pdf_color_push();
+ //pdf_color_push();
form_id = pdf_doc_begin_grabbing(ident, 0.0, 0.0, &(info.bbox));
@@ -1551,8 +1568,8 @@ mps_include_page (const char *ident, FILE *fp)
RELEASE(buffer);
if (error) {
- WARN("Errors occured while interpreting PostScript file.");
- WARN("Leaving garbage in output PDF file.");
+ WARN("Errors occured while interpreting MPS file.");
+ /* WARN("Leaving garbage in output PDF file."); */
form_id = -1;
}
@@ -1563,7 +1580,7 @@ mps_include_page (const char *ident, FILE *fp)
pdf_doc_end_grabbing();
- pdf_color_pop();
+ //pdf_color_pop();
pdf_dev_set_param(PDF_DEV_PARAM_AUTOROTATE, autorotate);
pdf_dev_set_dirmode(dirmode);
diff --git a/Build/source/texk/dvipdfmx/src/otl_conf.c b/Build/source/texk/dvipdfmx/src/otl_conf.c
index 298384961ff..affba8b672d 100644
--- a/Build/source/texk/dvipdfmx/src/otl_conf.c
+++ b/Build/source/texk/dvipdfmx/src/otl_conf.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/otl_conf.c,v 1.6 2005/07/17 09:53:38 hirata Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/otl_conf.c,v 1.8 2008/05/18 12:05:22 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -460,31 +460,16 @@ otl_read_conf (const char *conf_name)
pdf_obj *rule;
pdf_obj *gclass;
FILE *fp;
- char *fullname, *filename;
- char *wbuf, *p, *endptr;
+ char *filename, *wbuf, *p, *endptr;
long size, len;
filename = NEW(strlen(conf_name)+strlen(".otl")+1, char);
strcpy(filename, conf_name);
strcat(filename, ".otl");
-#ifdef MIKTEX
- if (!miktex_find_app_input_file("dvipdfm", filename, work_buffer))
- fullname = NULL;
- else {
- fullname = work_buffer;
- }
-#else /* !MIKTEX */
- fullname = kpse_find_file(filename, kpse_program_text_format, 0);
-#endif
- RELEASE(filename);
- if (!fullname) {
- WARN("Layout file %s not found.", conf_name);
- return NULL;
- }
- fp = MFOPEN(fullname, FOPEN_RBIN_MODE);
+ fp = DPXFOPEN(filename, DPX_RES_TYPE_TEXT);
if (!fp) {
- RELEASE(fullname);
+ RELEASE(filename);
return NULL;
}
@@ -494,8 +479,9 @@ otl_read_conf (const char *conf_name)
if (verbose > VERBOSE_LEVEL_MIN) {
MESG("\n");
MESG("otl_conf>> Layout config. \"%s\" found: file=\"%s\" (%ld bytes)\n",
- conf_name, fullname, size);
+ conf_name, filename, size);
}
+ RELEASE(filename);
if (size < 1)
return NULL;
diff --git a/Build/source/texk/dvipdfmx/src/pdfcolor.c b/Build/source/texk/dvipdfmx/src/pdfcolor.c
index 8d9341302c1..ab908079ec3 100644
--- a/Build/source/texk/dvipdfmx/src/pdfcolor.c
+++ b/Build/source/texk/dvipdfmx/src/pdfcolor.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pdfcolor.c,v 1.13 2006/12/11 12:46:03 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pdfcolor.c,v 1.14 2007/11/22 11:45:39 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -212,115 +212,28 @@ compare_color (const pdf_color *color1, const pdf_color *color2)
}
#endif
-static int
-valid_color_values (pdf_color *validated, const pdf_color *color)
+int
+pdf_color_is_valid (pdf_color *color)
{
- int i, num_components = 0;
+ int i, num_components;
num_components = color->num_components;
if (num_components != 1 &&
num_components != 3 &&
num_components != 4) {
ERROR("Only RGB/CMYK/Gray currently supported.");
- return -1;
+ return 0;
}
for (i = 0; i < num_components; i++) {
if (color->values[i] < 0.0 || color->values[i] > 1.0) {
WARN("Invalid color value: %g", color->values[i]);
- return -1;
- } else {
- validated->values[i] = color->values[i];
- }
- }
- validated->num_components = color->num_components;
-
- return 0;
-}
-
-int
-pdf_dev_currentcolor (pdf_color *color, int is_fill)
-{
- ASSERT(color);
-
- if (is_fill) {
- memcpy(color, &current_fill, sizeof(pdf_color));
- } else {
- memcpy(color, &current_stroke, sizeof(pdf_color));
- }
-
- return 0;
-}
-
-int
-pdf_dev_setcolor (const pdf_color *color, int is_fill)
-{
- int len = 0, colormode;
- int i;
- char format_buffer[128];
- pdf_color validated;
-
- if (!color) {
- WARN("No color specified.");
- return -1;
- }
-
- colormode = pdf_dev_get_param(PDF_DEV_PARAM_COLORMODE);
- if (!colormode) {
- WARN("setcolor ignored. (Ignore color option set)");
- return 0;
- }
-
- if (valid_color_values(&validated, color) < 0) {
- return -1;
- }
-
-#if 0
- /* There are much problems in this :( */
- if (is_fill) {
- if (!compare_color(&validated, &current_fill)) {
- return 0;
- }
- } else {
- if (!compare_color(&validated, &current_stroke)) {
return 0;
}
}
-#endif
-
- graphics_mode();
-
- for (i = 0; i < validated.num_components; i++) {
- len = sprintf(format_buffer, " %g", ROUND(validated.values[i], 0.01));
- pdf_doc_add_page_content(format_buffer, len);
- }
-
- switch (validated.num_components) {
- case 3:
- pdf_doc_add_page_content((is_fill ? " rg" : " RG"), 3);
- break;
- case 4:
- pdf_doc_add_page_content((is_fill ? " k" : " K" ), 2);
- break;
- case 1:
- pdf_doc_add_page_content((is_fill ? " g" : " G" ), 2);
- break;
- default:
- ERROR("Only RGB/CMYK/Gray currently supported.");
- return -1;
- break;
- }
-
- if (is_fill) {
- memcpy(&current_fill, &validated, sizeof(pdf_color));
- } else {
- memcpy(&current_stroke, &validated, sizeof(pdf_color));
- }
-
- return 0;
+ return 1;
}
-
/* Dvipdfm special */
pdf_color default_color = {
1,
@@ -330,116 +243,77 @@ pdf_color default_color = {
void
pdf_color_set_default (const pdf_color *color)
{
- ASSERT(color);
-
- memcpy(&default_color, color, sizeof(pdf_color));
+ pdf_color_copycolor(&default_color, color);
}
-
-/*
- * Having color stack here is wrong.
- * dvi.c or XXX_special should treat this.
- */
#define DEV_COLOR_STACK_MAX 128
static struct {
- int next;
+ int current;
pdf_color stroke[DEV_COLOR_STACK_MAX];
pdf_color fill[DEV_COLOR_STACK_MAX];
} color_stack = {
0,
};
-/* BUG (20060330): color change does not effect on the next page.
- * The problem is due to the part of grestore because it restores
- * the color values in the state of gsave which are not correct
- * if the color values are changed inside of a page.
- */
void
-pdf_dev_preserve_color (void)
+pdf_color_clear_stack (void)
{
- if (color_stack.next > 0) {
- current_stroke = color_stack.stroke[color_stack.next];
- current_fill = color_stack.fill[color_stack.next];
+ if (color_stack.current > 0) {
+ WARN("You've mistakenly made a global color change within nested colors.");
}
+ color_stack.current = 0;
+ pdf_color_copycolor(&color_stack.stroke[color_stack.current], &default_color);
+ pdf_color_copycolor(&color_stack.fill[color_stack.current], &default_color);
+ return;
}
void
-pdf_dev_reset_color (void)
+pdf_color_push (pdf_color *sc, pdf_color *fc)
{
- int colormode;
- pdf_color fillcolor, strokecolor;
-
- /* Shouldn't give a warning */
- colormode = pdf_dev_get_param(PDF_DEV_PARAM_COLORMODE);
- if (!colormode) {
- return;
- }
-
- if (color_stack.next > 0) {
- strokecolor = current_stroke;
- fillcolor = current_fill;
+ if (color_stack.current >= DEV_COLOR_STACK_MAX-1) {
+ WARN("Color stack overflow. Just ignore.");
} else {
- strokecolor = default_color;
- fillcolor = default_color;
+ color_stack.current++;
+ pdf_color_copycolor(&color_stack.stroke[color_stack.current], sc);
+ pdf_color_copycolor(&color_stack.fill[color_stack.current], fc);
+ pdf_dev_reset_color();
}
-
- pdf_dev_setcolor(&strokecolor, 0);
- pdf_dev_setcolor(&fillcolor, 1);
-
return;
}
-
void
-pdf_color_clear (void)
+pdf_color_pop (void)
{
- color_stack.next = 0;
+ if (color_stack.current <= 0) {
+ WARN("Color stack underflow. Just ignore.");
+ } else {
+ color_stack.current--;
+ pdf_dev_reset_color();
+ }
+ return;
}
void
-pdf_color_push (void)
+pdf_color_get_current (pdf_color **sc, pdf_color **fc)
{
- int current;
-
- current = color_stack.next;
- if (current >= DEV_COLOR_STACK_MAX) {
- WARN("Exceeded depth of color stack.");
- return;
- }
-
- memcpy(&color_stack.stroke[current],
- &current_stroke, sizeof(pdf_color));
- memcpy(&color_stack.fill[current],
- &current_fill , sizeof(pdf_color));
-
- color_stack.next++;
-
+ *sc = &color_stack.stroke[color_stack.current];
+ *fc = &color_stack.fill[color_stack.current];
return;
}
+/* BUG (20060330): color change does not effect on the next page.
+ * The problem is due to the part of grestore because it restores
+ * the color values in the state of gsave which are not correct
+ * if the color values are changed inside of a page.
+ */
void
-pdf_color_pop (void)
+pdf_dev_preserve_color (void)
{
- int current;
-
- current = --(color_stack.next);
-
- if (current < 0) {
- WARN("End color with no corresponding begin color.");
- /*
- * In the case of mismatched push and pop, color_stack.next must set
- * to be the default value, 0. Otherwise causes segmentation fault
- * in the next push command.
- */
- pdf_color_clear();
- return;
+ if (color_stack.current > 0) {
+ current_stroke = color_stack.stroke[color_stack.current];
+ current_fill = color_stack.fill[color_stack.current];
}
-
- pdf_dev_setcolor(&color_stack.stroke[current], 0);
- pdf_dev_setcolor(&color_stack.fill[current] , 1);
-
- return;
}
/***************************** COLOR SPACE *****************************/
diff --git a/Build/source/texk/dvipdfmx/src/pdfcolor.h b/Build/source/texk/dvipdfmx/src/pdfcolor.h
index 48e930be1a3..769d7e52a5c 100644
--- a/Build/source/texk/dvipdfmx/src/pdfcolor.h
+++ b/Build/source/texk/dvipdfmx/src/pdfcolor.h
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pdfcolor.h,v 1.7 2006/12/11 12:46:03 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pdfcolor.h,v 1.8 2007/11/22 11:45:39 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -51,10 +51,6 @@ typedef struct
extern void pdf_color_set_verbose (void);
-extern int pdf_dev_setcolor (const pdf_color *color, int is_fill);
-
-extern int pdf_dev_currentcolor (pdf_color *color, int is_fill);
-
extern int pdf_color_rgbcolor (pdf_color *color,
double r, double g, double b);
extern int pdf_color_cmykcolor (pdf_color *color,
@@ -63,6 +59,7 @@ extern int pdf_color_graycolor (pdf_color *color, double g);
extern void pdf_color_copycolor (pdf_color *color1, const pdf_color *color2);
extern int pdf_color_is_white (pdf_color *color);
+extern int pdf_color_is_valid (pdf_color *color);
/* Not check size */
extern pdf_obj *iccp_get_rendering_intent (const void *profile, long proflen);
@@ -88,12 +85,15 @@ extern int pdf_colorspace_load_ICCBased (const char *ident,
* See remark in spc_color.c.
*/
extern void pdf_color_set_default (const pdf_color *color);
-extern void pdf_color_push (void);
+extern void pdf_color_push (pdf_color *sc, pdf_color *fc);
extern void pdf_color_pop (void);
-extern void pdf_color_clear (void);
+
+/* Color stack
+ */
+extern void pdf_color_clear_stack (void);
+extern void pdf_color_get_current (pdf_color **sc, pdf_color **fc);
/* Reinstall color */
extern void pdf_dev_preserve_color(void);
-extern void pdf_dev_reset_color (void);
#endif /* _PDF_COLOR_H_ */
diff --git a/Build/source/texk/dvipdfmx/src/pdfdev.c b/Build/source/texk/dvipdfmx/src/pdfdev.c
index 650fac5d051..18387abc5f2 100644
--- a/Build/source/texk/dvipdfmx/src/pdfdev.c
+++ b/Build/source/texk/dvipdfmx/src/pdfdev.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pdfdev.c,v 1.61 2006/12/11 12:46:03 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pdfdev.c,v 1.65 2008/05/18 08:09:09 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -449,7 +449,6 @@ struct dev_font {
double bold; /* Boldness prameter */
/* Compatibility */
- int remap; /* Obsolete */
int mapc; /* Nasty workaround for Omega */
/* There are no font metric format supporting four-bytes
@@ -861,33 +860,6 @@ static unsigned char sbuf0[FORMAT_BUF_SIZE];
static unsigned char sbuf1[FORMAT_BUF_SIZE];
static int
-handle_remap (unsigned char **str_ptr, int length)
-{
- unsigned char *p;
- int i;
-
- p = *str_ptr;
-
-#define twiddle(n) ( \
- ( \
- ((n) <= 9) ? \
- ((n) + 161) : \
- (((n) <= 32) ? \
- ((n) + 163) : \
- (((n) == 127) ? 196: (n)) \
- ) \
- ) \
-)
-
- for (i = 0; i < length; i++) {
- sbuf0[i] = twiddle(p[i]);
- }
-
- *str_ptr = sbuf0;
- return 0;
-}
-
-static int
handle_multibyte_string (struct dev_font *font,
unsigned char **str_ptr, int *str_len, int ctype)
{
@@ -1026,8 +998,6 @@ pdf_dev_set_string (spt_t xpos, spt_t ypos,
(unsigned short) (str_ptr[i] << 8)|str_ptr[i+1]);
}
} else {
- if (font->remap)
- handle_remap(&str_ptr, length); /* length unchanged. */
if (font->used_chars != NULL) {
for (i = 0; i < length; i++)
font->used_chars[str_ptr[i]] = 1;
@@ -1090,11 +1060,8 @@ pdf_dev_set_string (spt_t xpos, spt_t ypos,
* Same issues as earlier. Use floating point for simplicity.
* This routine needs to be fast, so we don't call sprintf() or strcpy().
*/
-#if 0
- text_state.offset -=
+ text_state.offset -=
(spt_t) (kern * font->extend * (font->sptsize / 1000.0));
-#endif
- text_state.offset -= delh;
format_buffer[len++] = text_state.is_mb ? '>' : ')';
if (font->wmode)
len += p_itoa(-kern, format_buffer + len);
@@ -1150,7 +1117,7 @@ pdf_init_device (double dvi2pts, int precision, int black_and_white)
dev_param.colormode = (black_and_white ? 0 : 1);
graphics_mode();
- pdf_color_clear();
+ pdf_color_clear_stack();
pdf_dev_init_gstates();
num_dev_fonts = 0;
@@ -1178,7 +1145,7 @@ pdf_close_device (void)
num_dev_fonts = 0;
max_dev_fonts = 0;
- pdf_dev_clean_gstates();
+ pdf_dev_clear_gstates();
}
/*
@@ -1206,6 +1173,148 @@ pdf_dev_reset_fonts (void)
text_state.is_mb = 0;
}
+void
+pdf_dev_reset_color(void)
+{
+ pdf_color *sc, *fc;
+
+ if (pdf_dev_get_param(PDF_DEV_PARAM_COLORMODE)) {
+ pdf_color_get_current(&sc, &fc);
+ pdf_dev_set_strokingcolor(sc);
+ pdf_dev_set_nonstrokingcolor(fc);
+ }
+ return;
+}
+
+static int
+color_to_string (pdf_color *color, char *buffer)
+{
+ int i, len = 0;
+
+ for (i = 0; i < color->num_components; i++) {
+ len += sprintf(format_buffer+len, " %g", ROUND(color->values[i], 0.001));
+ }
+ return len;
+}
+
+void
+pdf_dev_set_color (pdf_color *color)
+{
+ int len;
+
+ if (!pdf_dev_get_param(PDF_DEV_PARAM_COLORMODE)) {
+ WARN("Ignore color option was set. Just ignore.");
+ return;
+ } else if (!(color && pdf_color_is_valid(color))) {
+ WARN("No valid color is specified. Just ignore.");
+ return;
+ }
+
+ graphics_mode();
+ len = color_to_string(color, format_buffer);
+ format_buffer[len++] = ' ';
+ switch (color->num_components) {
+ case 3:
+ format_buffer[len++] = 'R';
+ format_buffer[len++] = 'G';
+ break;
+ case 4:
+ format_buffer[len++] = 'K';
+ break;
+ case 1:
+ format_buffer[len++] = 'G';
+ break;
+ default: /* already verified the given color */
+ break;
+ }
+ strncpy(format_buffer+len, format_buffer, len);
+ len = len << 1;
+ switch (color->num_components) {
+ case 3:
+ format_buffer[len-2] = 'r';
+ format_buffer[len-1] = 'g';
+ break;
+ case 4:
+ format_buffer[len-1] = 'k';
+ break;
+ case 1:
+ format_buffer[len-1] = 'g';
+ break;
+ default: /* already verified the given color */
+ break;
+ }
+ pdf_doc_add_page_content(format_buffer, len);
+ return;
+}
+
+void
+pdf_dev_set_strokingcolor (pdf_color *color)
+{
+ int len;
+
+ if (!pdf_dev_get_param(PDF_DEV_PARAM_COLORMODE)) {
+ WARN("Ignore color option was set. Just ignore.");
+ return;
+ } else if (!(color && pdf_color_is_valid(color))) {
+ WARN("No valid color is specified. Just ignore.");
+ return;
+ }
+
+ graphics_mode();
+ len = color_to_string(color, format_buffer);
+ format_buffer[len++] = ' ';
+ switch (color->num_components) {
+ case 3:
+ format_buffer[len++] = 'R';
+ format_buffer[len++] = 'G';
+ break;
+ case 4:
+ format_buffer[len++] = 'K';
+ break;
+ case 1:
+ format_buffer[len++] = 'G';
+ break;
+ default: /* already verified the given color */
+ break;
+ }
+ pdf_doc_add_page_content(format_buffer, len);
+ return;
+}
+
+void
+pdf_dev_set_nonstrokingcolor (pdf_color *color)
+{
+ int len;
+
+ if (!pdf_dev_get_param(PDF_DEV_PARAM_COLORMODE)) {
+ WARN("Ignore color option was set. Just ignore.");
+ return;
+ } else if (!(color && pdf_color_is_valid(color))) {
+ WARN("No valid color is specified. Just ignore.");
+ return;
+ }
+
+ graphics_mode();
+ len = color_to_string(color, format_buffer);
+ format_buffer[len++] = ' ';
+ switch (color->num_components) {
+ case 3:
+ format_buffer[len++] = 'r';
+ format_buffer[len++] = 'g';
+ break;
+ case 4:
+ format_buffer[len++] = 'k';
+ break;
+ case 1:
+ format_buffer[len++] = 'g';
+ break;
+ default: /* already verified the given color */
+ break;
+ }
+ pdf_doc_add_page_content(format_buffer, len);
+ return;
+}
+
/* Not working */
void
pdf_dev_set_origin (double phys_x, double phys_y)
@@ -1232,7 +1341,6 @@ pdf_dev_bop (const pdf_tmatrix *M)
pdf_dev_concat(M);
pdf_dev_reset_fonts();
- pdf_dev_preserve_color(); /* preserve the last color in the previous page */
pdf_dev_reset_color();
}
@@ -1269,8 +1377,6 @@ print_fontmap (const char *font_name, fontmap_rec *mrec)
MESG("[slant:%g]", mrec->opt.slant);
if (mrec->opt.bold != 0.0)
MESG("[bold:%g]", mrec->opt.bold);
- if (mrec->opt.flags & FONTMAP_OPT_REMAP)
- MESG("[remap]");
if (mrec->opt.flags & FONTMAP_OPT_NOEMBED)
MESG("[noemb]");
if (mrec->opt.mapc >= 0)
@@ -1374,7 +1480,6 @@ pdf_dev_locate_font (const char *font_name, spt_t ptsize)
font->extend = 1.0;
font->slant = 0.0;
font->bold = 0.0;
- font->remap = 0;
font->mapc = -1;
font->is_unicode = 0;
font->ucs_group = 0;
@@ -1384,7 +1489,6 @@ pdf_dev_locate_font (const char *font_name, spt_t ptsize)
font->extend = mrec->opt.extend;
font->slant = mrec->opt.slant;
font->bold = mrec->opt.bold;
- font->remap = (int) (mrec->opt.flags & FONTMAP_OPT_REMAP);
if (mrec->opt.mapc >= 0)
font->mapc = (mrec->opt.mapc >> 8) & 0xff;
else {
diff --git a/Build/source/texk/dvipdfmx/src/pdfdev.h b/Build/source/texk/dvipdfmx/src/pdfdev.h
index f29481266b5..5e5b7a9adfe 100644
--- a/Build/source/texk/dvipdfmx/src/pdfdev.h
+++ b/Build/source/texk/dvipdfmx/src/pdfdev.h
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pdfdev.h,v 1.19 2006/12/11 12:46:03 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pdfdev.h,v 1.20 2007/11/22 11:45:39 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -27,6 +27,7 @@
#include "numbers.h"
#include "pdfobj.h"
+#include "pdfcolor.h"
typedef signed long spt_t;
@@ -202,7 +203,11 @@ extern void pdf_dev_set_param (int param_type, int value);
* XFrom (content grabbing) and Metapost support want them.
*/
extern void pdf_dev_reset_fonts (void);
-extern void pdf_dev_reset_color (void); /* defined in pdfcolor.c */
+extern void pdf_dev_reset_color (void);
+
+extern void pdf_dev_set_color (pdf_color *color);
+extern void pdf_dev_set_strokingcolor (pdf_color *color);
+extern void pdf_dev_set_nonstrokingcolor (pdf_color *color);
/* Initialization of transformation matrix with M and others.
* They are called within pdf_doc_begin_page() and pdf_doc_end_page().
diff --git a/Build/source/texk/dvipdfmx/src/pdfdoc.c b/Build/source/texk/dvipdfmx/src/pdfdoc.c
index 19212824ab5..8dbc246ccc5 100644
--- a/Build/source/texk/dvipdfmx/src/pdfdoc.c
+++ b/Build/source/texk/dvipdfmx/src/pdfdoc.c
@@ -1,8 +1,8 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pdfdoc.c,v 1.47 2007/11/14 03:36:01 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pdfdoc.c,v 1.52 2008/05/20 13:05:14 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
- Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata,
+ Copyright (C) 2008 by Jin-Hwan Cho, Matthias Franz, and Shunsaku Hirata,
the dvipdfmx project team <dvipdfmx@project.ktug.or.kr>
Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu>
@@ -55,10 +55,10 @@
#include "pdflimits.h"
-#ifndef NO_THUMBNAIL
+#if HAVE_LIBPNG
#include "pngimage.h"
+#endif
#include "jpegimage.h"
-#endif /* !NO_THUMBNAIL */
#include "pdfdoc.h"
@@ -68,87 +68,40 @@
static int verbose = 0;
-#ifndef NO_THUMBNAIL
-static char thumb_enabled = 0;
+static char manual_thumb_enabled = 0;
static char *thumb_basename = NULL;
-static char thumb_remove = 0;
void
-pdf_doc_enable_thumbnails (int t_remove)
+pdf_doc_enable_manual_thumbnails (void)
{
#if HAVE_LIBPNG
- thumb_enabled = 1;
- thumb_remove = t_remove;
+ manual_thumb_enabled = 1;
#else
- WARN("Thumbnail support not available without PNG support.");
+ WARN("Manual thumbnail is not supported without the libpng library.");
#endif
}
-#define DEFAULT_TMPDIR "/tmp"
-static char *
-guess_thumb_name (const char *thumb_filename)
-{
- /* Build path name for anticipated thumbnail image */
- char *tmpdir, *tmpname;
-
- if (!(tmpdir = getenv("TMP")) &&
- !(tmpdir = getenv("TEMP")))
- tmpdir = (char *) DEFAULT_TMPDIR;
- tmpname = NEW(strlen(tmpdir) +
- strlen(thumb_filename) + strlen(DIR_SEP_STRING) + 1,
- char);
- strcpy(tmpname, tmpdir);
- if (!IS_DIR_SEP(tmpname[strlen(tmpname)-1])) {
- strcat(tmpname, DIR_SEP_STRING);
- }
- strcat(tmpname, thumb_filename);
-
- return tmpname;
-}
-
-#ifndef HAVE_LIBPNG
-static pdf_obj *
-read_thumbnail (const char *thumb_filename)
-{
- WARN("Thumbnail support not available without PNG support.");
-}
-#else /* HAVE_LIBPNG */
static pdf_obj *
read_thumbnail (const char *thumb_filename)
{
pdf_obj *image_ref;
int xobj_id;
- char *guess_filename = NULL;
int found_in_cwd = 0;
FILE *fp;
- guess_filename = guess_thumb_name(thumb_filename);
- if ((fp = MFOPEN(thumb_filename, FOPEN_RBIN_MODE))) {
- found_in_cwd = 1;
- } else {
- fp = MFOPEN(guess_filename, FOPEN_RBIN_MODE);
- }
-
+ fp = MFOPEN(thumb_filename, FOPEN_RBIN_MODE);
if (!fp) {
WARN("Could not open thumbnail file \"%s\"", thumb_filename);
- if (guess_filename)
- RELEASE(guess_filename);
return NULL;
- } else if (!check_for_png(fp) && !check_for_jpeg(fp)) {
+ }
+ if (!check_for_png(fp) && !check_for_jpeg(fp)) {
WARN("Thumbnail \"%s\" not a png/jpeg file!", thumb_filename);
MFCLOSE(fp);
- if (guess_filename)
- RELEASE(guess_filename);
return NULL;
}
MFCLOSE(fp);
- if (found_in_cwd) {
- xobj_id = pdf_ximage_findresource(thumb_filename);
- } else {
- xobj_id = pdf_ximage_findresource(guess_filename);
- }
-
+ xobj_id = pdf_ximage_findresource(thumb_filename, 0);
if (xobj_id < 0) {
WARN("Could not read thumbnail file \"%s\".", thumb_filename);
image_ref = NULL;
@@ -156,25 +109,9 @@ read_thumbnail (const char *thumb_filename)
image_ref = pdf_ximage_get_reference(xobj_id);
}
- if (thumb_remove && found_in_cwd) {
- if (verbose > 1)
- MESG("\ndeleting thumbnail file \"%s\"...\n", thumb_filename);
- remove(thumb_filename);
- } else if (thumb_remove) {
- if (verbose > 1)
- MESG("\ndeleting thumbnail file \"%s\"...\n", guess_filename);
- remove(guess_filename);
- }
-
- if (guess_filename)
- RELEASE(guess_filename);
-
return image_ref;
}
-#endif /* HAVE_LIBPNG */
-#endif /* !NO_THUMBNAIL */
-
void
pdf_doc_set_verbose (void)
{
@@ -1335,10 +1272,10 @@ pdf_doc_add_annot (unsigned page_no, const pdf_rect *rect, pdf_obj *annot_dict)
#endif
rect_array = pdf_new_array();
- pdf_add_array(rect_array, pdf_new_number(ROUND(rect->llx - annot_grow, 0.01)));
- pdf_add_array(rect_array, pdf_new_number(ROUND(rect->lly - annot_grow, 0.01)));
- pdf_add_array(rect_array, pdf_new_number(ROUND(rect->urx + annot_grow, 0.01)));
- pdf_add_array(rect_array, pdf_new_number(ROUND(rect->ury + annot_grow, 0.01)));
+ pdf_add_array(rect_array, pdf_new_number(ROUND(rect->llx - annot_grow, 0.001)));
+ pdf_add_array(rect_array, pdf_new_number(ROUND(rect->lly - annot_grow, 0.001)));
+ pdf_add_array(rect_array, pdf_new_number(ROUND(rect->urx + annot_grow, 0.001)));
+ pdf_add_array(rect_array, pdf_new_number(ROUND(rect->ury + annot_grow, 0.001)));
pdf_add_dict (annot_dict, pdf_new_name("Rect"), rect_array);
pdf_add_array(page->annots, pdf_ref_obj(annot_dict));
@@ -1905,8 +1842,7 @@ pdf_doc_finish_page (pdf_doc *p)
currentpage->resources = NULL;
}
-#ifndef NO_THUMBNAIL
- if (thumb_enabled) {
+ if (manual_thumb_enabled) {
char *thumb_filename;
pdf_obj *thumb_ref;
@@ -1918,7 +1854,6 @@ pdf_doc_finish_page (pdf_doc *p)
if (thumb_ref)
pdf_add_dict(currentpage->page_obj, pdf_new_name("Thumb"), thumb_ref);
}
-#endif /* !NO_THUMBNAIL */
p->pages.num_entries++;
@@ -1962,10 +1897,10 @@ doc_fill_page_background (pdf_doc *p)
currentpage->contents = currentpage->background;
pdf_dev_gsave();
- pdf_color_push();
- pdf_dev_setcolor(&bgcolor, 1); /* is_fill */
+ //pdf_color_push();
+ pdf_dev_set_nonstrokingcolor(&bgcolor);
pdf_dev_rectfill(r.llx, r.lly, r.urx - r.llx, r.ury - r.lly);
- pdf_color_pop();
+ //pdf_color_pop();
pdf_dev_grestore();
currentpage->contents = saved_content;
@@ -2024,7 +1959,7 @@ static char *doccreator = NULL; /* Ugh */
void
pdf_open_document (const char *filename,
- int do_encryption, int do_objstm,
+ int do_encryption,
double media_width, double media_height,
double annot_grow_amount, int bookmark_open_depth)
{
@@ -2062,12 +1997,8 @@ pdf_open_document (const char *filename,
pdf_release_obj(encrypt);
}
- if (do_objstm)
- pdf_objstm_init();
-
-#ifndef NO_THUMBNAIL
/* Create a default name for thumbnail image files */
- if (thumb_enabled) {
+ if (manual_thumb_enabled) {
if (strlen(filename) > 4 &&
!strncmp(".pdf", filename + strlen(filename) - 4, 4)) {
thumb_basename = NEW(strlen(filename)-4+1, char);
@@ -2078,7 +2009,6 @@ pdf_open_document (const char *filename,
strcpy(thumb_basename, filename);
}
}
-#endif /* !NO_THUMBNAIL */
p->pending_forms = NULL;
@@ -2121,13 +2051,8 @@ pdf_close_document (void)
pdf_out_flush();
-#ifndef NO_THUMBNAIL
- if (thumb_basename) {
+ if (thumb_basename)
RELEASE(thumb_basename);
- }
-#endif /* !NO_THUMBNAIL */
-
- pdf_objstm_close();
return;
}
diff --git a/Build/source/texk/dvipdfmx/src/pdfdoc.h b/Build/source/texk/dvipdfmx/src/pdfdoc.h
index 2fd805c6077..587067a528b 100644
--- a/Build/source/texk/dvipdfmx/src/pdfdoc.h
+++ b/Build/source/texk/dvipdfmx/src/pdfdoc.h
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pdfdoc.h,v 1.21 2007/11/14 03:36:01 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pdfdoc.h,v 1.23 2008/05/20 13:05:14 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -33,7 +33,7 @@
extern void pdf_doc_set_verbose (void);
extern void pdf_open_document (const char *filename,
- int do_encryption, int do_objstm,
+ int do_encryption,
double media_width, double media_height,
double annot_grow_amount, int bookmark_open_depth);
extern void pdf_close_document (void);
@@ -123,8 +123,8 @@ extern void pdf_doc_end_annot (void);
extern void pdf_doc_break_annot (void);
extern void pdf_doc_expand_box (const pdf_rect *rect);
-/* Thumbnail */
-extern void pdf_doc_enable_thumbnails (int thumb_remove);
+/* Manual thumbnail */
+extern void pdf_doc_enable_manual_thumbnails (void);
/* PageLabels - */
extern void pdf_doc_set_pagelabel (long page_start,
diff --git a/Build/source/texk/dvipdfmx/src/pdfdraw.c b/Build/source/texk/dvipdfmx/src/pdfdraw.c
index 444d177d9b0..cb348206c4b 100644
--- a/Build/source/texk/dvipdfmx/src/pdfdraw.c
+++ b/Build/source/texk/dvipdfmx/src/pdfdraw.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pdfdraw.c,v 1.13 2006/12/11 12:46:03 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pdfdraw.c,v 1.14 2007/11/22 17:10:12 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -267,7 +267,7 @@ static char fmt_buf[1024]; /* FIXME */
#define FORMAT_BUFF_LEN(p) 1024
static void
-pdf_path__initpath (pdf_path *p)
+init_a_path (pdf_path *p)
{
ASSERT(p);
@@ -301,7 +301,7 @@ pdf_path__growpath (pdf_path *p, int max_pe)
}
static void
-pdf_path__cleanpath (pdf_path *p)
+clear_a_path (pdf_path *p)
{
ASSERT(p);
@@ -987,25 +987,18 @@ m_stack_top (m_stack *stack)
#define m_stack_depth(s) ((s) ? (s)->size : 0)
-
-static m_stack _gsstck; /* FIXME */
-
+static m_stack gs_stack;
static void
-pdf_dev__init_gstate (pdf_gstate *gs)
+init_a_gstate (pdf_gstate *gs)
{
- pdf_path *pa = &gs->path;
- pdf_color *cf = &gs->fillcolor;
- pdf_color *cs = &gs->strokecolor;
- pdf_tmatrix *M = &gs->matrix;
-
gs->cp.x = 0.0;
gs->cp.y = 0.0;
- pdf_setmatrix(M, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
+ pdf_setmatrix(&gs->matrix, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
- pdf_color_graycolor(cs, 0.0);
- pdf_color_graycolor(cf, 0.0);
+ pdf_color_graycolor(&gs->strokecolor, 0.0);
+ pdf_color_graycolor(&gs->fillcolor, 0.0);
gs->linedash.num_dash = 0;
gs->linedash.offset = 0;
@@ -1018,22 +1011,22 @@ pdf_dev__init_gstate (pdf_gstate *gs)
/* Internal variables */
gs->flags = 0;
- pdf_path__initpath(pa);
+ init_a_path(&gs->path);
return;
}
static void
-pdf_dev__clean_gstate (pdf_gstate *gs)
+clear_a_gstate (pdf_gstate *gs)
{
- pdf_path__cleanpath(&gs->path);
+ clear_a_path(&gs->path);
memset(gs, 0, sizeof(pdf_gstate));
return;
}
static void
-pdf_dev__copy_gstate (pdf_gstate *gs1, pdf_gstate *gs2)
+copy_a_gstate (pdf_gstate *gs1, pdf_gstate *gs2)
{
int i;
@@ -1072,156 +1065,89 @@ pdf_dev__copy_gstate (pdf_gstate *gs1, pdf_gstate *gs2)
void
pdf_dev_init_gstates (void)
{
- m_stack *gss = &_gsstck;
pdf_gstate *gs;
- m_stack_init(gss);
+ m_stack_init(&gs_stack);
gs = NEW(1, pdf_gstate);
- pdf_dev__init_gstate(gs);
+ init_a_gstate(gs);
- m_stack_push(gss, gs); /* Initial state */
+ m_stack_push(&gs_stack, gs); /* Initial state */
return;
}
void
-pdf_dev_clean_gstates (void)
+pdf_dev_clear_gstates (void)
{
- m_stack *gss = &_gsstck;
pdf_gstate *gs;
- if (m_stack_depth(gss) > 1) /* at least 1 elem. */
- WARN("GS stack depth not 0 at end of document.");
+ if (m_stack_depth(&gs_stack) > 1) /* at least 1 elem. */
+ WARN("GS stack depth is not zero at the end of the document.");
- while ((gs = m_stack_pop(gss)) != NULL) {
- pdf_dev__clean_gstate(gs);
+ while ((gs = m_stack_pop(&gs_stack)) != NULL) {
+ clear_a_gstate(gs);
RELEASE(gs);
}
-
return;
}
-
-int
-pdf_dev_currentpoint (pdf_coord *p)
-{
- m_stack *gss = &_gsstck;
- pdf_gstate *gs = m_stack_top(gss);
- pdf_coord *cpt = &gs->cp;
-
- ASSERT(p);
-
- p->x = cpt->x; p->y = cpt->y;
-
- return 0;
-}
-
-int
-pdf_dev_currentmatrix (pdf_tmatrix *M)
-{
- m_stack *gss = &_gsstck;
- pdf_gstate *gs = m_stack_top(gss);
- pdf_tmatrix *CTM = &gs->matrix;
-
- ASSERT(M);
-
- pdf_copymatrix(M, CTM);
-
- return 0;
-}
-
-#if 0
int
-pdf_dev_currentcolor (pdf_color *color, int is_fill)
+pdf_dev_gsave (void)
{
- m_stack *gss = &_gsstck;
- pdf_gstate *gs = m_stack_top(gss);
- pdf_color *fcl = &gs->fillcolor;
- pdf_color *scl = &gs->strokecolor;
+ pdf_gstate *gs0, *gs1;
+ pdf_color *sc, *fc;
- ASSERT(color);
+ gs0 = m_stack_top(&gs_stack);
+ gs1 = NEW(1, pdf_gstate);
+ init_a_gstate(gs1);
+ copy_a_gstate(gs1, gs0);
+ pdf_color_get_current(&sc, &fc);
+ pdf_color_copycolor(&gs1->strokecolor, sc);
+ pdf_color_copycolor(&gs1->fillcolor, fc);
+ m_stack_push(&gs_stack, gs1);
- pdf_color_copycolor(color, is_fill ? fcl : scl);
+ pdf_doc_add_page_content(" q", 2);
return 0;
}
-#endif /* 0 */
int
-pdf_dev_concat (const pdf_tmatrix *M)
+pdf_dev_grestore (void)
{
- m_stack *gss = &_gsstck;
- pdf_gstate *gs = m_stack_top(gss);
- pdf_path *cpa = &gs->path;
- pdf_coord *cpt = &gs->cp;
- pdf_tmatrix *CTM = &gs->matrix;
- pdf_tmatrix W;
- char *buf = FORMAT_BUFF_PTR(NULL);
- int len = 0;
-
- ASSERT(M);
+ pdf_gstate *gs;
+ pdf_color sc, fc;
- /* Adobe Reader erases page content if there are
- * non invertible transformation.
- */
- if (fabs(detP(M)) < 1.0e-8) {
- WARN("Transformation matrix not invertible.");
- WARN("--- M = [%g %g %g %g %g %g]",
- M->a, M->b, M->c, M->d, M->e, M->f);
- return -1;
+ if (m_stack_depth(&gs_stack) <= 1) { /* Initial state at bottom */
+ WARN("Too many grestores.");
+ return -1;
}
- buf[len++] = ' ';
- len += pdf_sprint_matrix(buf + len, M);
- buf[len++] = ' ';
- buf[len++] = 'c';
- buf[len++] = 'm';
- pdf_doc_add_page_content(buf, len);
-
- pdf_concatmatrix(CTM, M);
-
- inversematrix(&W, M);
-
- pdf_path__transform (cpa, &W);
- pdf_coord__transform(cpt, &W);
-
- return 0;
-}
-
-
-int
-pdf_dev_gsave (void)
-{
- m_stack *gss = &_gsstck;
- pdf_gstate *gs0, *gs1;
-
- gs0 = m_stack_top(gss);
- gs1 = NEW(1, pdf_gstate);
-
- pdf_dev__init_gstate(gs1);
- pdf_dev__copy_gstate(gs1, gs0);
-
- pdf_dev_currentcolor(&gs1->strokecolor, 0);
- pdf_dev_currentcolor(&gs1->fillcolor, 1);
+ gs = m_stack_pop(&gs_stack);
+// pdf_color_copycolor(&sc, &gs->strokecolor);
+// pdf_color_copycolor(&fc, &gs->fillcolor);
+ clear_a_gstate(gs);
+ RELEASE(gs);
- m_stack_push(gss, gs1);
+ pdf_doc_add_page_content(" Q", 2);
- pdf_doc_add_page_content(" q", 2);
+ pdf_dev_reset_fonts();
+// pdf_dev_set_strokingcolor(&sc);
+// pdf_dev_set_nonstrokingcolor(&fc);
- return 0;
+ return 0;
}
int
pdf_dev_push_gstate (void)
{
- m_stack *gss = &_gsstck;
+ m_stack *gss = &gs_stack;
pdf_gstate *gs0;
gs0 = NEW(1, pdf_gstate);
- pdf_dev__init_gstate(gs0);
+ init_a_gstate(gs0);
m_stack_push(gss, gs0);
@@ -1232,7 +1158,7 @@ pdf_dev_push_gstate (void)
int
pdf_dev_pop_gstate (void)
{
- m_stack *gss = &_gsstck;
+ m_stack *gss = &gs_stack;
pdf_gstate *gs;
if (m_stack_depth(gss) <= 1) { /* Initial state at bottom */
@@ -1241,7 +1167,7 @@ pdf_dev_pop_gstate (void)
}
gs = m_stack_pop(gss);
- pdf_dev__clean_gstate(gs);
+ clear_a_gstate(gs);
RELEASE(gs);
return 0;
@@ -1251,16 +1177,15 @@ pdf_dev_pop_gstate (void)
int
pdf_dev_current_depth (void)
{
- m_stack *gss = &_gsstck;
-
- return (m_stack_depth(gss) - 1); /* 0 means initial state */
+ return (m_stack_depth(&gs_stack) - 1); /* 0 means initial state */
}
void
pdf_dev_grestore_to (int depth)
{
- m_stack *gss = &_gsstck;
+ m_stack *gss = &gs_stack;
pdf_gstate *gs;
+ pdf_color sc, fc;
ASSERT(depth >= 0);
@@ -1271,44 +1196,102 @@ pdf_dev_grestore_to (int depth)
while (m_stack_depth(gss) > depth + 1) {
pdf_doc_add_page_content(" Q", 2);
gs = m_stack_pop(gss);
- pdf_dev__clean_gstate(gs);
+// pdf_color_copycolor(&sc, &gs->strokecolor);
+// pdf_color_copycolor(&fc, &gs->fillcolor);
+ clear_a_gstate(gs);
RELEASE(gs);
}
pdf_dev_reset_fonts();
- pdf_dev_reset_color();
+// pdf_dev_set_strokingcolor(&sc);
+// pdf_dev_set_nonstrokingcolor(&fc);
return;
}
int
-pdf_dev_grestore (void)
+pdf_dev_currentpoint (pdf_coord *p)
{
- m_stack *gss = &_gsstck;
- pdf_gstate *gs;
- pdf_color sc, fc;
+ m_stack *gss = &gs_stack;
+ pdf_gstate *gs = m_stack_top(gss);
+ pdf_coord *cpt = &gs->cp;
- if (m_stack_depth(gss) <= 1) { /* Initial state at bottom */
- WARN("Too many grestores.");
- return -1;
- }
+ ASSERT(p);
- gs = m_stack_pop(gss);
+ p->x = cpt->x; p->y = cpt->y;
+
+ return 0;
+}
- pdf_color_copycolor(&sc, &gs->strokecolor);
- pdf_color_copycolor(&fc, &gs->fillcolor);
+int
+pdf_dev_currentmatrix (pdf_tmatrix *M)
+{
+ m_stack *gss = &gs_stack;
+ pdf_gstate *gs = m_stack_top(gss);
+ pdf_tmatrix *CTM = &gs->matrix;
- pdf_dev__clean_gstate(gs);
- RELEASE(gs);
+ ASSERT(M);
- pdf_doc_add_page_content(" Q", 2);
+ pdf_copymatrix(M, CTM);
- pdf_dev_reset_fonts();
- pdf_dev_reset_color();
+ return 0;
+}
- pdf_dev_setcolor(&sc, 0);
- pdf_dev_setcolor(&fc, 1);
+#if 0
+int
+pdf_dev_currentcolor (pdf_color *color, int is_fill)
+{
+ m_stack *gss = &gs_stack;
+ pdf_gstate *gs = m_stack_top(gss);
+ pdf_color *fcl = &gs->fillcolor;
+ pdf_color *scl = &gs->strokecolor;
- return 0;
+ ASSERT(color);
+
+ pdf_color_copycolor(color, is_fill ? fcl : scl);
+
+ return 0;
+}
+#endif /* 0 */
+
+int
+pdf_dev_concat (const pdf_tmatrix *M)
+{
+ m_stack *gss = &gs_stack;
+ pdf_gstate *gs = m_stack_top(gss);
+ pdf_path *cpa = &gs->path;
+ pdf_coord *cpt = &gs->cp;
+ pdf_tmatrix *CTM = &gs->matrix;
+ pdf_tmatrix W;
+ char *buf = FORMAT_BUFF_PTR(NULL);
+ int len = 0;
+
+ ASSERT(M);
+
+ /* Adobe Reader erases page content if there are
+ * non invertible transformation.
+ */
+ if (fabs(detP(M)) < 1.0e-8) {
+ WARN("Transformation matrix not invertible.");
+ WARN("--- M = [%g %g %g %g %g %g]",
+ M->a, M->b, M->c, M->d, M->e, M->f);
+ return -1;
+ }
+
+ buf[len++] = ' ';
+ len += pdf_sprint_matrix(buf + len, M);
+ buf[len++] = ' ';
+ buf[len++] = 'c';
+ buf[len++] = 'm';
+ pdf_doc_add_page_content(buf, len);
+
+ pdf_concatmatrix(CTM, M);
+
+ inversematrix(&W, M);
+
+ pdf_path__transform (cpa, &W);
+ pdf_coord__transform(cpt, &W);
+
+ return 0;
}
/*
@@ -1324,7 +1307,7 @@ pdf_dev_grestore (void)
int
pdf_dev_setmiterlimit (double mlimit)
{
- m_stack *gss = &_gsstck;
+ m_stack *gss = &gs_stack;
pdf_gstate *gs = m_stack_top(gss);
int len = 0;
char *buf = FORMAT_BUFF_PTR(NULL);
@@ -1344,7 +1327,7 @@ pdf_dev_setmiterlimit (double mlimit)
int
pdf_dev_setlinecap (int capstyle)
{
- m_stack *gss = &_gsstck;
+ m_stack *gss = &gs_stack;
pdf_gstate *gs = m_stack_top(gss);
int len = 0;
char *buf = FORMAT_BUFF_PTR(NULL);
@@ -1361,7 +1344,7 @@ pdf_dev_setlinecap (int capstyle)
int
pdf_dev_setlinejoin (int joinstyle)
{
- m_stack *gss = &_gsstck;
+ m_stack *gss = &gs_stack;
pdf_gstate *gs = m_stack_top(gss);
int len = 0;
char *buf = FORMAT_BUFF_PTR(NULL);
@@ -1378,7 +1361,7 @@ pdf_dev_setlinejoin (int joinstyle)
int
pdf_dev_setlinewidth (double width)
{
- m_stack *gss = &_gsstck;
+ m_stack *gss = &gs_stack;
pdf_gstate *gs = m_stack_top(gss);
int len = 0;
char *buf = FORMAT_BUFF_PTR(NULL);
@@ -1398,7 +1381,7 @@ pdf_dev_setlinewidth (double width)
int
pdf_dev_setdash (int count, double *pattern, double offset)
{
- m_stack *gss = &_gsstck;
+ m_stack *gss = &gs_stack;
pdf_gstate *gs = m_stack_top(gss);
int len = 0;
char *buf = FORMAT_BUFF_PTR(NULL);
@@ -1424,7 +1407,7 @@ pdf_dev_setdash (int count, double *pattern, double offset)
int
pdf_dev_setflat (int flatness)
{
- m_stack *gss = &_gsstck;
+ m_stack *gss = &gs_stack;
pdf_gstate *gs = m_stack_top(gss);
int len = 0;
char *buf = FORMAT_BUFF_PTR(NULL);
@@ -1445,7 +1428,7 @@ pdf_dev_setflat (int flatness)
int
pdf_dev_clip (void)
{
- m_stack *gss = &_gsstck;
+ m_stack *gss = &gs_stack;
pdf_gstate *gs = m_stack_top(gss);
pdf_path *cpa = &gs->path;
@@ -1455,7 +1438,7 @@ pdf_dev_clip (void)
int
pdf_dev_eoclip (void)
{
- m_stack *gss = &_gsstck;
+ m_stack *gss = &gs_stack;
pdf_gstate *gs = m_stack_top(gss);
pdf_path *cpa = &gs->path;
@@ -1465,7 +1448,7 @@ pdf_dev_eoclip (void)
int
pdf_dev_flushpath (char p_op, int fill_rule)
{
- m_stack *gss = &_gsstck;
+ m_stack *gss = &gs_stack;
pdf_gstate *gs = m_stack_top(gss);
pdf_path *cpa = &gs->path;
int error = 0;
@@ -1485,7 +1468,7 @@ pdf_dev_flushpath (char p_op, int fill_rule)
int
pdf_dev_newpath (void)
{
- m_stack *gss = &_gsstck;
+ m_stack *gss = &gs_stack;
pdf_gstate *gs = m_stack_top(gss);
pdf_path *p = &gs->path;
@@ -1501,7 +1484,7 @@ pdf_dev_newpath (void)
int
pdf_dev_moveto (double x, double y)
{
- m_stack *gss = &_gsstck;
+ m_stack *gss = &gs_stack;
pdf_gstate *gs = m_stack_top(gss);
pdf_path *cpa = &gs->path;
pdf_coord *cpt = &gs->cp;
@@ -1514,7 +1497,7 @@ pdf_dev_moveto (double x, double y)
int
pdf_dev_rmoveto (double x, double y)
{
- m_stack *gss = &_gsstck;
+ m_stack *gss = &gs_stack;
pdf_gstate *gs = m_stack_top(gss);
pdf_path *cpa = &gs->path;
pdf_coord *cpt = &gs->cp;
@@ -1528,7 +1511,7 @@ pdf_dev_rmoveto (double x, double y)
int
pdf_dev_lineto (double x, double y)
{
- m_stack *gss = &_gsstck;
+ m_stack *gss = &gs_stack;
pdf_gstate *gs = m_stack_top(gss);
pdf_path *cpa = &gs->path;
pdf_coord *cpt = &gs->cp;
@@ -1542,7 +1525,7 @@ pdf_dev_lineto (double x, double y)
int
pdf_dev_rlineto (double x, double y)
{
- m_stack *gss = &_gsstck;
+ m_stack *gss = &gs_stack;
pdf_gstate *gs = m_stack_top(gss);
pdf_path *cpa = &gs->path;
pdf_coord *cpt = &gs->cp;
@@ -1558,7 +1541,7 @@ pdf_dev_curveto (double x0, double y0,
double x1, double y1,
double x2, double y2)
{
- m_stack *gss = &_gsstck;
+ m_stack *gss = &gs_stack;
pdf_gstate *gs = m_stack_top(gss);
pdf_path *cpa = &gs->path;
pdf_coord *cpt = &gs->cp;
@@ -1576,7 +1559,7 @@ pdf_dev_rcurveto (double x0, double y0,
double x1, double y1,
double x2, double y2)
{
- m_stack *gss = &_gsstck;
+ m_stack *gss = &gs_stack;
pdf_gstate *gs = m_stack_top(gss);
pdf_path *cpa = &gs->path;
pdf_coord *cpt = &gs->cp;
@@ -1593,7 +1576,7 @@ pdf_dev_rcurveto (double x0, double y0,
int
pdf_dev_closepath (void)
{
- m_stack *gss = &_gsstck;
+ m_stack *gss = &gs_stack;
pdf_gstate *gs = m_stack_top(gss);
pdf_coord *cpt = &gs->cp;
pdf_path *cpa = &gs->path;
@@ -1605,7 +1588,7 @@ pdf_dev_closepath (void)
void
pdf_dev_dtransform (pdf_coord *p, const pdf_tmatrix *M)
{
- m_stack *gss = &_gsstck;
+ m_stack *gss = &gs_stack;
pdf_gstate *gs = m_stack_top(gss);
pdf_tmatrix *CTM = &gs->matrix;
@@ -1619,7 +1602,7 @@ pdf_dev_dtransform (pdf_coord *p, const pdf_tmatrix *M)
void
pdf_dev_idtransform (pdf_coord *p, const pdf_tmatrix *M)
{
- m_stack *gss = &_gsstck;
+ m_stack *gss = &gs_stack;
pdf_gstate *gs = m_stack_top(gss);
pdf_tmatrix *CTM = &gs->matrix;
@@ -1633,7 +1616,7 @@ pdf_dev_idtransform (pdf_coord *p, const pdf_tmatrix *M)
void
pdf_dev_transform (pdf_coord *p, const pdf_tmatrix *M)
{
- m_stack *gss = &_gsstck;
+ m_stack *gss = &gs_stack;
pdf_gstate *gs = m_stack_top(gss);
pdf_tmatrix *CTM = &gs->matrix;
@@ -1647,7 +1630,7 @@ pdf_dev_transform (pdf_coord *p, const pdf_tmatrix *M)
void
pdf_dev_itransform (pdf_coord *p, const pdf_tmatrix *M)
{
- m_stack *gss = &_gsstck;
+ m_stack *gss = &gs_stack;
pdf_gstate *gs = m_stack_top(gss);
pdf_tmatrix *CTM = &gs->matrix;
@@ -1662,7 +1645,7 @@ int
pdf_dev_arc (double c_x , double c_y, double r,
double a_0 , double a_1)
{
- m_stack *gss = &_gsstck;
+ m_stack *gss = &gs_stack;
pdf_gstate *gs = m_stack_top(gss);
pdf_path *cpa = &gs->path;
pdf_coord *cpt = &gs->cp;
@@ -1678,7 +1661,7 @@ int
pdf_dev_arcn (double c_x , double c_y, double r,
double a_0 , double a_1)
{
- m_stack *gss = &_gsstck;
+ m_stack *gss = &gs_stack;
pdf_gstate *gs = m_stack_top(gss);
pdf_path *cpa = &gs->path;
pdf_coord *cpt = &gs->cp;
@@ -1696,7 +1679,7 @@ pdf_dev_arcx (double c_x , double c_y,
int a_d ,
double xar)
{
- m_stack *gss = &_gsstck;
+ m_stack *gss = &gs_stack;
pdf_gstate *gs = m_stack_top(gss);
pdf_path *cpa = &gs->path;
pdf_coord *cpt = &gs->cp;
@@ -1712,7 +1695,7 @@ int
pdf_dev_bspline (double x0, double y0,
double x1, double y1, double x2, double y2)
{
- m_stack *gss = &_gsstck;
+ m_stack *gss = &gs_stack;
pdf_gstate *gs = m_stack_top(gss);
pdf_path *cpa = &gs->path;
pdf_coord *cpt = &gs->cp;
diff --git a/Build/source/texk/dvipdfmx/src/pdfencoding.c b/Build/source/texk/dvipdfmx/src/pdfencoding.c
index 75fbfc76991..b595edee385 100644
--- a/Build/source/texk/dvipdfmx/src/pdfencoding.c
+++ b/Build/source/texk/dvipdfmx/src/pdfencoding.c
@@ -1,8 +1,8 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pdfencoding.c,v 1.6 2007/11/14 03:12:21 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pdfencoding.c,v 1.9 2008/05/13 12:23:45 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
- Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata,
+ Copyright (C) 2008 by Jin-Hwan Cho, Matthias Franz, and Shunsaku Hirata,
the dvipdfmx project team <dvipdfmx@project.ktug.or.kr>
Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu>
@@ -136,9 +136,18 @@ create_encoding_resource (pdf_encoding *encoding, pdf_encoding *baseenc)
pdf_add_dict(resource, pdf_new_name("Differences"), differences);
return resource;
} else {
- /* we must have a base encoding */
- ASSERT(baseenc);
- return pdf_link_obj(baseenc->resource);
+ /* Fix a bug with the MinionPro package using MnSymbol fonts
+ * in its virtual fonts:
+ *
+ * Some font may have font_id even if no character is used.
+ * For example, suppose that a virtual file A.vf uses two
+ * other fonts, B and C. Even if only characters of B are used
+ * in a DVI document, C will have font_id too.
+ * In this case, both baseenc and differences can be NULL.
+ *
+ * Actually these fonts will be ignored in pdffont.c.
+ */
+ return baseenc ? pdf_link_obj(baseenc->resource) : NULL;
}
}
@@ -312,7 +321,7 @@ load_encoding_file (const char *filename)
enc_name = parse_pdf_name(&p, endptr);
skip_white(&p, endptr);
- encoding_array = parse_pdf_array(&p, endptr);
+ encoding_array = parse_pdf_array(&p, endptr, NULL);
RELEASE(wbuf);
if (!encoding_array) {
if (enc_name)
diff --git a/Build/source/texk/dvipdfmx/src/pdfencrypt.c b/Build/source/texk/dvipdfmx/src/pdfencrypt.c
index 677febc3d5c..932b3960da1 100644
--- a/Build/source/texk/dvipdfmx/src/pdfencrypt.c
+++ b/Build/source/texk/dvipdfmx/src/pdfencrypt.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pdfencrypt.c,v 1.9 2007/04/03 05:25:50 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pdfencrypt.c,v 1.10 2008/02/12 18:44:40 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -143,8 +143,12 @@ static void compute_owner_password (void)
*/
if (revision == 3)
for (i = 0; i < 50; i++) {
+ /*
+ * NOTE: We truncate each MD5 hash as in the following step.
+ * Otherwise Adobe Reader won't decrypt the PDF file.
+ */
MD5_init(&md5_ctx);
- MD5_write(&md5_ctx, md5_buf, MAX_KEY_LEN);
+ MD5_write(&md5_ctx, md5_buf, key_size);
MD5_final(md5_buf, &md5_ctx);
}
/*
@@ -246,8 +250,12 @@ static void compute_encryption_key (unsigned char *pwd)
*/
if (revision == 3)
for (i = 0; i < 50; i++) {
+ /*
+ * NOTE: We truncate each MD5 hash as in the following step.
+ * Otherwise Adobe Reader won't decrypt the PDF file.
+ */
MD5_init(&md5_ctx);
- MD5_write(&md5_ctx, md5_buf, MAX_KEY_LEN);
+ MD5_write(&md5_ctx, md5_buf, key_size);
MD5_final(md5_buf, &md5_ctx);
}
/*
diff --git a/Build/source/texk/dvipdfmx/src/pdffont.c b/Build/source/texk/dvipdfmx/src/pdffont.c
index d011e59da9a..02e1f1962df 100644
--- a/Build/source/texk/dvipdfmx/src/pdffont.c
+++ b/Build/source/texk/dvipdfmx/src/pdffont.c
@@ -1,8 +1,8 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pdffont.c,v 1.17 2007/11/15 17:08:52 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pdffont.c,v 1.23 2008/05/18 14:49:20 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
- Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata,
+ Copyright (C) 2008 by Jin-Hwan Cho, Matthias Franz, and Shunsaku Hirata,
the dvipdfmx project team <dvipdfmx@project.ktug.or.kr>
Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu>
@@ -122,6 +122,7 @@ struct pdf_font
int font_id;
/* For simple font */
+ int index;
char *fontname;
char uniqueID[7];
@@ -154,6 +155,7 @@ pdf_init_font_struct (pdf_font *font)
font->font_id = -1; /* Type0 ID */
font->fontname = NULL;
memset(font->uniqueID, 0, 7);
+ font->index = 0;
font->encoding_id = -1;
@@ -531,9 +533,10 @@ pdf_close_fonts (void)
/* Predefined encodings (and those simplified to them) are embedded
as direct objects, but this is purely a matter of taste. */
- pdf_add_dict(font->resource,
- pdf_new_name("Encoding"),
- PDF_OBJ_NAMETYPE(enc_obj) ? pdf_link_obj(enc_obj) : pdf_ref_obj(enc_obj));
+ if (enc_obj)
+ pdf_add_dict(font->resource,
+ pdf_new_name("Encoding"),
+ PDF_OBJ_NAMETYPE(enc_obj) ? pdf_link_obj(enc_obj) : pdf_ref_obj(enc_obj));
if (!pdf_lookup_dict(font->resource, "ToUnicode")
&& (tounicode = pdf_encoding_get_tounicode(font->encoding_id)))
@@ -669,8 +672,6 @@ pdf_font_findresource (const char *tex_name,
font->subtype = PDF_FONT_FONTTYPE_TYPE0;
font->encoding_id = cmap_id;
- mrec->opt.flags &= ~FONTMAP_OPT_REMAP; /* _FIXME_ */
-
font_cache.count++;
if (__verbose) {
@@ -701,7 +702,8 @@ pdf_font_findresource (const char *tex_name,
*/
if (!strcmp(fontname, font->ident) &&
encoding_id == font->encoding_id) {
- found = 1;
+ if (mrec && mrec->opt.index == font->index)
+ found = 1;
}
break;
case PDF_FONT_FONTTYPE_TYPE3:
@@ -749,6 +751,7 @@ pdf_font_findresource (const char *tex_name,
strcpy(font->ident, fontname);
font->map_name = NEW(strlen(tex_name) + 1, char);
strcpy(font->map_name, tex_name);
+ font->index = (mrec && mrec->opt.index) ? mrec->opt.index : 0;
if (pdf_font_open_type1(font) >= 0) {
font->subtype = PDF_FONT_FONTTYPE_TYPE1;
@@ -785,6 +788,14 @@ pdf_font_is_in_use (pdf_font *font)
return ((font->reference) ? 1 : 0);
}
+int
+pdf_font_get_index (pdf_font *font)
+{
+ ASSERT(font);
+
+ return font->index;
+}
+
char *
pdf_font_get_ident (pdf_font *font)
{
@@ -794,6 +805,14 @@ pdf_font_get_ident (pdf_font *font)
}
char *
+pdf_font_get_mapname (pdf_font *font)
+{
+ ASSERT(font);
+
+ return font->map_name;
+}
+
+char *
pdf_font_get_fontname (pdf_font *font)
{
ASSERT(font);
diff --git a/Build/source/texk/dvipdfmx/src/pdffont.h b/Build/source/texk/dvipdfmx/src/pdffont.h
index 2bfb8aa6614..6fdc2c8f9f9 100644
--- a/Build/source/texk/dvipdfmx/src/pdffont.h
+++ b/Build/source/texk/dvipdfmx/src/pdffont.h
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pdffont.h,v 1.8 2004/09/11 14:50:28 hirata Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pdffont.h,v 1.10 2008/05/18 14:49:20 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -75,9 +75,9 @@ extern int pdf_get_font_wmode (int font_id);
extern int pdf_font_is_in_use (pdf_font *font);
extern char *pdf_font_get_ident (pdf_font *font);
-
-extern char *pdf_font_get_uniqueTag (pdf_font *font);
+extern char *pdf_font_get_mapname (pdf_font *font);
extern char *pdf_font_get_fontname (pdf_font *font); /* without unique tag */
+extern char *pdf_font_get_uniqueTag (pdf_font *font);
extern pdf_obj *pdf_font_get_resource (pdf_font *font);
extern pdf_obj *pdf_font_get_descriptor (pdf_font *font);
@@ -89,6 +89,8 @@ extern int pdf_font_get_flag (pdf_font *font, int mask);
extern int pdf_font_get_flags (pdf_font *font);
extern double pdf_font_get_param (pdf_font *font, int type);
+extern int pdf_font_get_index (pdf_font *font);
+
extern int pdf_font_set_fontname (pdf_font *font, const char *fontname);
extern int pdf_font_set_flags (pdf_font *font, int flags);
extern int pdf_font_set_subtype (pdf_font *font, int subtype);
diff --git a/Build/source/texk/dvipdfmx/src/pdfobj.c b/Build/source/texk/dvipdfmx/src/pdfobj.c
index 0c7227859df..f770cbeaba0 100644
--- a/Build/source/texk/dvipdfmx/src/pdfobj.c
+++ b/Build/source/texk/dvipdfmx/src/pdfobj.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pdfobj.c,v 1.47 2007/11/14 03:36:01 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pdfobj.c,v 1.57 2008/05/20 13:05:14 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -33,6 +33,7 @@
#include "mem.h"
#include "error.h"
#include "mfileio.h"
+#include "dpxutil.h"
#include "pdflimits.h"
#include "pdfencrypt.h"
#include "pdfparse.h"
@@ -107,6 +108,7 @@ struct pdf_stream
{
struct pdf_obj *dict;
unsigned char *stream;
+ long *objstm_data; /* used for object streams */
unsigned long stream_length;
unsigned long max_length;
unsigned char _flags;
@@ -114,13 +116,9 @@ struct pdf_stream
struct pdf_indirect
{
+ pdf_file *pf;
unsigned long label;
unsigned short generation;
- int dirty; /* Dirty objects came from an input file and were not
- generated by this program. They have a label in a
- different numbering sequence. These are translated
- when the object is written out */
- FILE *dirty_file;
};
typedef void pdf_null;
@@ -134,7 +132,6 @@ typedef struct pdf_stream pdf_stream;
typedef struct pdf_indirect pdf_indirect;
static FILE *pdf_output_file = NULL;
-static FILE *pdf_input_file = NULL;
static long pdf_output_file_position = 0;
static long pdf_output_line_position = 0;
@@ -143,32 +140,37 @@ static long compression_saved = 0;
#define FORMAT_BUF_SIZE 4096
static char format_buffer[FORMAT_BUF_SIZE];
-static struct xref_entry
+typedef struct xref_entry
{
- unsigned char type;
- unsigned long field2;
- unsigned short field3;
- int used; /* Used by PDF import */
-} *output_xref;
+ unsigned char type; /* object storage type */
+ unsigned long field2; /* offset in file or object stream */
+ unsigned short field3; /* generation or index */
+ pdf_obj *direct; /* used for imported objects */
+ pdf_obj *indirect; /* used for imported objects */
+} xref_entry;
+
+static xref_entry *output_xref;
static unsigned long pdf_max_ind_objects;
static unsigned long next_label;
static unsigned long startxref;
+struct pdf_file
+{
+ FILE *file;
+ pdf_obj *trailer;
+ xref_entry *xref_table;
+ long num_obj;
+ long file_size;
+ int version;
+};
+
static pdf_obj *output_stream;
#define OBJSTM_MAX_OBJS 200
/* the limit is only 100 for linearized PDF */
-typedef struct pdf_objstm
-{
- pdf_obj *stream;
- unsigned long obj_label[OBJSTM_MAX_OBJS];
- unsigned long obj_pos [OBJSTM_MAX_OBJS];
- unsigned char pos;
-} pdf_objstm;
-
static int enc_mode;
static int doc_enc_mode;
@@ -181,7 +183,9 @@ static void pdf_flush_obj (pdf_obj *object, FILE *file);
static void pdf_label_obj (pdf_obj *object);
static void pdf_write_obj (pdf_obj *object, FILE *file);
-static void pdf_flush_objstm (pdf_objstm *objstm);
+static void set_objstm_data (pdf_obj *objstm, long *data);
+static long *get_objstm_data (pdf_obj *objstm);
+static void release_objstm (pdf_obj *objstm);
static void pdf_out_char (FILE *file, char c);
static void pdf_out (FILE *file, const void *buffer, long length);
@@ -213,9 +217,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 pdf_obj *pdf_ref_file_obj (unsigned long obj_num, unsigned short obj_gen);
-static pdf_obj *pdf_read_object (unsigned long obj_num, unsigned short obj_gen);
-
static int verbose = 0;
static char compression_level = 9;
@@ -262,37 +263,22 @@ pdf_obj_set_verbose(void)
verbose++;
}
-static pdf_objstm *current_objstm = NULL;
-
-void
-pdf_objstm_init ()
-{
- if (pdf_version >= 5) {
- current_objstm = NEW(1, pdf_objstm);
- current_objstm->pos = 0;
- }
-}
-
-void
-pdf_objstm_close ()
-{
- if (current_objstm) {
- RELEASE(current_objstm);
- current_objstm = NULL;
- }
-}
+static pdf_obj *current_objstm = NULL;
+static int do_objstm;
static void
add_xref_entry (unsigned long label, unsigned char type, unsigned long field2, unsigned short field3)
{
if (label >= pdf_max_ind_objects) {
pdf_max_ind_objects = (label/IND_OBJECTS_ALLOC_SIZE+1)*IND_OBJECTS_ALLOC_SIZE;
- output_xref = RENEW(output_xref, pdf_max_ind_objects, struct xref_entry);
+ output_xref = RENEW(output_xref, pdf_max_ind_objects, xref_entry);
}
output_xref[label].type = type;
output_xref[label].field2 = field2;
output_xref[label].field3 = field3;
+ output_xref[label].direct = NULL;
+ output_xref[label].indirect = NULL;
}
#define BINARY_MARKER "%\344\360\355\370\n"
@@ -311,8 +297,12 @@ pdf_out_init (const char *filename, int do_encryption)
xref_stream->flags |= OBJ_NO_ENCRYPT;
trailer_dict = pdf_stream_dict(xref_stream);
pdf_add_dict(trailer_dict, pdf_new_name("Type"), pdf_new_name("XRef"));
- } else
+ do_objstm = 1;
+ } else {
+ xref_stream = NULL;
trailer_dict = pdf_new_dict();
+ do_objstm = 0;
+ }
output_stream = NULL;
@@ -383,8 +373,6 @@ dump_xref_stream (void)
pdf_obj *w;
- pdf_label_obj(xref_stream);
-
/* determine the necessary size of the offset field */
pos = startxref; /* maximal offset value */
poslen = 1;
@@ -425,8 +413,18 @@ pdf_out_flush (void)
long length;
/* Flush current object stream */
- if (current_objstm && current_objstm->pos)
- pdf_flush_objstm(current_objstm);
+ if (current_objstm) {
+ release_objstm(current_objstm);
+ current_objstm =NULL;
+ }
+
+ /*
+ * Label xref stream - we need the number of correct objects
+ * for the xref stream dictionary (= trailer).
+ * Labelling it in pdf_out_init (with 1) does not work (why?).
+ */
+ if (xref_stream)
+ pdf_label_obj(xref_stream);
/* Record where this xref is for trailer */
startxref = pdf_output_file_position;
@@ -434,7 +432,7 @@ pdf_out_flush (void)
pdf_add_dict(trailer_dict, pdf_new_name("Size"),
pdf_new_number(next_label));
- if (pdf_version >= 5)
+ if (xref_stream)
dump_xref_stream();
else {
dump_xref_table();
@@ -553,6 +551,16 @@ void pdf_out (FILE *file, const void *buffer, long length)
}
}
+/* returns 1 if a white-space character is necessary to separate
+ an object of type1 followed by an object of type2 */
+static
+int pdf_need_white (int type1, int type2)
+{
+ return !(type1 == PDF_STRING || type1 == PDF_ARRAY || type1 == PDF_DICT ||
+ type2 == PDF_STRING || type2 == PDF_NAME ||
+ type2 == PDF_ARRAY || type2 == PDF_DICT);
+}
+
static
void pdf_out_white (FILE *file)
{
@@ -564,7 +572,7 @@ void pdf_out_white (FILE *file)
}
#define TYPECHECK(o,t) if (!(o) || (o)->type != (t)) {\
- ERROR("typecheck: Invalid object type. %d %d", (o) ? (o)->type : -1, (t));\
+ ERROR("typecheck: Invalid object type: %d %d (line %d)", (o) ? (o)->type : -1, (t), __LINE__);\
}
#define INVALIDOBJ(o) ((o) == NULL || (o)->type <= 0 || (o)->type > PDF_INDIRECT)
@@ -631,9 +639,6 @@ pdf_link_obj (pdf_obj *object)
pdf_obj *
pdf_ref_obj (pdf_obj *object)
{
- pdf_obj *result;
- pdf_indirect *indirect;
-
if (INVALIDOBJ(object))
ERROR("pdf_ref_obj(): passed invalid object.");
@@ -643,25 +648,14 @@ pdf_ref_obj (pdf_obj *object)
ERROR("Cannot continue...");
}
- result = pdf_new_obj(PDF_INDIRECT);
- indirect = NEW(1, pdf_indirect);
- result->data = indirect;
- if (object->type == PDF_INDIRECT) {
- indirect->label = ((pdf_indirect *) (object->data))->label;
- indirect->generation = ((pdf_indirect *) (object->data))->generation;
- indirect->dirty = ((pdf_indirect *) (object->data))->dirty;
- indirect->dirty_file = ((pdf_indirect *) (object->data))->dirty_file;
+ if (PDF_OBJ_INDIRECTTYPE(object)) {
+ return pdf_link_obj(object);
} else {
if (object->label == 0) {
pdf_label_obj(object);
}
- indirect->label = object->label;
- indirect->generation = object->generation;
- indirect->dirty = 0;
- indirect->dirty_file = NULL;
+ return pdf_new_indirect(NULL, object->label, object->generation);
}
-
- return result;
}
static void
@@ -675,26 +669,10 @@ write_indirect (pdf_indirect *indirect, FILE *file)
{
long length;
- if (indirect->dirty) {
- if (file == stderr) {
- pdf_out(file, "{d}", 3);
- length = sprintf(format_buffer, "%lu %hu R", indirect->label, indirect->generation);
- pdf_out(stderr, format_buffer, length);
- } else {
- pdf_obj *clean;
+ ASSERT(!indirect->pf);
- if (indirect->dirty_file != pdf_input_file) {
- ERROR("Input PDF file doesn't match object: label=%lu, from_file=%p, current_file=%p",
- indirect->label, indirect->dirty_file, pdf_input_file);
- }
- clean = pdf_ref_file_obj(indirect->label, indirect->generation);
- pdf_write_obj(clean, file);
- pdf_release_obj(clean);
- }
- } else {
- length = sprintf(format_buffer, "%lu %hu R", indirect->label, indirect->generation);
- pdf_out(file, format_buffer, length);
- }
+ length = sprintf(format_buffer, "%lu %hu R", indirect->label, indirect->generation);
+ pdf_out(file, format_buffer, length);
}
pdf_obj *
@@ -1140,13 +1118,17 @@ write_array (pdf_array *array, FILE *file)
pdf_out_char(file, '[');
if (array->size > 0) {
unsigned long i;
-
+ int type1 = PDF_UNDEFINED, type2;
+
for (i = 0; i < array->size; i++) {
- if (i > 0)
- pdf_out_white(file);
- if (!array->values[i])
+ if (array->values[i]) {
+ type2 = array->values[i]->type;
+ if (type1 != PDF_UNDEFINED && pdf_need_white(type1, type2))
+ pdf_out_white(file);
+ type1 = type2;
+ pdf_write_obj(array->values[i], file);
+ } else
WARN("PDF array element #ld undefined.", i);
- pdf_write_obj(array->values[i], file);
}
}
pdf_out_char(file, ']');
@@ -1319,10 +1301,7 @@ write_dict (pdf_dict *dict, FILE *file)
pdf_out (file, "<<\n", 3); /* dropping \n saves few kb. */
while (dict->key != NULL) {
pdf_write_obj(dict->key, file);
- if (((dict -> value)->type) == PDF_BOOLEAN ||
- ((dict -> value)->type) == PDF_NUMBER ||
- ((dict -> value)->type) == PDF_INDIRECT ||
- ((dict -> value)->type) == PDF_NULL) {
+ if (pdf_need_white(PDF_NAME, (dict->value)->type)) {
pdf_out_white(file);
}
pdf_write_obj(dict->value, file);
@@ -1568,6 +1547,7 @@ pdf_new_stream (int flags)
data->stream = NULL;
data->stream_length = 0;
data->max_length = 0;
+ data->objstm_data = NULL;
result->data = data;
result->flags |= OBJ_NO_OBJSTM;
@@ -1693,6 +1673,12 @@ release_stream (pdf_stream *stream)
RELEASE(stream->stream);
stream->stream = NULL;
}
+
+ if (stream->objstm_data) {
+ RELEASE(stream->objstm_data);
+ stream->objstm_data = NULL;
+ }
+
RELEASE(stream);
}
@@ -1732,6 +1718,20 @@ pdf_stream_length (pdf_obj *stream)
return (long) data->stream_length;
}
+static void
+set_objstm_data (pdf_obj *objstm, long *data) {
+ TYPECHECK(objstm, PDF_STREAM);
+
+ ((pdf_stream *) objstm->data)->objstm_data = data;
+}
+
+static long *
+get_objstm_data (pdf_obj *objstm) {
+ TYPECHECK(objstm, PDF_STREAM);
+
+ return ((pdf_stream *) objstm->data)->objstm_data;
+}
+
void
pdf_add_stream (pdf_obj *stream, const void *stream_data, long length)
{
@@ -1750,6 +1750,119 @@ pdf_add_stream (pdf_obj *stream, const void *stream_data, long length)
data->stream_length += length;
}
+#if HAVE_ZLIB
+#define WBUF_SIZE 4096
+int
+pdf_add_stream_flate (pdf_obj *dst, const void *data, long len)
+{
+ z_stream z;
+ Bytef wbuf[WBUF_SIZE];
+
+ z.zalloc = Z_NULL; z.zfree = Z_NULL; z.opaque = Z_NULL;
+
+ z.next_in = (Bytef *) data; z.avail_in = len;
+ z.next_out = (Bytef *) wbuf; z.avail_out = WBUF_SIZE;
+
+ if (inflateInit(&z) != Z_OK) {
+ WARN("inflateInit() failed.");
+ return -1;
+ }
+
+ for (;;) {
+ int status;
+ status = inflate(&z, Z_NO_FLUSH);
+ if (status == Z_STREAM_END)
+ break;
+ else if (status != Z_OK) {
+ WARN("inflate() failed. Broken PDF file?");
+ inflateEnd(&z);
+ return -1;
+ }
+
+ if (z.avail_out == 0) {
+ pdf_add_stream(dst, wbuf, WBUF_SIZE);
+ z.next_out = wbuf;
+ z.avail_out = WBUF_SIZE;
+ }
+ }
+
+ if (WBUF_SIZE - z.avail_out > 0)
+ pdf_add_stream(dst, wbuf, WBUF_SIZE - z.avail_out);
+
+ return (inflateEnd(&z) == Z_OK ? 0 : -1);
+}
+#endif
+
+
+int
+pdf_concat_stream (pdf_obj *dst, pdf_obj *src)
+{
+ const char *stream_data;
+ long stream_length;
+ pdf_obj *stream_dict;
+ pdf_obj *filter;
+
+ if (!PDF_OBJ_STREAMTYPE(dst) || !PDF_OBJ_STREAMTYPE(src))
+ ERROR("Invalid type.");
+
+ stream_data = pdf_stream_dataptr(src);
+ stream_length = pdf_stream_length (src);
+ stream_dict = pdf_stream_dict (src);
+
+ if (pdf_lookup_dict(stream_dict, "DecodeParms")) {
+ WARN("Streams with DecodeParams not supported.");
+ return -1;
+ }
+
+ filter = pdf_lookup_dict(stream_dict, "Filter");
+ if (!filter) {
+ pdf_add_stream(dst, stream_data, stream_length);
+ return 0;
+#if HAVE_ZLIB
+ } else {
+ char *filter_name;
+ if (PDF_OBJ_NAMETYPE(filter)) {
+ filter_name = pdf_name_value(filter);
+ if (filter_name && !strcmp(filter_name, "FlateDecode"))
+ return pdf_add_stream_flate(dst, stream_data, stream_length);
+ else {
+ WARN("DecodeFilter \"%s\" not supported.", filter_name);
+ return -1;
+ }
+ } else if (PDF_OBJ_ARRAYTYPE(filter)) {
+ if (pdf_array_length(filter) > 1) {
+ WARN("Multiple DecodeFilter not supported.");
+ return -1;
+ } else {
+ filter_name = pdf_name_value(pdf_get_array(filter, 0));
+ if (filter_name && !strcmp(filter_name, "FlateDecode"))
+ return pdf_add_stream_flate(dst, stream_data, stream_length);
+ else {
+ WARN("DecodeFilter \"%s\" not supported.", filter_name);
+ return -1;
+ }
+ }
+ } else
+ ERROR("Broken PDF file?");
+#endif /* HAVE_ZLIB */
+ }
+
+ return -1;
+}
+
+static pdf_obj *
+pdf_stream_uncompress (pdf_obj *src) {
+ pdf_obj *dst = pdf_new_stream(0);
+
+ TYPECHECK(src, PDF_STREAM);
+
+ pdf_merge_dict(pdf_stream_dict(dst), pdf_stream_dict(src));
+ pdf_remove_dict(pdf_stream_dict(dst), "Length");
+ pdf_concat_stream(dst, src);
+
+ return dst;
+}
+
void
pdf_stream_set_flags (pdf_obj *stream, int flags)
{
@@ -1838,41 +1951,41 @@ pdf_flush_obj (pdf_obj *object, FILE *file)
pdf_out(file, "\nendobj\n", 8);
}
-static void
-pdf_add_objstm (pdf_objstm *objstm, pdf_obj *object)
+static long
+pdf_add_objstm (pdf_obj *objstm, pdf_obj *object)
{
- unsigned char pos = objstm->pos++;
+ long *data, pos;
- if (!pos) {
- pdf_obj *stream = pdf_new_stream(STREAM_COMPRESS);
- pdf_label_obj(stream);
- objstm->stream = stream;
- }
- objstm->obj_label[pos] = object->label;
- objstm->obj_pos[pos] = pdf_stream_length(objstm->stream);
-
- add_xref_entry(object->label, 2, objstm->stream->label, pos);
-
- output_stream = objstm->stream;
+ TYPECHECK(objstm, PDF_STREAM);
+
+ data = get_objstm_data(objstm);
+ pos = ++data[0];
+
+ data[2*pos] = object->label;
+ data[2*pos+1] = pdf_stream_length(objstm);
+
+ add_xref_entry(object->label, 2, objstm->label, pos-1);
+
+ /* redirect output into objstm */
+ output_stream = objstm;
enc_mode = 0;
pdf_write_obj(object, pdf_output_file);
pdf_out_char(pdf_output_file, '\n');
output_stream = NULL;
-
- if (pos == OBJSTM_MAX_OBJS-1)
- pdf_flush_objstm(objstm);
+
+ return pos;
}
static void
-pdf_flush_objstm (pdf_objstm *objstm)
+release_objstm (pdf_obj *objstm)
{
- unsigned char pos = objstm->pos;
- pdf_obj *stream_obj = objstm->stream, *dict;
+ long *data = get_objstm_data(objstm);
+ long pos = data[0];
+ pdf_obj *dict;
pdf_stream *stream;
- unsigned char i, *old_buf;
+ unsigned char *old_buf;
unsigned long old_length;
- TYPECHECK(stream_obj, PDF_STREAM);
- stream = (pdf_stream *) stream_obj->data;
+ stream = (pdf_stream *) objstm->data;
/* Precede stream data by offset table */
old_buf = stream->stream;
@@ -1880,22 +1993,23 @@ pdf_flush_objstm (pdf_objstm *objstm)
/* Reserve 22 bytes for each entry (two 10 digit numbers plus two spaces) */
stream->stream = NEW(old_length + 22*pos, unsigned char);
stream->stream_length = 0;
-
- for (i = 0; i < pos; i++) {
- long length = sprintf(format_buffer, "%lu %lu ",
- objstm->obj_label[i], objstm->obj_pos[i]);
- pdf_add_stream(stream_obj, format_buffer, length);
+
+ {
+ long i = 2*pos, *val = data+2;
+ while (i--) {
+ long length = sprintf(format_buffer, "%ld ", *(val++));
+ pdf_add_stream(objstm, format_buffer, length);
+ }
}
- dict = pdf_stream_dict(stream_obj);
+ dict = pdf_stream_dict(objstm);
pdf_add_dict(dict, pdf_new_name("Type"), pdf_new_name("ObjStm"));
pdf_add_dict(dict, pdf_new_name("N"), pdf_new_number(pos));
pdf_add_dict(dict, pdf_new_name("First"), pdf_new_number(stream->stream_length));
- pdf_add_stream(stream_obj, old_buf, old_length);
+ pdf_add_stream(objstm, old_buf, old_length);
RELEASE(old_buf);
- pdf_release_obj(stream_obj);
- objstm->pos = 0;
+ pdf_release_obj(objstm);
}
void
@@ -1916,12 +2030,23 @@ pdf_release_obj (pdf_obj *object)
* Nonzero "label" means object needs to be written before it's destroyed.
*/
if (object->label && pdf_output_file != NULL) {
- if (!current_objstm || object->flags & OBJ_NO_OBJSTM
+ if (!do_objstm || object->flags & OBJ_NO_OBJSTM
|| (doc_enc_mode && object->flags & OBJ_NO_ENCRYPT)
|| object->generation)
pdf_flush_obj(object, pdf_output_file);
- else
- pdf_add_objstm(current_objstm, object);
+ else {
+ if (!current_objstm) {
+ long *data = NEW(2*OBJSTM_MAX_OBJS+2, long);
+ data[0] = data[1] = 0;
+ current_objstm = pdf_new_stream(STREAM_COMPRESS);
+ set_objstm_data(current_objstm, data);
+ pdf_label_obj(current_objstm);
+ }
+ if (pdf_add_objstm(current_objstm, object) == OBJSTM_MAX_OBJS) {
+ release_objstm(current_objstm);
+ current_objstm = NULL;
+ }
+ }
}
switch (object->type) {
case PDF_BOOLEAN:
@@ -2045,10 +2170,9 @@ pdf_copy_object (pdf_obj *dst, pdf_obj *src)
pdf_indirect *data;
dst->data = data = NEW(1, pdf_indirect);
+ data->pf = ((pdf_indirect *) (src->data))->pf;
data->label = ((pdf_indirect *) (src->data))->label;
data->generation = ((pdf_indirect *) (src->data))->generation;
- data->dirty = ((pdf_indirect *) (src->data))->dirty;
- data->dirty_file = ((pdf_indirect *) (src->data))->dirty_file;
}
break;
}
@@ -2057,7 +2181,7 @@ pdf_copy_object (pdf_obj *dst, pdf_obj *src)
}
static int
-backup_line (void)
+backup_line (FILE *pdf_input_file)
{
int ch = -1;
@@ -2079,21 +2203,16 @@ backup_line (void)
return 1;
}
-static unsigned long pdf_file_size = 0;
-
static long
-find_xref (void)
+find_xref (FILE *pdf_input_file)
{
long xref_pos;
int tries = 10;
- seek_end(pdf_input_file);
-
- pdf_file_size = tell_position(pdf_input_file);
do {
long currentpos;
- if (!backup_line()) {
+ if (!backup_line(pdf_input_file)) {
tries = 0;
break;
}
@@ -2130,7 +2249,7 @@ find_xref (void)
* at the start of the trailer.
*/
static pdf_obj *
-parse_trailer (void)
+parse_trailer (pdf_file *pf)
{
pdf_obj *result;
/*
@@ -2138,7 +2257,7 @@ parse_trailer (void)
* be made a bit more robust sometime.
*/
if (fread(work_buffer, sizeof(char),
- WORK_BUFFER_SIZE, pdf_input_file) == 0 ||
+ WORK_BUFFER_SIZE, pf->file) == 0 ||
strncmp(work_buffer, "trailer", strlen("trailer"))) {
WARN("No trailer. Are you sure this is a PDF file?");
WARN("buffer:\n->%s<-\n", work_buffer);
@@ -2146,31 +2265,12 @@ parse_trailer (void)
} else {
char *p = work_buffer + strlen("trailer");
skip_white(&p, work_buffer + WORK_BUFFER_SIZE);
- result = parse_pdf_dict(&p, work_buffer + WORK_BUFFER_SIZE);
+ result = parse_pdf_dict(&p, work_buffer + WORK_BUFFER_SIZE, pf);
}
return result;
}
-struct object
-{
- unsigned long file_position;
- unsigned generation;
- /*
- * Object numbers in original file and new file must have different
- * object numbers.
- * new_ref provides a reference for the object in the new file object
- * space. When it is first set, an object in the old file is copied
- * to the new file with a new number. new_ref remains set until the
- * file is closed so that future references can access the object via
- * new_ref instead of copying the object again.
- */
- pdf_obj *direct;
- pdf_obj *indirect;
- int used;
-} *xref_table = NULL;
-long num_input_objects;
-
/*
* This routine tries to estimate an upper bound for character position
* of the end of the object, so it knows how big the buffer must be.
@@ -2180,110 +2280,52 @@ long num_input_objects;
* :-(
*/
static long
-next_object_offset (unsigned long obj_num)
+next_object_offset (pdf_file *pf, unsigned long obj_num)
{
- long next = pdf_file_size; /* Worst case */
+ long next = pf->file_size; /* Worst case */
long i, curr;
- curr = xref_table[obj_num].file_position;
- /* Check all other objects to find next one */
- for (i = 0; i < num_input_objects; i++) {
- if (xref_table[i].used &&
- xref_table[i].file_position > curr &&
- xref_table[i].file_position < next)
- next = xref_table[i].file_position;
+ curr = pf->xref_table[obj_num].field2;
+ /* Check all other type 1 objects to find next one */
+ for (i = 0; i < pf->num_obj; i++) {
+ if (pf->xref_table[i].type == 1 &&
+ pf->xref_table[i].field2 > curr &&
+ pf->xref_table[i].field2 < next)
+ next = pf->xref_table[i].field2;
}
return next;
}
-#define checklabel(n,g) ((n) > 0 && (n) < num_input_objects && \
- xref_table[(n)].generation == (g))
-#define labelfreed(n,g) (!xref_table[(n)].used)
-
-/*
- * The following routine returns a reference to an object existing
- * only in the input file. It does this as follows. If the object
- * has never been referenced before, it reads the object
- * in and creates a reference to it. Then it writes
- * the object out, keeping the existing reference. If the
- * object has been read in (and written out) before, it simply
- * returns the retained existing reference to that object
- */
-static pdf_obj *
-pdf_ref_file_obj (unsigned long obj_num, unsigned short obj_gen)
-{
- pdf_obj *obj, *ref;
-
- if (!checklabel(obj_num, obj_gen)) {
- WARN("Can't resolve object: %lu %u",
- obj_num, obj_gen);
- return NULL;
- }
- ref = xref_table[obj_num].indirect;
- if (ref != NULL)
- return pdf_link_obj(ref);
-
- obj = pdf_read_object(obj_num, obj_gen);
- if (!obj) {
- WARN("Could not read object: %lu %u",
- obj_num, obj_gen);
- return NULL;
- }
-
- ref = pdf_ref_obj(obj);
- xref_table[obj_num].indirect = ref;
- xref_table[obj_num].direct = obj;
- /* Make sure the caller doesn't free this object */
-
- return pdf_link_obj(ref);
-}
-
+#define checklabel(pf, n, g) ((n) > 0 && (n) < (pf)->num_obj && ( \
+ ((pf)->xref_table[(n)].type == 1 && (pf)->xref_table[(n)].field3 == (g)) || \
+ ((pf)->xref_table[(n)].type == 2 && !(g))))
pdf_obj *
-pdf_new_ref (unsigned long obj_num, unsigned short obj_gen)
+pdf_new_indirect (pdf_file *pf, unsigned long obj_num, unsigned short obj_gen)
{
pdf_obj *result;
pdf_indirect *indirect;
- if (!checklabel(obj_num, obj_gen)) {
- WARN("Invalid object label: %lu %hu", obj_num, obj_gen);
- return NULL;
- }
- result = pdf_new_obj(PDF_INDIRECT);
indirect = NEW(1, pdf_indirect);
- result->data = indirect;
+ indirect->pf = pf;
indirect->label = obj_num;
indirect->generation = obj_gen;
- indirect->dirty = 1;
- indirect->dirty_file = pdf_input_file;
+
+ result = pdf_new_obj(PDF_INDIRECT);
+ result->data = indirect;
return result;
}
-
-/* Label without corresponding object definition should
- * be replaced with "null". But we won't do that.
- */
static pdf_obj *
-pdf_read_object (unsigned long obj_num, unsigned short obj_gen)
+pdf_read_object (unsigned long obj_num, unsigned short obj_gen,
+ pdf_file *pf, long offset, long limit)
{
- pdf_obj *result;
- long offset, limit, length;
+ long length;
char *buffer, *p, *endptr;
+ pdf_obj *result;
- if (!checklabel(obj_num, obj_gen)) {
- WARN("Trying to read nonexistent object: %lu %u",
- obj_num, obj_gen);
- return NULL;
- }
- if (labelfreed(obj_num, obj_gen)) {
- WARN("Trying to read deleted object: %lu %u",
- obj_num, obj_gen);
- return NULL;
- }
- offset = xref_table[obj_num].file_position;
- limit = next_object_offset(obj_num);
length = limit - offset;
if (length <= 0)
@@ -2291,8 +2333,8 @@ pdf_read_object (unsigned long obj_num, unsigned short obj_gen)
buffer = NEW(length + 1, char);
- seek_absolute(pdf_input_file, offset);
- fread(buffer, sizeof(char), length, pdf_input_file);
+ seek_absolute(pf->file, offset);
+ fread(buffer, sizeof(char), length, pf->file);
p = buffer;
endptr = p + length;
@@ -2321,7 +2363,7 @@ pdf_read_object (unsigned long obj_num, unsigned short obj_gen)
g = strtoul(sp, NULL, 10);
RELEASE(sp);
- if (n != obj_num || g != obj_gen) {
+ if (obj_num && (n != obj_num || g != obj_gen)) {
RELEASE(buffer);
return NULL;
}
@@ -2338,7 +2380,7 @@ pdf_read_object (unsigned long obj_num, unsigned short obj_gen)
}
p += strlen("obj");
- result = parse_pdf_object(&p, endptr);
+ result = parse_pdf_object(&p, endptr, pf);
skip_white(&p, endptr);
if (memcmp(p, "endobj", strlen("endobj"))) {
@@ -2349,60 +2391,202 @@ pdf_read_object (unsigned long obj_num, unsigned short obj_gen)
}
RELEASE(buffer);
- return result;
+ return result;
}
-/* pdf_deref_obj always returns a link instead of the original */
-pdf_obj *
-pdf_deref_obj (pdf_obj *obj)
+static pdf_obj *
+read_objstm (pdf_file *pf, unsigned long num)
{
- pdf_obj *result;
+ unsigned long offset = pf->xref_table[num].field2;
+ unsigned short gen = pf->xref_table[num].field3;
+ long limit = next_object_offset(pf, num), n, first, *header = NULL;
+ char *data, data1, *p, *q;
+ int i;
- if (obj == NULL)
- return NULL;
- else if (pdf_obj_typeof(obj) != PDF_INDIRECT) {
- return pdf_link_obj(obj);
+ pdf_obj *objstm, *dict, *type, *n_obj, *first_obj;
+
+ objstm = pdf_read_object(num, gen, pf, offset, limit);
+
+ if (!PDF_OBJ_STREAMTYPE(objstm))
+ goto error;
+
+ {
+ pdf_obj *tmp = pdf_stream_uncompress(objstm);
+ if (!tmp)
+ goto error;
+ pdf_release_obj(objstm);
+ objstm = tmp;
+ }
+
+ dict = pdf_stream_dict(objstm);
+
+ type = pdf_lookup_dict(dict, "Type");
+ if (!PDF_OBJ_NAMETYPE(type) ||
+ strcmp(pdf_name_value(type), "ObjStm"))
+ goto error;
+
+ n_obj = pdf_lookup_dict(dict, "N");
+ if (!PDF_OBJ_NUMBERTYPE(n_obj))
+ goto error;
+ n = (long) pdf_number_value(n_obj);
+
+ first_obj = pdf_lookup_dict(dict, "First");
+ if (!PDF_OBJ_NUMBERTYPE(first_obj))
+ goto error;
+ first = (long) pdf_number_value(first_obj);
+ /* reject object streams without object data */
+ if (first >= pdf_stream_length(objstm))
+ goto error;
+
+ header = NEW(2*(n+1), long);
+ set_objstm_data(objstm, header);
+ *(header++) = n;
+ *(header++) = first;
+
+ data = (char *) pdf_stream_dataptr(objstm);
+
+ /* hack to avoid parsing beyond offset table */
+ data1 = data[first];
+ data[first] = 0;
+
+ p = data;
+ i = 2*n;
+ while (i--) {
+ *(header++) = strtoul(p, &q, 10);
+ if (q == p)
+ goto error;
+ p = q;
+ }
+ data[first] = data1;
+
+ /* Any garbage after last entry? */
+ skip_white(&p, data+first);
+ if (p != data+first)
+ goto error;
+
+ return pf->xref_table[num].direct = objstm;
+
+ error:
+ WARN("Cannot parse object stream.");
+ if (objstm)
+ pdf_release_obj(objstm);
+ return NULL;
+}
+
+/* Label without corresponding object definition are replaced by the
+ * null object, as required by the PDF spec. This is important to parse
+ * several cross-reference sections.
+ */
+static pdf_obj *
+pdf_get_object (pdf_file *pf, unsigned long obj_num, unsigned short obj_gen)
+{
+ pdf_obj *result;
+
+ if (!checklabel(pf, obj_num, obj_gen)) {
+ WARN("Trying to read nonexistent or deleted object: %lu %u",
+ obj_num, obj_gen);
+ return pdf_new_null();
}
-#define OBJ_NUM(o) (((pdf_indirect *)((o)->data))->label)
-#define OBJ_GEN(o) (((pdf_indirect *)((o)->data))->generation)
-#define ISDIRTY(o) (((pdf_indirect *)((o)->data))->dirty)
-#define OBJ_SRC(o) (((pdf_indirect *)((o)->data))->dirty_file)
- if (!ISDIRTY(obj))
- ERROR("Tried to deref a non-file object");
- result = pdf_read_object(OBJ_NUM(obj), OBJ_GEN(obj));
- while (result &&
- pdf_obj_typeof(result) == PDF_INDIRECT
- ) {
- pdf_obj *tmp;
+ if ((result = pf->xref_table[obj_num].direct)) {
+ return pdf_link_obj(result);
+ }
- tmp = pdf_read_object(OBJ_NUM(result), OBJ_GEN(result));
- pdf_release_obj(result);
- result = tmp;
+ if (pf->xref_table[obj_num].type == 1) {
+ /* type == 1 */
+ unsigned long offset;
+ long limit;
+ offset = pf->xref_table[obj_num].field2;
+ limit = next_object_offset(pf, obj_num);
+ result = pdf_read_object(obj_num, obj_gen, pf, offset, limit);
+ } else {
+ /* type == 2 */
+ unsigned long objstm_num = pf->xref_table[obj_num].field2;
+ unsigned short index = pf->xref_table[obj_num].field3;
+ pdf_obj *objstm;
+ long *data, n, first, length;
+ char *p, *q;
+
+ if (objstm_num >= pf->num_obj ||
+ pf->xref_table[objstm_num].type != 1 ||
+ !((objstm = pf->xref_table[objstm_num].direct) ||
+ (objstm = read_objstm(pf, objstm_num))))
+ goto error;
+
+ data = get_objstm_data(objstm);
+ n = *(data++);
+ first = *(data++);
+
+ if (index >= n || data[2*index] != obj_num)
+ goto error;
+
+ length = pdf_stream_length(objstm);
+ p = (char *) pdf_stream_dataptr(objstm) + first + data[2*index+1];
+ q = p + (index == n-1 ? length : first+data[2*index+3]);
+ result = parse_pdf_object(&p, q, pf);
+ if (!result)
+ goto error;
}
- return result;
+ /* Make sure the caller doesn't free this object */
+ pf->xref_table[obj_num].direct = pdf_link_obj(result);
+
+ return result;
+
+ error:
+ WARN("Could not read object from object stream.");
+ result = pdf_new_null();
+}
+
+#define OBJ_FILE(o) (((pdf_indirect *)((o)->data))->pf)
+#define OBJ_NUM(o) (((pdf_indirect *)((o)->data))->label)
+#define OBJ_GEN(o) (((pdf_indirect *)((o)->data))->generation)
+
+/* pdf_deref_obj always returns a link instead of the original */
+/* It never return the null object, but the NULL pointer instead */
+pdf_obj *
+pdf_deref_obj (pdf_obj *obj)
+{
+ if (obj)
+ obj = pdf_link_obj(obj);
+
+ while (PDF_OBJ_INDIRECTTYPE(obj)) {
+ pdf_file *pf = OBJ_FILE(obj);
+ unsigned long obj_num = OBJ_NUM(obj);
+ unsigned short obj_gen = OBJ_GEN(obj);
+ if (!pf)
+ ERROR("Tried to deref a non-file object");
+ pdf_release_obj(obj);
+ obj = pdf_get_object(pf, obj_num, obj_gen);
+ }
+
+ if (PDF_OBJ_NULLTYPE(obj)) {
+ pdf_release_obj(obj);
+ return NULL;
+ } else
+ return obj;
}
static void
-extend_xref (long new_size)
+extend_xref (pdf_file *pf, long new_size)
{
unsigned long i;
- xref_table = RENEW(xref_table, new_size, struct object);
- for (i = num_input_objects; i < new_size; i++) {
- xref_table[i].direct = NULL;
- xref_table[i].indirect = NULL;
- xref_table[i].used = 0;
- xref_table[i].generation = 0;
- xref_table[i].file_position = 0L;
+ pf->xref_table = RENEW(pf->xref_table, new_size, xref_entry);
+ for (i = pf->num_obj; i < new_size; i++) {
+ pf->xref_table[i].direct = NULL;
+ pf->xref_table[i].indirect = NULL;
+ pf->xref_table[i].type = 0;
+ pf->xref_table[i].field3 = 0;
+ pf->xref_table[i].field2 = 0L;
}
- num_input_objects = new_size;
+ pf->num_obj = new_size;
}
static int
-parse_xref (void)
+parse_xref_table (pdf_file *pf, long xref_pos)
{
+ FILE *pdf_input_file = pf->file;
unsigned long first, size;
unsigned long i, offset;
unsigned int obj_gen;
@@ -2410,13 +2594,15 @@ parse_xref (void)
int r;
/*
- * This routine reads one xref segment. It must be called positioned
- * at the beginning of an xref table. It may be called multiple times
+ * This routine reads one xref segment. It may be called multiple times
* on the same file. xref tables sometimes come in pieces.
*/
+
+ seek_absolute(pf->file, xref_pos);
+
mfgets(work_buffer, WORK_BUFFER_SIZE, pdf_input_file);
if (memcmp(work_buffer, "xref", strlen("xref"))) {
- WARN("No xref. Are you sure this is a PDF file?");
+ /* Might be an xref stream and not an xref table */
return 0;
}
/* Next line in file has first item and size of table */
@@ -2424,8 +2610,10 @@ parse_xref (void)
unsigned long current_pos;
current_pos = tell_position(pdf_input_file);
- if (mfgets(work_buffer, WORK_BUFFER_SIZE, pdf_input_file) == NULL)
- ERROR("parse_xref: premature end of PDF file while parsing xref");
+ if (mfgets(work_buffer, WORK_BUFFER_SIZE, pdf_input_file) == NULL) {
+ WARN("Premature end of PDF file while parsing xref table.");
+ return -1;
+ }
if (!strncmp(work_buffer, "trailer", strlen ("trailer"))) {
/*
* Backup... This is ugly, but it seems like the safest thing to
@@ -2438,8 +2626,8 @@ parse_xref (void)
break;
}
sscanf(work_buffer, "%lu %lu", &first, &size);
- if (num_input_objects < first + size) {
- extend_xref (first + size);
+ if (pf->num_obj < first + size) {
+ extend_xref(pf, first + size);
}
for (i = first; i < first + size; i++) {
@@ -2450,155 +2638,339 @@ parse_xref (void)
* through the reference table, so we only set "position"
* if it hasn't been set yet.
*/
-#define POSITION_UNSET(t,n) ((t)[(n)].file_position == 0)
-#define SET_XREF_ENTRY(t,n,o,g) \
-do { \
- (t)[(n)].file_position = (o); \
- (t)[(n)].generation = (g); \
-} while (0)
-#define SET_XREF_FLAG(t,n,f) ((t)[(n)].used = ((f) == 'n') ? 1 : 0)
work_buffer[19] = 0;
offset = 0UL; obj_gen = 0; flag = 0;
r = sscanf(work_buffer, "%010lu %05u %c", &offset, &obj_gen, &flag);
if ( r != 3 ||
((flag != 'n' && flag != 'f') ||
(flag == 'n' &&
- (offset >= pdf_file_size || (offset > 0 && offset < 4))))) {
+ (offset >= pf->file_size || (offset > 0 && offset < 4))))) {
WARN("Invalid xref table entry [%lu]. PDF file is corrupt...", i);
- return 0;
+ return -1;
+ }
+ if (!pf->xref_table[i].field2) {
+ pf->xref_table[i].type = (flag == 'n');
+ pf->xref_table[i].field2 = offset;
+ pf->xref_table[i].field3 = obj_gen;
}
- if (POSITION_UNSET(xref_table, i))
- SET_XREF_ENTRY(xref_table, i, offset, obj_gen);
- SET_XREF_FLAG(xref_table, i, flag);
}
}
return 1;
}
-static pdf_obj *
-read_xref (void)
+static unsigned long
+parse_xrefstm_field (const char **p, int length, unsigned long def)
{
- pdf_obj *main_trailer;
- long xref_pos;
+ unsigned long val = 0;
- xref_pos = find_xref();
- if (xref_pos == 0) {
- WARN("Can't find xref table.");
- return NULL;
- }
+ if (!length)
+ return def;
- /* Read primary xref table */
- seek_absolute(pdf_input_file, xref_pos);
- if (!parse_xref()) {
- WARN("Couldn't read xref table. Is this a correct PDF file?");
- return NULL;
+ while (length--) {
+ val <<= 8;
+ val |= (unsigned char) *((*p)++);
}
- main_trailer = parse_trailer();
- if (main_trailer == NULL) {
- WARN("Couldn't read xref trailer. Is this a correct PDF file?");
- return NULL;
+
+ return val;
+}
+
+static int
+parse_xrefstm_subsec (pdf_file *pf,
+ const char **p, long *length,
+ int *W, int wsum,
+ long first, long size) {
+ xref_entry *e;
+
+ if ((*length -= wsum*size) < 0)
+ return -1;
+
+ if (pf->num_obj < first+size)
+ extend_xref(pf, first+size); /* TODO: change! why? */
+
+ e = pf->xref_table + first;
+ while (size--) {
+ unsigned char type;
+ unsigned long field2;
+ unsigned short field3;
+
+ type = (unsigned char) parse_xrefstm_field(p, W[0], 1);
+ if (type > 2)
+ WARN("Unknown cross-reference stream entry type.");
+ else if (!W[1] || (type != 1 && !W[2]))
+ return -1;
+
+ field2 = (unsigned long) parse_xrefstm_field(p, W[1], 0);
+ field3 = (unsigned short) parse_xrefstm_field(p, W[2], 0);
+
+ if (!e->field2) {
+ e->type = type;
+ e->field2 = field2;
+ e->field3 = field3;
+ }
+ e++;
}
- {
- pdf_obj *xref_size;
+ return 0;
+}
- xref_size = pdf_lookup_dict(main_trailer, "Size");
- if (xref_size == NULL ||
- pdf_lookup_dict(main_trailer, "Root") == NULL) {
- WARN("Trailer doesn't have catalog or a size. Is this a correct PDF file?");
- return NULL;
- }
- if (num_input_objects < pdf_number_value(xref_size)) {
- extend_xref((long)pdf_number_value(xref_size));
+static int
+parse_xref_stream (pdf_file *pf, long xref_pos, pdf_obj **trailer)
+{
+ pdf_obj *xrefstm, *size_obj, *W_obj, *index;
+ unsigned long size;
+ long length;
+ int W[3], i, wsum = 0;
+ const char *p;
+
+ xrefstm = pdf_read_object(0, 0, pf, xref_pos, pf->file_size);
+ if (!PDF_OBJ_STREAMTYPE(xrefstm))
+ goto error;
+
+ {
+ pdf_obj *tmp = pdf_stream_uncompress(xrefstm);
+ if (!tmp)
+ goto error;
+ pdf_release_obj(xrefstm);
+ xrefstm = tmp;
+ }
+
+ *trailer = pdf_link_obj(pdf_stream_dict(xrefstm));
+
+ size_obj = pdf_lookup_dict(*trailer, "Size");
+ if (!PDF_OBJ_NUMBERTYPE(size_obj))
+ goto error;
+ size = (unsigned long) pdf_number_value(size_obj);
+
+ length = pdf_stream_length(xrefstm);
+
+ W_obj = pdf_lookup_dict(*trailer, "W");
+ if (!PDF_OBJ_ARRAYTYPE(W_obj) || pdf_array_length(W_obj) != 3)
+ goto error;
+
+ for (i = 0; i < 3; i++) {
+ pdf_obj *tmp = pdf_get_array(W_obj, i);
+ if (!PDF_OBJ_NUMBERTYPE(tmp))
+ goto error;
+ wsum += (W[i] = (int) pdf_number_value(tmp));
+ }
+
+ p = pdf_stream_dataptr(xrefstm);
+
+ index = pdf_lookup_dict(*trailer, "Index");
+ if (index) {
+ unsigned int index_len;
+ if (!PDF_OBJ_ARRAYTYPE(index) ||
+ ((index_len = pdf_array_length(index)) % 2 ))
+ goto error;
+
+ i = 0;
+ while (i < index_len) {
+ pdf_obj *first = pdf_get_array(index, i++);
+ pdf_obj *size = pdf_get_array(index, i++);
+ if (!PDF_OBJ_NUMBERTYPE(first) ||
+ !PDF_OBJ_NUMBERTYPE(size) ||
+ parse_xrefstm_subsec(pf, &p, &length, W, wsum,
+ (long) pdf_number_value(first),
+ (long) pdf_number_value(size)))
+ goto error;
}
+ } else if (parse_xrefstm_subsec(pf, &p, &length, W, wsum, 0, size))
+ goto error;
+
+ if (length)
+ WARN("Garbage in xref stream.");
+
+ pdf_release_obj(xrefstm);
+
+ return 1;
+
+ error:
+ WARN("Cannot parse cross-reference stream.");
+ if (xrefstm)
+ pdf_release_obj(xrefstm);
+ if (*trailer) {
+ pdf_release_obj(*trailer);
+ *trailer = NULL;
}
+ return 0;
+}
- /* Read any additional xref tables */
- {
- pdf_obj *prev_trailer, *prev_xref;
-
- prev_trailer = pdf_link_obj(main_trailer);
- while ((prev_xref = pdf_lookup_dict(prev_trailer, "Prev")) != NULL) {
- xref_pos = (long) pdf_number_value(prev_xref);
- seek_absolute(pdf_input_file, xref_pos);
- pdf_release_obj(prev_trailer);
- if (!parse_xref()) {
- WARN("Couldn't read xref table. Is this a correct PDF file?");
- return NULL;
- }
- prev_trailer = parse_trailer();
- if (prev_trailer == NULL) {
- WARN("Couldn't read xref trailer. Is this a correct PDF file?");
- return NULL;
+/* TODO: parse Version entry */
+static pdf_obj *
+read_xref (pdf_file *pf)
+{
+ pdf_obj *trailer = NULL, *main_trailer = NULL;
+ long xref_pos;
+
+ if (!(xref_pos = find_xref(pf->file)))
+ goto error;
+
+ while (xref_pos) {
+ pdf_obj *prev;
+
+ int res = parse_xref_table(pf, xref_pos);
+ if (res > 0) {
+ /* cross-reference table */
+ pdf_obj *xrefstm;
+
+ if (!(trailer = parse_trailer(pf)))
+ goto error;
+
+ if (!main_trailer)
+ main_trailer = pdf_link_obj(trailer);
+
+ if ((xrefstm = pdf_lookup_dict(trailer, "XRefStm"))) {
+ pdf_obj *new_trailer = NULL;
+ if (PDF_OBJ_NUMBERTYPE(xrefstm) &&
+ parse_xref_stream(pf, (long) pdf_number_value(xrefstm),
+ &new_trailer))
+ pdf_release_obj(new_trailer);
+ else
+ WARN("Skipping hybrid reference section.");
+ /* Many PDF 1.5 xref streams use DecodeParms, which we cannot
+ parse. This way we can use at least xref tables in hybrid
+ documents. Or should we better stop parsing the file?
+ */
}
- }
- pdf_release_obj(prev_trailer);
+
+ } else if (!res && parse_xref_stream(pf, xref_pos, &trailer)) {
+ /* cross-reference stream */
+ if (!main_trailer)
+ main_trailer = pdf_link_obj(trailer);
+ } else
+ goto error;
+
+ if ((prev = pdf_lookup_dict(trailer, "Prev"))) {
+ if (PDF_OBJ_NUMBERTYPE(prev))
+ xref_pos = (long) pdf_number_value(prev);
+ else
+ goto error;
+ } else
+ xref_pos = 0;
+
+ pdf_release_obj(trailer);
}
+#if 0
+ if (!pdf_lookup_dict(main_trailer, "Root")) {
+ WARN("Trailer doesn't have catalog. Is this a correct PDF file?");
+ goto error;
+ }
+#endif
+
return main_trailer;
+
+ error:
+ WARN("Error while parsing PDF file.");
+ if (trailer)
+ pdf_release_obj(trailer);
+ if (main_trailer)
+ pdf_release_obj(main_trailer);
+ return NULL;
}
-static char any_open = 0;
+static struct ht_table *pdf_files = NULL;
-pdf_obj *
-pdf_open (FILE *file)
+pdf_file *
+pdf_file_new (FILE *file)
{
- pdf_obj *trailer;
+ pdf_file *pf;
+ ASSERT(file);
+ pf = NEW(1, pdf_file);
+ pf->file = file;
+ pf->trailer = NULL;
+ pf->xref_table = NULL;
+ pf->num_obj = 0;
+ pf->version = 0;
- if (any_open) {
- WARN("Only one PDF file may be open at one time.");
- any_open = 1;
- exit(1);
- }
- pdf_input_file = file;
- if (!check_for_pdf(pdf_input_file)) {
- WARN("pdf_open: Not a PDF 1.[1-5] file.");
- return NULL;
+ seek_end(file);
+ pf->file_size = tell_position(file);
+
+ return pf;
+}
+
+static void
+pdf_file_free (pdf_file *pf)
+{
+ unsigned long i;
+
+ if (!pf) {
+ return;
}
- if ((trailer = read_xref()) == NULL) {
- WARN("No trailer.");
- pdf_close();
- return NULL;
+
+ for (i = 0; i < pf->num_obj; i++) {
+ if (pf->xref_table[i].direct)
+ pdf_release_obj(pf->xref_table[i].direct);
+ if (pf->xref_table[i].indirect)
+ pdf_release_obj(pf->xref_table[i].indirect);
}
- return trailer;
+ RELEASE(pf->xref_table);
+ pdf_release_obj(pf->trailer);
+
+ RELEASE(pf);
}
void
-pdf_close (void)
+pdf_files_init (void)
{
- unsigned long i;
- int done;
+ pdf_files = NEW(1, struct ht_table);
+ ht_init_table(pdf_files);
+}
- /*
- * Following loop must be iterated because each write could trigger
- * an additional indirect reference of an object with a lower number!
- */
- do {
- done = 1;
- for (i = 0; i < num_input_objects; i++) {
- if (xref_table[i].direct != NULL) {
- pdf_release_obj(xref_table[i].direct);
- xref_table[i].direct = NULL;
- done = 0;
- }
+pdf_obj *
+pdf_file_get_trailer (pdf_file *pf)
+{
+ ASSERT(pf);
+ return pdf_link_obj(pf->trailer);
+}
+
+pdf_file *
+pdf_open (char *ident, FILE *file)
+{
+ pdf_file *pf;
+
+ ASSERT(pdf_files);
+
+ pf = (pdf_file *) ht_lookup_table(pdf_files, ident, strlen(ident));
+
+ if (pf) {
+ pf->file = file;
+ } else {
+ int version = check_for_pdf(file);
+ if (!version) {
+ WARN("pdf_open: Not a PDF 1.[1-5] file.");
+ return NULL;
}
- } while (!done);
- /*
- * Now take care of the indirect objects. They had to be left around
- * until all the direct objects were flushed.
- */
- for (i = 0; i < num_input_objects; i++) {
- if (xref_table[i].indirect != NULL) {
- pdf_release_obj(xref_table[i].indirect);
+
+ pf = pdf_file_new(file);
+ pf->version = version;
+
+ if (!(pf->trailer = read_xref(pf))) {
+ pdf_file_free(pf);
+ return NULL;
}
+
+ ht_append_table(pdf_files, ident, strlen(ident), pf);
}
- RELEASE(xref_table);
- xref_table = NULL;
- num_input_objects = 0;
- any_open = 0;
- pdf_input_file = NULL;
+
+ return pf;
+}
+
+void
+pdf_close (pdf_file *pf)
+{
+ if (pf)
+ pf->file = NULL;
+}
+
+void
+pdf_files_close (void)
+{
+ ASSERT(pdf_files);
+ ht_clear_table(pdf_files, (void (*)(void *)) pdf_file_free);
+ RELEASE(pdf_files);
}
int
@@ -2638,6 +3010,51 @@ import_dict (pdf_obj *key, pdf_obj *value, void *pdata)
return 0;
}
+static pdf_obj *
+pdf_import_indirect (pdf_obj *object)
+{
+ pdf_file *pf = OBJ_FILE(object);
+ unsigned long obj_num = OBJ_NUM(object);
+ unsigned short obj_gen = OBJ_GEN(object);
+
+ pdf_obj *ref;
+
+ ASSERT(pf);
+
+ if (!checklabel(pf, obj_num, obj_gen)) {
+ WARN("Can't resolve object: %lu %u", obj_num, obj_gen);
+ return pdf_new_null();
+ }
+
+ if ((ref = pf->xref_table[obj_num].indirect)) {
+ return pdf_link_obj(ref);
+ } else {
+ pdf_obj *obj, *tmp;
+
+ obj = pdf_get_object(pf, obj_num, obj_gen);
+ if (!obj) {
+ WARN("Could not read object: %lu %u", obj_num, obj_gen);
+ return NULL;
+ }
+
+ tmp = pdf_import_object(obj);
+
+ pf->xref_table[obj_num].indirect = ref = pdf_ref_obj(tmp);
+
+ pdf_release_obj(tmp);
+ pdf_release_obj(obj);
+
+ return pdf_link_obj(ref);
+ }
+}
+
+/*
+ * pdf_import_object recursively copies the object and those
+ * referenced by it and changes the indirect references so that
+ * they refer to the current output file. New indirect references
+ * are remembered, which avoids duplicating objects when they
+ * are imported several times.
+ */
pdf_obj *
pdf_import_object (pdf_obj *object)
{
@@ -2648,12 +3065,8 @@ pdf_import_object (pdf_obj *object)
switch (pdf_obj_typeof(object)) {
case PDF_INDIRECT:
- if (ISDIRTY(object)) {
- if (OBJ_SRC(object) != pdf_input_file) {
- WARN("Different file is opened before object is imported?");
- return NULL;
- }
- imported = pdf_ref_file_obj(OBJ_NUM(object), OBJ_GEN(object));
+ if (OBJ_FILE(object)) {
+ imported = pdf_import_indirect(object);
} else {
imported = pdf_link_obj(object);
}
@@ -2721,10 +3134,8 @@ pdf_compare_reference (pdf_obj *ref1, pdf_obj *ref2)
data1 = (pdf_indirect *) ref1->data;
data2 = (pdf_indirect *) ref2->data;
- if (data1->dirty != data2->dirty)
- return (int) (data1->dirty - data2->dirty);
- if (data1->dirty_file != data2->dirty_file)
- return (int) (data1->dirty_file - data2->dirty_file);
+ if (data1->pf != data2->pf)
+ return (int) (data1->pf - data2->pf);
if (data1->label != data2->label)
return (int) (data1->label - data2->label);
if (data1->generation != data2->generation)
diff --git a/Build/source/texk/dvipdfmx/src/pdfobj.h b/Build/source/texk/dvipdfmx/src/pdfobj.h
index 346e38bd31b..d68f4108015 100644
--- a/Build/source/texk/dvipdfmx/src/pdfobj.h
+++ b/Build/source/texk/dvipdfmx/src/pdfobj.h
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pdfobj.h,v 1.23 2007/11/14 03:36:01 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pdfobj.h,v 1.27 2008/05/20 13:05:14 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -45,6 +45,7 @@
#define STREAM_COMPRESS (1 << 0)
typedef struct pdf_obj pdf_obj;
+typedef struct pdf_file pdf_file;
/* External interface to pdf routines */
@@ -55,8 +56,6 @@ extern void pdf_out_init (const char *filename, int do_encryption);
extern void pdf_out_flush (void);
extern void pdf_set_version (unsigned version);
extern unsigned pdf_get_version (void);
-extern void pdf_objstm_init (void);
-extern void pdf_objstm_close (void);
extern pdf_obj *pdf_new_obj (int type);
extern void pdf_release_obj (pdf_obj *object);
@@ -141,6 +140,12 @@ extern pdf_obj *pdf_new_stream (int flags);
extern void pdf_add_stream (pdf_obj *stream,
const void *stream_data_ptr,
long stream_data_len);
+#if HAVE_ZLIB
+extern int pdf_add_stream_flate (pdf_obj *stream,
+ const void *stream_data_ptr,
+ long stream_data_len);
+#endif
+extern int pdf_concat_stream (pdf_obj *dst, pdf_obj *src);
extern pdf_obj *pdf_stream_dict (pdf_obj *stream);
extern long pdf_stream_length (pdf_obj *stream);
extern void pdf_stream_set_flags (pdf_obj *stream, int flags);
@@ -164,16 +169,19 @@ extern void pdf_set_info (pdf_obj *obj);
extern void pdf_set_root (pdf_obj *obj);
extern void pdf_set_encrypt (pdf_obj *encrypt, pdf_obj *id);
+extern void pdf_files_init (void);
+extern void pdf_files_close (void);
extern int check_for_pdf (FILE *file);
-extern pdf_obj *pdf_open (FILE *file);
-extern void pdf_close (void);
+extern pdf_file *pdf_open (char *ident, FILE *file);
+extern void pdf_close (pdf_file *pf);
+extern pdf_obj *pdf_file_get_trailer (pdf_file *pf);
extern pdf_obj *pdf_deref_obj (pdf_obj *object);
extern pdf_obj *pdf_import_object (pdf_obj *object);
extern int pdfobj_escape_str (char *buffer, int size, const unsigned char *s, int len);
-extern pdf_obj *pdf_new_ref (unsigned long label, unsigned short generation);
+extern pdf_obj *pdf_new_indirect (pdf_file *pf, unsigned long label, unsigned short generation);
extern void pdf_copy_object (pdf_obj *dst, pdf_obj *src);
#endif /* _PDFOBJ_H_ */
diff --git a/Build/source/texk/dvipdfmx/src/pdfparse.c b/Build/source/texk/dvipdfmx/src/pdfparse.c
index f1c6a90a593..24705879b1b 100644
--- a/Build/source/texk/dvipdfmx/src/pdfparse.c
+++ b/Build/source/texk/dvipdfmx/src/pdfparse.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pdfparse.c,v 1.40 2007/04/03 05:11:39 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pdfparse.c,v 1.42 2008/05/16 10:51:25 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -599,18 +599,12 @@ parse_pdf_hex_string (char **pp, char *endptr)
p++;
- if ((endptr - p + 1) / 2 > PDF_STRING_LEN_MAX) {
- WARN("PDF string length too long. (limit: %ld)",
- PDF_STRING_LEN_MAX);
- return NULL;
- }
-
len = 0;
/*
* PDF Reference does not describe how to treat invalid char.
* Zero is appended if final hex digit is missing.
*/
- while (p < endptr && p[0] != '>') {
+ while (p < endptr && p[0] != '>' && len < PDF_STRING_LEN_MAX) {
int ch;
skip_white(&p, endptr);
@@ -628,9 +622,12 @@ parse_pdf_hex_string (char **pp, char *endptr)
sbuf[len++] = (ch & 0xff);
}
- if (p >= endptr || p[0] != '>') {
+ if (p >= endptr) {
WARN("Premature end of input hex string.");
return NULL;
+ } else if (p[0] != '>') {
+ WARN("PDF string length too long. (limit: %ld)", PDF_STRING_LEN_MAX);
+ return NULL;
}
*pp = p + 1;
@@ -662,7 +659,7 @@ parse_pdf_tainted_dict (char **pp, char *endptr)
pdf_obj *result;
parser_state.tainted = 1;
- result = parse_pdf_dict(pp, endptr);
+ result = parse_pdf_dict(pp, endptr, NULL);
parser_state.tainted = 0;
return result;
@@ -671,12 +668,12 @@ parse_pdf_tainted_dict (char **pp, char *endptr)
pdf_obj *
parse_pdf_tainted_dict (char **pp, char *endptr, int level)
{
- return parse_pdf_dict(pp, endptr);
+ return parse_pdf_dict(pp, endptr, NULL);
}
#endif /* !PDF_PARSE_STRICT */
pdf_obj *
-parse_pdf_dict (char **pp, char *endptr)
+parse_pdf_dict (char **pp, char *endptr, pdf_file *pf)
{
pdf_obj *result = NULL;
char *p;
@@ -708,7 +705,7 @@ parse_pdf_dict (char **pp, char *endptr)
skip_white(&p, endptr);
- value = parse_pdf_object(&p, endptr);
+ value = parse_pdf_object(&p, endptr, pf);
if (!value) {
pdf_release_obj(key);
pdf_release_obj(value);
@@ -733,7 +730,7 @@ parse_pdf_dict (char **pp, char *endptr)
}
pdf_obj *
-parse_pdf_array (char **pp, char *endptr)
+parse_pdf_array (char **pp, char *endptr, pdf_file *pf)
{
pdf_obj *result;
char *p;
@@ -754,7 +751,7 @@ parse_pdf_array (char **pp, char *endptr)
while (p < endptr && p[0] != ']') {
pdf_obj *elem;
- elem = parse_pdf_object(&p, endptr);
+ elem = parse_pdf_object(&p, endptr, pf);
if (!elem) {
pdf_release_obj(result);
WARN("Could not find a valid object in array object.");
@@ -776,7 +773,7 @@ parse_pdf_array (char **pp, char *endptr)
}
static pdf_obj *
-parse_pdf_stream (char **pp, char *endptr, pdf_obj *dict)
+parse_pdf_stream (char **pp, char *endptr, pdf_obj *dict, pdf_file *pf)
{
pdf_obj *result = NULL;
char *p;
@@ -950,11 +947,13 @@ parse_pdf_reference (char **start, char *end)
#endif /* !PDF_PARSE_STRICT */
static pdf_obj *
-try_pdf_reference (char *start, char *end, char **endptr)
+try_pdf_reference (char *start, char *end, char **endptr, pdf_file *pf)
{
unsigned long id = 0;
unsigned short gen = 0;
+ ASSERT(pf);
+
if (endptr)
*endptr = start;
@@ -990,11 +989,12 @@ try_pdf_reference (char *start, char *end, char **endptr)
if (endptr)
*endptr = start;
- return pdf_new_ref(id, gen);
+ return pdf_new_indirect(pf, id, gen);
}
pdf_obj *
-parse_pdf_object (char **pp, char *endptr)
+parse_pdf_object (char **pp, char *endptr, pdf_file *pf)
+/* If pf is NULL, then indirect references are not allowed */
{
pdf_obj *result = NULL;
char *nextptr;
@@ -1014,13 +1014,13 @@ parse_pdf_object (char **pp, char *endptr)
} else {
pdf_obj *dict;
- result = parse_pdf_dict(pp, endptr);
+ result = parse_pdf_dict(pp, endptr, pf);
skip_white(pp, endptr);
if ( result &&
*pp <= endptr - 15 &&
!memcmp(*pp, "stream", 6)) {
dict = result;
- result = parse_pdf_stream(pp, endptr, dict);
+ result = parse_pdf_stream(pp, endptr, dict, pf);
pdf_release_obj(dict);
}
}
@@ -1030,7 +1030,7 @@ parse_pdf_object (char **pp, char *endptr)
result = parse_pdf_string(pp, endptr);
break;
case '[':
- result = parse_pdf_array(pp, endptr);
+ result = parse_pdf_array(pp, endptr, pf);
break;
case '/':
result = parse_pdf_name(pp, endptr);
@@ -1047,8 +1047,11 @@ parse_pdf_object (char **pp, char *endptr)
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
- result = try_pdf_reference(*pp, endptr, &nextptr);
- if (result) {
+ /*
+ * If pf != NULL, then we are parsing a PDF file,
+ * and indirect references are allowed.
+ */
+ if (pf && (result = try_pdf_reference(*pp, endptr, &nextptr, pf))) {
*pp = nextptr;
} else {
result = parse_pdf_number(pp, endptr);
diff --git a/Build/source/texk/dvipdfmx/src/pdfparse.h b/Build/source/texk/dvipdfmx/src/pdfparse.h
index 6dfc4e1ee65..a02721be9df 100644
--- a/Build/source/texk/dvipdfmx/src/pdfparse.h
+++ b/Build/source/texk/dvipdfmx/src/pdfparse.h
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pdfparse.h,v 1.14 2005/07/17 09:53:38 hirata Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pdfparse.h,v 1.15 2008/05/13 12:23:45 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -46,9 +46,9 @@ extern pdf_obj *parse_pdf_boolean (char **pp, char *endptr);
extern pdf_obj *parse_pdf_number (char **pp, char *endptr);
extern pdf_obj *parse_pdf_null (char **pp, char *endptr);
extern pdf_obj *parse_pdf_string (char **pp, char *endptr);
-extern pdf_obj *parse_pdf_dict (char **pp, char *endptr);
-extern pdf_obj *parse_pdf_array (char **pp, char *endptr);
-extern pdf_obj *parse_pdf_object (char **pp, char *endptr);
+extern pdf_obj *parse_pdf_dict (char **pp, char *endptr, pdf_file *pf);
+extern pdf_obj *parse_pdf_array (char **pp, char *endptr, pdf_file *pf);
+extern pdf_obj *parse_pdf_object (char **pp, char *endptr, pdf_file *pf);
extern pdf_obj *parse_pdf_tainted_dict (char **pp, char *endptr);
diff --git a/Build/source/texk/dvipdfmx/src/pdfximage.c b/Build/source/texk/dvipdfmx/src/pdfximage.c
index a6e0da46658..a2c7776b23e 100644
--- a/Build/source/texk/dvipdfmx/src/pdfximage.c
+++ b/Build/source/texk/dvipdfmx/src/pdfximage.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pdfximage.c,v 1.16 2007/05/18 05:19:01 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pdfximage.c,v 1.20 2008/05/17 01:16:53 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -71,6 +71,7 @@ struct pdf_ximage_
{
char *ident;
char res_name[16];
+ long page_no, page_count;
int subtype;
@@ -107,10 +108,19 @@ static struct ic_ _ic = {
};
static void
-pdf_init_ximage_struct (pdf_ximage *I)
+pdf_init_ximage_struct (pdf_ximage *I, const char *ident, const char *filename)
{
- I->ident = NULL;
- I->filename = NULL;
+ if (ident) {
+ I->ident = NEW(strlen(ident)+1, char);
+ strcpy(I->ident, ident);
+ } else
+ I ->ident = NULL;
+ I->page_no = I->page_count = 0;
+ if (filename) {
+ I->filename = NEW(strlen(filename)+1, char);
+ strcpy(I->filename, filename);
+ } else
+ I->filename = NULL;
I->subtype = -1;
memset(I->res_name, 0, 16);
I->reference = NULL;
@@ -133,7 +143,7 @@ pdf_clean_ximage_struct (pdf_ximage *I)
pdf_release_obj(I->reference);
if (I->resource)
pdf_release_obj(I->resource);
- pdf_init_ximage_struct(I);
+ pdf_init_ximage_struct(I, NULL, NULL);
}
@@ -253,7 +263,7 @@ filter_put_form_attr (pdf_obj *kp, pdf_obj *vp, void *dp)
static int
load_image (const char *ident,
- const char *fullname, int format, FILE *fp)
+ const char *fullname, int format, FILE *fp, long page_no)
{
struct ic_ *ic = &_ic;
int id = -1; /* ret */
@@ -266,14 +276,15 @@ load_image (const char *ident,
}
I = &ic->ximages[id];
- pdf_init_ximage_struct(I);
+ pdf_init_ximage_struct(I, ident, ident);
+ pdf_ximage_set_page(I, page_no, 0);
switch (format) {
case IMAGE_TYPE_JPEG:
if (_opts.verbose)
MESG("[JPEG]");
if (jpeg_include_image(I, fp) < 0)
- return -1;
+ goto error;
I->subtype = PDF_XOBJECT_TYPE_IMAGE;
break;
#ifdef HAVE_LIBPNG
@@ -281,7 +292,7 @@ load_image (const char *ident,
if (_opts.verbose)
MESG("[PNG]");
if (png_include_image(I, fp) < 0)
- return -1;
+ goto error;
I->subtype = PDF_XOBJECT_TYPE_IMAGE;
break;
#endif
@@ -289,36 +300,29 @@ load_image (const char *ident,
if (_opts.verbose)
MESG("[BMP]");
if (bmp_include_image(I, fp) < 0)
- return -1;
+ goto error;
I->subtype = PDF_XOBJECT_TYPE_IMAGE;
break;
case IMAGE_TYPE_PDF:
if (_opts.verbose)
MESG("[PDF]");
if (pdf_include_page(I, fp) < 0)
- return -1;
- I->subtype = PDF_XOBJECT_TYPE_FORM;
- break;
- case IMAGE_TYPE_EPS:
+ goto error;
if (_opts.verbose)
- MESG("[PS]");
- if (ps_include_page(I, fullname) < 0)
- return -1;
+ MESG(",Page:%ld", I->page_no);
I->subtype = PDF_XOBJECT_TYPE_FORM;
break;
+ // case IMAGE_TYPE_EPS:
default:
if (_opts.verbose)
- MESG("[UNKNOWN]");
+ MESG(format == IMAGE_TYPE_EPS ? "[PS]" : "[UNKNOWN]");
if (ps_include_page(I, fullname) < 0)
- return -1;
+ goto error;
+ if (_opts.verbose)
+ MESG(",Page:%ld", I->page_no);
I->subtype = PDF_XOBJECT_TYPE_FORM;
}
- I->filename = NEW(strlen(ident)+1, char);
- I->ident = NEW(strlen(ident)+1, char);
- strcpy(I->filename, ident);
- strcpy(I->ident, ident);
-
switch (I->subtype) {
case PDF_XOBJECT_TYPE_IMAGE:
sprintf(I->res_name, "Im%d", id);
@@ -328,12 +332,16 @@ load_image (const char *ident,
break;
default:
ERROR("Unknown XObject subtype: %d", I->subtype);
- return -1;
+ goto error;
}
ic->count++;
return id;
+
+ error:
+ pdf_clean_ximage_struct(I);
+ return -1;
}
@@ -342,7 +350,7 @@ load_image (const char *ident,
#define dpx_fclose(f) (MFCLOSE((f)))
int
-pdf_ximage_findresource (const char *ident)
+pdf_ximage_findresource (const char *ident, long page_no)
{
struct ic_ *ic = &_ic;
int id = -1;
@@ -353,7 +361,8 @@ pdf_ximage_findresource (const char *ident)
for (id = 0; id < ic->count; id++) {
I = &ic->ximages[id];
- if (I->ident && !strcmp(ident, I->ident)) {
+ if (I->ident && !strcmp(ident, I->ident) &&
+ I->page_no == page_no + (page_no < 0 ? I->page_count+1 : 0)) {
return id;
}
}
@@ -383,9 +392,14 @@ pdf_ximage_findresource (const char *ident)
if (_opts.verbose)
MESG("[MPS]");
id = mps_include_page(ident, fp);
- break;
+ if (id < 0) {
+ WARN("Try again with the distiller.");
+ format = IMAGE_TYPE_EPS;
+ rewind(fp);
+ } else
+ break;
default:
- id = load_image(ident, fullname, format, fp);
+ id = load_image(ident, fullname, format, fp, page_no);
break;
}
dpx_fclose(fp);
@@ -473,6 +487,12 @@ pdf_ximage_init_image_info (ximage_info *info)
info->xdensity = info->ydensity = 1.0;
}
+char *
+pdf_ximage_get_ident (pdf_ximage *I)
+{
+ return I->ident;
+}
+
void
pdf_ximage_set_image (pdf_ximage *I, void *image_info, pdf_obj *resource)
{
@@ -521,6 +541,19 @@ pdf_ximage_set_form (pdf_ximage *I, void *form_info, pdf_obj *resource)
I->resource = NULL;
}
+long
+pdf_ximage_get_page (pdf_ximage *I)
+{
+ return I->page_no;
+}
+
+void
+pdf_ximage_set_page (pdf_ximage *I, long page_no, long page_count)
+{
+ I->page_no = page_no;
+ I->page_count = page_count;
+}
+
#define CHECK_ID(c,n) do {\
if ((n) < 0 || (n) >= (c)->count) {\
@@ -561,11 +594,7 @@ pdf_ximage_defineresource (const char *ident,
I = &ic->ximages[id];
- pdf_init_ximage_struct(I);
- if (ident) {
- I->ident = NEW(strlen(ident) + 1, char);
- strcpy(I->ident, ident);
- }
+ pdf_init_ximage_struct(I, ident, NULL);
switch (subtype) {
case PDF_XOBJECT_TYPE_IMAGE:
diff --git a/Build/source/texk/dvipdfmx/src/pdfximage.h b/Build/source/texk/dvipdfmx/src/pdfximage.h
index e66b17120f5..e8612484339 100644
--- a/Build/source/texk/dvipdfmx/src/pdfximage.h
+++ b/Build/source/texk/dvipdfmx/src/pdfximage.h
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pdfximage.h,v 1.10 2007/05/18 05:19:01 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pdfximage.h,v 1.12 2008/05/13 12:23:45 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -62,15 +62,18 @@ extern char *pdf_ximage_get_resname (int xobj_id);
extern pdf_obj *pdf_ximage_get_reference (int xobj_id);
-extern int pdf_ximage_findresource (const char *ident);
+extern int pdf_ximage_findresource (const char *ident, long page_no);
extern int pdf_ximage_defineresource (const char *ident,
int subtype, void *cdata, pdf_obj *resource);
/* Called by pngimage, jpegimage, epdf, mpost, etc. */
extern void pdf_ximage_init_image_info (ximage_info *info);
extern void pdf_ximage_init_form_info (xform_info *info);
+extern char *pdf_ximage_get_ident (pdf_ximage *ximage);
extern void pdf_ximage_set_image (pdf_ximage *ximage, void *info, pdf_obj *resource);
extern void pdf_ximage_set_form (pdf_ximage *ximage, void *info, pdf_obj *resource);
+extern void pdf_ximage_set_page (pdf_ximage *ximage, long page_no, long page_count);
+extern long pdf_ximage_get_page (pdf_ximage *I);
/* from psimage.h */
extern void set_distiller_template (char *s);
diff --git a/Build/source/texk/dvipdfmx/src/pst.c b/Build/source/texk/dvipdfmx/src/pst.c
index dc195ca6d91..430396d1c5d 100644
--- a/Build/source/texk/dvipdfmx/src/pst.c
+++ b/Build/source/texk/dvipdfmx/src/pst.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pst.c,v 1.5 2004/07/27 12:08:47 hirata Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pst.c,v 1.6 2008/01/11 18:04:15 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -100,12 +100,15 @@ pst_parse_comment (unsigned char **inbuf, unsigned char *inbufend)
}
#endif
+/* NOTE: the input buffer must be null-terminated, i.e., *inbufend == 0 */
pst_obj *
pst_get_token (unsigned char **inbuf, unsigned char *inbufend)
{
pst_obj *obj = NULL;
unsigned char c;
+ ASSERT(*inbuf <= inbufend && !*inbufend);
+
skip_white_spaces(inbuf, inbufend);
skip_comments(inbuf, inbufend);
if (*inbuf >= inbufend)
diff --git a/Build/source/texk/dvipdfmx/src/pst_obj.c b/Build/source/texk/dvipdfmx/src/pst_obj.c
index 55d5773cdd9..5f0a1fc0e1e 100644
--- a/Build/source/texk/dvipdfmx/src/pst_obj.c
+++ b/Build/source/texk/dvipdfmx/src/pst_obj.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pst_obj.c,v 1.5 2004/07/27 12:08:47 hirata Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pst_obj.c,v 1.7 2008/01/13 21:25:31 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -23,6 +23,9 @@
*/
#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+
#include "system.h"
#include "mem.h"
#include "error.h"
@@ -65,9 +68,6 @@ static long pst_boolean_length (pst_boolean *obj);
static void *pst_boolean_data_ptr(pst_boolean *obj);
/* NUMBERS */
-static long parse_long (unsigned char **inbuf, unsigned char *inbufend, unsigned char base, unsigned char *ndigits);
-static double cvtdbl (long ipart, long dpart, unsigned char nddigits, long epart);
-
static pst_integer *pst_integer_new (long value) ;
static void pst_integer_release (pst_integer *obj);
static long pst_integer_IV (pst_integer *obj);
@@ -521,147 +521,43 @@ pst_real_length (pst_real *obj)
return 0;
}
-/*
- * Does not skip white spaces
- * base number must be greater than 1 and less than 33.
- * TODO: overflow and underflow
- */
-static long
-parse_long (unsigned char **inbuf, unsigned char *inbufend, unsigned char base, unsigned char *ndigits)
-{
- long val = 0, sign = 1;
- unsigned char *cur = *inbuf, c;
- int count = 0;
-
- if (*cur == '+') {
- sign = 1;
- cur++;
- } else if (*cur == '-') {
- sign = -1;
- cur++;
- }
- while (cur < inbufend) {
- c = *cur;
- if (c >= '0' && c <= '0' + ((base <= 10) ? base-1 : 9)) {
- c = c - '0';
- } else if (base > 10) {
- if (c >= 'a' && c <= 'a' + (base - 11)) {
- c = c - 'a' + 10;
- } else if (c >= 'A' && c <= 'A' + (base - 11)) {
- c = c - 'A' + 10;
- } else {
- break;
- }
- } else {
- break;
- }
- val = val * base + c;
- cur++;
- count++;
- }
-
- if (ndigits != NULL)
- *ndigits = count;
- *inbuf = cur;
- return sign*val;
-}
-
-static double
-cvtdbl (long ipart, long dpart, unsigned char nddigits, long epart)
-{
- double dval = 0.0;
- int i;
-
- if (dpart > 0 && nddigits > 0) {
- dval = dpart;
- for (i = 0; i < nddigits; i++) {
- dval *= 0.1;
- }
- }
-
- if (ipart < 0)
- dval = ipart - dval;
- else
- dval = ipart + dval;
-
- if (epart > 0) {
- for (i = 0; i < epart; i++)
- dval *= 10.0;
- } else if (epart < 0) {
- for (i = 0; i < -epart; i++)
- dval *= 0.1;
- }
-
- return dval;
-}
-
+/* NOTE: the input buffer must be null-terminated, i.e., *inbufend == 0 */
+/* leading white-space is ignored */
pst_obj *
pst_parse_number (unsigned char **inbuf, unsigned char *inbufend)
{
- pst_obj *obj = NULL;
- unsigned char *cur = *inbuf;
- unsigned char ndigits = 0, nddigits = 0;
- int type;
- long ipart = 0, dpart = 0, epart = 0;
-
- if (cur >= inbufend)
- return NULL;
-
- ipart = parse_long(&cur, inbufend, 10, &ndigits);
- if (ndigits > 0 && PST_TOKEN_END(cur, inbufend)) {
- type = PST_TYPE_INTEGER;
- dpart = epart = 0;
- } else if (ndigits > 0 && *cur == '#' &&
- ipart >= 2 && ipart <= 36) { /* Radix */
- cur++;
- ipart = parse_long(&cur, inbufend, ipart, NULL);
- if (ipart >= 0 && PST_TOKEN_END(cur, inbufend)) { /* non-negative only ? */
- type = PST_TYPE_INTEGER;
- dpart = epart = 0;
- } else
- type = -1;
- } else if (*cur == '.') {
- cur++;
- dpart = parse_long(&cur, inbufend, 10, &nddigits);
- ndigits += nddigits;
- if (dpart < 0) {
- type = -1;
- } else if (ndigits > 0 && PST_TOKEN_END(cur, inbufend)) {
- type = PST_TYPE_REAL;
- epart = 0;
- } else if (ndigits > 0 && (*cur == 'e' || *cur == 'E')) {
- cur++;
- epart = parse_long(&cur, inbufend, 10, &ndigits);
- if (ndigits > 0 && PST_TOKEN_END(cur, inbufend))
- type = PST_TYPE_REAL;
- else
- type = -1;
- } else
- type = -1;
- } else if (ndigits > 0 && (*cur == 'e' || *cur == 'E')) {
- cur++;
- epart = parse_long(&cur, inbufend, 10, &ndigits);
- if (ndigits > 0 && PST_TOKEN_END(cur, inbufend)) {
- dpart = 0;
- type = PST_TYPE_REAL;
- } else
- type = -1;
- } else {
- type = -1;
+ unsigned char *cur;
+ long lval;
+ double dval;
+
+ errno = 0;
+ lval = strtol(*inbuf, (char **) &cur, 10);
+ if (errno || *cur == '.' || *cur == 'e' || *cur == 'E') {
+ /* real */
+ errno = 0;
+ dval = strtod(*inbuf, (char **) &cur);
+ if (!errno && PST_TOKEN_END(cur, inbufend)) {
+ *inbuf = cur;
+ return pst_new_obj(PST_TYPE_REAL, pst_real_new(dval));
+ }
+ } else if (cur != *inbuf && PST_TOKEN_END(cur, inbufend)) {
+ /* integer */
+ *inbuf = cur;
+ return pst_new_obj(PST_TYPE_INTEGER, pst_integer_new(lval));
+ } else if (lval >= 2 && lval <= 36 && *cur == '#' && isalnum(*++cur) &&
+ /* strtod allows leading "0x" for hex numbers, but we don't */
+ (lval != 16 || (cur[1] != 'x' && cur[1] != 'X'))) {
+ /* integer with radix */
+ /* Can the base have a (plus) sign? I think yes. */
+ errno = 0;
+ lval = strtol(cur, (char **) &cur, lval);
+ if (!errno && PST_TOKEN_END(cur, inbufend)) {
+ *inbuf = cur;
+ return pst_new_obj(PST_TYPE_INTEGER, pst_integer_new(lval));
+ }
}
-
- if (type < 0)
- return NULL;
-
- if (type == PST_TYPE_REAL)
- obj = pst_new_obj(type, pst_real_new(cvtdbl(ipart, dpart, nddigits, epart)));
- else if (type == PST_TYPE_INTEGER)
- obj = pst_new_obj(type, pst_integer_new(ipart));
- else
- return NULL;
-
- *inbuf = cur;
- return obj;
+ /* error */
+ return NULL;
}
/* NAME */
diff --git a/Build/source/texk/dvipdfmx/src/sfnt.c b/Build/source/texk/dvipdfmx/src/sfnt.c
index 5d29ed1fe41..55e285a989e 100644
--- a/Build/source/texk/dvipdfmx/src/sfnt.c
+++ b/Build/source/texk/dvipdfmx/src/sfnt.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/sfnt.c,v 1.12 2004/09/11 14:50:29 hirata Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/sfnt.c,v 1.13 2008/05/08 18:51:59 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -79,6 +79,64 @@ sfnt_open (FILE *fp)
rewind(sfont->stream);
sfont->directory = NULL;
+ sfont->offset = 0UL;
+
+ return sfont;
+}
+
+sfnt *
+dfont_open (FILE *fp, int index)
+{
+ sfnt *sfont;
+ ULONG rdata_pos, map_pos, tags_pos, types_pos, res_pos, tag, type;
+ USHORT tags_num, types_num, i;
+
+ ASSERT(fp);
+
+ rewind(fp);
+
+ sfont = NEW(1, sfnt);
+
+ sfont->stream = fp;
+
+ rdata_pos = sfnt_get_ulong(sfont);
+ map_pos = sfnt_get_ulong(sfont);
+ sfnt_seek_set(sfont, map_pos + 0x18);
+ tags_pos = map_pos + sfnt_get_ushort(sfont);
+ sfnt_seek_set(sfont, tags_pos);
+ tags_num = sfnt_get_ushort(sfont);
+
+ for (i = 0; i <= tags_num; i++) {
+ tag = sfnt_get_ulong(sfont); /* tag name */
+ types_num = sfnt_get_ushort(sfont); /* typefaces number */
+ types_pos = tags_pos + sfnt_get_ushort(sfont); /* typefaces position */
+ if (tag == 0x73666e74UL) /* "sfnt" */
+ break;
+ }
+
+ if (i > tags_num) {
+ RELEASE(sfont);
+ return NULL;
+ }
+
+ sfnt_seek_set(sfont, types_pos);
+ if (index > types_num) {
+ ERROR("Invalid index %d for dfont.", index);
+ }
+
+ for (i = 0; i <= types_num; i++) {
+ sfnt_get_ushort(sfont); /* resource id */
+ sfnt_get_ushort(sfont); /* resource name position from name_list */
+ res_pos = sfnt_get_ulong(sfont); /* resource flag (byte) + resource offset */
+ sfnt_get_ulong(sfont); /* mbz */
+ if (i == index) break;
+ }
+
+ rewind(sfont->stream);
+
+ sfont->type = SFNT_TYPE_DFONT;
+ sfont->directory = NULL;
+ sfont->offset = (res_pos & 0x00ffffffUL) + rdata_pos + 4;
return sfont;
}
@@ -325,9 +383,10 @@ sfnt_read_table_directory (sfnt *sfont, ULONG offset)
convert_tag(td->tables[i].tag, u_tag);
td->tables[i].check_sum = sfnt_get_ulong(sfont);
- td->tables[i].offset = sfnt_get_ulong(sfont);
+ td->tables[i].offset = sfnt_get_ulong(sfont) + sfont->offset;
td->tables[i].length = sfnt_get_ulong(sfont);
td->tables[i].data = NULL;
+//fprintf(stderr, "[%4s:%x]", td->tables[i].tag, td->tables[i].offset);
td->flags[i] = 0;
}
diff --git a/Build/source/texk/dvipdfmx/src/sfnt.h b/Build/source/texk/dvipdfmx/src/sfnt.h
index e3a419fd63c..5113de540ee 100644
--- a/Build/source/texk/dvipdfmx/src/sfnt.h
+++ b/Build/source/texk/dvipdfmx/src/sfnt.h
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/sfnt.h,v 1.9 2004/09/11 14:50:29 hirata Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/sfnt.h,v 1.10 2008/05/08 18:51:59 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -69,11 +69,13 @@ struct sfnt_table_directory
#define SFNT_TYPE_OPENTYPE (1 << 1)
#define SFNT_TYPE_POSTSCRIPT (1 << 2)
#define SFNT_TYPE_TTC (1 << 4)
+#define SFNT_TYPE_DFONT (1 << 8)
typedef struct
{
FILE *stream;
int type;
+ ULONG offset;
struct sfnt_table_directory *directory;
} sfnt;
@@ -101,6 +103,7 @@ extern int put_big_endian (void *s, LONG q, int n);
extern sfnt *sfnt_open (FILE *fp);
extern void sfnt_close (sfnt *sfont);
+extern sfnt *dfont_open (FILE *fp, int index);
/* table directory */
extern int sfnt_read_table_directory (sfnt *sfont, ULONG offset);
diff --git a/Build/source/texk/dvipdfmx/src/spc_color.c b/Build/source/texk/dvipdfmx/src/spc_color.c
index eea7e765b2a..35880193012 100644
--- a/Build/source/texk/dvipdfmx/src/spc_color.c
+++ b/Build/source/texk/dvipdfmx/src/spc_color.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/spc_color.c,v 1.5 2005/07/30 11:44:18 hirata Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/spc_color.c,v 1.6 2007/11/22 11:45:39 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -79,9 +79,7 @@ spc_handler_color_push (struct spc_env *spe, struct spc_arg *args)
error = spc_util_read_colorspec(spe, &colorspec, args, 1);
if (!error) {
- pdf_color_push(); /* save currentcolor */
- pdf_dev_setcolor(&colorspec, 0);
- pdf_dev_setcolor(&colorspec, 1);
+ pdf_color_push(&colorspec, &colorspec);
}
return error;
@@ -95,9 +93,8 @@ spc_handler_color_pop (struct spc_env *spe, struct spc_arg *args)
return 0;
}
-/* _FIXME_ ... I don't understand this well.
- * Dvips's implementation is to clear color stack and then
- * push color?
+/* Invoked by the special command "color rgb .625 0 0".
+ * DVIPS clears the color stack, and then saves and sets the given color.
*/
static int
spc_handler_color_default (struct spc_env *spe, struct spc_arg *args)
@@ -107,10 +104,9 @@ spc_handler_color_default (struct spc_env *spe, struct spc_arg *args)
error = spc_util_read_colorspec(spe, &colorspec, args, 1);
if (!error) {
- pdf_color_clear();
- pdf_dev_setcolor(&colorspec, 0);
- pdf_dev_setcolor(&colorspec, 1);
- pdf_color_push(); /* save currentcolor */
+ pdf_color_set_default(&colorspec);
+ pdf_color_clear_stack(); /* the default color is saved on color_stack */
+ pdf_color_push(&colorspec, &colorspec);
}
return error;
diff --git a/Build/source/texk/dvipdfmx/src/spc_dvips.c b/Build/source/texk/dvipdfmx/src/spc_dvips.c
index ef74e56f279..d026fa77ac0 100644
--- a/Build/source/texk/dvipdfmx/src/spc_dvips.c
+++ b/Build/source/texk/dvipdfmx/src/spc_dvips.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/spc_dvips.c,v 1.9 2005/08/19 12:06:24 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/spc_dvips.c,v 1.10 2008/02/13 20:22:21 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -119,12 +119,12 @@ spc_handler_ps_file (struct spc_env *spe, struct spc_arg *args)
}
transform_info_clear(&ti);
- if (spc_util_read_dimtrns(spe, &ti, args, 1) < 0) {
+ if (spc_util_read_dimtrns(spe, &ti, args, NULL, 1) < 0) {
RELEASE(filename);
return -1;
}
- form_id = pdf_ximage_findresource(filename);
+ form_id = pdf_ximage_findresource(filename, 1);
if (form_id < 0) {
spc_warn(spe, "Failed to read image file: %s", filename);
RELEASE(filename);
@@ -157,7 +157,7 @@ spc_handler_ps_plotfile (struct spc_env *spe, struct spc_arg *args)
return -1;
}
- form_id = pdf_ximage_findresource(filename);
+ form_id = pdf_ximage_findresource(filename, 1);
if (form_id < 0) {
spc_warn(spe, "Could not open PS file: %s", filename);
error = -1;
diff --git a/Build/source/texk/dvipdfmx/src/spc_html.c b/Build/source/texk/dvipdfmx/src/spc_html.c
index d2ba4140518..df21ec9d595 100644
--- a/Build/source/texk/dvipdfmx/src/spc_html.c
+++ b/Build/source/texk/dvipdfmx/src/spc_html.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/spc_html.c,v 1.6 2007/01/19 11:00:48 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/spc_html.c,v 1.7 2008/02/13 20:22:21 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -635,7 +635,7 @@ spc_html__img_empty (struct spc_env *spe, pdf_obj *attr, struct spc_html_ *sd)
return error;
}
- id = pdf_ximage_findresource(pdf_string_value(src));
+ id = pdf_ximage_findresource(pdf_string_value(src), 0);
if (id < 0) {
spc_warn(spe, "Could not find/load image: %s", pdf_string_value(src));
error = -1;
diff --git a/Build/source/texk/dvipdfmx/src/spc_misc.c b/Build/source/texk/dvipdfmx/src/spc_misc.c
index 01078602a3d..1dc3cabf1c5 100644
--- a/Build/source/texk/dvipdfmx/src/spc_misc.c
+++ b/Build/source/texk/dvipdfmx/src/spc_misc.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/spc_misc.c,v 1.6 2005/08/08 18:00:11 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/spc_misc.c,v 1.7 2008/02/13 20:22:21 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -134,7 +134,7 @@ spc_handler_postscriptbox (struct spc_env *spe, struct spc_arg *ap)
}
MFCLOSE(fp);
- form_id = pdf_ximage_findresource(filename);
+ form_id = pdf_ximage_findresource(filename, 0);
if (form_id < 0) {
spc_warn(spe, "Failed to load image file: %s", filename);
return -1;
diff --git a/Build/source/texk/dvipdfmx/src/spc_pdfm.c b/Build/source/texk/dvipdfmx/src/spc_pdfm.c
index 67a66dba7c5..a18addfd7d0 100644
--- a/Build/source/texk/dvipdfmx/src/spc_pdfm.c
+++ b/Build/source/texk/dvipdfmx/src/spc_pdfm.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/spc_pdfm.c,v 1.26 2007/04/25 09:44:49 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/spc_pdfm.c,v 1.34 2008/05/18 12:05:22 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -36,6 +36,7 @@
#include "numbers.h"
#include "fontmap.h"
+#include "dpxfile.h"
#include "dpxutil.h"
#include "pdfobj.h"
@@ -331,8 +332,7 @@ spc_handler_pdfm_put (struct spc_env *spe, struct spc_arg *ap)
}
skip_white(&ap->curptr, ap->endptr);
-
- obj2 = parse_pdf_object(&ap->curptr, ap->endptr);
+ obj2 = parse_pdf_object(&ap->curptr, ap->endptr, NULL);
if (!obj2) {
spc_warn(spe, "Missing (an) object(s) to put into \"%s\"!", ident);
RELEASE(ident);
@@ -378,7 +378,7 @@ spc_handler_pdfm_put (struct spc_env *spe, struct spc_arg *ap)
/* dvipdfm */
pdf_add_array(obj1, pdf_link_obj(obj2));
while (ap->curptr < ap->endptr) {
- pdf_obj *obj3 = parse_pdf_object(&ap->curptr, ap->endptr);
+ pdf_obj *obj3 = parse_pdf_object(&ap->curptr, ap->endptr, NULL);
if (!obj3)
break;
pdf_add_array(obj1, obj3);
@@ -392,7 +392,7 @@ spc_handler_pdfm_put (struct spc_env *spe, struct spc_arg *ap)
break;
}
pdf_release_obj(obj2);
-
+ RELEASE(ident);
return error;
}
@@ -507,13 +507,13 @@ my_parse_pdf_dict (char **pp, char *endptr, struct tounicode *cd)
pdf_obj *dict;
if (cd->cmap_id < 0)
- return parse_pdf_dict(pp, endptr);
+ return parse_pdf_dict(pp, endptr, NULL);
/* :( */
if (cd->unescape_backslash)
dict = parse_pdf_tainted_dict(pp, endptr);
else {
- dict = parse_pdf_dict(pp, endptr);
+ dict = parse_pdf_dict(pp, endptr, NULL);
}
if (dict)
pdf_foreach_dict(dict, modstrings, cd);
@@ -543,7 +543,7 @@ spc_handler_pdfm_annot (struct spc_env *spe, struct spc_arg *args)
}
transform_info_clear(&ti);
- if (spc_util_read_dimtrns(spe, &ti, args, 0) < 0) {
+ if (spc_util_read_dimtrns(spe, &ti, args, NULL, 0) < 0) {
if (ident)
RELEASE(ident);
return -1;
@@ -560,7 +560,7 @@ spc_handler_pdfm_annot (struct spc_env *spe, struct spc_arg *args)
#ifdef ENABLE_TOUNICODE
annot_dict = my_parse_pdf_dict(&args->curptr, args->endptr, &sd->cd);
#else
- annot_dict = parse_pdf_dict(&args->curptr, args->endptr);
+ annot_dict = parse_pdf_dict(&args->curptr, args->endptr, NULL);
#endif /* ENABLE_TOUNICODE */
if (!annot_dict) {
spc_warn(spe, "Could not find dictionary object.");
@@ -621,7 +621,7 @@ spc_handler_pdfm_bann (struct spc_env *spe, struct spc_arg *args)
#ifdef ENABLE_TOUNICODE
sd->annot_dict = my_parse_pdf_dict(&args->curptr, args->endptr, &sd->cd);
#else
- sd->annot_dict = parse_pdf_dict(&args->curptr, args->endptr);
+ sd->annot_dict = parse_pdf_dict(&args->curptr, args->endptr, NULL);
#endif /* ENABLE_TOUNICODE */
if (!sd->annot_dict) {
spc_warn(spe, "Ignoring annotation with invalid dictionary.");
@@ -677,9 +677,9 @@ spc_handler_pdfm_bcolor (struct spc_env *spe, struct spc_arg *ap)
if (error)
spc_warn(spe, "Invalid color specification?");
else {
- pdf_color_push(); /* save currentcolor */
- pdf_dev_setcolor(&fc, 1);
- pdf_dev_setcolor(&sc, 0);
+ pdf_color_push(&sc, &fc); /* save currentcolor */
+ pdf_dev_set_strokingcolor(&sc);
+ pdf_dev_set_nonstrokingcolor(&fc);
}
return error;
@@ -705,8 +705,8 @@ spc_handler_pdfm_scolor (struct spc_env *spe, struct spc_arg *ap)
spc_warn(spe, "Invalid color specification?");
else {
pdf_color_set_default(&fc); /* ????? */
- pdf_dev_setcolor(&fc, 1);
- pdf_dev_setcolor(&sc, 0);
+ pdf_dev_set_strokingcolor(&sc);
+ pdf_dev_set_nonstrokingcolor(&fc);
}
return error;
@@ -727,7 +727,7 @@ spc_handler_pdfm_btrans (struct spc_env *spe, struct spc_arg *args)
transform_info ti;
transform_info_clear(&ti);
- if (spc_util_read_dimtrns(spe, &ti, args, 0) < 0) {
+ if (spc_util_read_dimtrns(spe, &ti, args, NULL, 0) < 0) {
return -1;
}
@@ -788,7 +788,7 @@ spc_handler_pdfm_outline (struct spc_env *spe, struct spc_arg *args)
}
skip_white(&args->curptr, args->endptr);
- tmp = parse_pdf_object(&args->curptr, args->endptr);
+ tmp = parse_pdf_object(&args->curptr, args->endptr, NULL);
if (!tmp) {
spc_warn(spe, "Missing number for outline item depth.");
return -1;
@@ -818,7 +818,7 @@ spc_handler_pdfm_outline (struct spc_env *spe, struct spc_arg *args)
#ifdef ENABLE_TOUNICODE
item_dict = my_parse_pdf_dict(&args->curptr, args->endptr, &sd->cd);
#else
- item_dict = parse_pdf_dict(&args->curptr, args->endptr);
+ item_dict = parse_pdf_dict(&args->curptr, args->endptr, NULL);
#endif /* ENABLE_TOUNICODE */
if (!item_dict) {
spc_warn(spe, "Ignoring invalid dictionary.");
@@ -858,11 +858,11 @@ spc_handler_pdfm_article (struct spc_env *spe, struct spc_arg *args)
#ifdef ENABLE_TOUNICODE
info_dict = my_parse_pdf_dict(&args->curptr, args->endptr, &sd->cd);
#else
- info_dict = parse_pdf_dict(&args->curptr, args->endptr);
+ info_dict = parse_pdf_dict(&args->curptr, args->endptr, NULL);
#endif /* ENABLE_TOUNICODE */
if (!info_dict) {
- RELEASE(ident);
spc_warn(spe, "Ignoring article with invalid info dictionary.");
+ RELEASE(ident);
return -1;
}
@@ -902,7 +902,7 @@ spc_handler_pdfm_bead (struct spc_env *spe, struct spc_arg *args)
/* If okay so far, try to get a bounding box */
transform_info_clear(&ti);
- if (spc_util_read_dimtrns(spe, &ti, args, 0) < 0) {
+ if (spc_util_read_dimtrns(spe, &ti, args, NULL, 0) < 0) {
RELEASE(article_name);
return -1;
}
@@ -935,7 +935,7 @@ spc_handler_pdfm_bead (struct spc_env *spe, struct spc_arg *args)
#ifdef ENABLE_TOUNICODE
article_info = my_parse_pdf_dict(&args->curptr, args->endptr, &sd->cd);
#else
- article_info = parse_pdf_dict(&args->curptr, args->endptr);
+ article_info = parse_pdf_dict(&args->curptr, args->endptr, NULL);
#endif /* ENABLE_TOUNICODE */
if (!article_info) {
spc_warn(spe, "Error in reading dictionary.");
@@ -956,6 +956,7 @@ spc_handler_pdfm_bead (struct spc_env *spe, struct spc_arg *args)
page_no = pdf_doc_current_page_number();
pdf_doc_add_bead(article_name, NULL, page_no, &rect);
+ RELEASE(article_name);
return 0;
}
@@ -967,6 +968,7 @@ spc_handler_pdfm_image (struct spc_env *spe, struct spc_arg *args)
char *ident = NULL;
pdf_obj *fspec;
transform_info ti;
+ long page_no;
skip_white(&args->curptr, args->endptr);
if (args->curptr[0] == '@') {
@@ -980,14 +982,15 @@ spc_handler_pdfm_image (struct spc_env *spe, struct spc_arg *args)
}
transform_info_clear(&ti);
- if (spc_util_read_dimtrns(spe, &ti, args, 0) < 0) {
+ page_no = 1;
+ if (spc_util_read_dimtrns(spe, &ti, args, &page_no, 0) < 0) {
if (ident)
RELEASE(ident);
return -1;
}
skip_white(&args->curptr, args->endptr);
- fspec = parse_pdf_object(&args->curptr, args->endptr);
+ fspec = parse_pdf_object(&args->curptr, args->endptr, NULL);
if (!fspec) {
spc_warn(spe, "Missing filename string for pdf:image.");
if (ident)
@@ -996,10 +999,12 @@ spc_handler_pdfm_image (struct spc_env *spe, struct spc_arg *args)
} else if (!PDF_OBJ_STRINGTYPE(fspec)) {
spc_warn(spe, "Missing filename string for pdf:image.");
pdf_release_obj(fspec);
+ if (ident)
+ RELEASE(ident);
return -1;
}
- xobj_id = pdf_ximage_findresource(pdf_string_value(fspec));
+ xobj_id = pdf_ximage_findresource(pdf_string_value(fspec), page_no);
if (xobj_id < 0) {
spc_warn(spe, "Could not find image resource...");
pdf_release_obj(fspec);
@@ -1029,7 +1034,7 @@ spc_handler_pdfm_dest (struct spc_env *spe, struct spc_arg *args)
skip_white(&args->curptr, args->endptr);
- name = parse_pdf_object(&args->curptr, args->endptr);
+ name = parse_pdf_object(&args->curptr, args->endptr, NULL);
if (!name) {
spc_warn(spe, "PDF string expected for destination name but not found.");
return -1;
@@ -1039,7 +1044,7 @@ spc_handler_pdfm_dest (struct spc_env *spe, struct spc_arg *args)
return -1;
}
- array = parse_pdf_object(&args->curptr, args->endptr);
+ array = parse_pdf_object(&args->curptr, args->endptr, NULL);
if (!array) {
spc_warn(spe, "No destination not specified for pdf:dest.");
pdf_release_obj(name);
@@ -1069,7 +1074,7 @@ spc_handler_pdfm_names (struct spc_env *spe, struct spc_arg *args)
pdf_obj *category, *key, *value, *tmp;
int i, size;
- category = parse_pdf_object(&args->curptr, args->endptr);
+ category = parse_pdf_object(&args->curptr, args->endptr, NULL);
if (!category) {
spc_warn(spe, "PDF name expected but not found.");
return -1;
@@ -1079,7 +1084,7 @@ spc_handler_pdfm_names (struct spc_env *spe, struct spc_arg *args)
return -1;
}
- tmp = parse_pdf_object(&args->curptr, args->endptr);
+ tmp = parse_pdf_object(&args->curptr, args->endptr, NULL);
if (!tmp) {
spc_warn(spe, "PDF object expected but not found.");
pdf_release_obj(category);
@@ -1114,7 +1119,7 @@ spc_handler_pdfm_names (struct spc_env *spe, struct spc_arg *args)
pdf_release_obj(tmp);
} else if (PDF_OBJ_STRINGTYPE(tmp)) {
key = tmp;
- value = parse_pdf_object(&args->curptr, args->endptr);
+ value = parse_pdf_object(&args->curptr, args->endptr, NULL);
if (!value) {
pdf_release_obj(category);
pdf_release_obj(key);
@@ -1153,7 +1158,7 @@ spc_handler_pdfm_docinfo (struct spc_env *spe, struct spc_arg *args)
#ifdef ENABLE_TOUNICODE
dict = my_parse_pdf_dict(&args->curptr, args->endptr, &sd->cd);
#else
- dict = parse_pdf_dict(&args->curptr, args->endptr);
+ dict = parse_pdf_dict(&args->curptr, args->endptr, NULL);
#endif /* ENABLE_TOUNICODE */
if (!dict) {
spc_warn(spe, "Dictionary object expected but not found.");
@@ -1179,7 +1184,7 @@ spc_handler_pdfm_docview (struct spc_env *spe, struct spc_arg *args)
#ifdef ENABLE_TOUNICODE
dict = my_parse_pdf_dict(&args->curptr, args->endptr, &sd->cd);
#else
- dict = parse_pdf_dict(&args->curptr, args->endptr);
+ dict = parse_pdf_dict(&args->curptr, args->endptr, NULL);
#endif /* ENABLE_TOUNICODE */
if (!dict) {
spc_warn(spe, "Dictionary object expected but not found.");
@@ -1230,10 +1235,10 @@ spc_handler_pdfm_object (struct spc_env *spe, struct spc_arg *args)
return -1;
}
- object = parse_pdf_object(&args->curptr, args->endptr);
+ object = parse_pdf_object(&args->curptr, args->endptr, NULL);
if (!object) {
- RELEASE(ident);
spc_warn(spe, "Could not find an object definition for \"%s\".", ident);
+ RELEASE(ident);
return -1;
} else {
spc_push_object(ident, object);
@@ -1324,7 +1329,7 @@ spc_handler_pdfm_fstream (struct spc_env *spe, struct spc_arg *args)
{
pdf_obj *fstream;
long stream_len, nb_read;
- char *ident, *filename, *fullname;
+ char *ident, *filename;
pdf_obj *tmp;
FILE *fp;
@@ -1338,7 +1343,7 @@ spc_handler_pdfm_fstream (struct spc_env *spe, struct spc_arg *args)
skip_white(&args->curptr, args->endptr);
- tmp = parse_pdf_object(&args->curptr, args->endptr);
+ tmp = parse_pdf_object(&args->curptr, args->endptr, NULL);
if (!tmp) {
spc_warn(spe, "Missing filename string for pdf:fstream.");
RELEASE(ident);
@@ -1358,32 +1363,17 @@ spc_handler_pdfm_fstream (struct spc_env *spe, struct spc_arg *args)
return -1;
}
- fstream = pdf_new_stream(STREAM_COMPRESS);
+ fstream = pdf_new_stream(STREAM_COMPRESS);
-#ifdef MIKTEX
- if (!miktex_find_app_input_file("dvipdfm", filename, work_buffer))
- fullname = NULL;
- else {
- fullname = work_buffer;
- }
-#else /* !MIKTEX */
- fullname = kpse_find_file(filename, kpse_program_binary_format, 0);
-#endif
- pdf_release_obj(tmp);
- if (!fullname) {
- spc_warn(spe, "Could not find file.");
- RELEASE(ident);
- pdf_release_obj(fstream);
- return -1;
- }
-
- fp = MFOPEN(fullname, FOPEN_RBIN_MODE);
+ fp = DPXFOPEN(filename, DPX_RES_TYPE_BINARY);
if (!fp) {
- spc_warn(spe, "Could not open file: %s", fullname);
- RELEASE(ident);
+ spc_warn(spe, "Could not open file: %s", filename);
pdf_release_obj(fstream);
+ pdf_release_obj(tmp);
+ RELEASE(ident);
return -1;
}
+ pdf_release_obj(tmp);
stream_len = 0;
while ((nb_read =
@@ -1406,11 +1396,11 @@ spc_handler_pdfm_fstream (struct spc_env *spe, struct spc_arg *args)
stream_dict = pdf_stream_dict(fstream);
- tmp = parse_pdf_dict(&args->curptr, args->endptr);
+ tmp = parse_pdf_dict(&args->curptr, args->endptr, NULL);
if (!tmp) {
spc_warn(spe, "Parsing dictionary failed.");
- RELEASE(ident);
pdf_release_obj(fstream);
+ RELEASE(ident);
return -1;
}
if (pdf_lookup_dict(tmp, "Length")) {
@@ -1462,7 +1452,7 @@ spc_handler_pdfm_bform (struct spc_env *spe, struct spc_arg *args)
}
transform_info_clear(&ti);
- if (spc_util_read_dimtrns(spe, &ti, args, 0) < 0) {
+ if (spc_util_read_dimtrns(spe, &ti, args, NULL, 0) < 0) {
RELEASE(ident);
return -1;
}
@@ -1522,7 +1512,7 @@ spc_handler_pdfm_eform (struct spc_env *spe, struct spc_arg *args)
/* An extra dictionary after exobj must be merged to /Resources.
* Please use pdf:put @resources (before pdf:exobj) instead.
*/
- garbage = parse_pdf_dict(&args->curptr, args->endptr);
+ garbage = parse_pdf_dict(&args->curptr, args->endptr, NULL);
if (garbage) {
resource = pdf_doc_current_page_resources();
pdf_merge_dict(resource, garbage);
@@ -1575,7 +1565,7 @@ spc_handler_pdfm_uxobj (struct spc_env *spe, struct spc_arg *args)
transform_info_clear(&ti);
if (args->curptr < args->endptr) {
- if (spc_util_read_dimtrns(spe, &ti, args, 0) < 0) {
+ if (spc_util_read_dimtrns(spe, &ti, args, NULL, 0) < 0) {
RELEASE(ident);
return -1;
}
@@ -1587,7 +1577,7 @@ spc_handler_pdfm_uxobj (struct spc_env *spe, struct spc_arg *args)
*/
xobj_id = findresource(sd, ident);
if (xobj_id < 0) {
- xobj_id = pdf_ximage_findresource(ident);
+ xobj_id = pdf_ximage_findresource(ident, 0);
if (xobj_id < 0) {
spc_warn(spe, "Specified (image) object doesn't exist: %s", ident);
RELEASE(ident);
@@ -1676,7 +1666,7 @@ spc_handler_pdfm_mapline (struct spc_env *spe, struct spc_arg *ap)
case '+':
mrec = NEW(1, fontmap_rec);
pdf_init_fontmap_record(mrec);
- error = pdf_read_fontmap_line(mrec, ap->curptr, (long) (ap->endptr - ap->curptr));
+ error = pdf_read_fontmap_line(mrec, ap->curptr, (long) (ap->endptr - ap->curptr), is_pdfm_mapline(ap->curptr));
if (error)
spc_warn(spe, "Invalid fontmap line.");
else {
@@ -1688,7 +1678,7 @@ spc_handler_pdfm_mapline (struct spc_env *spe, struct spc_arg *ap)
default:
mrec = NEW(1, fontmap_rec);
pdf_init_fontmap_record(mrec);
- error = pdf_read_fontmap_line(mrec, ap->curptr, (long) (ap->endptr - ap->curptr));
+ error = pdf_read_fontmap_line(mrec, ap->curptr, (long) (ap->endptr - ap->curptr), is_pdfm_mapline(ap->curptr));
if (error)
spc_warn(spe, "Invalid fontmap line.");
else {
@@ -1735,6 +1725,7 @@ spc_handler_pdfm_mapfile (struct spc_env *spe, struct spc_arg *args)
} else {
error = pdf_load_fontmap_file(mapfile, mode);
}
+ RELEASE(mapfile);
return error;
}
@@ -1746,7 +1737,6 @@ spc_handler_pdfm_tounicode (struct spc_env *spe, struct spc_arg *args)
{
struct spc_pdf_ *sd = &_pdf_stat;
char *cmap_name;
- int error = 0;
/* First clear */
sd->cd.cmap_id = -1;
@@ -1766,19 +1756,20 @@ spc_handler_pdfm_tounicode (struct spc_env *spe, struct spc_arg *args)
cmap_name = parse_ident(&args->curptr, args->endptr);
if (!cmap_name) {
spc_warn(spe, "Missing ToUnicode mapping name...");
- return -1;
+ return -1;
}
sd->cd.cmap_id = CMap_cache_find(cmap_name);
if (sd->cd.cmap_id < 0) {
spc_warn(spe, "Failed to load ToUnicode mapping: %s", cmap_name);
- error = -1;
+ RELEASE(cmap_name);
+ return -1;
}
/* Shift-JIS like encoding may contain backslash in 2nd byte.
* WARNING: This will add nasty extension to PDF parser.
*/
- if (!error && sd->cd.cmap_id >= 0) {
+ if (sd->cd.cmap_id >= 0) {
if (strstr(cmap_name, "RKSJ") ||
strstr(cmap_name, "B5") ||
strstr(cmap_name, "GBK") ||
@@ -1786,8 +1777,7 @@ spc_handler_pdfm_tounicode (struct spc_env *spe, struct spc_arg *args)
sd->cd.unescape_backslash = 1;
}
RELEASE(cmap_name);
-
- return error;
+ return 0;
}
#endif /* ENABLE_TOUNICODE */
diff --git a/Build/source/texk/dvipdfmx/src/spc_util.c b/Build/source/texk/dvipdfmx/src/spc_util.c
index ad53e6d0b95..606a97bea4c 100644
--- a/Build/source/texk/dvipdfmx/src/spc_util.c
+++ b/Build/source/texk/dvipdfmx/src/spc_util.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/spc_util.c,v 1.8 2007/04/24 09:29:39 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/spc_util.c,v 1.11 2008/03/01 09:00:31 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -396,9 +396,8 @@ spc_read_dimtrns_dvips (struct spc_env *spe, transform_info *t, struct spc_arg *
spc_warn(spe, "Missing value for dimension/transformation: %s", kp);
error = -1;
}
-
+ RELEASE(kp);
if (!vp || error) {
- RELEASE(kp);
break;
}
@@ -461,7 +460,7 @@ spc_read_dimtrns_dvips (struct spc_env *spe, transform_info *t, struct spc_arg *
static int
-spc_read_dimtrns_pdfm (struct spc_env *spe, transform_info *p, struct spc_arg *ap)
+spc_read_dimtrns_pdfm (struct spc_env *spe, transform_info *p, struct spc_arg *ap, long *page_no)
{
int has_scale, has_xscale, has_yscale, has_rotate, has_matrix;
const char *_dtkeys[] = {
@@ -478,6 +477,11 @@ spc_read_dimtrns_pdfm (struct spc_env *spe, transform_info *p, struct spc_arg *a
"bbox", /* See "Dvipdfmx User's Manual", p.5 */
#define K_TRN__MATRIX 8
"matrix",
+#undef K__CLIP
+#define K__CLIP 9
+ "clip",
+#define K__PAGE 10
+ "page",
NULL
};
double xscale, yscale, rotate;
@@ -485,6 +489,7 @@ spc_read_dimtrns_pdfm (struct spc_env *spe, transform_info *p, struct spc_arg *a
has_xscale = has_yscale = has_scale = has_rotate = has_matrix = 0;
xscale = yscale = 1.0; rotate = 0.0;
+ p->flags |= INFO_DO_CLIP; /* default: do clipping */
skip_blank(&ap->curptr, ap->endptr);
@@ -562,7 +567,6 @@ spc_read_dimtrns_pdfm (struct spc_env *spe, transform_info *p, struct spc_arg *a
p->bbox.urx = v[2];
p->bbox.ury = v[3];
p->flags |= INFO_HAS_USER_BBOX;
- p->flags |= INFO_DO_CLIP; /* always clip */
}
}
break;
@@ -577,6 +581,27 @@ spc_read_dimtrns_pdfm (struct spc_env *spe, transform_info *p, struct spc_arg *a
}
}
break;
+ case K__CLIP:
+ vp = parse_float_decimal(&ap->curptr, ap->endptr);
+ if (!vp)
+ error = -1;
+ else {
+ if (atof(vp))
+ p->flags |= INFO_DO_CLIP;
+ else
+ p->flags &= ~INFO_DO_CLIP;
+ RELEASE(vp);
+ }
+ break;
+ case K__PAGE:
+ {
+ double page;
+ if (page_no && spc_util_read_numbers(&page, 1, spe, ap) == 1)
+ *page_no = (long) page;
+ else
+ error = -1;
+ }
+ break;
default:
error = -1;
break;
@@ -611,18 +636,23 @@ spc_read_dimtrns_pdfm (struct spc_env *spe, transform_info *p, struct spc_arg *a
make_transmatrix(&(p->matrix), 0.0, 0.0, xscale, yscale, rotate);
}
+ if (!(p->flags & INFO_HAS_USER_BBOX)) {
+ p->flags &= ~INFO_DO_CLIP; /* no clipping needed */
+ }
+
return error;
}
int
-spc_util_read_dimtrns (struct spc_env *spe, transform_info *ti, struct spc_arg *args, int syntax)
+spc_util_read_dimtrns (struct spc_env *spe, transform_info *ti, struct spc_arg *args, long *page_no, int syntax)
{
ASSERT(ti && spe && args);
if (syntax) {
+ ASSERT(!page_no);
return spc_read_dimtrns_dvips(spe, ti, args);
} else {
- return spc_read_dimtrns_pdfm (spe, ti, args);
+ return spc_read_dimtrns_pdfm (spe, ti, args, page_no);
}
return -1;
diff --git a/Build/source/texk/dvipdfmx/src/spc_util.h b/Build/source/texk/dvipdfmx/src/spc_util.h
index 32706189904..0dd2c938ea1 100644
--- a/Build/source/texk/dvipdfmx/src/spc_util.h
+++ b/Build/source/texk/dvipdfmx/src/spc_util.h
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/spc_util.h,v 1.4 2005/07/30 11:44:18 hirata Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/spc_util.h,v 1.5 2008/02/13 20:22:21 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -36,7 +36,7 @@
* This is for reading *single* color specification.
*/
extern int spc_util_read_colorspec (struct spc_env *spe, pdf_color *colorspec, struct spc_arg *args, int syntax);
-extern int spc_util_read_dimtrns (struct spc_env *spe, transform_info *dimtrns, struct spc_arg *args, int syntax);
+extern int spc_util_read_dimtrns (struct spc_env *spe, transform_info *dimtrns, struct spc_arg *args, long *page, int syntax);
extern int spc_util_read_length (struct spc_env *spe, double *length, struct spc_arg *ap);
#endif /* _SPC_UTIL_H_ */
diff --git a/Build/source/texk/dvipdfmx/src/subfont.c b/Build/source/texk/dvipdfmx/src/subfont.c
index 5ba8600d56f..ed299303f53 100644
--- a/Build/source/texk/dvipdfmx/src/subfont.c
+++ b/Build/source/texk/dvipdfmx/src/subfont.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/subfont.c,v 1.21 2007/11/14 03:36:01 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/subfont.c,v 1.22 2008/01/13 21:25:31 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -20,6 +20,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
+#include <errno.h>
+
#if HAVE_CONFIG_H
#include "config.h"
#endif
diff --git a/Build/source/texk/dvipdfmx/src/system.h b/Build/source/texk/dvipdfmx/src/system.h
index b758ff14405..2b65ce372da 100644
--- a/Build/source/texk/dvipdfmx/src/system.h
+++ b/Build/source/texk/dvipdfmx/src/system.h
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/system.h,v 1.6 2004/01/11 02:51:33 hirata Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/system.h,v 1.7 2008/05/18 10:40:40 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -26,9 +26,9 @@
#define _SYSTEM_H_
#ifdef MIKTEX
-#include "miktex.h"
+#include <miktex/Core/Core>
#include "gnu-miktex.h"
-#include "web2c-miktex.h"
+#include <miktex/KPSE/Emulation>
#else
#include <kpathsea/c-auto.h>
#include <kpathsea/kpathsea.h>
diff --git a/Build/source/texk/dvipdfmx/src/t1_load.c b/Build/source/texk/dvipdfmx/src/t1_load.c
index 6395278e57a..422885a782a 100644
--- a/Build/source/texk/dvipdfmx/src/t1_load.c
+++ b/Build/source/texk/dvipdfmx/src/t1_load.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/t1_load.c,v 1.10 2006/12/06 12:52:43 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/t1_load.c,v 1.11 2008/01/11 18:04:15 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -1064,6 +1064,9 @@ get_pfb_segment (FILE *fp, int expected_type, long *length)
ERROR("PFB segment length zero?");
}
+ buffer = RENEW(buffer, bytesread+1, unsigned char);
+ buffer[bytesread] = 0;
+
if (length)
*length = bytesread;
return buffer;
diff --git a/Build/source/texk/dvipdfmx/src/tfm.c b/Build/source/texk/dvipdfmx/src/tfm.c
index cb2afbe4eb3..e5fee9e7d88 100644
--- a/Build/source/texk/dvipdfmx/src/tfm.c
+++ b/Build/source/texk/dvipdfmx/src/tfm.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/tfm.c,v 1.21 2005/07/27 15:47:44 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/tfm.c,v 1.22 2007/11/17 18:08:58 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -906,6 +906,8 @@ tfm_open (const char *tfm_name, int must_exist)
MESG("[%s]", file_name);
}
+ RELEASE(file_name);
+
tfm_file_size = file_size(tfm_file);
if (tfm_file_size < 24) {
ERROR("TFM/OFM file too small to be a valid file.");
diff --git a/Build/source/texk/dvipdfmx/src/truetype.c b/Build/source/texk/dvipdfmx/src/truetype.c
index c9b27405399..1ab5143b27f 100644
--- a/Build/source/texk/dvipdfmx/src/truetype.c
+++ b/Build/source/texk/dvipdfmx/src/truetype.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/truetype.c,v 1.6 2007/11/14 03:12:21 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/truetype.c,v 1.9 2008/05/18 14:52:39 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -53,6 +53,8 @@
#include "truetype.h"
+#include "tfm.h"
+
/* Modifying this has no effect :P */
#ifdef ENABLE_NOEMBED
# undef ENABLE_NOEMBED
@@ -62,7 +64,7 @@ int
pdf_font_open_truetype (pdf_font *font)
{
char *ident;
- int encoding_id;
+ int index, encoding_id;
pdf_obj *fontdict, *descriptor;
sfnt *sfont;
int embedding = 1; /* Must be embedded. */
@@ -72,24 +74,34 @@ pdf_font_open_truetype (pdf_font *font)
ASSERT( font );
ident = pdf_font_get_ident(font);
+ index = pdf_font_get_index(font);
ASSERT( ident );
fp = DPXFOPEN(ident, DPX_RES_TYPE_TTFONT);
- if (!fp)
- return -1;
+ if (!fp) {
+ fp = DPXFOPEN(ident, DPX_RES_TYPE_DFONT);
+ if (!fp) return -1;
+ sfont = dfont_open(fp, index);
+ } else {
+ sfont = sfnt_open(fp);
+ }
- sfont = sfnt_open(fp);
if (!sfont) {
WARN("Could not open TrueType font: %s", ident);
DPXFCLOSE(fp);
return -1;
}
- if (sfont->type == SFNT_TYPE_TTC)
- error = sfnt_read_table_directory(sfont, ttc_read_offset(sfont, 0));
- else
- error = sfnt_read_table_directory(sfont, 0);
+ if (sfont->type == SFNT_TYPE_TTC) {
+ unsigned long offset;
+ offset = ttc_read_offset(sfont, index);
+ if (offset == 0) ERROR("Invalid TTC index in %s.", ident);
+ error = sfnt_read_table_directory(sfont, offset);
+ } else {
+ error = sfnt_read_table_directory(sfont, sfont->offset);
+ }
+
if (error) {
sfnt_close(sfont);
DPXFCLOSE(fp);
@@ -110,7 +122,7 @@ pdf_font_open_truetype (pdf_font *font)
{
pdf_obj *tmp;
- tmp = tt_get_fontdesc(sfont, &embedding, 1);
+ tmp = tt_get_fontdesc(sfont, &embedding, -1, 1);
if (!tmp) {
ERROR("Could not obtain neccesary font info.");
sfnt_close(sfont);
@@ -205,7 +217,7 @@ static struct
const char *name;
int must_exist;
} required_table[] = {
- {"OS/2", 1}, {"head", 1}, {"hhea", 1}, {"loca", 1}, {"maxp", 1},
+ {"OS/2", 0}, {"head", 1}, {"hhea", 1}, {"loca", 1}, {"maxp", 1},
{"name", 1}, {"glyf", 1}, {"hmtx", 1}, {"fpgm", 0}, {"cvt ", 0},
{"prep", 0}, {"cmap", 1}, {NULL, 0}
};
@@ -213,13 +225,16 @@ static struct
static void
do_widths (pdf_font *font, double *widths)
{
- pdf_obj *fontdict = pdf_font_get_resource (font);
- char *usedchars = pdf_font_get_usedchars(font);
+ pdf_obj *fontdict;
pdf_obj *tmparray;
- int code, firstchar, lastchar;
+ int code, firstchar, lastchar, tfm_id;
+ char *usedchars;
- firstchar = 255; lastchar = 0;
- for (code = 0; code < 256; code++) {
+ fontdict = pdf_font_get_resource (font);
+ usedchars = pdf_font_get_usedchars (font);
+
+ tmparray = pdf_new_array();
+ for (firstchar = 255, lastchar = 0, code = 0; code < 256; code++) {
if (usedchars[code]) {
if (code < firstchar) firstchar = code;
if (code > lastchar) lastchar = code;
@@ -227,23 +242,30 @@ do_widths (pdf_font *font, double *widths)
}
if (firstchar > lastchar) {
WARN("No glyphs actually used???");
+ pdf_release_obj(tmparray);
return;
}
-
- tmparray = pdf_new_array();
+ tfm_id = tfm_open(pdf_font_get_mapname(font), 0);
for (code = firstchar; code <= lastchar; code++) {
- if (usedchars[code])
+ if (usedchars[code]) {
+ double width;
+ if (tfm_id < 0) /* tfm is not found */
+ width = widths[code];
+ else
+ width = 1000. * tfm_get_width(tfm_id, code);
pdf_add_array(tmparray,
- pdf_new_number(ROUND(widths[code], 1)));
- else {
+ pdf_new_number(ROUND(width, 1.0)));
+ } else {
pdf_add_array(tmparray, pdf_new_number(0.0));
}
}
+
if (pdf_array_length(tmparray) > 0) {
pdf_add_dict(fontdict,
- pdf_new_name("Widths"), pdf_ref_obj(tmparray)); /* _FIXME_ */
+ pdf_new_name("Widths"), pdf_ref_obj(tmparray));
}
pdf_release_obj(tmparray);
+
pdf_add_dict(fontdict,
pdf_new_name("FirstChar"), pdf_new_number(firstchar));
pdf_add_dict(fontdict,
@@ -857,6 +879,7 @@ pdf_font_load_truetype (pdf_font *font)
#ifdef ENABLE_NOEMBED
int embedding = pdf_font_get_flag(font, PDF_FONT_FLAG_NOEMBED) ? 0 : 1;
#endif /* ENABLE_NOEMBED */
+ int index = pdf_font_get_index(font);
char **enc_vec;
pdf_obj *fontfile;
FILE *fp;
@@ -869,26 +892,35 @@ pdf_font_load_truetype (pdf_font *font)
verbose = pdf_font_get_verbose();
fp = DPXFOPEN(ident, DPX_RES_TYPE_TTFONT);
- if (!fp)
- ERROR("Unable to open TrueType font file: %s", ident); /* Should find *truetype* here */
+ if (!fp) {
+ fp = DPXFOPEN(ident, DPX_RES_TYPE_DFONT);
+ if (!fp) ERROR("Unable to open TrueType/dfont font file: %s", ident); /* Should find *truetype* here */
+ sfont = dfont_open(fp, index);
+ } else {
+ sfont = sfnt_open(fp);
+ }
- sfont = sfnt_open(fp);
if (!sfont) {
- ERROR("Unable to open TrueType file: %s", ident);
+ ERROR("Unable to open TrueType/dfont file: %s", ident);
DPXFCLOSE(fp);
return -1;
} else if (sfont->type != SFNT_TYPE_TRUETYPE &&
- sfont->type != SFNT_TYPE_TTC) {
- ERROR("Font \"%s\" not a TrueType font?", ident);
+ sfont->type != SFNT_TYPE_TTC &&
+ sfont->type != SFNT_TYPE_DFONT) {
+ ERROR("Font \"%s\" not a TrueType/dfont font?", ident);
sfnt_close(sfont);
DPXFCLOSE(fp);
return -1;
}
- if (sfont->type == SFNT_TYPE_TTC)
- error = sfnt_read_table_directory(sfont, ttc_read_offset(sfont, 0));
- else
- error = sfnt_read_table_directory(sfont, 0);
+ if (sfont->type == SFNT_TYPE_TTC) {
+ unsigned long offset;
+ offset = ttc_read_offset(sfont, index);
+ if (offset == 0) ERROR("Invalid TTC index in %s.", ident);
+ error = sfnt_read_table_directory(sfont, ttc_read_offset(sfont, offset));
+ } else {
+ error = sfnt_read_table_directory(sfont, sfont->offset);
+ }
if (error) {
ERROR("Reading SFND table dir failed for font-file=\"%s\"... Not a TrueType font?", ident);
diff --git a/Build/source/texk/dvipdfmx/src/tt_aux.c b/Build/source/texk/dvipdfmx/src/tt_aux.c
index ee7466d08ff..14dc36e01f4 100644
--- a/Build/source/texk/dvipdfmx/src/tt_aux.c
+++ b/Build/source/texk/dvipdfmx/src/tt_aux.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/tt_aux.c,v 1.7 2004/09/11 14:50:29 hirata Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/tt_aux.c,v 1.9 2008/05/17 04:18:47 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -129,11 +129,11 @@ ULONG ttc_read_offset (sfnt *sfont, int ttc_idx)
#define ALLCAP (1 << 16) /* All-cap font */
#define SMALLCAP (1 << 17) /* Small-cap font */
#define FORCEBOLD (1 << 18) /* Force bold at small text sizes */
-pdf_obj *tt_get_fontdesc (sfnt *sfont, int *embed, int type)
+pdf_obj *tt_get_fontdesc (sfnt *sfont, int *embed, int stemv, int type)
{
pdf_obj *descriptor = NULL;
pdf_obj *bbox = NULL;
- int stemv = 0, flag = SYMBOLIC;
+ int flag = SYMBOLIC;
/* TrueType tables */
struct tt_head_table *head;
struct tt_os2__table *os2;
@@ -191,7 +191,8 @@ pdf_obj *tt_get_fontdesc (sfnt *sfont, int *embed, int type)
pdf_add_dict (descriptor,
pdf_new_name ("Descent"),
pdf_new_number (PDFUNIT(os2->sTypoDescender)));
- stemv = (os2->usWeightClass/65)*(os2->usWeightClass/65)+50; /* arbitrary */
+ if (stemv < 0) /* if not given by the option '-v' */
+ stemv = (os2->usWeightClass/65.)*(os2->usWeightClass/65.)+50;
pdf_add_dict (descriptor,
pdf_new_name ("StemV"),
pdf_new_number (stemv));
@@ -212,9 +213,11 @@ pdf_obj *tt_get_fontdesc (sfnt *sfont, int *embed, int type)
);
}
/* optional */
- pdf_add_dict (descriptor,
- pdf_new_name ("AvgWidth"),
- pdf_new_number (PDFUNIT(os2->xAvgCharWidth)));
+ if (os2->xAvgCharWidth != 0) {
+ pdf_add_dict (descriptor,
+ pdf_new_name ("AvgWidth"),
+ pdf_new_number (PDFUNIT(os2->xAvgCharWidth)));
+ }
/* BoundingBox (array) */
bbox = pdf_new_array ();
diff --git a/Build/source/texk/dvipdfmx/src/tt_aux.h b/Build/source/texk/dvipdfmx/src/tt_aux.h
index d2528d53335..e20212c35e1 100644
--- a/Build/source/texk/dvipdfmx/src/tt_aux.h
+++ b/Build/source/texk/dvipdfmx/src/tt_aux.h
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/tt_aux.h,v 1.5 2004/09/11 14:50:29 hirata Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/tt_aux.h,v 1.6 2008/05/17 04:18:47 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -30,6 +30,6 @@
extern ULONG ttc_read_offset (sfnt *sfont, int ttc_idx);
/* FontDescriptor */
-extern pdf_obj *tt_get_fontdesc (sfnt *sfont, int *embed, int type);
+extern pdf_obj *tt_get_fontdesc (sfnt *sfont, int *embed, int stemv, int type);
#endif /* _TT_AUX_H_ */
diff --git a/Build/source/texk/dvipdfmx/src/tt_cmap.c b/Build/source/texk/dvipdfmx/src/tt_cmap.c
index e938e61b80d..ff1aa9ba664 100644
--- a/Build/source/texk/dvipdfmx/src/tt_cmap.c
+++ b/Build/source/texk/dvipdfmx/src/tt_cmap.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/tt_cmap.c,v 1.25 2007/04/13 06:48:03 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/tt_cmap.c,v 1.26 2008/05/08 18:51:59 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -1598,7 +1598,7 @@ otf_load_Unicode_CMap (const char *map_name, int ttc_index, /* 0 for non-TTC fon
int cmap_id = -1;
int tounicode_id = -1, is_cidfont = 0;
sfnt *sfont;
- long offset = 0;
+ unsigned long offset = 0;
char *base_name = NULL, *cmap_name = NULL;
char *tounicode_name = NULL;
FILE *fp;
@@ -1619,12 +1619,16 @@ otf_load_Unicode_CMap (const char *map_name, int ttc_index, /* 0 for non-TTC fon
if (!fp) {
fp = DPXFOPEN(map_name, DPX_RES_TYPE_OTFONT);
}
- if (!fp)
- return -1;
+ if (!fp) {
+ fp = DPXFOPEN(map_name, DPX_RES_TYPE_DFONT);
+ if (!fp) return -1;
+ sfont = dfont_open(fp, ttc_index);
+ } else {
+ sfont = sfnt_open(fp);
+ }
- sfont = sfnt_open(fp);
if (!sfont) {
- ERROR("Could not open OpenType/TrueType font file \"%s\"", map_name);
+ ERROR("Could not open OpenType/TrueType/dfont font file \"%s\"", map_name);
}
switch (sfont->type) {
case SFNT_TYPE_TTC:
@@ -1637,6 +1641,9 @@ otf_load_Unicode_CMap (const char *map_name, int ttc_index, /* 0 for non-TTC fon
case SFNT_TYPE_POSTSCRIPT:
offset = 0;
break;
+ case SFNT_TYPE_DFONT:
+ offset = sfont->offset;
+ break;
default:
ERROR("Not a OpenType/TrueType/TTC font?: %s", map_name);
break;
diff --git a/Build/source/texk/dvipdfmx/src/tt_glyf.c b/Build/source/texk/dvipdfmx/src/tt_glyf.c
index c7c6d7041f0..ca8e73a0604 100644
--- a/Build/source/texk/dvipdfmx/src/tt_glyf.c
+++ b/Build/source/texk/dvipdfmx/src/tt_glyf.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/tt_glyf.c,v 1.3 2007/02/14 05:56:43 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/tt_glyf.c,v 1.4 2008/05/08 18:51:59 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -219,7 +219,8 @@ tt_build_tables (sfnt *sfont, struct tt_glyphs *g)
ERROR("File not opened.");
if (sfont->type != SFNT_TYPE_TRUETYPE &&
- sfont->type != SFNT_TYPE_TTC)
+ sfont->type != SFNT_TYPE_TTC &&
+ sfont->type != SFNT_TYPE_DFONT)
ERROR("Invalid font type");
if (g->num_glyphs > NUM_GLYPH_LIMIT)
@@ -523,7 +524,8 @@ tt_get_metrics (sfnt *sfont, struct tt_glyphs *g)
ERROR("File not opened.");
if (sfont->type != SFNT_TYPE_TRUETYPE &&
- sfont->type != SFNT_TYPE_TTC)
+ sfont->type != SFNT_TYPE_TTC &&
+ sfont->type != SFNT_TYPE_DFONT)
ERROR("Invalid font type");
/*
diff --git a/Build/source/texk/dvipdfmx/src/tt_table.c b/Build/source/texk/dvipdfmx/src/tt_table.c
index 826cb036d58..93568d1e379 100644
--- a/Build/source/texk/dvipdfmx/src/tt_table.c
+++ b/Build/source/texk/dvipdfmx/src/tt_table.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/tt_table.c,v 1.8 2007/02/14 05:56:43 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/tt_table.c,v 1.9 2008/05/08 10:32:09 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -346,51 +346,67 @@ tt_read_os2__table (sfnt *sfont)
struct tt_os2__table *table = NULL;
int i;
- sfnt_locate_table(sfont, "OS/2");
-
table = NEW(1, struct tt_os2__table);
- table->version = sfnt_get_ushort(sfont);
- table->xAvgCharWidth = sfnt_get_short(sfont);
- table->usWeightClass = sfnt_get_ushort(sfont);
- table->usWidthClass = sfnt_get_ushort(sfont);
- table->fsType = sfnt_get_short(sfont);
- table->ySubscriptXSize = sfnt_get_short(sfont);
- table->ySubscriptYSize = sfnt_get_short(sfont);
- table->ySubscriptXOffset = sfnt_get_short(sfont);
- table->ySubscriptYOffset = sfnt_get_short(sfont);
- table->ySuperscriptXSize = sfnt_get_short(sfont);
- table->ySuperscriptYSize = sfnt_get_short(sfont);
- table->ySuperscriptXOffset = sfnt_get_short(sfont);
- table->ySuperscriptYOffset = sfnt_get_short(sfont);
- table->yStrikeoutSize = sfnt_get_short(sfont);
- table->yStrikeoutPosition = sfnt_get_short(sfont);
- table->sFamilyClass = sfnt_get_short(sfont);
- for (i = 0; i < 10; i++) {
- table->panose[i] = sfnt_get_byte(sfont);
- }
- table->ulUnicodeRange1 = sfnt_get_ulong(sfont);
- table->ulUnicodeRange2 = sfnt_get_ulong(sfont);
- table->ulUnicodeRange3 = sfnt_get_ulong(sfont);
- table->ulUnicodeRange4 = sfnt_get_ulong(sfont);
- for (i = 0; i < 4; i++) {
- table->achVendID[i] = sfnt_get_char(sfont);
- }
- table->fsSelection = sfnt_get_ushort(sfont);
- table->usFirstCharIndex = sfnt_get_ushort(sfont);
- table->usLastCharIndex = sfnt_get_ushort(sfont);
- table->sTypoAscender = sfnt_get_short(sfont);
- table->sTypoDescender = sfnt_get_short(sfont);
- table->sTypoLineGap = sfnt_get_short(sfont);
- table->usWinAscent = sfnt_get_ushort(sfont);
- table->usWinDescent = sfnt_get_ushort(sfont);
- table->ulCodePageRange1 = sfnt_get_ulong(sfont);
- table->ulCodePageRange2 = sfnt_get_ulong(sfont);
- if (table->version == 0x0002) {
- table->sxHeight = sfnt_get_short(sfont);
- table->sCapHeight = sfnt_get_short(sfont);
- table->usDefaultChar = sfnt_get_ushort(sfont);
- table->usBreakChar = sfnt_get_ushort(sfont);
- table->usMaxContext = sfnt_get_ushort(sfont);
+
+ if (sfnt_find_table_pos(sfont, "OS/2") > 0) {
+ sfnt_locate_table(sfont, "OS/2");
+ table->version = sfnt_get_ushort(sfont);
+ table->xAvgCharWidth = sfnt_get_short(sfont);
+ table->usWeightClass = sfnt_get_ushort(sfont);
+ table->usWidthClass = sfnt_get_ushort(sfont);
+ table->fsType = sfnt_get_short(sfont);
+ table->ySubscriptXSize = sfnt_get_short(sfont);
+ table->ySubscriptYSize = sfnt_get_short(sfont);
+ table->ySubscriptXOffset = sfnt_get_short(sfont);
+ table->ySubscriptYOffset = sfnt_get_short(sfont);
+ table->ySuperscriptXSize = sfnt_get_short(sfont);
+ table->ySuperscriptYSize = sfnt_get_short(sfont);
+ table->ySuperscriptXOffset = sfnt_get_short(sfont);
+ table->ySuperscriptYOffset = sfnt_get_short(sfont);
+ table->yStrikeoutSize = sfnt_get_short(sfont);
+ table->yStrikeoutPosition = sfnt_get_short(sfont);
+ table->sFamilyClass = sfnt_get_short(sfont);
+ for (i = 0; i < 10; i++) {
+ table->panose[i] = sfnt_get_byte(sfont);
+ }
+ table->ulUnicodeRange1 = sfnt_get_ulong(sfont);
+ table->ulUnicodeRange2 = sfnt_get_ulong(sfont);
+ table->ulUnicodeRange3 = sfnt_get_ulong(sfont);
+ table->ulUnicodeRange4 = sfnt_get_ulong(sfont);
+ for (i = 0; i < 4; i++) {
+ table->achVendID[i] = sfnt_get_char(sfont);
+ }
+ table->fsSelection = sfnt_get_ushort(sfont);
+ table->usFirstCharIndex = sfnt_get_ushort(sfont);
+ table->usLastCharIndex = sfnt_get_ushort(sfont);
+ table->sTypoAscender = sfnt_get_short(sfont);
+ table->sTypoDescender = sfnt_get_short(sfont);
+ table->sTypoLineGap = sfnt_get_short(sfont);
+ table->usWinAscent = sfnt_get_ushort(sfont);
+ table->usWinDescent = sfnt_get_ushort(sfont);
+ table->ulCodePageRange1 = sfnt_get_ulong(sfont);
+ table->ulCodePageRange2 = sfnt_get_ulong(sfont);
+ if (table->version == 0x0002) {
+ table->sxHeight = sfnt_get_short(sfont);
+ table->sCapHeight = sfnt_get_short(sfont);
+ table->usDefaultChar = sfnt_get_ushort(sfont);
+ table->usBreakChar = sfnt_get_ushort(sfont);
+ table->usMaxContext = sfnt_get_ushort(sfont);
+ }
+ } else {
+ /* used in add_CIDVMetrics() of cidtype0.c */
+ table->sTypoAscender = 880;
+ table->sTypoDescender = -120;
+ /* used in tt_get_fontdesc() of tt_aux.c */
+ table->usWeightClass = 400U; /* Normal(Regular) */
+ table->xAvgCharWidth = 0; /* ignore */
+ table->version = 0; /* TrueType rev 1.5 */
+ table->fsType = 0; /* Installable Embedding */
+ table->fsSelection = 0U; /* All undefined */
+ table->sFamilyClass = 0; /* No Classification */
+ for (i = 0; i < 10; i++) {
+ table->panose[i] = 0; /* All Any */
+ }
}
return table;
diff --git a/Build/source/texk/dvipdfmx/src/type1.c b/Build/source/texk/dvipdfmx/src/type1.c
index 859af73f873..73134113ec2 100644
--- a/Build/source/texk/dvipdfmx/src/type1.c
+++ b/Build/source/texk/dvipdfmx/src/type1.c
@@ -1,8 +1,8 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/type1.c,v 1.40 2007/11/14 03:12:21 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/type1.c,v 1.43 2008/05/18 17:05:56 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
- Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata,
+ Copyright (C) 2008 by Jin-Hwan Cho, Matthias Franz, and Shunsaku Hirata,
the dvipdfmx project team <dvipdfmx@project.ktug.or.kr>
Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu>
@@ -58,6 +58,8 @@
#include "type1.h"
+#include "tfm.h"
+
#define FONT_FLAG_FIXEDPITCH (1 << 0) /* Fixed-width font */
#define FONT_FLAG_SERIF (1 << 1) /* Serif font */
#define FONT_FLAG_SYMBOLIC (1 << 2) /* Symbolic font */
@@ -274,9 +276,9 @@ add_metrics (pdf_font *font, cff_font *cffont, char **enc_vec, double *widths, l
pdf_obj *tmp_array;
int code, firstchar, lastchar;
double val;
- card16 gid;
- int i;
+ int i, tfm_id;
char *usedchars;
+ double scaling;
fontdict = pdf_font_get_resource (font);
descriptor = pdf_font_get_descriptor(font);
@@ -292,6 +294,15 @@ add_metrics (pdf_font *font, cff_font *cffont, char **enc_vec, double *widths, l
ERROR("No FontBBox?");
}
+ /* The widhts array in the font dictionary must be given relative
+ * to the default scaling of 1000:1, not relative to the scaling
+ * given by the font matrix.
+ */
+ if (cff_dict_known(cffont->topdict, "FontMatrix"))
+ scaling = 1000*cff_dict_get(cffont->topdict, "FontMatrix", 0);
+ else
+ scaling = 1;
+
tmp_array = pdf_new_array();
for (i = 0; i < 4; i++) {
val = cff_dict_get(cffont->topdict, "FontBBox", i);
@@ -300,18 +311,14 @@ add_metrics (pdf_font *font, cff_font *cffont, char **enc_vec, double *widths, l
pdf_add_dict(descriptor, pdf_new_name("FontBBox"), tmp_array);
tmp_array = pdf_new_array();
- if (num_glyphs <= 1) {
- /* This should be error. */
+ if (num_glyphs <= 1) { /* This must be an error. */
firstchar = lastchar = 0;
pdf_add_array(tmp_array, pdf_new_number(0.0));
} else {
- for (firstchar = 255, lastchar = 0, code = 0;
- code < 256; code++) {
+ for (firstchar = 255, lastchar = 0, code = 0; code < 256; code++) {
if (usedchars[code]) {
- if (code < firstchar)
- firstchar = code;
- if (code > lastchar)
- lastchar = code;
+ if (code < firstchar) firstchar = code;
+ if (code > lastchar) lastchar = code;
}
}
if (firstchar > lastchar) {
@@ -319,20 +326,25 @@ add_metrics (pdf_font *font, cff_font *cffont, char **enc_vec, double *widths, l
pdf_release_obj(tmp_array);
return;
}
+ tfm_id = tfm_open(pdf_font_get_mapname(font), 0);
for (code = firstchar; code <= lastchar; code++) {
if (usedchars[code]) {
- gid = cff_glyph_lookup(cffont, enc_vec[code]);
+ double width;
+ if (tfm_id < 0) /* tfm is not found */
+ width = scaling * widths[cff_glyph_lookup(cffont, enc_vec[code])];
+ else
+ width = 1000. * tfm_get_width(tfm_id, code);
pdf_add_array(tmp_array,
- pdf_new_number(ROUND(widths[gid], 1.0)));
+ pdf_new_number(ROUND(width, 1.0)));
} else {
pdf_add_array(tmp_array, pdf_new_number(0.0));
}
}
-
}
+
if (pdf_array_length(tmp_array) > 0) {
pdf_add_dict(fontdict,
- pdf_new_name("Widths"), pdf_ref_obj(tmp_array));
+ pdf_new_name("Widths"), pdf_ref_obj(tmp_array));
}
pdf_release_obj(tmp_array);
@@ -344,6 +356,7 @@ add_metrics (pdf_font *font, cff_font *cffont, char **enc_vec, double *widths, l
return;
}
+
static long
write_fontfile (pdf_font *font, cff_font *cffont, long num_glyphs)
{
diff --git a/Build/source/texk/dvipdfmx/src/type1c.c b/Build/source/texk/dvipdfmx/src/type1c.c
index be2525da446..0daf3784a77 100644
--- a/Build/source/texk/dvipdfmx/src/type1c.c
+++ b/Build/source/texk/dvipdfmx/src/type1c.c
@@ -1,8 +1,8 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/type1c.c,v 1.22 2007/11/14 03:12:21 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/type1c.c,v 1.26 2008/05/18 17:05:56 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
- Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata,
+ Copyright (C) 2008 by Jin-Hwan Cho, Matthias Franz, and Shunsaku Hirata,
the dvipdfmx project team <dvipdfmx@project.ktug.or.kr>
Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu>
@@ -64,6 +64,8 @@
#include "type1c.h"
+#include "tfm.h"
+
int
pdf_font_open_type1c (pdf_font *font)
{
@@ -135,7 +137,7 @@ pdf_font_open_type1c (pdf_font *font)
* Create font descriptor from OpenType tables.
* We can also use CFF TOP DICT/Private DICT for this.
*/
- tmp = tt_get_fontdesc(sfont, &embedding, 1);
+ tmp = tt_get_fontdesc(sfont, &embedding, -1, 1);
if (!tmp) {
ERROR("Could not obtain neccesary font info from OpenType table.");
return -1;
@@ -153,16 +155,27 @@ pdf_font_open_type1c (pdf_font *font)
}
static void
-add_SimpleMetrics (pdf_font *font, double *widths, card16 num_glyphs)
+add_SimpleMetrics (pdf_font *font, cff_font *cffont,
+ double *widths, card16 num_glyphs)
{
pdf_obj *fontdict;
- int code, firstchar, lastchar;
+ int code, firstchar, lastchar, tfm_id;
char *usedchars;
pdf_obj *tmp_array;
+ double scaling;
fontdict = pdf_font_get_resource(font);
usedchars = pdf_font_get_usedchars(font);
+ /* The widhts array in the font dictionary must be given relative
+ * to the default scaling of 1000:1, not relative to the scaling
+ * given by the font matrix.
+ */
+ if (cff_dict_known(cffont->topdict, "FontMatrix"))
+ scaling = 1000*cff_dict_get(cffont->topdict, "FontMatrix", 0);
+ else
+ scaling = 1;
+
tmp_array = pdf_new_array();
if (num_glyphs <= 1) {
/* This should be error. */
@@ -181,15 +194,22 @@ add_SimpleMetrics (pdf_font *font, double *widths, card16 num_glyphs)
pdf_release_obj(tmp_array);
return;
}
+ tfm_id = tfm_open(pdf_font_get_mapname(font), 0);
for (code = firstchar; code <= lastchar; code++) {
if (usedchars[code]) {
+ double width;
+ if (tfm_id < 0) /* tfm is not found */
+ width = scaling * widths[code];
+ else
+ width = 1000. * tfm_get_width(tfm_id, code);
pdf_add_array(tmp_array,
- pdf_new_number(ROUND(widths[code], 1.0)));
+ pdf_new_number(ROUND(width, 1.0)));
} else {
pdf_add_array(tmp_array, pdf_new_number(0.0));
}
}
}
+
if (pdf_array_length(tmp_array) > 0) {
pdf_add_dict(fontdict,
pdf_new_name("Widths"), pdf_ref_obj(tmp_array));
@@ -687,7 +707,7 @@ pdf_font_load_type1c (pdf_font *font)
}
/* Handle Widths in fontdict. */
- add_SimpleMetrics(font, widths, num_glyphs);
+ add_SimpleMetrics(font, cffont, widths, num_glyphs);
/*
* CharSet might be recommended for subsetted font, but it is meaningful
diff --git a/Build/source/texk/dvipdfmx/src/vf.c b/Build/source/texk/dvipdfmx/src/vf.c
index c682398593d..5da73f93658 100644
--- a/Build/source/texk/dvipdfmx/src/vf.c
+++ b/Build/source/texk/dvipdfmx/src/vf.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/vf.c,v 1.18 2007/11/14 03:36:01 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/vf.c,v 1.19 2007/11/18 08:06:03 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -314,6 +314,8 @@ int vf_locate_font (const char *tex_name, spt_t ptsize)
fprintf (stderr, ")");
MFCLOSE (vf_file);
}
+ if (full_vf_file_name)
+ RELEASE(full_vf_file_name);
}
return thisfont;
}
diff --git a/Build/source/texk/dvipdfmx/src/xbb.c b/Build/source/texk/dvipdfmx/src/xbb.c
index 4f1b17e825d..cac27b3867b 100644
--- a/Build/source/texk/dvipdfmx/src/xbb.c
+++ b/Build/source/texk/dvipdfmx/src/xbb.c
@@ -1,10 +1,8 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/xbb.c,v 1.3 2007/11/14 03:36:01 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/xbb.c,v 1.12 2008/05/18 14:31:06 matthias Exp $
- This is xbb, a bounding box extraction program extending ebb.
+ This is extractbb, a bounding box extraction program.
- Copyright (C) 2007 by Jin-Hwan Cho <chofchof@ktug.or.kr>
-
- Copyright (C) 1998, 1999 by Mark A. Wicks
+ Copyright (C) 2008 by Jin-Hwan Cho <chofchof@ktug.or.kr>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -36,19 +34,25 @@
#include <png.h>
#endif
-#define XBB_PROGRAM "xbb"
-#define XBB_VERSION "Version 0.1"
+#include "xbb.h"
+
+#define XBB_PROGRAM "extractbb"
+#define XBB_VERSION "Version 0.2"
-static void usage (void)
+static void usage(void)
{
- fprintf (stderr, "%s, version %s, Copyright (C) 2007 by Jin-Hwan Cho\n",
+ fprintf (stderr, "%s, version %s, Copyright (C) 2008 by Jin-Hwan Cho\n",
XBB_PROGRAM, XBB_VERSION);
- fprintf (stderr, "xbb is an extension of ebb developed by Mark A. Wicks.\n");
- fprintf (stderr, "This is free software, and you are welcome to redistribute it\n");
- fprintf (stderr, "under certain conditions. Details are distributed with the software.\n");
- fprintf (stderr, "\nUsage: xbb [-v] [-b] [files]\n");
- fprintf (stderr, "\t-b\t\tWrite .xbb file in binary mode\n");
- fprintf (stderr, "\t-v\t\tVerbose\n");
+ fprintf (stderr, "A bounding box extraction utility from PDF, PNG, and JPG.\n");
+ fprintf (stdout, "\nThis is free software; you can redistribute it and/or modify\n");
+ fprintf (stdout, "it under the terms of the GNU General Public License as published by\n");
+ fprintf (stdout, "the Free Software Foundation; either version 2 of the License, or\n");
+ fprintf (stdout, "(at your option) any later version.\n");
+ fprintf (stderr, "\nUsage: %s [-v] [-b] [-m|-x] [files]\n", XBB_PROGRAM);
+ fprintf (stderr, "\t-b\tWrite output file in binary mode\n");
+ fprintf (stderr, "\t-m\tOutput .bb file used in DVIPDFM\n");
+ fprintf (stderr, "\t-x\tOutput .xbb file used in DVIPDFMx (default)\n");
+ fprintf (stderr, "\t-v\tVerbose\n");
exit(1);
}
@@ -58,111 +62,79 @@ static void do_time(FILE *file)
{
time_t current_time;
struct tm *bd_time;
+
time(&current_time);
bd_time = localtime(&current_time);
- fprintf (file, "%%%%CreationDate: %s\n", asctime (bd_time));
+ fprintf(file, "%%%%CreationDate: %s\n", asctime(bd_time));
}
char *extensions[] = {
".jpeg", ".JPEG", ".jpg", ".JPG", ".pdf", ".PDF", ".png", ".PNG"
};
-static char *make_xbb_filename (const char *name)
+static int xbb_output_mode = XBB_OUTPUT;
+
+static char *make_xbb_filename(const char *name)
{
int i;
char *result;
- name = xbasename (name);
- for (i=0; i<sizeof(extensions)/sizeof(extensions[0]); i++) {
- if (strlen (extensions[i]) < strlen(name) &&
- !strncmp (name+strlen(name)-strlen(extensions[i]),
- extensions[i], strlen(extensions[i])))
+
+ for (i = 0; i < sizeof(extensions) / sizeof(extensions[0]); i++) {
+ if (strlen(extensions[i]) < strlen(name) &&
+ strncmp(name+strlen(name)-strlen(extensions[i]), extensions[i], strlen(extensions[i])) == 0)
break;
}
- if (i == sizeof(extensions)/sizeof(extensions[0])) {
- fprintf (stderr,
- "xbb: Warning: %s: Filename does not end in a recognizeable extension.\n",
- name);
- result = NEW (strlen(name)+3, char);
- strcpy (result, name);
- }
- else { /* Remove extension */
- result = NEW (strlen(name)+3-strlen(extensions[i])+1, char);
- strncpy (result, name, strlen(name)-strlen(extensions[i]));
+ if (i == sizeof(extensions) / sizeof(extensions[0])) {
+ fprintf(stderr, "Warning: %s: Filename does not end in a recognizeable extension.\n", name);
+ result = NEW(strlen(name)+3, char);
+ strcpy(result, name);
+ } else { /* Remove extension */
+ result = NEW(strlen(name)+3-strlen(extensions[i])+1, char);
+ strncpy(result, name, strlen(name)-strlen(extensions[i]));
result[strlen(name)-strlen(extensions[i])] = 0;
}
- strcat (result, ".xbb");
+ strcat(result, (xbb_output_mode == XBB_OUTPUT ? ".xbb" : ".bb"));
return result;
}
static char *xbb_file_mode = FOPEN_W_MODE;
-static void write_xbb (char *filename, int bbllx, int bblly, int bburx,
- int bbury)
+static void write_xbb(char *fname, int bbllx, int bblly, int bburx, int bbury)
{
- char *xbbfilename;
- FILE *xbbfile;
- if (verbose)
- fprintf (stderr, "okay\n");
- xbbfilename = make_xbb_filename (filename);
- if ((xbbfile = MFOPEN (xbbfilename, xbb_file_mode)) == NULL) {
- fprintf (stderr, "Unable to open output file: %s\n", xbbfilename);
+ char *outname;
+ FILE *fp;
+
+ outname = make_xbb_filename(fname);
+ if ((fp = MFOPEN(outname, xbb_file_mode)) == NULL) {
+ fprintf(stderr, "Unable to open output file: %s\n", outname);
+ RELEASE(outname);
return;
}
if (verbose) {
- fprintf (stderr, "Writing to %s: ", xbbfilename);
- fprintf (stderr, "Bounding box: %d %d %d %d\n", bbllx, bblly,
- bburx, bbury);
+ fprintf(stderr, "Writing to %s: ", outname);
+ fprintf(stderr, "Bounding box: %d %d %d %d\n", bbllx, bblly, bburx, bbury);
}
- fprintf (xbbfile, "%%%%Title: %s\n", filename);
- fprintf (xbbfile, "%%%%Creator: %s %s\n", XBB_PROGRAM, XBB_VERSION);
- fprintf (xbbfile, "%%%%BoundingBox: %d %d %d %d\n",
- bbllx, bblly, bburx, bbury);
- do_time(xbbfile);
- RELEASE (xbbfilename);
- MFCLOSE (xbbfile);
- return;
+ fprintf(fp,"%%%%Title: %s\n", fname);
+ fprintf(fp,"%%%%Creator: %s %s\n", XBB_PROGRAM, XBB_VERSION);
+ fprintf(fp,"%%%%BoundingBox: %d %d %d %d\n", bbllx, bblly, bburx, bbury);
+ do_time(fp);
+ RELEASE(outname);
+ MFCLOSE(fp);
}
-/* JPEG Markers */
typedef enum {
- JM_SOF0 = 0xc0,
- JM_SOF1 = 0xc1,
- JM_SOF2 = 0xc2,
- JM_SOF3 = 0xc3,
- JM_SOF5 = 0xc5,
- JM_DHT = 0xc4,
- JM_SOF6 = 0xc6,
- JM_SOF7 = 0xc7,
- JM_SOF9 = 0xc9,
- JM_SOF10 = 0xca,
- JM_SOF11 = 0xcb,
- JM_DAC = 0xcc,
- JM_SOF13 = 0xcd,
- JM_SOF14 = 0xce,
- JM_SOF15 = 0xcf,
-
- JM_RST0 = 0xd0,
- JM_RST1 = 0xd1,
- JM_RST2 = 0xd2,
- JM_RST3 = 0xd3,
- JM_RST4 = 0xd4,
- JM_RST5 = 0xd5,
- JM_RST6 = 0xd6,
- JM_RST7 = 0xd7,
-
- JM_SOI = 0xd8,
- JM_EOI = 0xd9,
- JM_SOS = 0xda,
- JM_DQT = 0xdb,
- JM_DNL = 0xdc,
- JM_DRI = 0xdd,
- JM_DHP = 0xde,
- JM_EXP = 0xdf,
-
- JM_APP0 = 0xe0,
- JM_APP2 = 0xe2,
- JM_APP14 = 0xee,
- JM_APP15 = 0xef,
+ JM_SOF0 = 0xc0, JM_SOF1 = 0xc1, JM_SOF2 = 0xc2, JM_SOF3 = 0xc3,
+ JM_SOF5 = 0xc5, JM_DHT = 0xc4, JM_SOF6 = 0xc6, JM_SOF7 = 0xc7,
+ JM_SOF9 = 0xc9, JM_SOF10 = 0xca, JM_SOF11 = 0xcb, JM_DAC = 0xcc,
+ JM_SOF13 = 0xcd, JM_SOF14 = 0xce, JM_SOF15 = 0xcf,
+
+ JM_RST0 = 0xd0, JM_RST1 = 0xd1, JM_RST2 = 0xd2, JM_RST3 = 0xd3,
+ JM_RST4 = 0xd4, JM_RST5 = 0xd5, JM_RST6 = 0xd6, JM_RST7 = 0xd7,
+
+ JM_SOI = 0xd8, JM_EOI = 0xd9, JM_SOS = 0xda, JM_DQT = 0xdb,
+ JM_DNL = 0xdc, JM_DRI = 0xdd, JM_DHP = 0xde, JM_EXP = 0xdf,
+
+ JM_APP0 = 0xe0, JM_APP2 = 0xe2, JM_APP14 = 0xee, JM_APP15 = 0xef,
JM_COM = 0xfe
} JPEG_marker;
@@ -213,6 +185,9 @@ static int jpeg_get_info (FILE *fp, int *width, int *height)
case JM_SOF10: case JM_SOF11: case JM_SOF13: case JM_SOF14:
case JM_SOF15:
get_unsigned_byte(fp);
+ if (xbb_output_mode != XBB_OUTPUT) { /* EBB_OUTPUT */
+ xdensity = ydensity = 72.0 / 100.0;
+ }
*height = (int)(get_unsigned_pair(fp) * ydensity + 0.5);
*width = (int)(get_unsigned_pair(fp) * xdensity + 0.5);
return 0;
@@ -226,7 +201,6 @@ static int jpeg_get_info (FILE *fp, int *width, int *height)
units = (int)get_unsigned_byte(fp);
xden = (int)get_unsigned_pair(fp);
yden = (int)get_unsigned_pair(fp);
- fprintf(stderr, "%d:%d:%d\n", units, xden, yden);
switch (units) {
case 1: /* pixels per inch */
xdensity = 72.0 / xden;
@@ -275,28 +249,36 @@ static int check_for_png (FILE *png_file)
else return 1;
}
-static int png_get_info (FILE *png_file, int *width, int *height)
+static int png_get_info(FILE *png_file, int *width, int *height)
{
png_structp png_ptr;
png_infop png_info_ptr;
png_uint_32 xppm, yppm;
- rewind (png_file);
+ rewind(png_file);
+
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
- if (png_ptr == NULL || (png_info_ptr = png_create_info_struct (png_ptr)) == NULL) {
+ if (png_ptr == NULL || (png_info_ptr = png_create_info_struct(png_ptr)) == NULL) {
if (png_ptr) png_destroy_read_struct(&png_ptr, NULL, NULL);
return -1;
}
- png_init_io (png_ptr, png_file);
+ png_init_io(png_ptr, png_file);
png_read_info(png_ptr, png_info_ptr);
- *width = (int)png_get_image_width (png_ptr, png_info_ptr);
+
+ *width = (int)png_get_image_width(png_ptr, png_info_ptr);
*height = (int)png_get_image_height(png_ptr, png_info_ptr);
- xppm = png_get_x_pixels_per_meter(png_ptr, png_info_ptr);
- yppm = png_get_y_pixels_per_meter(png_ptr, png_info_ptr);
- if (xppm > 0)
- *width = (int)(*width * 72.0 / 0.0254 / xppm + 0.5);
- if (yppm > 0)
- *height = (int)(*height * 72.0 / 0.0254 / yppm + 0.5);
+
+ if (xbb_output_mode == XBB_OUTPUT) {
+ xppm = png_get_x_pixels_per_meter(png_ptr, png_info_ptr);
+ yppm = png_get_y_pixels_per_meter(png_ptr, png_info_ptr);
+ if (xppm > 0)
+ *width = (int)(*width * 72.0 / 0.0254 / xppm + 0.5);
+ if (yppm > 0)
+ *height = (int)(*height * 72.0 / 0.0254 / yppm + 0.5);
+ } else { /* EBB_OUTPUT */
+ *width = (int)(*width * 72.0 / 100.0 + 0.5);
+ *height = (int)(*height * 72.0 / 100.0 + 0.5);
+ }
return 0;
}
@@ -323,31 +305,32 @@ static int rect_equal (pdf_obj *rect1, pdf_obj *rect2)
return 1;
}
-static int pdf_get_info (FILE *image_file, int *llx, int *lly, int *urx, int *ury)
+static int pdf_get_info (FILE *image_file, char *filename, int *llx, int *lly, int *urx, int *ury)
{
pdf_obj *page_tree;
pdf_obj *bbox;
+ pdf_file *pf;
page_tree = NULL;
{
pdf_obj *trailer, *catalog, *tmp;
- trailer = pdf_open(image_file);
- if (!trailer) {
- WARN("Trailer not found! Corrupt PDF file?");
- pdf_close();
+ pf = pdf_open(filename, image_file);
+ if (!pf)
return -1;
- }
+
+ trailer = pdf_file_get_trailer(pf);
+
if (pdf_lookup_dict(trailer, "Encrypt")) {
WARN("This PDF document is encrypted.");
pdf_release_obj(trailer);
- pdf_close();
+ pdf_close(pf);
return -1;
}
catalog = pdf_deref_obj(pdf_lookup_dict(trailer, "Root"));
if (!catalog) {
WARN("Catalog isn't where I expect it.");
- pdf_close();
+ pdf_close(pf);
return -1;
}
pdf_release_obj(trailer);
@@ -356,7 +339,7 @@ static int pdf_get_info (FILE *image_file, int *llx, int *lly, int *urx, int *ur
}
if (!page_tree) {
WARN("Page tree not found.");
- pdf_close();
+ pdf_close(pf);
return -1;
}
{
@@ -385,21 +368,24 @@ static int pdf_get_info (FILE *image_file, int *llx, int *lly, int *urx, int *ur
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)
@@ -412,11 +398,11 @@ static int pdf_get_info (FILE *image_file, int *llx, int *lly, int *urx, int *ur
bbox = crop_box;
}
}
+ pdf_release_obj(page_tree);
if (!bbox) {
WARN("No BoundingBox information available.");
- pdf_release_obj(page_tree);
- pdf_close();
+ pdf_close(pf);
return -1;
}
@@ -425,7 +411,9 @@ static int pdf_get_info (FILE *image_file, int *llx, int *lly, int *urx, int *ur
*urx = (int)pdf_number_value(pdf_get_array(bbox, 2));
*ury = (int)pdf_number_value(pdf_get_array(bbox, 3));
- pdf_close();
+ pdf_release_obj(bbox);
+
+ pdf_close(pf);
return 0;
}
@@ -433,7 +421,7 @@ static void do_pdf (FILE *fp, char *filename)
{
int llx, lly, urx, ury;
- if (pdf_get_info(fp, &llx, &lly, &urx, &ury) < 0) {
+ if (pdf_get_info(fp, filename, &llx, &lly, &urx, &ury) < 0) {
fprintf (stderr, "%s does not look like a PDF file...\n", filename);
return;
}
@@ -441,124 +429,81 @@ static void do_pdf (FILE *fp, char *filename)
return;
}
-FILE *inputfile;
-
-int main (int argc, char *argv[])
+int extractbb (int argc, char *argv[], int mode)
{
mem_debug_init();
+ xbb_output_mode = mode;
+
+ pdf_files_init();
+
pdf_set_version(5);
- kpse_set_program_name (argv[0], NULL);
- argc -= 1;
- argv += 1;
+
+ kpse_set_program_name(argv[0], NULL);
+
+ argc -= 1; argv += 1;
if (argc == 0)
usage();
+
while (argc > 0 && *argv[0] == '-') {
switch (*(argv[0]+1)) {
case 'b':
xbb_file_mode = FOPEN_WBIN_MODE;
+ argc -= 1; argv += 1;
+ break;
+ case 'm':
+ xbb_output_mode = EBB_OUTPUT;
+ argc -= 1; argv += 1;
+ break;
+ case 'x':
+ xbb_output_mode = XBB_OUTPUT;
+ argc -= 1; argv += 1;
+ break;
case 'v':
verbose = 1;
- argc -= 1;
- argv += 1;
+ argc -= 1; argv += 1;
break;
case 'h':
usage();
- argc -= 1;
- argv += 1;
+ argc -= 1; argv += 1;
break;
default:
usage();
}
}
for (; argc > 0; argc--, argv++) {
+ FILE *infile;
char *kpse_file_name;
if (!(kpse_file_name = kpse_find_pict(argv[0])) ||
- (inputfile = MFOPEN (kpse_file_name, FOPEN_RBIN_MODE)) == NULL) {
- fprintf (stderr, "Can't find file (%s)...skipping\n", argv[0]);
- continue;
+ (infile = MFOPEN(kpse_file_name, FOPEN_RBIN_MODE)) == NULL) {
+ fprintf(stderr, "Can't find file (%s)...skipping\n", argv[0]);
+ goto cont;
}
- if (check_for_jpeg(inputfile)) {
- do_jpeg(inputfile, kpse_file_name);
- MFCLOSE(inputfile);
- continue;
+ if (check_for_jpeg(infile)) {
+ do_jpeg(infile, kpse_file_name);
+ goto cont;
}
- if (check_for_pdf(inputfile)) {
- do_pdf(inputfile, kpse_file_name);
- MFCLOSE(inputfile);
- continue;
+ if (check_for_pdf(infile)) {
+ do_pdf(infile, kpse_file_name);
+ goto cont;
}
#ifdef HAVE_LIBPNG
- if (check_for_png(inputfile)) {
- do_png(inputfile, kpse_file_name);
- MFCLOSE(inputfile);
- continue;
+ if (check_for_png(infile)) {
+ do_png(infile, kpse_file_name);
+ goto cont;
}
#endif /* HAVE_LIBPNG */
- fprintf (stderr, "Can't handle file type for file named %s\n",
- argv[0]);
- }
- mem_debug_check();
-
- return 0;
-}
-
-/* The following is here to prevent a link error. Other routines
- that get linked with xbb call this, but it isn't actually needed
- for xbb */
-
-pdf_obj *get_reference (char **start, char *end)
-{
- fprintf (stderr, "get_reference(): This should never have been called\n");
- return NULL;
-}
-
-void error_cleanup(void)
-{
- /* For now, this is a do nothing routine, but the stub is required
- by error.h */
- return;
-}
-
-static int p_dtoa (double value, int prec, char *buf)
-{
- int n;
- char *p, *q;
- n = sprintf(buf, "%.*f", prec, value);
- for (p = buf + n - 1; p > buf && *p != '.'; p--);
- if (p > buf) {
- for (q = buf + n - 1; q > p && *q == '0'; q--) { *q = '\0'; n--; }
- if (q == p) { *q = '\0'; n--; }
+ fprintf(stderr, "Can't handle file type for file named %s\n", argv[0]);
+ cont:
+ if (kpse_file_name)
+ RELEASE(kpse_file_name);
+ if (infile)
+ MFCLOSE(infile);
}
- if (n == 2 && buf[0] == '-' && buf[1] == '0') {
- buf[0] = '0'; buf[1] = '\0'; n = 1;
- }
- return n;
-}
-int pdf_sprint_number (char *buf, double value)
-{
- int len = p_dtoa(value, 8, buf);
- buf[len] = '\0';
- return len;
-}
-
-pdf_obj *spc_lookup_reference (const char *key)
-{
- return NULL;
-}
-
-void pdf_enc_set_generation (unsigned generation)
-{
- return;
-}
+ pdf_files_close();
-void pdf_enc_set_label (unsigned long label)
-{
- return;
-}
+ mem_debug_check();
-void pdf_encrypt_data (unsigned char *data, unsigned long len)
-{
- return;
+ return 0;
}
diff --git a/Build/source/texk/dvipdfmx/src/xbb.h b/Build/source/texk/dvipdfmx/src/xbb.h
new file mode 100644
index 00000000000..a36513b2220
--- /dev/null
+++ b/Build/source/texk/dvipdfmx/src/xbb.h
@@ -0,0 +1,31 @@
+/* $Header: /home/cvsroot/dvipdfmx/src/xbb.h,v 1.1 2008/05/17 07:22:21 chofchof Exp $
+
+ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
+
+ Copyright (C) 2008 by Jin-Hwan Cho, Matthias Franz, and Shunsaku Hirata,
+ the dvipdfmx project team <dvipdfmx@project.ktug.or.kr>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+*/
+
+#ifndef _XBB_H_
+#define _XBB_H_
+
+#define EBB_OUTPUT 0
+#define XBB_OUTPUT 1
+
+extern int extractbb(int argc, char *argv[], int mode);
+
+#endif /* _XBB_H_ */