diff options
Diffstat (limited to 'Build/source/texk/dvipdfmx/src')
48 files changed, 2131 insertions, 1418 deletions
diff --git a/Build/source/texk/dvipdfmx/src/Makefile.am b/Build/source/texk/dvipdfmx/src/Makefile.am index 061c7efd192..cfd424f11e4 100644 --- a/Build/source/texk/dvipdfmx/src/Makefile.am +++ b/Build/source/texk/dvipdfmx/src/Makefile.am @@ -1,4 +1,4 @@ -bin_PROGRAMS = dvipdfmx +bin_PROGRAMS = dvipdfmx xbb 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 \ @@ -11,7 +11,7 @@ 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 \ -agl.h bmpimage.h asl_charset.h cff.h cff_dict.h cff_limits.h cff_stdstr.h cff_types.h \ +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 \ jpegimage.h mem.h mfileio.h mpost.h numbers.h otl_conf.h otl_opt.h pdfcolor.h pdfdev.h \ @@ -23,6 +23,8 @@ 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 + LIBPNGDIR=$(top_builddir)/../../libs/libpng LIBPNGSRCDIR=$(srcdir)/$(LIBPNGDIR) LIBPNGDEP = @LIBPNGDEP@ @@ -37,3 +39,8 @@ dvipdfmx_CPPFLAGS = @LIBPNGCPPFLAGS@ @ZLIBCPPFLAGS@ dvipdfmx_LDADD = $(LDADD) $(LDLIBPNG) $(LDZLIB) dvipdfmx_DEPENDENCIES = $(ZLIBDEP) $(LIBPNGDEP) dvipdfmx_LDFLAGS = @dvipdfmx_LDFLAGS@ + +xbb_CPPFLAGS = @LIBPNGCPPFLAGS@ +xbb_LDADD = $(LDADD) $(LDLIBPNG) $(LDZLIB) +xbb_DEPENDENCIES = $(LIBPNGDEP) $(LDZLIB) +xbb_LDFLAGS = @dvipdfmx_LDFLAGS@ diff --git a/Build/source/texk/dvipdfmx/src/Makefile.in b/Build/source/texk/dvipdfmx/src/Makefile.in index a3b1661c765..849285b693c 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) +bin_PROGRAMS = dvipdfmx$(EXEEXT) xbb$(EXEEXT) subdir = src DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -88,6 +88,13 @@ 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 @@ -95,8 +102,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) -DIST_SOURCES = $(dvipdfmx_SOURCES) +SOURCES = $(dvipdfmx_SOURCES) $(xbb_SOURCES) +DIST_SOURCES = $(dvipdfmx_SOURCES) $(xbb_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) @@ -191,6 +198,7 @@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ dvipdfmx_SOURCES = agl.c bmpimage.c cff.c cff_dict.c cid.c cidtype0.c cidtype2.c \ @@ -205,7 +213,7 @@ 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 \ -agl.h bmpimage.h asl_charset.h cff.h cff_dict.h cff_limits.h cff_stdstr.h cff_types.h \ +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 \ jpegimage.h mem.h mfileio.h mpost.h numbers.h otl_conf.h otl_opt.h pdfcolor.h pdfdev.h \ @@ -217,6 +225,7 @@ 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 LIBPNGDIR = $(top_builddir)/../../libs/libpng LIBPNGSRCDIR = $(srcdir)/$(LIBPNGDIR) ZLIBDIR = $(top_builddir)/../../libs/zlib @@ -224,6 +233,10 @@ ZLIBSRCDIR = $(srcdir)/$(ZLIBDIR) dvipdfmx_CPPFLAGS = @LIBPNGCPPFLAGS@ @ZLIBCPPFLAGS@ dvipdfmx_LDADD = $(LDADD) $(LDLIBPNG) $(LDZLIB) dvipdfmx_DEPENDENCIES = $(ZLIBDEP) $(LIBPNGDEP) +xbb_CPPFLAGS = @LIBPNGCPPFLAGS@ +xbb_LDADD = $(LDADD) $(LDLIBPNG) $(LDZLIB) +xbb_DEPENDENCIES = $(LIBPNGDEP) $(LDZLIB) +xbb_LDFLAGS = @dvipdfmx_LDFLAGS@ all: all-am .SUFFIXES: @@ -283,6 +296,9 @@ 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) @@ -358,6 +374,15 @@ 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@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @@ -1325,6 +1350,132 @@ 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@ +@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 + +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@ +@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` + ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ diff --git a/Build/source/texk/dvipdfmx/src/agl.c b/Build/source/texk/dvipdfmx/src/agl.c index a525003b71a..815ccfd6ed5 100644 --- a/Build/source/texk/dvipdfmx/src/agl.c +++ b/Build/source/texk/dvipdfmx/src/agl.c @@ -1,8 +1,8 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/agl.c,v 1.32 2005/07/20 10:41:54 hirata Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/agl.c,v 1.33 2007/11/14 02:07:14 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -70,6 +70,7 @@ agl_new_name (void) agln->suffix = NULL; agln->n_components = 0; agln->alternate = NULL; + agln->is_predef = 0; return agln; } @@ -368,6 +369,9 @@ agl_init_map (void) { ht_init_table(&aglmap); agl_load_listfile(AGL_EXTRA_LISTFILE, 0); + if (agl_load_listfile(AGL_PREDEF_LISTFILE, 1) < 0) { + WARN("Failed to load AGL file \"%s\"...", AGL_PREDEF_LISTFILE); + } if (agl_load_listfile(AGL_DEFAULT_LISTFILE, 0) < 0) { WARN("Failed to load AGL file \"%s\"...", AGL_DEFAULT_LISTFILE); } @@ -388,7 +392,7 @@ agl_close_map (void) #define WBUF_SIZE 1024 int -agl_load_listfile (const char *filename, int format) /* format unused. */ +agl_load_listfile (const char *filename, int is_predef) { int count = 0; char *p, *endptr, *nextptr; @@ -458,6 +462,7 @@ agl_load_listfile (const char *filename, int format) /* format unused. */ } agln = agl_normalized_name(name); + agln->is_predef = is_predef; agln->n_components = n_unicodes; for (i = 0; i < n_unicodes; i++) { agln->unicodes[i] = unicodes[i]; diff --git a/Build/source/texk/dvipdfmx/src/agl.h b/Build/source/texk/dvipdfmx/src/agl.h index 00e54a87686..da7f52ca40d 100644 --- a/Build/source/texk/dvipdfmx/src/agl.h +++ b/Build/source/texk/dvipdfmx/src/agl.h @@ -1,8 +1,8 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/agl.h,v 1.17 2005/07/07 08:00:31 chofchof Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/agl.h,v 1.18 2007/11/14 02:07:14 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -26,6 +26,7 @@ #define _AGL_H_ #define AGL_DEFAULT_LISTFILE "glyphlist.txt" +#define AGL_PREDEF_LISTFILE "pdfglyphlist.txt" #define AGL_EXTRA_LISTFILE "texglyphlist.txt" #define AGL_MAX_UNICODES 16 @@ -35,6 +36,7 @@ struct agl_name { int n_components; long unicodes[AGL_MAX_UNICODES]; struct agl_name *alternate; + int is_predef; }; typedef struct agl_name agl_name; diff --git a/Build/source/texk/dvipdfmx/src/asl_charset.h b/Build/source/texk/dvipdfmx/src/asl_charset.h deleted file mode 100644 index 91192a62cc7..00000000000 --- a/Build/source/texk/dvipdfmx/src/asl_charset.h +++ /dev/null @@ -1,364 +0,0 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/asl_charset.h,v 1.3 2004/01/30 18:34:19 hirata Exp $ - - This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, - the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> - - Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> - - 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 _ASL_CHARSET_H_ -#define _ASL_CHARSET_H_ - -/* - * Adobe Standard Latin Character Set - from PLRM 3rd. ed. - * - * Characters marked as EXT are present in the extended (315-character) - * Latin character set, but not in the original (229-character) set. - * - * This list contains 314 characters, Maybe one character missing. - * - * Most of strings are also found in cff_stdstr.h. - * CFF Standard Strings contains all glyph names from the original ASL - * character set (plus Expert set). But it does not contains glyph names - * found only in the extented version. - * - */ - -#ifdef _ENCODINGS_C_ -#define ASL_CHARSET_MAX 314 -static const char *const -ASL_Charset[ASL_CHARSET_MAX] = { - "A", - "AE", - "Aacute", - "Abreve", /* EXT */ - "Acircumflex", - "Adieresis", - "Agrave", - "Amacron", /* EXT */ - "Aogonek", /* EXT */ - "Aring", - "Atilde", - "B", - "C", - "Cacute", /* EXT */ - "Ccaron", /* EXT */ - "Ccedilla", - "D", - "Dcaron", /* EXT */ - "Dcroat", /* EXT */ - "Delta", /* EXT */ - "E", - "Eacute", - "Ecaron", /* EXT */ - "Ecircumflex", - "Edieresis", - "Edotaccent", /* EXT */ - "Egrave", - "Emacron", /* EXT */ - "Eogonek", /* EXT */ - "Eth", - "F", - "G", - "Gbreve", /* EXT */ - "Gcommaaccent", /* EXT */ - "H", - "I", - "Iacute", - "Icircumflex", - "Idieresis", - "Idotaccent", /* EXT */ - "Igrave", - "Imacron", /* EXT */ - "Iogonek", /* EXT */ - "J", - "K", - "Kcommaaccent", /* EXT */ - "L", - "Lacute", /* EXT */ - "Lcaron", /* EXT */ - "Lcommaaccent", /* EXT */ - "Lslash", - "M", - "N", - "Nacute", /* EXT */ - "Ncaron", /* EXT */ - "Ncommaaccent", /* EXT */ - "Ntilde", - "O", - "OE", - "Oacute", - "Ocircumflex", - "Odieresis", - "Ograve", - "Ohungarumlaut", /* EXT */ - "Omacron", /* EXT */ - "Oslash", - "Otilde", - "P", - "Q", - "R", - "Racute", /* EXT */ - "Rcaron", /* EXT */ - "Rcommaaccent", /* EXT */ - "S", - "Sacute", /* EXT */ - "Scaron", - "Scedilla", /* EXT */ - "Scommaaccent", /* EXT */ - "T", - "Tcaron", /* EXT */ - "Tcommaaccent", /* EXT */ - "Thorn", - "U", - "Uacute", - "Ucircumflex", - "Udieresis", - "Ugrave", - "Uhungarumlaut", /* EXT */ - "Umacron", /* EXT */ - "Uogonek", /* EXT */ - "Uring", /* EXT */ - "V", - "W", - "X", - "Y", - "Yacute", - "Ydieresis", - "Z", - "Zacute", /* EXT */ - "Zcaron", - "Zdotaccent", /* EXT */ - "a", - "aacute", - "abreve", /* EXT */ - "acircumflex", - "acute", - "adieresis", - "ae", - "agrave", - "amacron", /* EXT */ - "ampersand", - "aogonek", /* EXT */ - "aring", - "asciicircum", - "asciitilde", - "asterisk", - "at", - "atilde", - "b", - "backslash", - "bar", - "braceleft", - "braceright", - "bracketleft", - "bracketright", - "breve", - "brokenbar", - "bullet", - "c", - "cacute", /* EXT */ - "caron", - "ccaron", /* EXT */ - "ccedilla", - "cedilla", - "cent", - "circumflex", - "colon", - "comma", - "commaaccent", /* EXT */ - "copyright", - "currency", - "d", - "dagger", - "daggerdbl", - "dcaron", /* EXT */ - "dcroat", /* EXT */ - "degree", - "dieresis", - "divide", - "dollar", - "dotaccent", - "dotlessi", - "e", - "eacute", - "ecaron", /* EXT */ - "ecircumflex", - "edieresis", - "edotaccent", /* EXT */ - "egrave", - "eight", - "ellipsis", - "emacron", /* EXT */ - "emdash", - "endash", - "eogonek", /* EXT */ - "equal", - "eth", - "exclam", - "exclamdown", - "f", - "fi", - "five", - "fl", - "florin", - "four", - "fraction", - "g", - "gbreve", /* EXT */ - "gcammaaccent", /* EXT */ - "germandbls", - "grave", - "greater", - "greaterequal", /* EXT */ - "guillemotleft", /* MISSPELED BY ADOBE */ - "guillemotright", /* MISSPELED BY ADOBE */ - "guilsinglleft", - "guilsinglright", - "h", - "hungarumlaut", - "hyphen", - "i", - "iacute", - "icircumflex", - "idieresis", - "igrave", - "imacron", /* EXT */ - "iogonek", /* EXT */ - "j", - "k", - "kcommaaccent", /* EXT */ - "l", - "lacute", /* EXT */ - "lcaron", /* EXT */ - "lcommaaccent", /* EXT */ - "less", - "lessequal", /* EXT */ - "logicalnot", - "lozenge", /* EXT */ - "lslash", - "m", - "macron", - "minus", - "mu", - "multiply", - "n", - "nacute", /* EXT */ - "ncaron", /* EXT */ - "ncommaaccent", /* EXT */ - "nine", - "notequal", /* EXT */ - "ntilde", - "numbersign", - "o", - "oacute", - "ocircumflex", - "odieresis", - "oe", - "ogonek", - "ograve", - "ohungarumlaut", /* EXT */ - "omacron", /* EXT */ - "one", - "onehalf", - "onequarter", - "onesuperior", - "ordfeminine", - "ordmasculine", - "oslash", - "otilde", - "p", - "paragraph", - "parenleft", - "parenright", - "partialdiff", /* EXT */ - "percent", - "period", - "periodcentered", - "perthousand", - "plus", - "plusminus", - "q", - "question", - "questiondown", - "quotedbl", - "quotedblbase", - "quotedblleft", - "quotedblright", - "quoteleft", - "quoteright", - "quotesinglbase", - "quotesingle", - "r", - "racute", /* EXT */ - "radical", /* EXT */ - "rcaron", /* EXT */ - "rcommaaccent", /* EXT */ - "registered", - "ring", - "s", - "scacute", /* EXT */ - "scaron", - "scedilla", /* EXT */ - "scommaaccent", /* EXT */ - "section", - "semicolon", - "seven", - "six", - "slash", - "space", - "sterling", - "summation", /* EXT */ - "t", - "tcaron", /* EXT */ - "tcommaaccent", /* EXT */ - "thorn", - "three", - "threequarters", - "threesuperior", - "tilde", - "trademark", - "two", - "twosuperior", - "u", - "uacute", - "ucircumflex", - "udieresis", - "ugrave", - "uhungarumlaut", /* EXT */ - "umacron", /* EXT */ - "underscore", - "uogonek", /* EXT */ - "uring", /* EXT */ - "v", - "w", - "x", - "y", - "yacute", - "ydieresis", - "yen", - "z", - "zacute", /* EXT */ - "zcaron", - "zdotaccent", /* EXT */ - "zero" -}; -#endif /* _ENCODINGS_C_ */ - -#endif /* _ASL_CHARSET_H_ */ diff --git a/Build/source/texk/dvipdfmx/src/cff_dict.c b/Build/source/texk/dvipdfmx/src/cff_dict.c index 875210ca090..44f9c24931e 100644 --- a/Build/source/texk/dvipdfmx/src/cff_dict.c +++ b/Build/source/texk/dvipdfmx/src/cff_dict.c @@ -1,8 +1,8 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/cff_dict.c,v 1.13 2004/08/26 16:02:26 hirata Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/cff_dict.c,v 1.15 2007/07/05 05:45:06 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> This program is free software; you can redistribute it and/or modify @@ -430,7 +430,7 @@ static long pack_real (card8 *dest, long destlen, double value) { long e; int i = 0, pos = 2; -#define CFF_REAL_MAX_LEN 17 + char buffer[32]; if (destlen < 2) ERROR("%s: Buffer overflow.", CFF_DEBUG_STR); @@ -448,28 +448,19 @@ static long pack_real (card8 *dest, long destlen, double value) pos++; } - e = 0; - if (value >= 10.0) { - while (value >= 10.0) { - value /= 10.0; - e++; - } - } else if (value < 1.0) { - while (value < 1.0) { - value *= 10.0; - e--; - } - } + /* To avoid the problem with Mac OS X 10.4 Quartz, + * change the presion of the real numbers + * on June 27, 2007 for musix20.pfb */ + sprintf(buffer, "%.13g", value); - sprintf(work_buffer, "%1.14g", value); - for (i=0;i<CFF_REAL_MAX_LEN;i++) { + for (i = 0; buffer[i] != '\0'; i++) { unsigned char ch = 0; - if (work_buffer[i] == '\0') { - break; - } else if (work_buffer[i] == '.') { + if (buffer[i] == '.') { ch = 0x0a; - } else if (work_buffer[i] >= '0' && work_buffer[i] <= '9') { - ch = work_buffer[i] - '0'; + } else if (buffer[i] >= '0' && buffer[i] <= '9') { + ch = buffer[i] - '0'; + } else if (buffer[i] == 'e') { + ch = (buffer[++i] == '-' ? 0x0c : 0x0b); } else { ERROR("%s: Invalid character.", CFF_DEBUG_STR); } @@ -485,53 +476,6 @@ static long pack_real (card8 *dest, long destlen, double value) pos++; } - if (e > 0) { - if (pos % 2) { - dest[pos/2] += 0x0b; - } else { - if (destlen < pos/2 + 1) - ERROR("%s: Buffer overflow.", CFF_DEBUG_STR); - dest[pos/2] = 0xb0; - } - pos++; - } else if (e < 0) { - if (pos % 2) { - dest[pos/2] += 0x0c; - } else { - if (destlen < pos/2 + 1) - ERROR("%s: Buffer overflow.", CFF_DEBUG_STR); - dest[pos/2] = 0xc0; - } - e *= -1; - pos++; - } - - if (e != 0) { - sprintf(work_buffer, "%ld", e); - for (i=0;i<CFF_REAL_MAX_LEN;i++) { - unsigned char ch = 0; - if (work_buffer[i] == '\0') { - break; - } else if (work_buffer[i] == '.') { - ch = 0x0a; - } else if (work_buffer[i] >= '0' && work_buffer[i] <= '9') { - ch = work_buffer[i] - '0'; - } else { - ERROR("%s: Invalid character.", CFF_DEBUG_STR); - } - - if (destlen < pos/2 + 1) - ERROR("%s: Buffer overflow.", CFF_DEBUG_STR); - - if (pos % 2) { - dest[pos/2] += ch; - } else { - dest[pos/2] = (ch << 4); - } - pos++; - } - } - if (pos % 2) { dest[pos/2] += 0x0f; pos++; diff --git a/Build/source/texk/dvipdfmx/src/cff_dict.h b/Build/source/texk/dvipdfmx/src/cff_dict.h index 806fc4be50d..7a8d1f888b7 100644 --- a/Build/source/texk/dvipdfmx/src/cff_dict.h +++ b/Build/source/texk/dvipdfmx/src/cff_dict.h @@ -1,8 +1,8 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/cff_dict.h,v 1.6 2004/02/15 12:59:42 hirata Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/cff_dict.h,v 1.7 2007/06/30 01:18:13 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> This program is free software; you can redistribute it and/or modify @@ -26,7 +26,6 @@ #include "cff_types.h" #include "cff.h" -#define CFF_CIDCOUNT_DEFAULT 8720 #define CFF_NOMINALWIDTHX_DEFAULT 0.0 #define CFF_DEFAULTWIDTHX_DEFAULT 0.0 diff --git a/Build/source/texk/dvipdfmx/src/cid_basefont.h b/Build/source/texk/dvipdfmx/src/cid_basefont.h index 9dd947bcb57..4b87320950f 100644 --- a/Build/source/texk/dvipdfmx/src/cid_basefont.h +++ b/Build/source/texk/dvipdfmx/src/cid_basefont.h @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/cid_basefont.h,v 1.14 2005/06/27 11:54:50 hirata Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/cid_basefont.h,v 1.15 2007/11/15 17:08:52 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -456,6 +456,32 @@ const struct { >> \ >>" }, + + /* Addition in Adobe Reader 8 */ + /* + * Font information of AdobeHeitiStd-Regular.otf may not be correct! + * Just copied the information of AdobeSongStd-Light.otf. + */ + { + "AdobeHeitiStd-Regular", + "<< \ +/Subtype/CIDFontType0 \ +/CIDSystemInfo << /Registry (Adobe) /Ordering (GB1) /Supplement 4 >> \ +/DW 1000 \ +/W [\ + 814 939 500 \ + 7716 [500] \ +22355 [500 500] \ +22357 [500] \ +]\ +>>", + "<< \ +/Ascent 880 /Descent -120 /StemV 66 /CapHeight 626 \ +/FontBBox [-134 -254 1001 905] \ +/ItalicAngle 0 /Flags 6 /XHeight 416 \ +/Style << /Panose <000002020300000000000000> >> \ +>>" + }, /* END */ {NULL, NULL, NULL} }; diff --git a/Build/source/texk/dvipdfmx/src/cidtype0.c b/Build/source/texk/dvipdfmx/src/cidtype0.c index ec88c13b38c..f070cd2fe43 100644 --- a/Build/source/texk/dvipdfmx/src/cidtype0.c +++ b/Build/source/texk/dvipdfmx/src/cidtype0.c @@ -1,8 +1,8 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/cidtype0.c,v 1.34 2005/07/17 09:53:37 hirata Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/cidtype0.c,v 1.36 2007/06/30 01:18:13 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> This program is free software; you can redistribute it and/or modify @@ -182,7 +182,7 @@ add_CIDVMetrics (sfnt *sfont, pdf_obj *fontdict, vhea = tt_read_vhea_table(sfont); if (vhea && sfnt_find_table_pos(sfont, "vmtx") > 0) { sfnt_locate_table(sfont, "vmtx"); - vmtx = tt_read_longMetrics(sfont, maxp->numGlyphs, vhea->numOfLongVerMetrics); + vmtx = tt_read_longMetrics(sfont, maxp->numGlyphs, vhea->numOfLongVerMetrics, vhea->numOfExSideBearings); } /* * OpenType font must have OS/2 table. @@ -312,7 +312,7 @@ add_CIDMetrics (sfnt *sfont, pdf_obj *fontdict, hhea = tt_read_hhea_table(sfont); sfnt_locate_table(sfont, "hmtx"); - hmtx = tt_read_longMetrics(sfont, maxp->numGlyphs, hhea->numberOfHMetrics); + hmtx = tt_read_longMetrics(sfont, maxp->numGlyphs, hhea->numOfLongHorMetrics, hhea->numOfExSideBearings); add_CIDHMetrics(sfont, fontdict, CIDToGIDMap, last_cid, maxp, head, hmtx); if (need_vmetrics) @@ -472,8 +472,8 @@ CIDFont_type0_dofont (CIDFont *font) long size, offset = 0; card8 *data; card16 num_glyphs, gid; - long cid; - card16 cid_count, cs_count, last_cid; + long cid, cid_count; + card16 cs_count, last_cid; int fd, prev_fd, parent_id; char *used_chars; unsigned char *CIDToGIDMap = NULL; @@ -526,9 +526,9 @@ CIDFont_type0_dofont (CIDFont *font) ERROR("Not a CIDFont."); if (cff_dict_known(cffont->topdict, "CIDCount")) { - cid_count = (card16) cff_dict_get(cffont->topdict, "CIDCount", 0); + cid_count = (long) cff_dict_get(cffont->topdict, "CIDCount", 0); } else { - cid_count = CFF_CIDCOUNT_DEFAULT; + cid_count = CID_MAX + 1; } cff_read_charsets(cffont); @@ -538,11 +538,6 @@ CIDFont_type0_dofont (CIDFont *font) cid = 0; last_cid = 0; num_glyphs = 0; for (cid = 0; cid <= CID_MAX; cid++) { if (is_used_char2(used_chars, cid)) { - if (cid >= cid_count) { - WARN("Glyph for CID %u missing in font \"%s\".", (CID) cid, font->ident); - used_chars[cid/8] &= ~(1 << (7 - (cid % 8))); - continue; - } gid = cff_charsets_lookup(cffont, cid); if (cid != 0 && gid == 0) { WARN("Glyph for CID %u missing in font \"%s\".", (CID) cid, font->ident); diff --git a/Build/source/texk/dvipdfmx/src/dpxfile.c b/Build/source/texk/dvipdfmx/src/dpxfile.c index 295e4d2f4fd..195bb4faa8c 100644 --- a/Build/source/texk/dvipdfmx/src/dpxfile.c +++ b/Build/source/texk/dvipdfmx/src/dpxfile.c @@ -1,8 +1,8 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/dpxfile.c,v 1.14 2005/12/18 14:56:47 chofchof Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/dpxfile.c,v 1.16 2007/11/14 03:36:01 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -323,7 +323,7 @@ dpx_open_file (const char *filename, int type) } if (fqpn) { fp = MFOPEN(fqpn, FOPEN_RBIN_MODE); - RELEASE(fqpn); + free(fqpn); /* no RELEASE because not allocated by NEW */ } return fp; @@ -523,9 +523,9 @@ dpx_find_enc_file (const char *filename) } #else # if defined(__TDS_VERSION__) && __TDS_VERSION__ >= 0x200406L - fqpn = kpse_find_file(filename, kpse_enc_format, 0); + fqpn = kpse_find_file(q, kpse_enc_format, 0); # else - fqpn = kpse_find_file(filename, kpse_tex_ps_header_format, 0); + fqpn = kpse_find_file(q, kpse_tex_ps_header_format, 0); # endif #endif /* MIKTEX */ diff --git a/Build/source/texk/dvipdfmx/src/dpxutil.c b/Build/source/texk/dvipdfmx/src/dpxutil.c index 2b0cf946b79..c87568b96a5 100644 --- a/Build/source/texk/dvipdfmx/src/dpxutil.c +++ b/Build/source/texk/dvipdfmx/src/dpxutil.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/dpxutil.c,v 1.7 2005/07/17 09:53:38 hirata Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/dpxutil.c,v 1.8 2007/11/14 03:36:01 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -235,9 +235,10 @@ ht_lookup_table (struct ht_table *ht, const void *key, int keylen) return NULL; } -void +int ht_remove_table (struct ht_table *ht, const void *key, int keylen, void (*hval_free_fn) (void *)) +/* returns 1 if the element was found and removed and 0 otherwise */ { struct ht_entry *hent, *prev; unsigned int hkey; @@ -269,7 +270,9 @@ ht_remove_table (struct ht_table *ht, } RELEASE(hent); ht->count--; - } + return 1; + } else + return 0; } /* replace... */ diff --git a/Build/source/texk/dvipdfmx/src/dpxutil.h b/Build/source/texk/dvipdfmx/src/dpxutil.h index 54fc8e8cd09..09a755c22b8 100644 --- a/Build/source/texk/dvipdfmx/src/dpxutil.h +++ b/Build/source/texk/dvipdfmx/src/dpxutil.h @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/dpxutil.h,v 1.7 2005/07/17 09:53:38 hirata Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/dpxutil.h,v 1.8 2007/11/14 03:36:01 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -76,7 +76,7 @@ extern void ht_clear_table (struct ht_table *ht, void (*hval_free_fn) (void *) extern void *ht_lookup_table (struct ht_table *ht, const void *key, int keylen); extern void ht_append_table (struct ht_table *ht, const void *key, int keylen, void *value) ; -extern void ht_remove_table (struct ht_table *ht, +extern int ht_remove_table (struct ht_table *ht, const void *key, int keylen, void (*hval_free_fn) (void*)); extern void ht_insert_table (struct ht_table *ht, const void *key, int keylen, void *value, diff --git a/Build/source/texk/dvipdfmx/src/dvipdfmx.c b/Build/source/texk/dvipdfmx/src/dvipdfmx.c index de113ac8386..3c9e043c4a7 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.47 2006/12/11 13:23:26 chofchof Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/dvipdfmx.c,v 1.53 2007/11/14 03:36:01 chofchof Exp $ This is DVIPDFMx, an eXtended version of DVIPDFM by Mark A. Wicks. - Copyright (C) 2002-2003 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the DVIPDFMx project team <dvipdfmx@project.ktug.or.kr> Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -65,6 +65,9 @@ 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; @@ -123,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-2006 by the DVIPDFMx project team\n"); + fprintf (stdout, "\nCopyright (C) 2002-2007 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"); @@ -131,38 +134,47 @@ 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"); - fprintf (stdout, "-l \t\tLandscape mode\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, "-g dimension\tAnnotation \"grow\" amount [0.0in]\n"); + fprintf (stdout, "-l \t\tLandscape mode\n"); fprintf (stdout, "-m number\tSet additional magnification\n"); fprintf (stdout, "-o filename\tSet output file name [dvifile.pdf]\n"); fprintf (stdout, "-p papersize\tSet papersize [a4]\n"); + 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, "-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"); - fprintf (stdout, "-v \tBe verbose\n"); - fprintf (stdout, "-vv \tBe more verbose\n"); + fprintf (stdout, "-v \t\tBe verbose\n"); + fprintf (stdout, "-vv\t\tBe more verbose\n"); fprintf (stdout, "-C number\tSpecify miscellaneous option flags [0]:\n"); fprintf (stdout, "\t\t 0x0001 reserved\n"); fprintf (stdout, "\t\t 0x0002 Use semi-transparent filling for tpic shading command,\n"); - fprintf (stdout, "\t\t instead of opaque gray color. (requires PDF 1.4)\n"); + 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 \tEnable PDF encryption\n"); - fprintf (stdout, "-T \tEmbed thumbnail images. Remove images files when finished.\n"); - fprintf (stdout, "-M \tExperimental mps-to-pdf mode\n"); - fprintf (stdout, "-V number\tSet PDF minor version [3]\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"); fprintf (stdout, "Papersize is specified by paper format (e.g., \"a4\") or by w<unit>,h<unit> (e.g., \"20cm,30cm\").\n"); @@ -416,9 +428,9 @@ do_args (int argc, char *argv[]) ver_minor = atoi(argv[1]); POP_ARG(); } - if (ver_minor < 3 || ver_minor > 5) { - WARN("PDF version 1.%d not supported. (1.3 used instead)", ver_minor); - ver_minor = 3; + if (ver_minor < 3 || ver_minor > 6) { + WARN("PDF version 1.%d not supported. (1.4 used instead)", ver_minor); + ver_minor = 4; } pdf_set_version((unsigned) ver_minor); } @@ -654,7 +666,6 @@ do_dvi_pages (void) mediabox.urx = paper_width; mediabox.ury = paper_height; - pdf_doc_set_creator (dvi_comment()); pdf_doc_set_mediabox(0, &mediabox); /* Root node */ for (i = 0; i < num_page_ranges; i++) { @@ -773,6 +784,8 @@ main (int argc, char *argv[]) { double dvi2pts; + mem_debug_init(); + if (argc < 2) { fprintf(stderr, "No dvi filename specified."); usage(); @@ -823,10 +836,14 @@ main (int argc, char *argv[]) if (do_encryption) { pdf_enc_set_passwd(key_bits, permission, dvi_filename, pdf_filename); - if (key_bits > 40) + if (key_bits > 40 && pdf_get_version() < 4) 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; @@ -847,7 +864,7 @@ main (int argc, char *argv[]) * annot_grow: Margin of annotation. * bookmark_open: Miximal depth of open bookmarks. */ - pdf_open_document(pdf_filename, + pdf_open_document(pdf_filename, do_encryption, do_objstm, paper_width, paper_height, annot_grow, bookmark_open); /* Ignore_colors placed here since @@ -886,5 +903,7 @@ main (int argc, char *argv[]) miktex_uninitialize (); #endif + mem_debug_check(); + return 0; } diff --git a/Build/source/texk/dvipdfmx/src/epdf.c b/Build/source/texk/dvipdfmx/src/epdf.c index 83bfcfbbb09..1cb621a4149 100644 --- a/Build/source/texk/dvipdfmx/src/epdf.c +++ b/Build/source/texk/dvipdfmx/src/epdf.c @@ -1,28 +1,27 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/epdf.c,v 1.14 2004/09/12 11:57:49 hirata Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/epdf.c,v 1.16 2007/11/14 03:12:21 chofchof Exp $ - This is dvipdfm, a DVI to PDF translator. - Copyright (C) 1998, 1999 by Mark A. Wicks + This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. + + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, + the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> + + Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> 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 - - The author may be contacted via the e-mail address - - mwicks@kettering.edu + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ - /* * Concatinating content streams are only supported for streams that only uses * single FlateDecode filter, i.e., @@ -60,44 +59,55 @@ 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); /* - * From PDF Reference 4th ed. + * From PDFReference15_v6.pdf (p.119 and p.834) * - * MediaBox rectangle (Required; inheritable) + * MediaBox rectangle (Required; inheritable) * - * A rectangle, expressed in default user space units, defining the boundaries of the - * physical medium on which the page is intended to be displayed or printed. + * The media box defines the boundaries of the physical medium on which the + * page is to be printed. It may include any extended area surrounding the + * finished page for bleed, printing marks, or other such purposes. It may + * also include areas close to the edges of the medium that cannot be marked + * because of physical limitations of the output device. Content falling + * outside this boundary can safely be discarded without affecting the + * meaning of the PDF file. * - * CropBox rectangle (Optional; inheritable) + * CropBox rectangle (Optional; inheritable) * - * A rectangle, expressed in default user space units, defining the visible region of - * default user space. When the page is displayed or printed, its contents are to be - * clipped (cropped) to this rectangle and then imposed on the output medium in some - * implementation-defined manner. - * Default value: the value of MediaBox. + * The crop box defines the region to which the contents of the page are to be + * clipped (cropped) when displayed or printed. Unlike the other boxes, the + * crop box has no defined meaning in terms of physical page geometry or + * intended use; it merely imposes clipping on the page contents. However, + * in the absence of additional information (such as imposition instructions + * specified in a JDF or PJTF job ticket), the crop box will determine how + * the page’s contents are to be positioned on the output medium. The default + * value is the page’s media box. * - * BleedBox rectangle (Optional; PDF 1.3) + * BleedBox rectangle (Optional; PDF 1.3) * - * A rectangle, expressed in default user space units, defining the region to which the - * contents of the page should be clipped when output in a production environment. - * Default value: the value of CropBox. + * The bleed box (PDF 1.3) defines the region to which the contents of the + * page should be clipped when output in a production environment. This may + * include any extra “bleed area” needed to accommodate the physical + * limitations of cutting, folding, and trimming equipment. The actual printed + * page may include printing marks that fall outside the bleed box. + * The default value is the page’s crop box. * - * TrimBox rectangle (Optional; PDF 1.3) + * TrimBox rectangle (Optional; PDF 1.3) * - * A rectangle, expressed in default user space units, defining the intended dimensions - * of the finished page after trimming. - * Default value: the value of CropBox. + * The trim box (PDF 1.3) defines the intended dimensions of the finished page + * after trimming. It may be smaller than the media box, to allow for + * production-related content such as printing instructions, cut marks, or + * color bars. The default value is the page’s crop box. * - * ArtBox rectangle (Optional; PDF 1.3) + * ArtBox rectangle (Optional; PDF 1.3) * - * A rectangle, expressed in default user space units, defining the extent of the page's - * meaningful content (including potential white space) as intended by the page's creator - * Default value: the value of CropBox. + * The art box (PDF 1.3) defines the extent of the page’s meaningful content + * (including potential white space) as intended by the page’s creator. + * The default value is the page’s crop box. * - * Rotate integer (Optional; inheritable) + * Rotate integer (Optional; inheritable) * - * The number of degrees by which the page should be rotated clockwise when displayed or - * printed. The value must be a multiple of 90. - * Default value: 0. + * The number of degrees by which the page should be rotated clockwise when + * displayed or printed. The value must be a multiple of 90. Default value: 0. */ static int @@ -222,6 +232,27 @@ pdf_include_page (pdf_ximage *ximage, FILE *image_file) pdf_release_obj(bbox); bbox = tmp; } + if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "BleedBox")))) { + if (!rect_equal(tmp, bbox)) { + if (bbox) + pdf_release_obj(bbox); + bbox = tmp; + } + } + if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "TrimBox")))) { + if (!rect_equal(tmp, bbox)) { + if (bbox) + pdf_release_obj(bbox); + bbox = 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; + } + } if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "CropBox")))) { if (crop_box) pdf_release_obj(crop_box); @@ -246,6 +277,7 @@ pdf_include_page (pdf_ximage *ximage, FILE *image_file) bbox = crop_box; } } + if (!bbox) { WARN("No BoundingBox information available."); pdf_release_obj(page_tree); @@ -256,49 +288,18 @@ pdf_include_page (pdf_ximage *ximage, FILE *image_file) return -1; } - /* - * BleedBox, TrimBox, and ArtBox are not inheritable. - */ - { - pdf_obj *tmp; - - if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "TrimBox")))) { - if (!rect_equal(tmp, bbox)) { - print_bbox_info(tmp, "TrimBox", bbox); - if (bbox) - pdf_release_obj(bbox); - bbox = tmp; - } - } - if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "BleedBox")))) { - if (!rect_equal(tmp, bbox)) { - print_bbox_info(tmp, "BleedBox", bbox); - if (bbox) - pdf_release_obj(bbox); - bbox = tmp; - } - } - if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "ArtBox")))) { - if (!rect_equal(tmp, bbox)) { - print_bbox_info(tmp, "ArtBox", bbox); - if (bbox) - pdf_release_obj(bbox); - bbox = tmp; - } - } - if (rotate) { - if (pdf_number_value(rotate) != 0.0) - WARN("<< /Rotate %d >> found. (Not supported yet)", (int)pdf_number_value(rotate)); - pdf_release_obj(rotate); - 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)); + if (rotate) { + if (pdf_number_value(rotate) != 0.0) + WARN("<< /Rotate %d >> found. (Not supported yet)", (int)pdf_number_value(rotate)); + pdf_release_obj(rotate); + 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)); + /* * Handle page content stream. * page_tree is now set to the first page. diff --git a/Build/source/texk/dvipdfmx/src/fontmap.c b/Build/source/texk/dvipdfmx/src/fontmap.c index 041021ba9ff..f55e4a9a738 100644 --- a/Build/source/texk/dvipdfmx/src/fontmap.c +++ b/Build/source/texk/dvipdfmx/src/fontmap.c @@ -1,8 +1,8 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/fontmap.c,v 1.33 2005/07/30 11:44:18 hirata Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/fontmap.c,v 1.36 2007/11/14 03:36:01 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -738,8 +738,11 @@ pdf_insert_fontmap_record (const char *kp, const fontmap_rec *vp) char **subfont_ids; int n = 0; subfont_ids = sfd_get_subfont_ids(sfd_name, &n); - if (!subfont_ids) + if (!subfont_ids) { + RELEASE(fnt_name); + RELEASE(sfd_name); return -1; + } if (verbose > 3) MESG("\nfontmap>> Expand @%s@:", sfd_name); while (n-- > 0) { @@ -1039,6 +1042,8 @@ pdf_close_fontmaps (void) RELEASE(fontmap); } fontmap = NULL; + + release_sfd_record(); } void diff --git a/Build/source/texk/dvipdfmx/src/jpegimage.c b/Build/source/texk/dvipdfmx/src/jpegimage.c index 65cde6c9a26..c605394311e 100644 --- a/Build/source/texk/dvipdfmx/src/jpegimage.c +++ b/Build/source/texk/dvipdfmx/src/jpegimage.c @@ -1,8 +1,8 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/jpegimage.c,v 1.8 2004/09/05 13:30:05 hirata Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/jpegimage.c,v 1.9 2007/05/18 05:19:01 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -331,6 +331,32 @@ jpeg_include_image (pdf_ximage *ximage, FILE *fp) info.bits_per_component = j_info.bits_per_component; info.num_components = j_info.num_components; +#define IS_JFIF(j) ((j).flags & HAVE_APPn_JFIF) + if (IS_JFIF(j_info)) { + struct JPEG_APPn_JFIF *app_data; + int i; + for (i = 0; i < j_info.num_appn; i++) { + if (j_info.appn[i].marker != JM_APP0 || + j_info.appn[i].app_sig != JS_APPn_JFIF) + continue; + } + if (i < j_info.num_appn) { + app_data = (struct JPEG_APPn_JFIF *)j_info.appn[i].app_data; + switch (app_data->units) { + case 1: /* pixels per inch */ + info.xdensity = 72.0 / app_data->Xdensity; + info.ydensity = 72.0 / app_data->Ydensity; + break; + case 2: /* pixels per centimeter */ + info.xdensity = 72.0 / 2.54 / app_data->Xdensity; + info.ydensity = 72.0 / 2.54 / app_data->Ydensity; + break; + default: + break; + } + } + } + pdf_ximage_set_image(ximage, &info, stream); JPEG_info_clear(&j_info); diff --git a/Build/source/texk/dvipdfmx/src/mem.c b/Build/source/texk/dvipdfmx/src/mem.c index 382f0dd8e81..ecc42c6321c 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.3 2002/10/30 02:27:11 chofchof Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/mem.c,v 1.4 2007/11/14 03:36:01 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -25,24 +25,69 @@ #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; + #ifdef MEM_DEBUG -FILE *debugfile = NULL; -static long int event = 0; + +#define MEM_LINE 128 + +long int mem_event = 0; + +static void +mem_noop (void *vp) +{ +} + +static void +mem_error (void *vp) +{ + fprintf(stderr, "pointer %p released, but not allocated\n", vp); +} + #endif /* MEM_DEBUG */ -#ifdef MEM_DEBUG -void mem_debug_init(void) +void mem_debug_check(void) { - if (debugfile == NULL) { - debugfile = fopen ("malloc.log", "w"); - fprintf (stderr, "*** Memory Debugging Log started ***\n"); +#ifdef MEM_DEBUG + struct ht_iter iter; + + fprintf(stderr, "*** Memory still in use ***\n"); + + if (ht_set_iter(mem_ht, &iter) == 0) { + do { + int pl; + void *p = ht_iter_getkey(&iter, &pl); + char *s = ht_iter_getval(&iter); + + fprintf(stderr, "%p %s\n", p, s); + } while (!ht_iter_next(&iter)); } + 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) +{ +#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, char *function, int line) +void *new (size_t size, const char *file, const char *function, int line) { void *result; if ((result = malloc (size)) == NULL) { @@ -51,44 +96,107 @@ void *new (size_t size, char *function, int line) exit (1); } -#ifdef MEM_DEBUG - mem_debug_init(); - event += 1; - fprintf (debugfile, "%p %07ld [new] %s:%d\n", result, event, function, line); + if (!mem_internal) { + mem_count++; +#ifdef MEM_DEBUG + 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; } -void *renew (void *mem, size_t size, char *function, int line) +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 - mem_debug_init(); - event += 1; - if (mem) - fprintf (debugfile, "%p %07ld [fre] %s:%d\n", mem, - event, function, line); + 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)" +#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 */ + } + if ((result = realloc (mem, size)) == NULL) { fprintf (stderr, "Out of memory!\n"); exit (1); } + #ifdef MEM_DEBUG - if (result) - fprintf (debugfile, "%p %07ld [new] %s:%d\n", result, event, function, line); + 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; } -void release (void *mem, char *function, int line) +void release (void *mem, const char *file, const char *function, int line) { + if (mem && !mem_internal) { + mem_count--; #ifdef MEM_DEBUG - mem_debug_init(); - event += 1; - fprintf (debugfile, "%p %07ld [fre] %s:%d\n", mem, event, function, line); + 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 */ + } free (mem); } diff --git a/Build/source/texk/dvipdfmx/src/mem.h b/Build/source/texk/dvipdfmx/src/mem.h index da690d4c588..90e9db7da7a 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.3 2002/10/30 02:27:11 chofchof Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/mem.h,v 1.4 2007/11/14 03:36:01 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -25,26 +25,31 @@ #ifndef _MEM_H_ #define _MEM_H_ +#undef MEM_DEBUG + #include <stdlib.h> -extern void *new (size_t size, char *function, int line); -extern void *renew (void *p, size_t size, char *function, int line); -extern void release (void *mem, char *function, int line); +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); -#ifdef MEM_DEBUG extern void mem_debug_init(void); -extern FILE *debugfile; -#define NEW(n,type) (type *)(new (((size_t) (n))*sizeof(type),__FUNCTION__,__LINE__)) -#define RENEW(p,n,type) (type *)(renew ((p),(n)*sizeof(type),__FUNCTION__,__LINE__)) -#define RELEASE(p) release ((p),__FUNCTION__,__LINE__) -#define MEM_START {mem_debug_init();fprintf (debugfile, "Entered %s\n", __FUNCTION__);} -#define MEM_END fprintf (debugfile, "Leaving %s\n", __FUNCTION__); +extern void mem_debug_check(void); + +#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,0)) -#define RENEW(p,n,type) (type *)(renew ((p),(n)*sizeof(type),NULL,0)) -#define RELEASE(p) release ((p),NULL,0) +#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) #endif /* MEM_DEBUG */ #endif /* _MEM_H_ */ diff --git a/Build/source/texk/dvipdfmx/src/mpost.c b/Build/source/texk/dvipdfmx/src/mpost.c index 6875d5d573e..c3bb35410a5 100644 --- a/Build/source/texk/dvipdfmx/src/mpost.c +++ b/Build/source/texk/dvipdfmx/src/mpost.c @@ -1,8 +1,8 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/mpost.c,v 1.36 2006/12/11 12:46:03 chofchof Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/mpost.c,v 1.37 2007/11/03 05:31:20 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -260,7 +260,8 @@ skip_prolog (char **start, char *end) save = *start; while (*start < end) { - skip_white(start, end); + if (**start != '%') + skip_white(start, end); if (*start >= end) break; if (!strncmp(*start, "%%EndProlog", 11)) { diff --git a/Build/source/texk/dvipdfmx/src/pdfdoc.c b/Build/source/texk/dvipdfmx/src/pdfdoc.c index eba290014c9..19212824ab5 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.44 2006/12/20 08:10:13 chofchof Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pdfdoc.c,v 1.47 2007/11/14 03:36:01 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -511,7 +511,7 @@ asn_date (char *date_string) # ifdef HAVE_TM_GMTOFF # define timezone (-bd_time->tm_gmtoff) # else -# define timezone (-compute_timezone_offset()) +# define timezone (-compute_timezone_offset()) # endif /* not HAVE_TM_GMTOFF */ #endif /* not HAVE_TIMEZONE */ time_t current_time; @@ -1037,6 +1037,7 @@ flush_bookmarks (pdf_olitem *node, pdf_new_name("Last"), pdf_link_obj(prev_ref)); + pdf_release_obj(prev_ref); pdf_release_obj(node->dict); node->dict = NULL; @@ -2023,12 +2024,13 @@ static char *doccreator = NULL; /* Ugh */ void pdf_open_document (const char *filename, + int do_encryption, int do_objstm, double media_width, double media_height, double annot_grow_amount, int bookmark_open_depth) { pdf_doc *p = &pdoc; - pdf_out_init(filename); + pdf_out_init(filename, do_encryption); pdf_doc_init_catalog(p); @@ -2054,7 +2056,14 @@ pdf_open_document (const char *filename, pdf_doc_init_names (p); pdf_doc_init_page_tree(p, media_width, media_height); - create_encrypt(); + if (do_encryption) { + pdf_obj *encrypt = pdf_encrypt_obj(); + pdf_set_encrypt(encrypt, pdf_enc_id_array()); + pdf_release_obj(encrypt); + } + + if (do_objstm) + pdf_objstm_init(); #ifndef NO_THUMBNAIL /* Create a default name for thumbnail image files */ @@ -2118,6 +2127,8 @@ pdf_close_document (void) } #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 0d160e18a7f..2fd805c6077 100644 --- a/Build/source/texk/dvipdfmx/src/pdfdoc.h +++ b/Build/source/texk/dvipdfmx/src/pdfdoc.h @@ -1,8 +1,8 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/pdfdoc.h,v 1.19 2005/07/30 11:44:18 hirata Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pdfdoc.h,v 1.21 2007/11/14 03:36:01 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -33,6 +33,7 @@ extern void pdf_doc_set_verbose (void); extern void pdf_open_document (const char *filename, + int do_encryption, int do_objstm, double media_width, double media_height, double annot_grow_amount, int bookmark_open_depth); extern void pdf_close_document (void); diff --git a/Build/source/texk/dvipdfmx/src/pdfencoding.c b/Build/source/texk/dvipdfmx/src/pdfencoding.c index bbf8e03a280..e95486473e0 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.5 2005/07/21 08:23:46 hirata Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pdfencoding.c,v 1.6 2007/11/14 03:12:21 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -39,12 +39,9 @@ #include "pdfencoding.h" -#define _ENCODINGS_C_ -#include "asl_charset.h" -#undef _ENCODINGS_C_ - -static int is_ASL_charset (char **encoding); -static pdf_obj *make_encoding_differences (char **encoding, char **baseenc); +static int is_similar_charset (char **encoding, const char **encoding2); +static pdf_obj *make_encoding_differences (char **encoding, char **baseenc, + const char *is_used); static unsigned char verbose = 0; @@ -68,12 +65,11 @@ pdf_encoding_set_verbose (void) * IS_PREDEFINED: * Encoding is one of the MacRomanEncoding, MacExpertEncoding, and * WinAnsiEncoding. - * IS_ASL_CHARSET: - * Encoded glyphs are only form Adobe Standard Latin Character Set. - * Fonts only uses encodings of this flag set can be "nonsymbolic". + * FLAG_USED_BY_TYPE3: + * Encoding is used by a Type 3 font. */ #define FLAG_IS_PREDEFINED (1 << 0) -#define FLAG_IS_ASL_CHARSET (1 << 1) +#define FLAG_USED_BY_TYPE3 (1 << 1) typedef struct pdf_encoding { @@ -81,18 +77,21 @@ typedef struct pdf_encoding char *enc_name; int flags; - char *glyphs[256]; + char *glyphs[256]; /* ".notdef" must be represented as NULL */ char is_used[256]; + struct pdf_encoding *baseenc; pdf_obj *tounicode; - char accessible[256]; /* Flag indicating if glyphs - * are accessible in Unicode. - */ pdf_obj *resource; - pdf_obj *reference; } pdf_encoding; +static int pdf_encoding_new_encoding (const char *enc_name, + const char *ident, + const char **encoding_vec, + char *baseenc_name, + int flags); + static void pdf_init_encoding_struct (pdf_encoding *encoding) { @@ -105,45 +104,59 @@ pdf_init_encoding_struct (pdf_encoding *encoding) memset(encoding->glyphs, 0, 256*sizeof(char *)); memset(encoding->is_used, 0, 256); - memset(encoding->accessible, 0, 256); encoding->tounicode = NULL; + encoding->baseenc = NULL; encoding->resource = NULL; - encoding->reference = NULL; encoding->flags = 0; return; } +/* Creates the PDF Encoding entry for the encoding. + * If baseenc is non-null, it is used as BaseEncoding entry. + */ +static pdf_obj * +create_encoding_resource (pdf_encoding *encoding, pdf_encoding *baseenc) +{ + ASSERT(encoding); + ASSERT(!encoding->resource); + + pdf_obj *differences; + + differences = make_encoding_differences(encoding->glyphs, + baseenc ? baseenc->glyphs : NULL, + encoding->is_used); + + if (differences) { + pdf_obj *resource = pdf_new_dict(); + if (baseenc) + pdf_add_dict(resource, pdf_new_name("BaseEncoding"), + pdf_link_obj(baseenc->resource)); + 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); + } +} + static void pdf_flush_encoding (pdf_encoding *encoding) { ASSERT(encoding); - if (encoding->resource) + if (encoding->resource) { pdf_release_obj(encoding->resource); - if (encoding->reference) - pdf_release_obj(encoding->reference); + encoding->resource = NULL; + } if (encoding->tounicode) { - pdf_obj *tounicode; - - tounicode = pdf_create_ToUnicode_CMap(encoding->enc_name, - encoding->glyphs, - encoding->is_used); - if (tounicode) { - pdf_add_stream(encoding->tounicode, - pdf_stream_dataptr(tounicode), - pdf_stream_length(tounicode)); - pdf_release_obj(tounicode); - } pdf_release_obj(encoding->tounicode); encoding->tounicode = NULL; } - encoding->resource = NULL; - encoding->reference = NULL; - return; } @@ -154,8 +167,6 @@ pdf_clean_encoding_struct (pdf_encoding *encoding) ASSERT(encoding); - if (encoding->reference) - ERROR("Object not flushed."); if (encoding->resource) ERROR("Object not flushed."); @@ -180,88 +191,6 @@ pdf_clean_encoding_struct (pdf_encoding *encoding) return; } -/* - * The original dvipdfm describes as: - * - * Some software doesn't like BaseEncoding key (e.g., FastLane) - * so this code is commented out for the moment. It may reemerge in the - * future - * - * and the line for BaseEncoding is commented out. - * - * I'm not sure why this happens. But maybe BaseEncoding key causes problems - * when the font is Symbol font or TrueType font. - */ - -static void -pdf_encoding_set_encoding (pdf_encoding *encoding, - char **encoding_vec, const char *baseenc_name) -{ - char **baseenc_vec = NULL; - pdf_obj *differences; - int code; - - ASSERT(encoding); - ASSERT(encoding_vec); - - if (encoding->reference) { - WARN("Object already have a label... flushing"); - pdf_flush_encoding(encoding); - } - - encoding->flags = 0; - if (!encoding->resource) { - encoding->resource = pdf_new_dict(); - pdf_add_dict(encoding->resource, - pdf_new_name("Type"), pdf_new_name("Encoding")); - } - - for (code = 0; code < 256; code++) { - if (encoding->glyphs[code]) - RELEASE(encoding->glyphs[code]); - if (!encoding_vec[code] || - !strcmp(encoding_vec[code], ".notdef")) - encoding->glyphs[code] = NULL; - else { - encoding->glyphs[code] = NEW(strlen(encoding_vec[code])+1, char); - strcpy(encoding->glyphs[code], encoding_vec[code]); - } - } - - if (baseenc_name) { - if (!strcmp(baseenc_name, "WinAnsiEncoding")) - baseenc_vec = (char **) WinAnsiEncoding; - else if (!strcmp(baseenc_name, "MacRomanEncoding")) - baseenc_vec = (char **) MacRomanEncoding; - else if (!strcmp(baseenc_name, "MacExpertEncoding")) - baseenc_vec = (char **) MacExpertEncoding; - else - ERROR("Unknown encoding \"%s\".", baseenc_name); - } else { - baseenc_vec = NULL; - } - - if (is_ASL_charset(encoding->glyphs)) { - encoding->flags |= FLAG_IS_ASL_CHARSET; - /* Dvipdfmx default setting. */ - if (!baseenc_name) { - baseenc_vec = (char **) WinAnsiEncoding; - baseenc_name = (char *) "WinAnsiEncoding"; - } - } - - if (baseenc_name) { - pdf_add_dict(encoding->resource, - pdf_new_name("BaseEncoding"), pdf_new_name(baseenc_name)); - } - differences = make_encoding_differences(encoding->glyphs, baseenc_vec); - if (differences) { - pdf_add_dict(encoding->resource, pdf_new_name("Differences"), differences); - } - - return; -} - static int CDECL glycmp (const void *pv1, const void *pv2) { @@ -274,23 +203,25 @@ glycmp (const void *pv1, const void *pv2) } static int -is_ASL_charset (char **enc_vec) +is_similar_charset (char **enc_vec, const char **enc_vec2) { - int code; + int code, same = 0; - for (code = 0; code < 256; code++) { - if (enc_vec[code] && strcmp(enc_vec[code], ".notdef")) { - if (!bsearch(enc_vec[code], - ASL_Charset, ASL_CHARSET_MAX, sizeof(char *), glycmp)) - return 0; - } - } + for (code = 0; code < 256; code++) + if (!(enc_vec[code] && strcmp(enc_vec[code], enc_vec2[code])) + && ++same >= 64) + /* is 64 a good level? */ + return 1; - return 1; + return 0; } +/* Creates a PDF Differences array for the encoding, based on the + * base encoding baseenc (if not NULL). Only character codes which + * are actually used in the document are considered. + */ static pdf_obj * -make_encoding_differences (char **enc_vec, char **baseenc) +make_encoding_differences (char **enc_vec, char **baseenc, const char *is_used) { pdf_obj *differences = NULL; int code, count = 0; @@ -300,13 +231,14 @@ make_encoding_differences (char **enc_vec, char **baseenc) /* * Write all entries (except .notdef) if baseenc is unknown. + * If is_used is given, write only used entries. */ differences = pdf_new_array(); for (code = 0; code < 256; code++) { - /* We skip ".notdef". Any character code mapped to ".notdef" + /* We skip NULL (= ".notdef"). Any character code mapped to ".notdef" * glyph should not be used in the document. */ - if (!enc_vec[code] || !strcmp(".notdef", enc_vec[code])) + if ((is_used && !is_used[code]) || !enc_vec[code]) skipping = 1; else if (!baseenc || !baseenc[code] || strcmp(baseenc[code], enc_vec[code]) != 0) { @@ -335,17 +267,22 @@ make_encoding_differences (char **enc_vec, char **baseenc) } static int -load_encoding_file (pdf_encoding *encoding, const char *filename) +load_encoding_file (const char *filename) { FILE *fp; + pdf_obj *enc_name = NULL; pdf_obj *encoding_array = NULL; char *wbuf, *p, *endptr; char *enc_vec[256]; - int code, fsize; + int code, fsize, enc_id; - if (!encoding || !filename) + if (!filename) return -1; + if (verbose) { + MESG("(Encoding:%s", filename); + } + fp = DPXFOPEN(filename, DPX_RES_TYPE_ENC); if (!fp) return -1; @@ -372,30 +309,34 @@ load_encoding_file (pdf_encoding *encoding, const char *filename) skip_line (&p, endptr); skip_white(&p, endptr); } - if (p[0] == '/') { - pdf_obj *tmp; - - tmp = parse_pdf_name(&p, endptr); - - encoding->enc_name = NEW(strlen(pdf_name_value(tmp))+1, char); - strcpy(encoding->enc_name, pdf_name_value(tmp)); - pdf_release_obj(tmp); - } + if (p[0] == '/') + enc_name = parse_pdf_name(&p, endptr); skip_white(&p, endptr); encoding_array = parse_pdf_array(&p, endptr); RELEASE(wbuf); if (!encoding_array) { + if (enc_name) + pdf_release_obj(enc_name); return -1; } for (code = 0; code < 256; code++) { enc_vec[code] = pdf_name_value(pdf_get_array(encoding_array, code)); } - pdf_encoding_set_encoding(encoding, enc_vec, NULL); + enc_id = pdf_encoding_new_encoding(enc_name ? pdf_name_value(enc_name) : NULL, + filename, (const char **) enc_vec, NULL, 0); + + if (enc_name) { + if (verbose > 1) + MESG("[%s]", pdf_name_value(enc_name)); + pdf_release_obj(enc_name); + } pdf_release_obj(encoding_array); - return 0; + if (verbose) MESG(")"); + + return enc_id; } #define CHECK_ID(n) do { \ @@ -427,63 +368,111 @@ pdf_init_encodings (void) /* * PDF Predefined Encodings */ - encoding = &enc_cache.encodings[0]; - pdf_init_encoding_struct(encoding); - encoding->ident = NEW(strlen("WinAnsiEncoding")+1, char); - strcpy(encoding->ident, "WinAnsiEncoding"); - encoding->enc_name = NEW(strlen("WinAnsiEncoding")+1, char); - strcpy(encoding->enc_name, "WinAnsiEncoding"); - encoding->flags = (FLAG_IS_PREDEFINED|FLAG_IS_ASL_CHARSET); - encoding->resource = pdf_new_name("WinAnsiEncoding"); - for (code = 0; code < 256; code++) { - if (!WinAnsiEncoding[code] || - !strcmp(WinAnsiEncoding[code], ".notdef")) - encoding->glyphs[code] = NULL; - else { - encoding->glyphs[code] = NEW(strlen(WinAnsiEncoding[code])+1, char); - strcpy(encoding->glyphs[code], WinAnsiEncoding[code]); - } + pdf_encoding_new_encoding("WinAnsiEncoding", "WinAnsiEncoding", + WinAnsiEncoding, NULL, FLAG_IS_PREDEFINED); + pdf_encoding_new_encoding("MacRomanEncoding", "MacRomanEncoding", + MacRomanEncoding, NULL, FLAG_IS_PREDEFINED); + pdf_encoding_new_encoding("MacExpertEncoding", "MacExpertEncoding", + MacExpertEncoding, NULL, FLAG_IS_PREDEFINED); + + return; +} + +/* + * The original dvipdfm describes as: + * + * Some software doesn't like BaseEncoding key (e.g., FastLane) + * so this code is commented out for the moment. It may reemerge in the + * future + * + * and the line for BaseEncoding is commented out. + * + * I'm not sure why this happens. But maybe BaseEncoding key causes problems + * when the font is Symbol font or TrueType font. + */ + +static int +pdf_encoding_new_encoding (const char *enc_name, const char *ident, + const char **encoding_vec, + char *baseenc_name, int flags) +{ + char **baseenc_vec = NULL; + pdf_obj *differences; + int enc_id, code; + + pdf_encoding *encoding; + + enc_id = enc_cache.count; + if (enc_cache.count++ >= enc_cache.capacity) { + enc_cache.capacity += 16; + enc_cache.encodings = RENEW(enc_cache.encodings, + enc_cache.capacity, pdf_encoding); } + encoding = &enc_cache.encodings[enc_id]; - encoding = &enc_cache.encodings[1]; pdf_init_encoding_struct(encoding); - encoding->ident = NEW(strlen("MacRomanEncoding")+1, char); - strcpy(encoding->ident, "MacRomanEncoding"); - encoding->enc_name = NEW(strlen("MacRomanEncoding")+1, char); - strcpy(encoding->enc_name, "MacRomanEncoding"); - encoding->flags = (FLAG_IS_PREDEFINED|FLAG_IS_ASL_CHARSET); - encoding->resource = pdf_new_name("MacRomanEncoding"); - for (code = 0; code < 256; code++) { - if (!MacRomanEncoding[code] || - !strcmp(MacRomanEncoding[code], ".notdef")) - encoding->glyphs[code] = NULL; - else { - encoding->glyphs[code] = NEW(strlen(MacRomanEncoding[code])+1, char); - strcpy(encoding->glyphs[code], MacRomanEncoding[code]); + + encoding->ident = NEW(strlen(ident)+1, char); + strcpy(encoding->ident, ident); + encoding->enc_name = NEW(strlen(enc_name)+1, char); + strcpy(encoding->enc_name, enc_name); + + encoding->flags = flags; + + for (code = 0; code < 256; code++) + if (encoding_vec[code] && strcmp(encoding_vec[code], ".notdef")) { + encoding->glyphs[code] = NEW(strlen(encoding_vec[code])+1, char); + strcpy(encoding->glyphs[code], encoding_vec[code]); } + + if (!baseenc_name && !(flags & FLAG_IS_PREDEFINED) + && is_similar_charset(encoding->glyphs, WinAnsiEncoding)) { + /* Dvipdfmx default setting. */ + baseenc_name = "WinAnsiEncoding"; } - encoding = &enc_cache.encodings[2]; - pdf_init_encoding_struct(encoding); - encoding->ident = NEW(strlen("MacExpertEncoding")+1, char); - strcpy(encoding->ident, "MacExpertEncoding"); - encoding->enc_name = NEW(strlen("MacExpertEncoding")+1, char); - strcpy(encoding->enc_name, "MacExpertEncoding"); - encoding->flags = FLAG_IS_PREDEFINED; - encoding->resource = pdf_new_name("MacExpertEncoding"); - for (code = 0; code < 256; code++) { - if (!MacExpertEncoding[code] || - !strcmp(MacExpertEncoding[code], ".notdef")) - encoding->glyphs[code] = NULL; - else { - encoding->glyphs[code] = NEW(strlen(MacExpertEncoding[code])+1, char); - strcpy(encoding->glyphs[code], MacExpertEncoding[code]); - } + /* TODO: make base encoding configurable */ + if (baseenc_name) { + int baseenc_id = pdf_encoding_findresource(baseenc_name); + if (baseenc_id < 0 || !pdf_encoding_is_predefined(baseenc_id)) + ERROR("Illegal base encoding %s for encoding %s\n", + baseenc_name, encoding->enc_name); + encoding->baseenc = &enc_cache.encodings[baseenc_id]; } - enc_cache.count = 3; + if (flags & FLAG_IS_PREDEFINED) + encoding->resource = pdf_new_name(encoding->enc_name); - return; + return enc_id; +} + +/* Creates Encoding resource and ToUnicode CMap + * for all non-predefined encodings. + */ +void pdf_encoding_complete () +{ + int enc_id; + + for (enc_id = 0; enc_id < enc_cache.count; enc_id++) { + if (!pdf_encoding_is_predefined(enc_id)) { + pdf_encoding *encoding = &enc_cache.encodings[enc_id]; + /* Section 5.5.4 of the PDF 1.5 reference says that the encoding + * of a Type 3 font must be completely described by a Differences + * array, but implementation note 56 explains that this is rather + * an incorrect implementation in Acrobat 4 and earlier. Hence, + * we do use a base encodings for PDF versions >= 1.3. + */ + int with_base = !(encoding->flags & FLAG_USED_BY_TYPE3) + || pdf_get_version() >= 4; + ASSERT(!encoding->resource); + encoding->resource = create_encoding_resource(encoding, + with_base ? encoding->baseenc : NULL); + ASSERT(!encoding->tounicode); + encoding->tounicode = pdf_create_ToUnicode_CMap(encoding->enc_name, + encoding->glyphs, + encoding->is_used); + } + } } void @@ -509,7 +498,7 @@ pdf_close_encodings (void) } int -pdf_encoding_findresource (const char *enc_name) +pdf_encoding_findresource (char *enc_name) { int enc_id; pdf_encoding *encoding; @@ -525,37 +514,7 @@ pdf_encoding_findresource (const char *enc_name) return enc_id; } - if (verbose) { - MESG("(Encoding:%s", enc_name); - } - - enc_id = enc_cache.count; - if (enc_cache.count >= enc_cache.capacity) { - enc_cache.capacity += 16; - enc_cache.encodings = RENEW(enc_cache.encodings, - enc_cache.capacity, pdf_encoding); - } - encoding = &enc_cache.encodings[enc_id]; - - pdf_init_encoding_struct(encoding); - encoding->ident = NEW(strlen(enc_name)+1, char); - strcpy(encoding->ident, enc_name); - if (load_encoding_file(encoding, enc_name) < 0) { - pdf_clean_encoding_struct(encoding); - return -1; - } - - if (verbose > 1) { - if (encoding->enc_name) { - MESG("[%s]", encoding->enc_name); - } - } - - if (verbose) MESG(")"); - - enc_cache.count++; - - return enc_id; + return load_encoding_file(enc_name); } @@ -576,7 +535,7 @@ pdf_encoding_get_encoding (int enc_id) } pdf_obj * -pdf_get_encoding_reference (int enc_id) +pdf_get_encoding_obj (int enc_id) { pdf_encoding *encoding; @@ -584,10 +543,7 @@ pdf_get_encoding_reference (int enc_id) encoding = &enc_cache.encodings[enc_id]; - if (!encoding->reference) - encoding->reference = pdf_ref_obj(encoding->resource); - - return pdf_link_obj(encoding->reference); + return encoding->resource; } int @@ -602,8 +558,8 @@ pdf_encoding_is_predefined (int enc_id) return (encoding->flags & FLAG_IS_PREDEFINED) ? 1 : 0; } -int -pdf_encoding_is_ASL_charset (int enc_id) +void +pdf_encoding_used_by_type3 (int enc_id) { pdf_encoding *encoding; @@ -611,9 +567,10 @@ pdf_encoding_is_ASL_charset (int enc_id) encoding = &enc_cache.encodings[enc_id]; - return (encoding->flags & FLAG_IS_ASL_CHARSET) ? 1 : 0; + encoding->flags |= FLAG_USED_BY_TYPE3; } + char * pdf_encoding_get_name (int enc_id) { @@ -640,110 +597,49 @@ static unsigned char wbuf[WBUF_SIZE]; static unsigned char range_min[1] = {0x00u}; static unsigned char range_max[1] = {0xFFu}; -#define UNICODE_ACCESSIBLE 1 -#define UNICODE_INACCESSIBLE -1 -#define UNICODE_UNKNOWN 0 - -static int -check_unicode_mappable (pdf_encoding *encoding, char *is_used) -{ - int code; - int glyph_count, total_fail_count; - - glyph_count = total_fail_count = 0; - for (code = 0; code <= 0xff; code++) { - if (is_used && !is_used[code]) - continue; - - switch (encoding->accessible[code]) { - case UNICODE_ACCESSIBLE: - break; - case UNICODE_INACCESSIBLE: - total_fail_count++; - break; - default: /* Unknown */ - if (!encoding->glyphs[code] || - !strcmp(encoding->glyphs[code], ".notdef")) - encoding->accessible[code] = UNICODE_INACCESSIBLE; - else { - long len; - int fail_count = 0; - unsigned char *p, *endptr; - - p = wbuf; - endptr = wbuf + WBUF_SIZE; - len = agl_sput_UTF16BE(encoding->glyphs[code], - &p, endptr, &fail_count); - if (len < 1 || fail_count > 0) { - total_fail_count++; - encoding->accessible[code] = UNICODE_INACCESSIBLE; - } else { - encoding->accessible[code] = UNICODE_ACCESSIBLE; - } - } - } - glyph_count++; - } - - if (glyph_count < 1) - return 0; - - return (int) (100.0 * total_fail_count / glyph_count + 0.5); -} - -int -pdf_attach_ToUnicode_CMap (pdf_obj *fontdict, - int encoding_id, char *is_used) +void +pdf_encoding_add_usedchars (int encoding_id, const char *is_used) { pdf_encoding *encoding; - int inaccessibles, code; - - ASSERT(fontdict); + int code; CHECK_ID(encoding_id); - if (pdf_encoding_is_predefined(encoding_id)) { - return 0; - } + if (!is_used || pdf_encoding_is_predefined(encoding_id)) + return; encoding = &enc_cache.encodings[encoding_id]; - - inaccessibles = check_unicode_mappable(encoding, is_used); - if (inaccessibles > 10) { /* 10 % */ - if (verbose) { - WARN("%d%% of glyph in font (encoding: %s) could not converted to Unicode.", - inaccessibles, encoding->enc_name); - WARN("ToUnicode CMap not attached for this font."); - } - return -1; - } - - for (code = 0; code <= 0xff; code++) { - if (is_used && !is_used[code]) - continue; - encoding->is_used[code] = 1; - } - if (!encoding->tounicode) { - encoding->tounicode = pdf_new_stream(STREAM_COMPRESS); - } + for (code = 0; code <= 0xff; code++) + encoding->is_used[code] |= is_used[code]; +} - pdf_add_dict(fontdict, - pdf_new_name("ToUnicode"), - pdf_ref_obj(encoding->tounicode)); +pdf_obj * +pdf_encoding_get_tounicode (int encoding_id) +{ + CHECK_ID(encoding_id); - return 0; + return enc_cache.encodings[encoding_id].tounicode; } - +/* Creates a ToUnicode CMap. An empty CMap is replaced by NULL. + * + * For PDF <= 1.4 a complete CMap is created unless all character codes + * are predefined in PDF. For PDF >= 1.5 only those character codes which + * are not predefined appear in the CMap. + * + * Note: The PDF 1.4 reference is not consistent: Section 5.9 describes + * the Unicode mapping of PDF 1.3 and Section 9.7.2 (in the context of + * Tagged PDF) the one of PDF 1.5. + */ pdf_obj * pdf_create_ToUnicode_CMap (const char *enc_name, - char **enc_vec, char *is_used) + char **enc_vec, const char *is_used) { pdf_obj *stream; CMap *cmap; - int code, glyph_count, total_fail_count; + int code, all_predef; char *cmap_name; unsigned char *p, *endptr; @@ -761,38 +657,33 @@ pdf_create_ToUnicode_CMap (const char *enc_name, CMap_add_codespacerange(cmap, range_min, range_max, 1); - glyph_count = total_fail_count = 0; + all_predef = 1; for (code = 0; code <= 0xff; code++) { if (is_used && !is_used[code]) continue; - if (enc_vec[code] && strcmp(enc_vec[code], ".notdef")) { + if (enc_vec[code]) { long len; int fail_count = 0; - - wbuf[0] = (code & 0xff); - p = wbuf + 1; - endptr = wbuf + WBUF_SIZE; - len = agl_sput_UTF16BE(enc_vec[code], &p, endptr, &fail_count); - if (len < 1 || fail_count > 0) { - total_fail_count++; - } else { - CMap_add_bfchar(cmap, wbuf, 1, wbuf + 1, len); + agl_name *agln = agl_lookup_list(enc_vec[code]); + /* Adobe glyph naming conventions are not used by viewers, + * hence even ligatures (e.g, "f_i") must be explicitly defined + */ + if (pdf_get_version() < 5 || !agln || !agln->is_predef) { + wbuf[0] = (code & 0xff); + p = wbuf + 1; + endptr = wbuf + WBUF_SIZE; + len = agl_sput_UTF16BE(enc_vec[code], &p, endptr, &fail_count); + if (len >= 1 && !fail_count) { + CMap_add_bfchar(cmap, wbuf, 1, wbuf + 1, len); + all_predef &= agln && agln->is_predef; + } } - glyph_count++; } } - if (total_fail_count < (glyph_count + 9) / 10) { - stream = CMap_create_stream(cmap, 0); - } else { - if (verbose) { - WARN("%d (out of %d) glyphs in encoding \"%s\" missing Unicode mapping...", - total_fail_count, glyph_count, enc_name); - WARN("ToUnicode CMap \"%s\" removed.", cmap_name); - } - stream = NULL; - } + stream = all_predef ? NULL : CMap_create_stream(cmap, 0); + CMap_release(cmap); RELEASE(cmap_name); diff --git a/Build/source/texk/dvipdfmx/src/pdfencoding.h b/Build/source/texk/dvipdfmx/src/pdfencoding.h index 05ac38d2e22..fdfbe7b6923 100644 --- a/Build/source/texk/dvipdfmx/src/pdfencoding.h +++ b/Build/source/texk/dvipdfmx/src/pdfencoding.h @@ -1,8 +1,8 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/pdfencoding.h,v 1.3 2005/06/08 11:18:37 hirata Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pdfencoding.h,v 1.4 2007/11/14 03:12:21 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -32,17 +32,22 @@ extern void pdf_encoding_set_verbose (void); extern void pdf_init_encodings (void); extern void pdf_close_encodings (void); +/* Creates Encoding resource and ToUnicode CMap + * for all non-predefined encodings. + */ +extern void pdf_encoding_complete (void); + /* enc_name here is .enc file name or the name of predefined * encodings. */ -extern int pdf_encoding_findresource (const char *enc_name); +extern int pdf_encoding_findresource (char *enc_name); -/* Returns indirect reference to Encoding resource. +/* Returns the Encoding resource object. */ -extern pdf_obj *pdf_get_encoding_reference (int enc_id); +extern pdf_obj *pdf_get_encoding_obj (int enc_id); -extern int pdf_encoding_is_ASL_charset (int enc_id); extern int pdf_encoding_is_predefined (int enc_id); +extern void pdf_encoding_used_by_type3 (int enc_id); /* WARNING: * Pointer(s) may change after another encoding is loaded. @@ -51,29 +56,21 @@ extern char *pdf_encoding_get_name (int enc_id); extern char **pdf_encoding_get_encoding (int enc_id); /* - * The last argument "is_used" is 256 char array, value 0 - * indicates glyph in that slot is not used in the document - * (at least for that font). We need this to handle the - * situation that the encoding contains, e.g., 30 rarely - * used glyphs without Unicode mapping and 200+ glyphs with - * Unicode mapping. * pdf_create_ToUnicode_CMap() returns stream object but not * reference. This need to be renamed to other name like * pdf_create_ToUnicode_stream(). */ extern pdf_obj *pdf_create_ToUnicode_CMap (const char *enc_name, - char **enc_vec, char *is_used); - -/* Add /ToUnicode entry with indirect reference to ToUnicode stream - * to font dictionary "fontdict". This creates an empty stream object - * if it has not already created. Generation of actual ToUnicode CMap - * data is delayed until pdf_close_encodings(). This also check if - * glyphs can be converted to (a sequence of) Unicode and returns -1 - * if more than 10% of glyphs can't be converted. ToUnicode CMap is - * not attached in that case. + char **enc_vec, + const char *is_used); + +/* pdf_encoding_copy_usedchars adds the given vector of used characters + * to the corresponding vector of the encoding. */ -extern int pdf_attach_ToUnicode_CMap (pdf_obj *fontdict, - int encoding_id, char *is_used); +extern void pdf_encoding_add_usedchars (int encoding_id, + const char *is_used); + +extern pdf_obj * pdf_encoding_get_tounicode (int encoding_id); /* Just load CMap identified with 'ident'. (parsed) * PDF stream object (not reference) returned. diff --git a/Build/source/texk/dvipdfmx/src/pdfencrypt.c b/Build/source/texk/dvipdfmx/src/pdfencrypt.c index dc9b8efde20..677febc3d5c 100644 --- a/Build/source/texk/dvipdfmx/src/pdfencrypt.c +++ b/Build/source/texk/dvipdfmx/src/pdfencrypt.c @@ -1,8 +1,8 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/pdfencrypt.c,v 1.8 2005/07/20 08:49:55 chofchof Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pdfencrypt.c,v 1.9 2007/04/03 05:25:50 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> This program is free software; you can redistribute it and/or modify @@ -71,7 +71,6 @@ static const unsigned char padding_string[MAX_STR_LEN] = { static char owner_passwd[MAX_PWD_LEN], user_passwd[MAX_PWD_LEN]; -static unsigned char do_encryption = 0; static unsigned char verbose = 0; void pdf_enc_set_verbose (void) @@ -379,7 +378,6 @@ void pdf_enc_set_passwd (unsigned bits, unsigned perm, char *dviname, char *pdfn fflush(stderr); } - do_encryption = 1; key_size = (unsigned char)(bits / 8); algorithm = (key_size == 5 ? 1 : 2); permission = (unsigned long)perm | 0x000000C0; @@ -396,8 +394,6 @@ void pdf_encrypt_data (unsigned char *data, unsigned long len) { unsigned char *result; - if (!do_encryption) return; - memcpy(in_buf, key_data, key_size); in_buf[key_size] = (unsigned char)(current_label) & 0xFF; in_buf[key_size+1] = (unsigned char)(current_label >> 8) & 0xFF; @@ -416,20 +412,15 @@ void pdf_encrypt_data (unsigned char *data, unsigned long len) RELEASE (result); } -void create_encrypt (void) +pdf_obj *pdf_encrypt_obj (void) { pdf_obj *doc_encrypt; - if (!do_encryption) return; - #ifdef DEBUG - fprintf (stderr, "(create_encrypt)"); + fprintf (stderr, "(pdf_encrypt_obj)"); #endif - /* Create an empty Encryption entry and make it - be the root object */ doc_encrypt = pdf_new_dict (); - pdf_set_encrypt (doc_encrypt); /* KEY : Filter * TYPE : name @@ -509,20 +500,15 @@ void create_encrypt (void) pdf_new_name ("P"), pdf_new_number (permission)); - do_encryption = 0; - pdf_release_obj (doc_encrypt); - do_encryption = 1; + return doc_encrypt; } -unsigned char *pdf_enc_id_string (void) +pdf_obj *pdf_enc_id_array (void) { - register int i; - static unsigned char result[MAX_STR_LEN+1]; - - for (i = 0; i < MAX_KEY_LEN; i++) - sprintf((char *)(result+2*i), "%02x", id_string[i]); - - return result; + pdf_obj *id = pdf_new_array(); + pdf_add_array(id, pdf_new_string(id_string, MAX_KEY_LEN)); + pdf_add_array(id, pdf_new_string(id_string, MAX_KEY_LEN)); + return id; } void pdf_enc_set_label (unsigned long label) diff --git a/Build/source/texk/dvipdfmx/src/pdfencrypt.h b/Build/source/texk/dvipdfmx/src/pdfencrypt.h index daaa6f52bcc..b0c9a429223 100644 --- a/Build/source/texk/dvipdfmx/src/pdfencrypt.h +++ b/Build/source/texk/dvipdfmx/src/pdfencrypt.h @@ -1,8 +1,8 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/pdfencrypt.h,v 1.2 2002/10/30 02:27:13 chofchof Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pdfencrypt.h,v 1.3 2007/04/03 05:25:50 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> This program is free software; you can redistribute it and/or modify @@ -23,13 +23,14 @@ #ifndef _PDFENCRYPT_H_ #define _PDFENCRYPT_H_ +#include "pdfobj.h" + extern void pdf_enc_set_verbose (void); -extern unsigned char *pdf_enc_id_string (void); -extern void pdf_enc_set_encryption (void); +extern pdf_obj *pdf_enc_id_array (void); extern void pdf_enc_set_label (unsigned long label); extern void pdf_enc_set_generation (unsigned generation); extern void pdf_enc_set_passwd (unsigned size, unsigned perm, char *dviname, char *pdfname); extern void pdf_encrypt_data (unsigned char *data, unsigned long len); -extern void create_encrypt (void); +extern pdf_obj *pdf_encrypt_obj (void); #endif /* _PDFENCRYPT_H_ */ diff --git a/Build/source/texk/dvipdfmx/src/pdffont.c b/Build/source/texk/dvipdfmx/src/pdffont.c index 086b9c990ae..d011e59da9a 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.15 2005/07/20 10:41:54 hirata Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pdffont.c,v 1.17 2007/11/15 17:08:52 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -484,12 +484,15 @@ pdf_close_fonts (void) case PDF_FONT_FONTTYPE_TYPE1: if (__verbose) MESG("[Type1]"); - retval = pdf_font_load_type1 (font); + if (!pdf_font_get_flag(font, PDF_FONT_FLAG_BASEFONT)) + retval = pdf_font_load_type1(font); + else + retval = 0; break; case PDF_FONT_FONTTYPE_TYPE1C: if (__verbose) MESG("[Type1C]"); - retval = pdf_font_load_type1c (font); + retval = pdf_font_load_type1c(font); break; case PDF_FONT_FONTTYPE_TRUETYPE: if (__verbose) @@ -508,10 +511,41 @@ pdf_close_fonts (void) break; } + if (font->encoding_id >= 0 && font->subtype != PDF_FONT_FONTTYPE_TYPE0) + pdf_encoding_add_usedchars(font->encoding_id, font->usedchars); + if (__verbose) { if (font->subtype != PDF_FONT_FONTTYPE_TYPE0) MESG(")"); } + } + + pdf_encoding_complete(); + + for (font_id = 0; font_id < font_cache.count; font_id++) { + pdf_font *font = GET_FONT(font_id); + + if (font->encoding_id >= 0 && font->subtype != PDF_FONT_FONTTYPE_TYPE0) { + pdf_obj *enc_obj = pdf_get_encoding_obj(font->encoding_id); + pdf_obj *tounicode; + + /* 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 (!pdf_lookup_dict(font->resource, "ToUnicode") + && (tounicode = pdf_encoding_get_tounicode(font->encoding_id))) + pdf_add_dict(font->resource, + pdf_new_name("ToUnicode"), pdf_ref_obj(tounicode)); + } else if (font->subtype == PDF_FONT_FONTTYPE_TRUETYPE) { + /* encoding_id < 0 means MacRoman here (but not really) + * We use MacRoman as "default" encoding. */ + pdf_add_dict(font->resource, + pdf_new_name("Encoding"), + pdf_new_name("MacRomanEncoding")); + } pdf_flush_font(font); pdf_clean_font_struct(font); @@ -661,6 +695,9 @@ pdf_font_findresource (const char *tex_name, case PDF_FONT_FONTTYPE_TRUETYPE: /* fontname here is font file name. * We must compare both font file name and encoding + * + * TODO: Embed a font only once if it is used + * with two different encodings */ if (!strcmp(fontname, font->ident) && encoding_id == font->encoding_id) { @@ -670,7 +707,9 @@ pdf_font_findresource (const char *tex_name, case PDF_FONT_FONTTYPE_TYPE3: /* There shouldn't be any encoding specified for PK font. * It must be always font's build-in encoding. - */ + * + * TODO: a PK font with two encodings makes no sense. Change? + */ if (!strcmp(fontname, font->ident) && font_scale == font->point_size) { found = 1; diff --git a/Build/source/texk/dvipdfmx/src/pdfobj.c b/Build/source/texk/dvipdfmx/src/pdfobj.c index 39445ba875a..645295ebb12 100644 --- a/Build/source/texk/dvipdfmx/src/pdfobj.c +++ b/Build/source/texk/dvipdfmx/src/pdfobj.c @@ -1,8 +1,8 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/pdfobj.c,v 1.40 2006/12/06 13:14:54 chofchof Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pdfobj.c,v 1.47 2007/11/14 03:36:01 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -42,11 +42,19 @@ #endif /* HAVE_ZLIB */ #include "pdfobj.h" +#include "pdfdev.h" #define STREAM_ALLOC_SIZE 4096u #define ARRAY_ALLOC_SIZE 256 #define IND_OBJECTS_ALLOC_SIZE 512 +#define OBJ_NO_OBJSTM (1 << 0) +/* Objects with this flag will not be put into an object stream. + For instance, all stream objects have this flag set. */ +#define OBJ_NO_ENCRYPT (1 << 1) +/* Objects with this flag will not be encrypted. + This implies OBJ_NO_OBJSTM if encryption is turned on. */ + /* Any of these types can be represented as follows */ struct pdf_obj { @@ -56,6 +64,7 @@ struct pdf_obj all other "label" to zero */ unsigned short generation; /* Only used if "label" is used */ unsigned refcount; /* Number of links to this object */ + int flags; void *data; }; @@ -105,8 +114,8 @@ struct pdf_stream struct pdf_indirect { - unsigned label; - unsigned generation; + 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 @@ -136,19 +145,35 @@ static char format_buffer[FORMAT_BUF_SIZE]; static struct xref_entry { - long file_position; - pdf_obj *object; - int used; /* Used by PDF import */ -} *output_xref = NULL; + unsigned char type; + unsigned long field2; + unsigned short field3; + int used; /* Used by PDF import */ +} *output_xref; -static unsigned long pdf_max_ind_objects = 0; -static unsigned long next_label = 1; +static unsigned long pdf_max_ind_objects; +static unsigned long next_label; static unsigned long startxref; -static unsigned pdf_root_obj = 0; -static unsigned pdf_info_obj = 0; -static unsigned pdf_encrypt_obj = 0; +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; + +static pdf_obj *trailer_dict; +static pdf_obj *xref_stream; /* Internal static routines */ @@ -156,6 +181,8 @@ 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 pdf_out_char (FILE *file, char c); static void pdf_out (FILE *file, const void *buffer, long length); @@ -186,8 +213,8 @@ 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 obj_gen); -static pdf_obj *pdf_read_object (unsigned long obj_num, unsigned obj_gen); +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; @@ -212,7 +239,7 @@ pdf_set_compression (int level) return; } -static unsigned pdf_version = 3; +static unsigned pdf_version = 4; void pdf_set_version (unsigned version) @@ -235,12 +262,60 @@ 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 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[label].type = type; + output_xref[label].field2 = field2; + output_xref[label].field3 = field3; +} + #define BINARY_MARKER "%\344\360\355\370\n" void -pdf_out_init (const char *filename) +pdf_out_init (const char *filename, int do_encryption) { char v; + output_xref = NULL; + pdf_max_ind_objects = 0; + add_xref_entry(0, 0, 0, 0xffff); + next_label = 1; + + if (pdf_version >= 5) { + xref_stream = pdf_new_stream(STREAM_COMPRESS); + 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 + trailer_dict = pdf_new_dict(); + + output_stream = NULL; + pdf_output_file = MFOPEN(filename, FOPEN_WBIN_MODE); if (!pdf_output_file) { if (strlen(filename) < 128) @@ -253,94 +328,134 @@ pdf_out_init (const char *filename) pdf_out(pdf_output_file, &v, 1); pdf_out(pdf_output_file, "\n", 1); pdf_out(pdf_output_file, BINARY_MARKER, strlen(BINARY_MARKER)); + + enc_mode = 0; + doc_enc_mode = do_encryption; } static void -dump_xref (void) +dump_xref_table (void) { long length; unsigned long i; - /* Record where this xref is for trailer */ - startxref = pdf_output_file_position; - pdf_out(pdf_output_file, "xref\n", 5); length = sprintf(format_buffer, "%d %lu\n", 0, next_label); pdf_out(pdf_output_file, format_buffer, length); - length = sprintf(format_buffer, "%010ld %05ld f \n", 0L, 65535L); /* * Every space counts. The space after the 'f' and 'n' is * *essential*. * The PDF spec says the lines must be 20 characters long including the * end of line character. */ - pdf_out(pdf_output_file, format_buffer, length); - for (i = 1; i < next_label; i++){ - length = sprintf(format_buffer, "%010ld %05ld n \n", - output_xref[i-1].file_position, 0L); + for (i = 0; i < next_label; i++) { + unsigned char type = output_xref[i].type; + if (type > 1) + ERROR("object type %hu not allowed in xref table", type); + length = sprintf(format_buffer, "%010lu %05hu %c \n", + output_xref[i].field2, output_xref[i].field3, + type ? 'n' : 'f'); pdf_out(pdf_output_file, format_buffer, length); } - /* Done with xref table */ - RELEASE(output_xref); - output_xref = NULL; } static void -dump_trailer (void) +dump_trailer_dict (void) { - long length; - unsigned long starttrailer; - - starttrailer = pdf_output_file_position; - pdf_out(pdf_output_file, "trailer\n", 8); - pdf_out(pdf_output_file, "<<\n", 3); - - length = sprintf(format_buffer, "/Size %lu\n", next_label); - pdf_out(pdf_output_file, format_buffer, length); - - if (pdf_root_obj == 0) - ERROR ("dump_trailer: Invalid root object"); - length = sprintf(format_buffer, "/Root %u %u R\n", pdf_root_obj, 0); - pdf_out(pdf_output_file, format_buffer, length); + enc_mode = 0; + write_dict(trailer_dict->data, pdf_output_file); + pdf_release_obj(trailer_dict); + pdf_out_char(pdf_output_file, '\n'); +} - if (pdf_encrypt_obj != 0) { - length = sprintf(format_buffer, "/Encrypt %u %u R\n", pdf_encrypt_obj, 0); - pdf_out(pdf_output_file, format_buffer, length); - } - if (pdf_info_obj != 0) { - length = sprintf(format_buffer, "/Info %u %u R\n", pdf_info_obj, 0); - pdf_out(pdf_output_file, format_buffer, length); - } - if (pdf_encrypt_obj != 0) { - unsigned char *id; - id = pdf_enc_id_string(); - length = sprintf(format_buffer, "/ID [<%s> <%s>]\n", id, id); - pdf_out(pdf_output_file, format_buffer, length); +/* + * output a PDF 1.5 cross-reference stream; + * contributed by Matthias Franz (March 21, 2007) + */ +static void +dump_xref_stream (void) +{ + unsigned long pos, i; + unsigned poslen; + unsigned char buf[7] = {0, 0, 0, 0, 0}; + + pdf_obj *w; + + pdf_label_obj(xref_stream); + + /* determine the necessary size of the offset field */ + pos = startxref; /* maximal offset value */ + poslen = 1; + while (pos >>= 8) + poslen++; + + w = pdf_new_array(); + pdf_add_array(w, pdf_new_number(1)); /* type */ + pdf_add_array(w, pdf_new_number(poslen)); /* offset (big-endian) */ + pdf_add_array(w, pdf_new_number(2)); /* generation */ + pdf_add_dict(trailer_dict, pdf_new_name("W"), w); + + /* We need the xref entry for the xref stream right now */ + add_xref_entry(next_label-1, 1, startxref, 0); + + for (i = 0; i < next_label; i++) { + unsigned j; + buf[0] = output_xref[i].type; + pos = output_xref[i].field2; + for (j = poslen; j--; ) { + buf[1+j] = (unsigned char) pos; + pos >>= 8; + } + unsigned short f3 = output_xref[i].field3; + buf[poslen+1] = (unsigned char) (f3 >> 8); + buf[poslen+2] = (unsigned char) (f3); + pdf_add_stream(xref_stream, &buf, poslen+3); } - pdf_out(pdf_output_file, ">>\n", 3); - pdf_out(pdf_output_file, "startxref\n", 10); - - length = sprintf(format_buffer, "%lu\n", startxref); - pdf_out(pdf_output_file, format_buffer, length); - pdf_out(pdf_output_file, "%%EOF\n", 6); + pdf_release_obj(xref_stream); } void pdf_out_flush (void) { if (pdf_output_file) { - dump_xref(); - dump_trailer(); + long length; + + /* Flush current object stream */ + if (current_objstm && current_objstm->pos) + pdf_flush_objstm(current_objstm); + + /* Record where this xref is for trailer */ + startxref = pdf_output_file_position; + + pdf_add_dict(trailer_dict, pdf_new_name("Size"), + pdf_new_number(next_label)); + + if (pdf_version >= 5) + dump_xref_stream(); + else { + dump_xref_table(); + dump_trailer_dict(); + } + + /* Done with xref table */ + RELEASE(output_xref); + + pdf_out(pdf_output_file, "startxref\n", 10); + length = sprintf(format_buffer, "%lu\n", startxref); + pdf_out(pdf_output_file, format_buffer, length); + pdf_out(pdf_output_file, "%%EOF\n", 6); + MESG("\n"); if (verbose) { if (compression_level > 0) { - MESG("Compression eliminated approximately %lu bytes\n", compression_saved); + MESG("Compression saved %ld bytes%s\n", compression_saved, + pdf_version < 5 ? ". Try \"-V 5\" for better compression" : ""); } } - MESG("%lu bytes written", pdf_output_file_position); + MESG("%ld bytes written", pdf_output_file_position); MFCLOSE(pdf_output_file); } @@ -361,50 +476,52 @@ pdf_error_cleanup (void) void pdf_set_root (pdf_obj *object) { - if (pdf_root_obj != 0) { + if (pdf_add_dict(trailer_dict, pdf_new_name("Root"), pdf_ref_obj(object))) { ERROR("Root object already set!"); } - if (object->label == 0) { /* Make sure this object has a label */ - pdf_label_obj(object); - } - pdf_root_obj = object->label; + /* Adobe Readers don't like a document catalog inside an encrypted + * object stream, although the PDF v1.5 spec seems to allow this. + * Note that we don't set OBJ_NO_ENCRYPT since the name dictionary in + * a document catalog may contain strings, which should be encrypted. + */ + if (doc_enc_mode) + object->flags |= OBJ_NO_OBJSTM; } void pdf_set_info (pdf_obj *object) { - if (pdf_info_obj != 0) { + if (pdf_add_dict(trailer_dict, pdf_new_name("Info"), pdf_ref_obj(object))) { ERROR ("Info object already set!"); } - if (object->label == 0) { /* Make sure this object has a label */ - pdf_label_obj(object); - } - pdf_info_obj = object->label; } void -pdf_set_encrypt (pdf_obj *object) +pdf_set_encrypt (pdf_obj *encrypt, pdf_obj *id) { - if (pdf_encrypt_obj != 0) { + if (pdf_add_dict(trailer_dict, pdf_new_name("Encrypt"), pdf_ref_obj(encrypt))) { ERROR("Encrypt object already set!"); } - if (object->label == 0) { /* Make sure this object has a label */ - pdf_label_obj(object); - } - pdf_encrypt_obj = object->label; + encrypt->flags |= OBJ_NO_ENCRYPT; + + pdf_add_dict(trailer_dict, pdf_new_name("ID"), id); } static void pdf_out_char (FILE *file, char c) { - fputc(c, file); - /* Keep tallys for xref table *only* if writing a pdf file. */ - if (file == pdf_output_file) { - pdf_output_file_position += 1; - if (c == '\n') - pdf_output_line_position = 0; - else - pdf_output_line_position += 1; + if (output_stream && file == pdf_output_file) + pdf_add_stream(output_stream, &c, 1); + else { + fputc(c, file); + /* Keep tallys for xref table *only* if writing a pdf file. */ + if (file == pdf_output_file) { + pdf_output_file_position += 1; + if (c == '\n') + pdf_output_line_position = 0; + else + pdf_output_line_position += 1; + } } } @@ -419,15 +536,19 @@ void pdf_out_char (FILE *file, char c) static void pdf_out (FILE *file, const void *buffer, long length) { - fwrite(buffer, 1, length, file); - /* Keep tallys for xref table *only* if writing a pdf file */ - if (file == pdf_output_file) { - pdf_output_file_position += length; - pdf_output_line_position += length; - /* "foo\nbar\n "... */ - if (length > 0 && + if (output_stream && file == pdf_output_file) + pdf_add_stream(output_stream, buffer, length); + else { + fwrite(buffer, 1, length, file); + /* Keep tallys for xref table *only* if writing a pdf file */ + if (file == pdf_output_file) { + pdf_output_file_position += length; + pdf_output_line_position += length; + /* "foo\nbar\n "... */ + if (length > 0 && ((char *)buffer)[length-1] == '\n') - pdf_output_line_position = 0; + pdf_output_line_position = 0; + } } } @@ -461,6 +582,7 @@ pdf_new_obj(int type) result->label = 0; result->generation = 0; result->refcount = 1; + result->flags = 0; return result; } @@ -480,20 +602,12 @@ pdf_label_obj (pdf_obj *object) if (INVALIDOBJ(object)) ERROR("pdf_label_obj(): passed invalid object."); - if (next_label > pdf_max_ind_objects) { - pdf_max_ind_objects += IND_OBJECTS_ALLOC_SIZE; - output_xref = RENEW(output_xref, pdf_max_ind_objects, struct xref_entry); - } /* * Don't change label on an already labeled object. Ignore such calls. */ if (object->label == 0) { - /* Save so we can lookup this object by its number */ - output_xref[next_label-1].object = object; - output_xref[next_label-1].file_position = 0L; - object->label = next_label; + object->label = next_label++; object->generation = 0; - next_label++; } } @@ -563,13 +677,13 @@ write_indirect (pdf_indirect *indirect, FILE *file) if (indirect->dirty) { if (file == stderr) { pdf_out(file, "{d}", 3); - length = sprintf(format_buffer, "%d %d R", indirect->label, indirect->generation); + length = sprintf(format_buffer, "%lu %hu R", indirect->label, indirect->generation); pdf_out(stderr, format_buffer, length); } else { pdf_obj *clean; if (indirect->dirty_file != pdf_input_file) { - ERROR("Input PDF file doesn't match object: label=%d, from_file=%p, current_file=%p", + 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); @@ -577,7 +691,7 @@ write_indirect (pdf_indirect *indirect, FILE *file) pdf_release_obj(clean); } } else { - length = sprintf(format_buffer, "%d %d R", indirect->label, indirect->generation); + length = sprintf(format_buffer, "%lu %hu R", indirect->label, indirect->generation); pdf_out(file, format_buffer, length); } } @@ -821,7 +935,10 @@ write_string (pdf_string *str, FILE *file) int nescc = 0, i, count; s = str->string; - pdf_encrypt_data(s, str->length); + + if (enc_mode) + pdf_encrypt_data(s, str->length); + /* * Count all ASCII non-printable characters. */ @@ -1248,10 +1365,11 @@ release_dict (pdf_dict *data) } /* Array is ended by a node with NULL this pointer */ -void +/* pdf_add_dict returns 0 if the key is new and non-zero otherwise */ +int pdf_add_dict (pdf_obj *dict, pdf_obj *key, pdf_obj *value) { - pdf_dict *data; + pdf_dict *data, *new_node; TYPECHECK(dict, PDF_DICT); TYPECHECK(key, PDF_NAME); @@ -1260,34 +1378,29 @@ pdf_add_dict (pdf_obj *dict, pdf_obj *key, pdf_obj *value) if (value != NULL && INVALIDOBJ(value)) ERROR("pdf_add_dict(): Passed invalid value"); - data = dict->data; /* If this key already exists, simply replace the value */ - while (data->key != NULL) { + for (data = dict->data; data->key != NULL; data = data->next) { if (!strcmp(pdf_name_value(key), pdf_name_value(data->key))) { /* Release the old value */ pdf_release_obj(data->value); /* Release the new key (we don't need it) */ pdf_release_obj(key); data->value = value; - break; + return 1; } - data = data->next; } /* - * If we didn't find the key, build a new "end" node and add + * We didn't find the key. We build a new "end" node and add * the new key just before the end */ - if (data->key == NULL) { - pdf_dict *new_node; - - new_node = NEW (1, pdf_dict); - new_node->key = NULL; - new_node->value = NULL; - new_node->next = NULL; - data->next = new_node; - data->key = key; - data->value = value; - } + new_node = NEW (1, pdf_dict); + new_node->key = NULL; + new_node->value = NULL; + new_node->next = NULL; + data->next = new_node; + data->key = key; + data->value = value; + return 0; } void @@ -1456,6 +1569,7 @@ pdf_new_stream (int flags) data->max_length = 0; result->data = data; + result->flags |= OBJ_NO_OBJSTM; return result; } @@ -1490,19 +1604,25 @@ write_stream (pdf_stream *stream, FILE *file) (stream->_flags & STREAM_COMPRESS) && compression_level > 0) { + pdf_obj *filters = pdf_lookup_dict(stream->dict, "Filter"); + buffer_length = filtered_length + filtered_length/1000 + 14; buffer = NEW(buffer_length, unsigned char); { - pdf_obj *filters; + pdf_obj *filter_name = pdf_new_name("FlateDecode"); - filters = pdf_lookup_dict(stream->dict, "Filter"); - if (!filters) - filters = pdf_new_array(); - /* - * FlateDecode is the first filter to be applied to the stream. - */ - pdf_unshift_array(filters, pdf_new_name("FlateDecode")); - pdf_add_dict(stream->dict, pdf_new_name("Filter"), filters); + if (filters) + /* + * FlateDecode is the first filter to be applied to the stream. + */ + pdf_unshift_array(filters, filter_name); + else + /* + * Adding the filter as a name instead of a one-element array + * is crucial because otherwise Adobe Reader cannot read the + * cross-reference stream any more, cf. the PDF v1.5 Errata. + */ + pdf_add_dict(stream->dict, pdf_new_name("Filter"), filter_name); } #ifdef HAVE_ZLIB_COMPRESS2 if (compress2(buffer, &buffer_length, filtered, @@ -1516,7 +1636,8 @@ write_stream (pdf_stream *stream, FILE *file) } #endif /* HAVE_ZLIB_COMPRESS2 */ RELEASE(filtered); - compression_saved += filtered_length - buffer_length - strlen("/Filter [/FlateDecode]\n"); + compression_saved += filtered_length - buffer_length + - (filters ? strlen("/FlateDecode "): strlen("/Filter/FlateDecode\n")); filtered = buffer; filtered_length = buffer_length; @@ -1541,7 +1662,10 @@ write_stream (pdf_stream *stream, FILE *file) pdf_write_obj(stream->dict, file); pdf_out(file, "\nstream\n", 8); - pdf_encrypt_data(filtered, filtered_length); + + if (enc_mode) + pdf_encrypt_data(filtered, filtered_length); + if (filtered_length > 0) { pdf_out(file, filtered, filtered_length); } @@ -1700,11 +1824,12 @@ pdf_flush_obj (pdf_obj *object, FILE *file) long length; /* - * Record file position. No object is numbered 0, so subtract 1 - * when using as an array index + * Record file position */ - output_xref[object->label-1].file_position = pdf_output_file_position; - length = sprintf(format_buffer, "%lu %d obj\n", object->label, object->generation); + add_xref_entry(object->label, 1, + pdf_output_file_position, object->generation); + length = sprintf(format_buffer, "%lu %hu obj\n", object->label, object->generation); + enc_mode = doc_enc_mode && !(object->flags & OBJ_NO_ENCRYPT); pdf_enc_set_label(object->label); pdf_enc_set_generation(object->generation); pdf_out(file, format_buffer, length); @@ -1712,6 +1837,64 @@ 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) +{ + unsigned char pos = objstm->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; + 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); +} + +static void +pdf_flush_objstm (pdf_objstm *objstm) +{ + unsigned char pos = objstm->pos; + pdf_obj *stream_obj = objstm->stream; + TYPECHECK(stream_obj, PDF_STREAM); + pdf_stream *stream = (pdf_stream *) stream_obj->data; + + /* Precede stream data by offset table */ + unsigned char *old_buf = stream->stream; + unsigned long old_length = stream->stream_length; + /* 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; + + unsigned char i; + 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); + } + + pdf_obj *dict = pdf_stream_dict(stream_obj); + 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); + RELEASE(old_buf); + pdf_release_obj(stream_obj); + objstm->pos = 0; +} + void pdf_release_obj (pdf_obj *object) { @@ -1729,8 +1912,13 @@ pdf_release_obj (pdf_obj *object) * Nothing is using this object so it's okay to remove it. * Nonzero "label" means object needs to be written before it's destroyed. */ - if (object->label && pdf_output_file != NULL) { - pdf_flush_obj(object, pdf_output_file); + if (object->label && pdf_output_file != NULL) { + if (!current_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); } switch (object->type) { case PDF_BOOLEAN: @@ -2020,7 +2208,7 @@ next_object_offset (unsigned long obj_num) * returns the retained existing reference to that object */ static pdf_obj * -pdf_ref_file_obj (unsigned long obj_num, unsigned obj_gen) +pdf_ref_file_obj (unsigned long obj_num, unsigned short obj_gen) { pdf_obj *obj, *ref; @@ -2050,13 +2238,13 @@ pdf_ref_file_obj (unsigned long obj_num, unsigned obj_gen) pdf_obj * -pdf_new_ref (unsigned long obj_num, int obj_gen) +pdf_new_ref (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 %d", obj_num, obj_gen); + WARN("Invalid object label: %lu %hu", obj_num, obj_gen); return NULL; } result = pdf_new_obj(PDF_INDIRECT); @@ -2075,7 +2263,7 @@ pdf_new_ref (unsigned long obj_num, int obj_gen) * be replaced with "null". But we won't do that. */ static pdf_obj * -pdf_read_object (unsigned long obj_num, unsigned obj_gen) +pdf_read_object (unsigned long obj_num, unsigned short obj_gen) { pdf_obj *result; long offset, limit, length; @@ -2362,7 +2550,7 @@ pdf_open (FILE *file) } pdf_input_file = file; if (!check_for_pdf(pdf_input_file)) { - WARN("pdf_open: Not a PDF 1.[1-3] file."); + WARN("pdf_open: Not a PDF 1.[1-5] file."); return NULL; } if ((trailer = read_xref()) == NULL) { diff --git a/Build/source/texk/dvipdfmx/src/pdfobj.h b/Build/source/texk/dvipdfmx/src/pdfobj.h index 9ca8df47b7e..346e38bd31b 100644 --- a/Build/source/texk/dvipdfmx/src/pdfobj.h +++ b/Build/source/texk/dvipdfmx/src/pdfobj.h @@ -1,8 +1,8 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/pdfobj.h,v 1.21 2005/05/04 16:10:06 hirata Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pdfobj.h,v 1.23 2007/11/14 03:36:01 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -51,10 +51,12 @@ typedef struct pdf_obj pdf_obj; extern void pdf_obj_set_verbose (void); extern void pdf_error_cleanup (void); -extern void pdf_out_init (const char *filename); +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); @@ -124,7 +126,7 @@ extern pdf_obj *pdf_dict_keys (pdf_obj *dict); * pdf_link_obj() it rather than allocate/free-ing them each time. But I * already removed that. */ -extern void pdf_add_dict (pdf_obj *dict, pdf_obj *key, pdf_obj *value); +extern int pdf_add_dict (pdf_obj *dict, pdf_obj *key, pdf_obj *value); extern void pdf_put_dict (pdf_obj *dict, const char *key, pdf_obj *value); /* Apply proc(key, value, pdata) for each key-value pairs in dict, stop if proc() @@ -160,7 +162,7 @@ extern void pdf_set_compression (int level); extern void pdf_set_info (pdf_obj *obj); extern void pdf_set_root (pdf_obj *obj); -extern void pdf_set_encrypt (pdf_obj *obj); +extern void pdf_set_encrypt (pdf_obj *encrypt, pdf_obj *id); extern int check_for_pdf (FILE *file); extern pdf_obj *pdf_open (FILE *file); @@ -171,7 +173,7 @@ 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, int generation); +extern pdf_obj *pdf_new_ref (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 c7dc79a2990..f1c6a90a593 100644 --- a/Build/source/texk/dvipdfmx/src/pdfparse.c +++ b/Build/source/texk/dvipdfmx/src/pdfparse.c @@ -1,8 +1,8 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/pdfparse.c,v 1.39 2005/07/21 05:05:14 chofchof Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pdfparse.c,v 1.40 2007/04/03 05:11:39 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -952,7 +952,8 @@ parse_pdf_reference (char **start, char *end) static pdf_obj * try_pdf_reference (char *start, char *end, char **endptr) { - unsigned long id = 0, gen = 0; + unsigned long id = 0; + unsigned short gen = 0; if (endptr) *endptr = start; @@ -989,7 +990,7 @@ try_pdf_reference (char *start, char *end, char **endptr) if (endptr) *endptr = start; - return pdf_new_ref(id, (int) gen); + return pdf_new_ref(id, gen); } pdf_obj * diff --git a/Build/source/texk/dvipdfmx/src/pdfximage.c b/Build/source/texk/dvipdfmx/src/pdfximage.c index 9cc8ccdb49b..a6e0da46658 100644 --- a/Build/source/texk/dvipdfmx/src/pdfximage.c +++ b/Build/source/texk/dvipdfmx/src/pdfximage.c @@ -1,8 +1,8 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/pdfximage.c,v 1.14 2005/07/30 11:44:18 hirata Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pdfximage.c,v 1.16 2007/05/18 05:19:01 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -63,6 +63,7 @@ static int ps_include_page (pdf_ximage *ximage, const char *file_name); struct attr_ { long width, height; + double xdensity, ydensity; pdf_rect bbox; }; @@ -116,6 +117,7 @@ pdf_init_ximage_struct (pdf_ximage *I) I->resource = NULL; I->attr.width = I->attr.height = 0; + I->attr.xdensity = I->attr.ydensity = 1.0; I->attr.bbox.llx = I->attr.bbox.lly = 0; I->attr.bbox.urx = I->attr.bbox.ury = 0; } @@ -399,6 +401,20 @@ pdf_ximage_findresource (const char *ident) return id; } +/* Reference: PDF Reference 1.5 v6, pp.321--322 + * + * TABLE 4.42 Additional entries specific to a type 1 form dictionary + * + * BBox rectangle (Required) An array of four numbers in the form coordinate + * system, giving the coordinates of the left, bottom, right, + * and top edges, respectively, of the form XObject's bounding + * box. These boundaries are used to clip the form XObject and + * to determine its size for caching. + * + * Matrix array (Optional) An array of six numbers specifying the form + * matrix, which maps form space into user space. + * Default value: the identity matrix [1 0 0 1 0 0]. + */ void pdf_ximage_init_form_info (xform_info *info) { @@ -415,6 +431,36 @@ pdf_ximage_init_form_info (xform_info *info) info->matrix.f = 0.0; } +/* Reference: PDF Reference 1.5 v6, pp.303--306 + * + * TABLE 4.42 Additional entries specific to an image dictionary + * + * Width integer (Required) The width of the image, in samples. + * + * Height integer (Required) The height of the image, in samples. + * + * ColorSpace name or array + * (Required for images, except those that use the JPXDecode + * filter; not allowed for image masks) The color space in + * which image samples are specified. This may be any type + * of color space except Patter. + * + * If the image uses the JPXDecode filter, this entry is + * optional. + * + * BitsPerComponent integer + * (Required except for image masks and images that use the + * JPXDecode filter) The number of bits used to represent + * each color component. Only a single value may be specified; + * the number of bits is the same for all color components. + * Valid values are 1,2,4,8, and (in PDF1.5) 16. If ImageMask + * is true, this entry is optional, and if speficified, its + * value must be 1. + * + * If the image stream uses the JPXDecode filter, this entry + * is optional and ignored if present. The bit depth is + * determined in the process of decoding the JPEG2000 image. + */ void pdf_ximage_init_image_info (ximage_info *info) { @@ -424,6 +470,7 @@ pdf_ximage_init_image_info (ximage_info *info) info->bits_per_component = 0; info->num_components = 0; info->min_dpi = 0; + info->xdensity = info->ydensity = 1.0; } void @@ -433,12 +480,14 @@ pdf_ximage_set_image (pdf_ximage *I, void *image_info, pdf_obj *resource) ximage_info *info = image_info; if (!PDF_OBJ_STREAMTYPE(resource)) - ERROR("Image XObject must be stream type."); + ERROR("Image XObject must be of stream type."); I->subtype = PDF_XOBJECT_TYPE_IMAGE; - I->attr.width = info->width; - I->attr.height = info->height; + I->attr.width = info->width; /* The width of the image, in samples */ + I->attr.height = info->height; /* The height of the image, in samples */ + I->attr.xdensity = info->xdensity; + I->attr.ydensity = info->ydensity; I->reference = pdf_ref_obj(resource); @@ -455,17 +504,19 @@ pdf_ximage_set_image (pdf_ximage *I, void *image_info, pdf_obj *resource) } void -pdf_ximage_set_form (pdf_ximage *I, void *form_info, pdf_obj *resource) +pdf_ximage_set_form (pdf_ximage *I, void *form_info, pdf_obj *resource) { - xform_info *info = form_info; + xform_info *info = form_info; I->subtype = PDF_XOBJECT_TYPE_FORM; + I->attr.bbox.llx = info->bbox.llx; I->attr.bbox.lly = info->bbox.lly; I->attr.bbox.urx = info->bbox.urx; I->attr.bbox.ury = info->bbox.ury; I->reference = pdf_ref_obj(resource); + pdf_release_obj(resource); /* Caller don't know we are using reference. */ I->resource = NULL; } @@ -481,8 +532,8 @@ pdf_ximage_set_form (pdf_ximage *I, void *form_info, pdf_obj *resource) pdf_obj * pdf_ximage_get_reference (int id) { - struct ic_ *ic = &_ic; - pdf_ximage *I; + struct ic_ *ic = &_ic; + pdf_ximage *I; CHECK_ID(ic, id); @@ -490,16 +541,17 @@ pdf_ximage_get_reference (int id) if (!I->reference) I->reference = pdf_ref_obj(I->resource); - return pdf_link_obj(I->reference); + return pdf_link_obj(I->reference); } +/* called from pdfdoc.c only for late binding */ int pdf_ximage_defineresource (const char *ident, int subtype, void *info, pdf_obj *resource) { - struct ic_ *ic = &_ic; - int id; - pdf_ximage *I; + struct ic_ *ic = &_ic; + int id; + pdf_ximage *I; id = ic->count; if (ic->count >= ic->capacity) { @@ -518,12 +570,10 @@ pdf_ximage_defineresource (const char *ident, switch (subtype) { case PDF_XOBJECT_TYPE_IMAGE: pdf_ximage_set_image(I, info, resource); - I->subtype = PDF_XOBJECT_TYPE_IMAGE; sprintf(I->res_name, "Im%d", id); break; case PDF_XOBJECT_TYPE_FORM: pdf_ximage_set_form (I, info, resource); - I->subtype = PDF_XOBJECT_TYPE_FORM; sprintf(I->res_name, "Fm%d", id); break; default: @@ -538,14 +588,14 @@ pdf_ximage_defineresource (const char *ident, char * pdf_ximage_get_resname (int id) { - struct ic_ *ic = &_ic; - pdf_ximage *I; + struct ic_ *ic = &_ic; + pdf_ximage *I; CHECK_ID(ic, id); I = GET_IMAGE(ic, id); - return I->res_name; + return I->res_name; } @@ -554,47 +604,61 @@ pdf_ximage_get_resname (int id) * not as vertical dimension of scaled image. (And there are bugs.) * This part contains incompatibile behaviour than dvipdfm! */ -#define EBB_DPI 100 +#define EBB_DPI 72 + static void scale_to_fit_I (pdf_tmatrix *T, transform_info *p, pdf_ximage *I) { - double s_x, s_y; - long wdx = I->attr.width; - long htx = I->attr.height; - double ar, dp; + double s_x, s_y, d_x, d_y; + double wd0, ht0, dp, xscale, yscale; - if (htx == 0) { - WARN("Image height=0!"); - htx = 1; + if (p->flags & INFO_HAS_USER_BBOX) { + wd0 = p->bbox.urx - p->bbox.llx; + ht0 = p->bbox.ury - p->bbox.lly; + xscale = I->attr.width * I->attr.xdensity / wd0; + yscale = I->attr.height * I->attr.ydensity / ht0; + d_x = -p->bbox.llx / wd0; + d_y = -p->bbox.lly / ht0; + } else { + wd0 = I->attr.width * I->attr.xdensity; + ht0 = I->attr.height * I->attr.ydensity; + xscale = yscale = 1.0; + d_x = 0.0; + d_y = 0.0; } - ar = (double) wdx / htx; + if (wd0 == 0.0) { + WARN("Image width=0.0!"); + wd0 = 1.0; + } + if (ht0 == 0.0) { + WARN("Image height=0.0!"); + ht0 = 1.0; + } - /* only width/height --> uniform (keep aspect ratio) - * no width-height --> uniform with 72dpi implied (?) - * both width-height --> non-uniform - */ if ( (p->flags & INFO_HAS_WIDTH ) && (p->flags & INFO_HAS_HEIGHT) ) { - s_x = p->width; s_y = p->height + p->depth; - dp = p->depth; - } else if ( p->flags & INFO_HAS_WIDTH ) { - s_x = p->width; s_y = s_x / ar; + s_x = p->width * xscale; + s_y = (p->height + p->depth) * yscale; + dp = p->depth * yscale; + } else if ( p->flags & INFO_HAS_WIDTH ) { + s_x = p->width * xscale; + s_y = s_x * ((double)I->attr.height / I->attr.width); dp = 0.0; - } else if ( p->flags & INFO_HAS_HEIGHT ) { - s_y = p->height + p->depth; s_x = s_y * ar; - dp = p->depth; + } else if ( p->flags & INFO_HAS_HEIGHT) { + s_y = (p->height + p->depth) * yscale; + s_x = s_y * ((double)I->attr.width / I->attr.height); + dp = p->depth * yscale; } else { - s_x = wdx * 72.0 / EBB_DPI; - s_y = htx * 72.0 / EBB_DPI; + s_x = wd0; + s_y = ht0; dp = 0.0; } - - T->a = s_x; T->c = 0.0; - T->b = 0.0; T->d = s_y; - T->e = 0.0; T->f = -dp; + T->a = s_x; T->c = 0.0; + T->b = 0.0; T->d = s_y; + T->e = d_x * s_x / xscale; T->f = d_y * s_y / yscale - dp; return; } @@ -655,15 +719,16 @@ scale_to_fit_F (pdf_tmatrix *T, } +/* called from pdfdev.c and spc_html.c */ int pdf_ximage_scale_image (int id, - pdf_tmatrix *M, /* ret */ - pdf_rect *r, /* ret */ - transform_info *p /* arg */ + pdf_tmatrix *M, /* return value for trans matrix */ + pdf_rect *r, /* return value for clipping */ + transform_info *p /* argument from specials */ ) { - struct ic_ *ic = &_ic; - pdf_ximage *I; + struct ic_ *ic = &_ic; + pdf_ximage *I; CHECK_ID(ic, id); @@ -672,13 +737,47 @@ pdf_ximage_scale_image (int id, pdf_setmatrix(M, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0); switch (I->subtype) { + /* Reference: PDF Reference 1.5 v6, p.302 + * + * An image can be placed on the output page in any desired position, + * orientation, and size by using the cm operator to modify the current + * transformation matrix (CTM) so as to map the unit square of user space + * to the rectangle or parallelogram in which the image is to be painted. + * + * There is neither BBox nor Matrix key in the image XObject. + * Everything must be controlled by the cm operator. + * + * The argument [p] contains the user-defined bounding box, the scailing + * factor of which is bp as EPS and PDF. On the other hand, I->attr + * contains the (sampling) width and the (sampling) height of the image. + * + * There is no problem if a bitmap image has density information. + * Otherwise, DVIPDFM's ebb generates bounding box as 100px = 72bp = 1in. + * In this case, screen captured images look bad. Moreover, DVIPDFM's ebb + * ignores all density information and use just 100px = 72bp = 1in. + * + * On the other hand, pdfTeX uses 100px = 100bp to get a better quality + * for screen captured images. + * + * DVIPDFMx's xbb generates bounding box as 100px = 100bp in the same + * way as pdfTeX. Furthermore, it takes care of density information too. + */ case PDF_XOBJECT_TYPE_IMAGE: scale_to_fit_I(M, p, I); - r->llx = 0.0; - r->lly = 0.0; - r->urx = M->a; - r->ury = M->d; + if (p->flags & INFO_HAS_USER_BBOX) { + r->llx = p->bbox.llx / (I->attr.width * I->attr.xdensity); + r->lly = p->bbox.lly / (I->attr.height * I->attr.ydensity); + r->urx = p->bbox.urx / (I->attr.width * I->attr.xdensity); + r->ury = p->bbox.ury / (I->attr.height * I->attr.ydensity); + } else { + r->llx = 0.0; + r->lly = 0.0; + r->urx = 1.0; + r->ury = 1.0; + } break; + /* User-defined transformation and clipping are controlled by + * the cm operator and W operator, explicitly */ case PDF_XOBJECT_TYPE_FORM: scale_to_fit_F(M, p, I); if (p->flags & INFO_HAS_USER_BBOX) { @@ -686,7 +785,7 @@ pdf_ximage_scale_image (int id, r->lly = p->bbox.lly; r->urx = p->bbox.urx; r->ury = p->bbox.ury; - } else { + } else { /* I->attr.bbox from the image bounding box */ r->llx = I->attr.bbox.llx; r->lly = I->attr.bbox.lly; r->urx = I->attr.bbox.urx; @@ -781,5 +880,3 @@ static int check_for_ps (FILE *image_file) return 1; return 0; } - - diff --git a/Build/source/texk/dvipdfmx/src/pdfximage.h b/Build/source/texk/dvipdfmx/src/pdfximage.h index 2a51a9fbfc5..e66b17120f5 100644 --- a/Build/source/texk/dvipdfmx/src/pdfximage.h +++ b/Build/source/texk/dvipdfmx/src/pdfximage.h @@ -1,8 +1,8 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/pdfximage.h,v 1.8 2005/07/30 11:44:18 hirata Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pdfximage.h,v 1.10 2007/05/18 05:19:01 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -40,6 +40,8 @@ typedef struct { int num_components; long min_dpi; /* NOT USED YET */ + + double xdensity, ydensity; /* scale factor for bp */ } ximage_info; typedef struct { @@ -80,4 +82,6 @@ pdf_ximage_scale_image (int id, transform_info *p /* arg */ ); +/* from dvipdfmx.c */ +extern void pdf_ximage_disable_ebb (void); #endif /* _PDFXIMAGE_H_ */ diff --git a/Build/source/texk/dvipdfmx/src/pkfont.c b/Build/source/texk/dvipdfmx/src/pkfont.c index e081705addb..4822d50bc71 100644 --- a/Build/source/texk/dvipdfmx/src/pkfont.c +++ b/Build/source/texk/dvipdfmx/src/pkfont.c @@ -1,8 +1,8 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/pkfont.c,v 1.16 2005/08/12 18:22:24 chofchof Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pkfont.c,v 1.17 2007/11/14 03:12:21 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -127,6 +127,7 @@ pdf_font_open_pkfont (pdf_font *font) pdf_font_set_fontname(font, ident); if (encoding_id >= 0) { + pdf_encoding_used_by_type3(encoding_id); WARN("PK font is found for font \"%s\" but non built-in encoding \"%s\" is specified.", ident, pdf_encoding_get_name(encoding_id)); #if ENABLE_GLYPHENC @@ -636,7 +637,7 @@ pdf_font_load_pkfont (pdf_font *font) #if ENABLE_GLYPHENC if (encoding_id >= 0 && enc_vec) { charname = (char *) enc_vec[pkh.chrcode & 0xff]; - if (!charname || !strcmp(charname, ".notdef")) { + if (!charname) { WARN("\".notdef\" glyph used in font (code=0x%02x): %s", pkh.chrcode, ident); charname = work_buffer; pk_char2name(charname, pkh.chrcode); @@ -711,7 +712,7 @@ pdf_font_load_pkfont (pdf_font *font) #if ENABLE_GLYPHENC if (encoding_id >= 0 && enc_vec) { charname = (char *) enc_vec[(unsigned char) code]; - if (!charname || !strcmp(charname, ".notdef")) { + if (!charname) { charname = work_buffer; pk_char2name(charname, code); } @@ -732,14 +733,20 @@ pdf_font_load_pkfont (pdf_font *font) pdf_release_obj(tmp_array); return -1; } - encoding = pdf_new_dict(); - pdf_add_dict(encoding, - pdf_new_name("Type"), pdf_new_name("Encoding")); - pdf_add_dict(encoding, - pdf_new_name("Differences"), tmp_array); - pdf_add_dict(fontdict, - pdf_new_name("Encoding"), pdf_ref_obj(encoding)); - pdf_release_obj(encoding); +#if ENABLE_GLYPHENC + if (encoding_id < 0 || !enc_vec) { +#else + if (1) { +#endif /* ENABLE_GLYPHENC */ + encoding = pdf_new_dict(); + pdf_add_dict(encoding, + pdf_new_name("Type"), pdf_new_name("Encoding")); + pdf_add_dict(encoding, + pdf_new_name("Differences"), tmp_array); + pdf_add_dict(fontdict, + pdf_new_name("Encoding"), pdf_ref_obj(encoding)); + pdf_release_obj(encoding); + } /* FontBBox: Accurate value is important. */ @@ -782,10 +789,8 @@ pdf_font_load_pkfont (pdf_font *font) pdf_new_name("LastChar"), pdf_new_number(lastchar)); #if ENABLE_GLYPHENC - /* ToUnicode */ if (encoding_id >= 0) { - if (!pdf_lookup_dict(fontdict, "ToUnicode")) - pdf_attach_ToUnicode_CMap(fontdict, encoding_id, usedchars); + pdf_encoding_add_usedchars(encoding_id, usedchars); } #endif /* ENABLE_GLYPHENC */ diff --git a/Build/source/texk/dvipdfmx/src/pngimage.c b/Build/source/texk/dvipdfmx/src/pngimage.c index 39509976bc7..f7eb4ba3513 100644 --- a/Build/source/texk/dvipdfmx/src/pngimage.c +++ b/Build/source/texk/dvipdfmx/src/pngimage.c @@ -1,8 +1,8 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/pngimage.c,v 1.24 2004/09/11 14:50:29 hirata Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pngimage.c,v 1.25 2007/05/18 05:19:01 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -165,7 +165,7 @@ png_include_image (pdf_ximage *ximage, FILE *png_file) png_structp png_ptr; png_infop png_info_ptr; png_byte bpc, color_type; - png_uint_32 width, height, rowbytes; + png_uint_32 width, height, rowbytes, xppm, yppm; pdf_ximage_init_image_info(&info); @@ -192,6 +192,8 @@ png_include_image (pdf_ximage *ximage, FILE *png_file) width = png_get_image_width (png_ptr, png_info_ptr); height = png_get_image_height(png_ptr, png_info_ptr); bpc = png_get_bit_depth (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); /* We do not need 16-bpc color. Ask libpng to convert down to 8-bpc. */ if (bpc > 8) { @@ -211,6 +213,10 @@ png_include_image (pdf_ximage *ximage, FILE *png_file) info.width = width; info.height = height; info.bits_per_component = bpc; + if (xppm > 0) + info.xdensity = 72.0 / 0.0254 / xppm; + if (yppm > 0) + info.ydensity = 72.0 / 0.0254 / yppm; stream_data_ptr = (png_bytep) NEW(rowbytes*height, png_byte); read_image_data(png_ptr, png_info_ptr, stream_data_ptr, height, rowbytes); diff --git a/Build/source/texk/dvipdfmx/src/spc_html.c b/Build/source/texk/dvipdfmx/src/spc_html.c index 912839179d1..d2ba4140518 100644 --- a/Build/source/texk/dvipdfmx/src/spc_html.c +++ b/Build/source/texk/dvipdfmx/src/spc_html.c @@ -1,8 +1,8 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/spc_html.c,v 1.5 2005/08/14 15:50:36 chofchof Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/spc_html.c,v 1.6 2007/01/19 11:00:48 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> diff --git a/Build/source/texk/dvipdfmx/src/spc_pdfm.c b/Build/source/texk/dvipdfmx/src/spc_pdfm.c index 8681af2586b..67a66dba7c5 100644 --- a/Build/source/texk/dvipdfmx/src/spc_pdfm.c +++ b/Build/source/texk/dvipdfmx/src/spc_pdfm.c @@ -1,8 +1,8 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/spc_pdfm.c,v 1.24 2006/12/11 12:46:03 chofchof Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/spc_pdfm.c,v 1.26 2007/04/25 09:44:49 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -765,11 +765,29 @@ spc_handler_pdfm_outline (struct spc_env *spe, struct spc_arg *args) { struct spc_pdf_ *sd = &_pdf_stat; pdf_obj *item_dict, *tmp; - int level; + int level, is_open = -1; int current_depth; skip_white(&args->curptr, args->endptr); + /* + * pdf:outline is extended to support open/close feature + * + * pdf:outline 1 ... (as DVIPDFM) + * pdf:outline [] 1 ... (open bookmark) + * pdf:outline [-] 1 ... (closed bookmark) + */ + if (args->curptr+3 < args->endptr && *args->curptr == '[') { + args->curptr++; + if (*args->curptr == '-') { + args->curptr++; + } else { + is_open = 1; + } + args->curptr++; + } + skip_white(&args->curptr, args->endptr); + tmp = parse_pdf_object(&args->curptr, args->endptr); if (!tmp) { spc_warn(spe, "Missing number for outline item depth."); @@ -815,7 +833,7 @@ spc_handler_pdfm_outline (struct spc_env *spe, struct spc_arg *args) pdf_doc_bookmarks_down(); } - pdf_doc_bookmarks_add(item_dict, -1); /* Use global setting for open/close */ + pdf_doc_bookmarks_add(item_dict, is_open); return 0; } diff --git a/Build/source/texk/dvipdfmx/src/spc_util.c b/Build/source/texk/dvipdfmx/src/spc_util.c index e2d86eded94..ad53e6d0b95 100644 --- a/Build/source/texk/dvipdfmx/src/spc_util.c +++ b/Build/source/texk/dvipdfmx/src/spc_util.c @@ -1,8 +1,8 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/spc_util.c,v 1.7 2005/08/12 16:27:52 chofchof Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/spc_util.c,v 1.8 2007/04/24 09:29:39 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -636,6 +636,7 @@ spc_util_read_dimtrns (struct spc_env *spe, transform_info *ti, struct spc_arg * #ifdef cmyk #undef cmyk #endif +#define gray(g) {1, {g}} #define rgb8(r,g,b) {3, {((r)/255.0), ((g)/255.0), ((b)/255.0), 0.0}} #define cmyk(c,m,y,k) {4, {(c), (m), (y), (k)}} @@ -709,9 +710,13 @@ static struct colordef_ {"Sepia", cmyk(0.00, 0.83, 1.00, 0.70)}, {"Brown", cmyk(0.00, 0.81, 1.00, 0.60)}, {"Tan", cmyk(0.14, 0.42, 0.56, 0.00)}, - {"Gray", cmyk(0.00, 0.00, 0.00, 0.50)}, - {"Black", cmyk(0.00, 0.00, 0.00, 1.00)}, - {"White", cmyk(0.00, 0.00, 0.00, 0.00)}, + /* Adobe Reader 7 and 8 had problem when gray and cmyk black colors + * are mixed. No problem with Previewer.app. + * It happens when \usepackage[dvipdfm]{graphicx} and then called + * \usepackage{color} without dvipdfm option. */ + {"Gray", gray(0.5)}, + {"Black", gray(0.0)}, + {"White", gray(1.0)}, {NULL} }; diff --git a/Build/source/texk/dvipdfmx/src/specials.h b/Build/source/texk/dvipdfmx/src/specials.h index 2be14952ea9..8cd2ceda1bf 100644 --- a/Build/source/texk/dvipdfmx/src/specials.h +++ b/Build/source/texk/dvipdfmx/src/specials.h @@ -1,8 +1,8 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/specials.h,v 1.3 2005/07/31 16:44:42 hirata Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/specials.h,v 1.4 2007/01/20 23:53:20 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> diff --git a/Build/source/texk/dvipdfmx/src/subfont.c b/Build/source/texk/dvipdfmx/src/subfont.c index 7d7927e36b5..5ba8600d56f 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.20 2005/07/28 13:19:00 hirata Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/subfont.c,v 1.21 2007/11/14 03:36:01 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -454,8 +454,7 @@ lookup_sfd_record (int rec_id, unsigned char c) return sfd_record[rec_id].vector[c]; } -#if 0 -static void +void release_sfd_record (void) { int i; @@ -474,7 +473,6 @@ release_sfd_record (void) num_sfd_records = max_sfd_records = 0; num_sfd_files = max_sfd_files = 0; } -#endif /* 0 */ #if DPXTEST diff --git a/Build/source/texk/dvipdfmx/src/subfont.h b/Build/source/texk/dvipdfmx/src/subfont.h index e1c6010d5bc..1d90c21ef65 100644 --- a/Build/source/texk/dvipdfmx/src/subfont.h +++ b/Build/source/texk/dvipdfmx/src/subfont.h @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/subfont.h,v 1.8 2005/07/17 09:53:38 hirata Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/subfont.h,v 1.9 2007/11/14 03:36:01 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -25,6 +25,8 @@ extern void subfont_set_verbose (void); +extern void release_sfd_record (void); + extern unsigned short lookup_sfd_record(int rec_id, unsigned char code); extern int sfd_load_record (const char *sfd_name, const char *subfont_id); diff --git a/Build/source/texk/dvipdfmx/src/truetype.c b/Build/source/texk/dvipdfmx/src/truetype.c index 76b7ba3666a..c9b27405399 100644 --- a/Build/source/texk/dvipdfmx/src/truetype.c +++ b/Build/source/texk/dvipdfmx/src/truetype.c @@ -1,8 +1,8 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/truetype.c,v 1.5 2005/12/29 04:07:04 chofchof Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/truetype.c,v 1.6 2007/11/14 03:12:21 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> This program is free software; you can redistribute it and/or modify @@ -126,7 +126,7 @@ pdf_font_open_truetype (pdf_font *font) if (!embedding) { if (encoding_id >= 0 && !pdf_encoding_is_predefined(encoding_id)) { - ERROR("Custum encoding not allowed for non-embedded TrueType font."); + ERROR("Custom encoding not allowed for non-embedded TrueType font."); sfnt_close(sfont); return -1; } else { @@ -184,19 +184,6 @@ pdf_font_open_truetype (pdf_font *font) pdf_add_dict(fontdict, pdf_new_name("Subtype"), pdf_new_name("TrueType")); - /* - * We use MacRoman as "default" encoding. - */ - if (encoding_id >= 0) - pdf_add_dict(fontdict, - pdf_new_name("Encoding"), - pdf_new_name(pdf_encoding_get_name(encoding_id))); - else { - pdf_add_dict(fontdict, - pdf_new_name("Encoding"), - pdf_new_name("MacRomanEncoding")); - } - return 0; } @@ -761,7 +748,7 @@ clean_glyph_mapper (struct glyph_mapper *gm) } static int -do_custum_encoding (pdf_font *font, +do_custom_encoding (pdf_font *font, char **encoding, const char *usedchars, sfnt *sfont) { struct tt_glyphs *glyphs; @@ -881,13 +868,6 @@ pdf_font_load_truetype (pdf_font *font) verbose = pdf_font_get_verbose(); - if (!pdf_lookup_dict(fontdict, "ToUnicode")) { - if (encoding_id >= 0) - pdf_attach_ToUnicode_CMap(fontdict, - encoding_id, usedchars); - /* encoding_id < 0 means MacRoman here (but not really) */ - } - fp = DPXFOPEN(ident, DPX_RES_TYPE_TTFONT); if (!fp) ERROR("Unable to open TrueType font file: %s", ident); /* Should find *truetype* here */ @@ -924,7 +904,7 @@ pdf_font_load_truetype (pdf_font *font) error = do_builtin_encoding(font, usedchars, sfont); else { enc_vec = pdf_encoding_get_encoding(encoding_id); - error = do_custum_encoding(font, enc_vec, usedchars, sfont); + error = do_custom_encoding(font, enc_vec, usedchars, sfont); } if (error) { ERROR("Error occured while creating font subfont for \"%s\"", ident); diff --git a/Build/source/texk/dvipdfmx/src/tt_cmap.c b/Build/source/texk/dvipdfmx/src/tt_cmap.c index 74b1764397c..e938e61b80d 100644 --- a/Build/source/texk/dvipdfmx/src/tt_cmap.c +++ b/Build/source/texk/dvipdfmx/src/tt_cmap.c @@ -1,8 +1,8 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/tt_cmap.c,v 1.24 2005/07/08 14:18:05 hirata Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/tt_cmap.c,v 1.25 2007/04/13 06:48:03 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> This program is free software; you can redistribute it and/or modify @@ -1088,20 +1088,27 @@ otf_create_ToUnicode_stream (const char *font_name, } CMap_set_silent(1); /* many warnings without this... */ - ttcmap = tt_cmap_read(sfont, 3, 10); /* UCS4 */ + ttcmap = tt_cmap_read(sfont, 3, 10); /* Microsoft UCS4 */ if (ttcmap && ttcmap->format == 12) { WARN("Format 12 cmap table ... untested"); cmap_obj = create_ToUnicode_cmap12(ttcmap->map, cmap_name, cmap_add, used_glyphs); } else { - ttcmap = tt_cmap_read(sfont, 3, 1); + ttcmap = tt_cmap_read(sfont, 3, 1); /* Microsoft UCS2 */ if (ttcmap && ttcmap->format == 4) { cmap_obj = create_ToUnicode_cmap4(ttcmap->map, cmap_name, cmap_add, used_glyphs); } else { - ERROR("Unable to read TrueType Unicode cmap table."); + ttcmap = tt_cmap_read(sfont, 0, 3); /* Unicode 2.0 or later */ + if (ttcmap && + ttcmap->format == 4) { + cmap_obj = create_ToUnicode_cmap4(ttcmap->map, + cmap_name, cmap_add, used_glyphs); + } else { + ERROR("Unable to read OpenType/TrueType Unicode cmap table."); + } } } tt_cmap_release(ttcmap); @@ -1617,7 +1624,7 @@ otf_load_Unicode_CMap (const char *map_name, int ttc_index, /* 0 for non-TTC fon sfont = sfnt_open(fp); if (!sfont) { - ERROR("Could not open TrueType font file \"%s\"", map_name); + ERROR("Could not open OpenType/TrueType font file \"%s\"", map_name); } switch (sfont->type) { case SFNT_TYPE_TTC: @@ -1631,12 +1638,12 @@ otf_load_Unicode_CMap (const char *map_name, int ttc_index, /* 0 for non-TTC fon offset = 0; break; default: - ERROR("Not a TrueType/TTC font?: %s", map_name); + ERROR("Not a OpenType/TrueType/TTC font?: %s", map_name); break; } if (sfnt_read_table_directory(sfont, offset) < 0) - ERROR("Could not read TrueType table directory."); + ERROR("Could not read OpenType/TrueType table directory."); base_name = NEW(strlen(map_name)+strlen("-UCS4-H")+5, char); if (wmode) @@ -1693,18 +1700,21 @@ otf_load_Unicode_CMap (const char *map_name, int ttc_index, /* 0 for non-TTC fon return cmap_id; } - ttcmap = tt_cmap_read(sfont, 3, 10); + ttcmap = tt_cmap_read(sfont, 3, 10); /* Microsoft UCS4 */ if (!ttcmap) { - ttcmap = tt_cmap_read(sfont, 3, 1); - } - if (!ttcmap) { - ERROR("Unable to read TrueType Unicode cmap table."); + ttcmap = tt_cmap_read(sfont, 3, 1); /* Microsoft UCS2 */ + if (!ttcmap) { + ttcmap = tt_cmap_read(sfont, 0, 3); /* Unicode 2.0 or later */ + if (!ttcmap) { + ERROR("Unable to read OpenType/TrueType Unicode cmap table."); + } + } } cmap_id = load_base_CMap(base_name, wmode, (is_cidfont ? &csi : NULL), GIDToCIDMap, ttcmap); if (cmap_id < 0) - ERROR("Failed to read TrueType cmap table."); + ERROR("Failed to read OpenType/TrueType cmap table."); if (!otl_tags) { RELEASE(cmap_name); diff --git a/Build/source/texk/dvipdfmx/src/tt_glyf.c b/Build/source/texk/dvipdfmx/src/tt_glyf.c index ad116edb8b0..c7c6d7041f0 100644 --- a/Build/source/texk/dvipdfmx/src/tt_glyf.c +++ b/Build/source/texk/dvipdfmx/src/tt_glyf.c @@ -1,8 +1,8 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/tt_glyf.c,v 1.2 2005/06/09 14:31:11 hirata Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/tt_glyf.c,v 1.3 2007/02/14 05:56:43 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> This program is free software; you can redistribute it and/or modify @@ -243,7 +243,7 @@ tt_build_tables (sfnt *sfont, struct tt_glyphs *g) g->emsize = head->unitsPerEm; sfnt_locate_table(sfont, "hmtx"); - hmtx = tt_read_longMetrics(sfont, maxp->numGlyphs, hhea->numberOfHMetrics); + hmtx = tt_read_longMetrics(sfont, maxp->numGlyphs, hhea->numOfLongHorMetrics, hhea->numOfExSideBearings); os2 = tt_read_os2__table(sfont); g->default_advh = os2->sTypoAscender - os2->sTypoDescender; @@ -253,7 +253,7 @@ tt_build_tables (sfnt *sfont, struct tt_glyphs *g) struct tt_vhea_table *vhea; vhea = tt_read_vhea_table(sfont); sfnt_locate_table(sfont, "vmtx"); - vmtx = tt_read_longMetrics(sfont, maxp->numGlyphs, vhea->numOfLongVerMetrics); + vmtx = tt_read_longMetrics(sfont, maxp->numGlyphs, vhea->numOfLongVerMetrics, vhea->numOfExSideBearings); RELEASE(vhea); } else { vmtx = NULL; @@ -417,15 +417,15 @@ tt_build_tables (sfnt *sfont, struct tt_glyphs *g) padlen = (g->gd[i].length % 4) ? (4 - (g->gd[i].length % 4)) : 0; glyf_table_size += g->gd[i].length + padlen; if (!num_hm_known && last_advw != g->gd[i].advw) { - hhea->numberOfHMetrics = g->gd[i].gid + 2; + hhea->numOfLongHorMetrics = g->gd[i].gid + 2; num_hm_known = 1; } } /* All advance widths are same. */ if (!num_hm_known) { - hhea->numberOfHMetrics = 1; + hhea->numOfLongHorMetrics = 1; } - hmtx_table_size = hhea->numberOfHMetrics * 2 + (g->last_gid + 1) * 2; + hmtx_table_size = hhea->numOfLongHorMetrics * 2 + (g->last_gid + 1) * 2; /* * Choosing short format does not always give good result @@ -448,9 +448,9 @@ tt_build_tables (sfnt *sfont, struct tt_glyphs *g) long gap, j; gap = (long) g->gd[i].gid - prev - 1; for (j = 1; j <= gap; j++) { - if (prev + j == hhea->numberOfHMetrics - 1) { + if (prev + j == hhea->numOfLongHorMetrics - 1) { p += sfnt_put_ushort(p, last_advw); - } else if (prev + j < hhea->numberOfHMetrics) { + } else if (prev + j < hhea->numOfLongHorMetrics) { p += sfnt_put_ushort(p, 0); } p += sfnt_put_short (p, 0); @@ -461,7 +461,7 @@ tt_build_tables (sfnt *sfont, struct tt_glyphs *g) } } padlen = (g->gd[i].length % 4) ? (4 - (g->gd[i].length % 4)) : 0; - if (g->gd[i].gid < hhea->numberOfHMetrics) { + if (g->gd[i].gid < hhea->numOfLongHorMetrics) { p += sfnt_put_ushort(p, g->gd[i].advw); } p += sfnt_put_short (p, g->gd[i].lsb); @@ -544,7 +544,7 @@ tt_get_metrics (sfnt *sfont, struct tt_glyphs *g) g->emsize = head->unitsPerEm; sfnt_locate_table(sfont, "hmtx"); - hmtx = tt_read_longMetrics(sfont, maxp->numGlyphs, hhea->numberOfHMetrics); + hmtx = tt_read_longMetrics(sfont, maxp->numGlyphs, hhea->numOfLongHorMetrics, hhea->numOfExSideBearings); os2 = tt_read_os2__table(sfont); g->default_advh = os2->sTypoAscender - os2->sTypoDescender; @@ -554,7 +554,7 @@ tt_get_metrics (sfnt *sfont, struct tt_glyphs *g) struct tt_vhea_table *vhea; vhea = tt_read_vhea_table(sfont); sfnt_locate_table(sfont, "vmtx"); - vmtx = tt_read_longMetrics(sfont, maxp->numGlyphs, vhea->numOfLongVerMetrics); + vmtx = tt_read_longMetrics(sfont, maxp->numGlyphs, vhea->numOfLongVerMetrics, vhea->numOfExSideBearings); RELEASE(vhea); } else { vmtx = NULL; diff --git a/Build/source/texk/dvipdfmx/src/tt_table.c b/Build/source/texk/dvipdfmx/src/tt_table.c index fde4d083e94..826cb036d58 100644 --- a/Build/source/texk/dvipdfmx/src/tt_table.c +++ b/Build/source/texk/dvipdfmx/src/tt_table.c @@ -1,8 +1,8 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/tt_table.c,v 1.7 2004/09/11 14:50:29 hirata Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/tt_table.c,v 1.8 2007/02/14 05:56:43 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> This program is free software; you can redistribute it and/or modify @@ -33,7 +33,7 @@ /* tables contains information refered by other tables maxp->numGlyphs, etc --> loca, etc - hhea->numberOfHMetrics --> hmtx + hhea->numOfLongHorMetrics --> hmtx head->indexToLocFormat --> loca head->glyphDataFormat --> glyf */ @@ -162,20 +162,21 @@ char *tt_pack_hhea_table (struct tt_hhea_table *table) p = data = NEW(TT_HHEA_TABLE_SIZE, char); p += sfnt_put_ulong(p, table->version); - p += sfnt_put_short(p, table->Ascender); - p += sfnt_put_short(p, table->Descender); - p += sfnt_put_short(p, table->LineGap); + p += sfnt_put_short(p, table->ascent); + p += sfnt_put_short(p, table->descent); + p += sfnt_put_short(p, table->lineGap); p += sfnt_put_ushort(p, table->advanceWidthMax); p += sfnt_put_short(p, table->minLeftSideBearing); p += sfnt_put_short(p, table->minRightSideBearing); p += sfnt_put_short(p, table->xMaxExtent); p += sfnt_put_short(p, table->caretSlopeRise); p += sfnt_put_short(p, table->caretSlopeRun); - for (i = 0; i < 5; i++) { + p += sfnt_put_short(p, table->caretOffset); + for (i = 0; i < 4; i++) { p += sfnt_put_short(p, table->reserved[i]); } p += sfnt_put_short(p, table->metricDataFormat); - p += sfnt_put_ushort(p, table->numberOfHMetrics); + p += sfnt_put_ushort(p, table->numOfLongHorMetrics); return data; } @@ -184,28 +185,32 @@ struct tt_hhea_table * tt_read_hhea_table (sfnt *sfont) { int i; + ULONG len; struct tt_hhea_table *table = NULL; + len = sfnt_find_table_len(sfont, "hhea"); sfnt_locate_table(sfont, "hhea"); table = NEW(1, struct tt_hhea_table); - table->version = sfnt_get_ulong(sfont); - table->Ascender = sfnt_get_short (sfont); - table->Descender = sfnt_get_short(sfont); - table->LineGap = sfnt_get_short(sfont); + table->version = sfnt_get_ulong(sfont); + table->ascent = sfnt_get_short (sfont); + table->descent = sfnt_get_short(sfont); + table->lineGap = sfnt_get_short(sfont); table->advanceWidthMax = sfnt_get_ushort(sfont); table->minLeftSideBearing = sfnt_get_short(sfont); table->minRightSideBearing = sfnt_get_short(sfont); table->xMaxExtent = sfnt_get_short(sfont); table->caretSlopeRise = sfnt_get_short(sfont); table->caretSlopeRun = sfnt_get_short(sfont); - for(i = 0; i < 5; i++) { + table->caretOffset = sfnt_get_short(sfont); + for(i = 0; i < 4; i++) { table->reserved[i] = sfnt_get_short(sfont); } table->metricDataFormat = sfnt_get_short(sfont); if (table->metricDataFormat != 0) ERROR("unknown metricDaraFormat"); - table->numberOfHMetrics = sfnt_get_ushort(sfont); + table->numOfLongHorMetrics = sfnt_get_ushort(sfont); + table->numOfExSideBearings = (USHORT)((len - table->numOfLongHorMetrics * 4) / 2); return table; } @@ -229,9 +234,10 @@ tt_pack_vhea_table (struct tt_vhea_table *table) p += sfnt_put_short(p, table->caretSlopeRise); p += sfnt_put_short(p, table->caretSlopeRun); p += sfnt_put_short(p, table->caretOffset); - for(i = 0; i < 5; i++) { + for(i = 0; i < 4; i++) { p += sfnt_put_short(p, table->reserved[i]); } + p += sfnt_put_short(p, table->metricDataFormat); p += sfnt_put_ushort(p, table->numOfLongVerMetrics); return data; @@ -239,9 +245,11 @@ tt_pack_vhea_table (struct tt_vhea_table *table) struct tt_vhea_table *tt_read_vhea_table (sfnt *sfont) { - int i; + int i; + ULONG len; struct tt_vhea_table *table = NULL; + len = sfnt_find_table_len(sfont, "vhea"); sfnt_locate_table(sfont, "vhea"); table = NEW(1, struct tt_vhea_table); @@ -256,10 +264,12 @@ struct tt_vhea_table *tt_read_vhea_table (sfnt *sfont) table->caretSlopeRise = sfnt_get_short(sfont); table->caretSlopeRun = sfnt_get_short(sfont); table->caretOffset = sfnt_get_short(sfont); - for(i=0;i<5;i++) { + for(i = 0; i < 4; i++) { (table->reserved)[i] = sfnt_get_short(sfont); } + table->metricDataFormat = sfnt_get_short(sfont); table->numOfLongVerMetrics = sfnt_get_ushort(sfont); + table->numOfExSideBearings = (USHORT)((len - table->numOfLongVerMetrics * 4) / 2); return table; } @@ -309,17 +319,20 @@ tt_read_VORG_table (sfnt *sfont) */ struct tt_longMetrics * -tt_read_longMetrics (sfnt *sfont, USHORT numGlyphs, USHORT numLongMetrics) +tt_read_longMetrics (sfnt *sfont, USHORT numGlyphs, USHORT numLongMetrics, USHORT numExSideBearings) { struct tt_longMetrics *m; USHORT gid, last_adv = 0; + SHORT last_esb = 0; m = NEW(numGlyphs, struct tt_longMetrics); for (gid = 0; gid < numGlyphs; gid++) { if (gid < numLongMetrics) last_adv = sfnt_get_ushort(sfont); - m[gid].sideBearing = sfnt_get_short(sfont); + if (gid < numLongMetrics + numExSideBearings) + last_esb = sfnt_get_short(sfont); m[gid].advance = last_adv; + m[gid].sideBearing = last_esb; } return m; diff --git a/Build/source/texk/dvipdfmx/src/tt_table.h b/Build/source/texk/dvipdfmx/src/tt_table.h index 172ec04f542..bba65d923ee 100644 --- a/Build/source/texk/dvipdfmx/src/tt_table.h +++ b/Build/source/texk/dvipdfmx/src/tt_table.h @@ -1,8 +1,8 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/tt_table.h,v 1.6 2004/09/11 14:50:29 hirata Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/tt_table.h,v 1.7 2007/02/14 05:56:43 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> This program is free software; you can redistribute it and/or modify @@ -51,18 +51,20 @@ struct tt_head_table struct tt_hhea_table { Fixed version; - FWord Ascender; - FWord Descender; - FWord LineGap; + FWord ascent; + FWord descent; + FWord lineGap; uFWord advanceWidthMax; FWord minLeftSideBearing; FWord minRightSideBearing; FWord xMaxExtent; SHORT caretSlopeRise; SHORT caretSlopeRun; - SHORT reserved[5]; /* set to 0 */ + FWord caretOffset; + SHORT reserved[4]; /* set to 0 */ SHORT metricDataFormat; - USHORT numberOfHMetrics; + USHORT numOfLongHorMetrics; + USHORT numOfExSideBearings; /* extra information */ }; struct tt_vhea_table @@ -78,8 +80,10 @@ struct tt_vhea_table SHORT caretSlopeRise; SHORT caretSlopeRun; SHORT caretOffset; - SHORT reserved[5]; /* set to 0 */ + SHORT reserved[4]; /* set to 0 */ + SHORT metricDataFormat; USHORT numOfLongVerMetrics; + USHORT numOfExSideBearings; /* extra information */ }; struct tt_maxp_table @@ -179,7 +183,7 @@ extern struct tt_VORG_table *tt_read_VORG_table (sfnt *sfont); /* hmtx and vmtx */ extern struct tt_longMetrics *tt_read_longMetrics (sfnt *sfont, - USHORT numGlyphs, USHORT numLongMetrics); + USHORT numGlyphs, USHORT numLongMetrics, USHORT numExSideBearings); /* OS/2 table */ extern struct tt_os2__table *tt_read_os2__table (sfnt *sfont); diff --git a/Build/source/texk/dvipdfmx/src/type1.c b/Build/source/texk/dvipdfmx/src/type1.c index e896508210e..859af73f873 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.38 2005/07/17 09:53:38 hirata Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/type1.c,v 1.40 2007/11/14 03:12:21 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -268,7 +268,7 @@ get_font_attr (pdf_font *font, cff_font *cffont) } static void -add_metrics (pdf_font *font, cff_font *cffont, double *widths, long num_glyphs) +add_metrics (pdf_font *font, cff_font *cffont, char **enc_vec, double *widths, long num_glyphs) { pdf_obj *fontdict, *descriptor; pdf_obj *tmp_array; @@ -321,7 +321,7 @@ add_metrics (pdf_font *font, cff_font *cffont, double *widths, long num_glyphs) } for (code = firstchar; code <= lastchar; code++) { if (usedchars[code]) { - gid = cff_encoding_lookup(cffont, code); + gid = cff_glyph_lookup(cffont, enc_vec[code]); pdf_add_array(tmp_array, pdf_new_number(ROUND(widths[gid], 1.0))); } else { @@ -414,6 +414,9 @@ write_fontfile (pdf_font *font, cff_font *cffont, long num_glyphs) offset += cff_pack_index(cffont->gsubr, stream_data_ptr + offset, stream_data_len - offset); /* Encoding */ + /* TODO: don't write Encoding entry if the font is always used + * with PDF Encoding information. Applies to type1c.c as well. + */ cff_dict_set(cffont->topdict, "Encoding", 0, offset); offset += cff_pack_encoding(cffont, stream_data_ptr + offset, stream_data_len - offset); @@ -488,15 +491,6 @@ pdf_font_load_type1 (pdf_font *font) encoding_id = pdf_font_get_encoding (font); fontdict = pdf_font_get_resource (font); - if (pdf_font_get_flag(font, PDF_FONT_FLAG_BASEFONT)) { - if (encoding_id >= 0) { - pdf_add_dict(fontdict, - pdf_new_name("Encoding"), - pdf_get_encoding_reference(encoding_id)); - } - return 0; - } - descriptor = pdf_font_get_descriptor(font); usedchars = pdf_font_get_usedchars (font); ident = pdf_font_get_ident (font); @@ -536,22 +530,6 @@ pdf_font_load_type1 (pdf_font *font) * Encoding related things. */ if (encoding_id >= 0) { - if (pdf_encoding_is_predefined(encoding_id)) { - pdf_add_dict(fontdict, - pdf_new_name("Encoding"), - pdf_new_name(pdf_encoding_get_name(encoding_id))); - } else { -#if 0 - /* - * Gs not working with this. - */ - pdf_add_dict(fontdict, - pdf_new_name("Encoding"), - pdf_get_encoding_resource(enc)); -#endif - if (!pdf_lookup_dict(fontdict, "ToUnicode")) - pdf_attach_ToUnicode_CMap(fontdict, encoding_id, usedchars); - } enc_vec = pdf_encoding_get_encoding(encoding_id); } else { pdf_obj *tounicode; @@ -781,7 +759,7 @@ pdf_font_load_type1 (pdf_font *font) if (verbose > 2) MESG("]"); - add_metrics(font, cffont, widths, num_glyphs); + add_metrics(font, cffont, enc_vec, widths, num_glyphs); offset = write_fontfile(font, cffont, num_glyphs); if (verbose > 1) diff --git a/Build/source/texk/dvipdfmx/src/type1c.c b/Build/source/texk/dvipdfmx/src/type1c.c index 836a4c4e06d..be2525da446 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.21 2005/07/17 09:53:38 hirata Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/type1c.c,v 1.22 2007/11/14 03:12:21 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -304,22 +304,6 @@ pdf_font_load_type1c (pdf_font *font) */ enc_vec = NULL; if (encoding_id >= 0) { - if (pdf_encoding_is_predefined(encoding_id)) { - pdf_add_dict(fontdict, - pdf_new_name("Encoding"), - pdf_new_name(pdf_encoding_get_name(encoding_id))); - } else { -#if 0 - /* - * Gs not working with this. - */ - pdf_add_dict(fontdict, - pdf_new_name("Encoding"), - pdf_get_encoding_reference(encoding_id)); -#endif - if (!pdf_lookup_dict(fontdict, "ToUnicode")) - pdf_attach_ToUnicode_CMap(fontdict, encoding_id, usedchars); - } enc_vec = pdf_encoding_get_encoding(encoding_id); } else { pdf_obj *tounicode; @@ -340,16 +324,16 @@ pdf_font_load_type1c (pdf_font *font) } } if (!pdf_lookup_dict(fontdict, "ToUnicode")) { - tounicode = pdf_create_ToUnicode_CMap(fullname, - enc_vec, usedchars); - if (tounicode) { - pdf_add_dict(fontdict, + tounicode = pdf_create_ToUnicode_CMap(fullname, + enc_vec, usedchars); + if (tounicode) { + pdf_add_dict(fontdict, pdf_new_name("ToUnicode"), pdf_ref_obj (tounicode)); - pdf_release_obj(tounicode); + pdf_release_obj(tounicode); + } } } - } /* * New Encoding data: diff --git a/Build/source/texk/dvipdfmx/src/vf.c b/Build/source/texk/dvipdfmx/src/vf.c index 589c5907767..c682398593d 100644 --- a/Build/source/texk/dvipdfmx/src/vf.c +++ b/Build/source/texk/dvipdfmx/src/vf.c @@ -1,8 +1,8 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/vf.c,v 1.16 2005/07/20 10:41:54 hirata Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/vf.c,v 1.18 2007/11/14 03:36:01 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. - Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata, + Copyright (C) 2007 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu> @@ -768,7 +768,8 @@ static void vf_xxx (SIGNED_QUAD len, unsigned char **start, unsigned char *end) * Warning message from virtual font. */ if (!memcmp((char *)p, "Warning:", 8)) { - WARN("VF:%s", p+8); + if (verbose) + WARN("VF:%s", p+8); } else { dvi_do_special(buffer, len); } @@ -1011,9 +1012,6 @@ void vf_close_all_fonts(void) unsigned long i; int j; struct font_def *one_font; -#ifdef MEM_DEBUG -MEM_START -#endif for (i=0; i<num_vf_fonts; i++) { /* Release the packet for each character */ if (vf_fonts[i].ch_pkt) { @@ -1038,8 +1036,5 @@ MEM_START } if (vf_fonts != NULL) RELEASE (vf_fonts); -#ifdef MEM_DEBUG -MEM_END -#endif return; } diff --git a/Build/source/texk/dvipdfmx/src/xbb.c b/Build/source/texk/dvipdfmx/src/xbb.c new file mode 100644 index 00000000000..4f1b17e825d --- /dev/null +++ b/Build/source/texk/dvipdfmx/src/xbb.c @@ -0,0 +1,564 @@ +/* $Header: /home/cvsroot/dvipdfmx/src/xbb.c,v 1.3 2007/11/14 03:36:01 chofchof Exp $ + + This is xbb, a bounding box extraction program extending ebb. + + Copyright (C) 2007 by Jin-Hwan Cho <chofchof@ktug.or.kr> + + Copyright (C) 1998, 1999 by Mark A. Wicks + + 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 +*/ +#include <stdio.h> +#include <time.h> +#include <string.h> +#include "system.h" +#include "mem.h" +#include "mfileio.h" +#include "numbers.h" +#include "pdfobj.h" +#include "pdfparse.h" + +#include "config.h" + +#ifdef HAVE_LIBPNG +#include <png.h> +#endif + +#define XBB_PROGRAM "xbb" +#define XBB_VERSION "Version 0.1" + +static void usage (void) +{ + fprintf (stderr, "%s, version %s, Copyright (C) 2007 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"); + exit(1); +} + +static char verbose = 0; + +static void do_time(FILE *file) +{ + time_t current_time; + struct tm *bd_time; + time(¤t_time); + bd_time = localtime(¤t_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) +{ + 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]))) + 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])); + result[strlen(name)-strlen(extensions[i])] = 0; + } + strcat (result, ".xbb"); + return result; +} + +static char *xbb_file_mode = FOPEN_W_MODE; + +static void write_xbb (char *filename, 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); + return; + } + if (verbose) { + fprintf (stderr, "Writing to %s: ", xbbfilename); + 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; +} + +/* 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_COM = 0xfe +} JPEG_marker; + +static JPEG_marker JPEG_get_marker (FILE *fp) +{ + int c = fgetc(fp); + if (c != 255) return -1; + for (;;) { + c = fgetc(fp); + if (c < 0) return -1; + else if (c > 0 && c < 255) return c; + } + return -1; +} + +static int check_for_jpeg (FILE *fp) +{ + unsigned char jpeg_sig[2]; + rewind(fp); + if (fread(jpeg_sig, sizeof(unsigned char), 2, fp) != 2) return 0; + else if (jpeg_sig[0] != 0xff || jpeg_sig[1] != JM_SOI) return 0; + return 1; +} + +static int jpeg_get_info (FILE *fp, int *width, int *height) +{ + JPEG_marker marker; + unsigned short length; + int count; + float xdensity = 1.0, ydensity = 1.0; + char app_sig[128]; + + if (!check_for_jpeg(fp)) { + rewind(fp); + return -1; + } + rewind(fp); + count = 0; + while ((marker = JPEG_get_marker(fp)) >= 0) { + if (marker == JM_SOI || (marker >= JM_RST0 && marker <= JM_RST7)) { + count++; continue; + } + length = get_unsigned_pair(fp) - 2; + switch (marker) { + case JM_SOF0: case JM_SOF1: case JM_SOF2: case JM_SOF3: + case JM_SOF5: case JM_SOF6: case JM_SOF7: case JM_SOF9: + case JM_SOF10: case JM_SOF11: case JM_SOF13: case JM_SOF14: + case JM_SOF15: + get_unsigned_byte(fp); + *height = (int)(get_unsigned_pair(fp) * ydensity + 0.5); + *width = (int)(get_unsigned_pair(fp) * xdensity + 0.5); + return 0; + case JM_APP0: + if (length > 5) { + if (fread(app_sig, sizeof(char), 5, fp) != 5) return -1; + length -= 5; + if (!memcmp(app_sig, "JFIF\000", 5)) { + int units, xden, yden; + get_unsigned_pair(fp); + 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; + ydensity = 72.0 / yden; + break; + case 2: /* pixels per centimeter */ + xdensity = 72.0 / 2.54 / xden; + ydensity = 72.0 / 2.54 / yden; + break; + default: + break; + } + length -= 7; + } + } + seek_relative(fp, length); + break; + default: + seek_relative(fp, length); + break; + } + count++; + } + return -1; +} + +static void do_jpeg (FILE *fp, char *filename) +{ + int width, height; + + if (jpeg_get_info(fp, &width, &height) < 0) { + fprintf (stderr, "%s does not look like a JPEG file...\n", filename); + return; + } + write_xbb(filename, 0, 0, width, height); + return; +} + +#ifdef HAVE_LIBPNG +static int check_for_png (FILE *png_file) +{ + unsigned char sigbytes[4]; + rewind (png_file); + if (fread(sigbytes, 1, sizeof(sigbytes), png_file) != sizeof(sigbytes) || + (!png_check_sig (sigbytes, sizeof(sigbytes)))) return 0; + else return 1; +} + +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); + 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) png_destroy_read_struct(&png_ptr, NULL, NULL); + return -1; + } + 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); + *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); + return 0; +} + +static void do_png (FILE *fp, char *filename) +{ + int width, height; + + if (png_get_info(fp, &width, &height) < 0) { + fprintf (stderr, "%s does not look like a PNG file...\n", filename); + return; + } + write_xbb(filename, 0, 0, width, height); + return; +} +#endif /* HAVE_LIBPNG */ + +static int rect_equal (pdf_obj *rect1, pdf_obj *rect2) +{ + int i; + if (!rect1 || !rect2) return 0; + for (i = 0; i < 4; i++) { + if (pdf_number_value(pdf_get_array(rect1, i)) != pdf_number_value(pdf_get_array(rect2, i))) return 0; + } + return 1; +} + +static int pdf_get_info (FILE *image_file, int *llx, int *lly, int *urx, int *ury) +{ + pdf_obj *page_tree; + pdf_obj *bbox; + + page_tree = NULL; + { + pdf_obj *trailer, *catalog, *tmp; + + trailer = pdf_open(image_file); + if (!trailer) { + WARN("Trailer not found! Corrupt PDF file?"); + pdf_close(); + return -1; + } + if (pdf_lookup_dict(trailer, "Encrypt")) { + WARN("This PDF document is encrypted."); + pdf_release_obj(trailer); + pdf_close(); + return -1; + } + catalog = pdf_deref_obj(pdf_lookup_dict(trailer, "Root")); + if (!catalog) { + WARN("Catalog isn't where I expect it."); + pdf_close(); + return -1; + } + pdf_release_obj(trailer); + page_tree = pdf_deref_obj(pdf_lookup_dict(catalog, "Pages")); + pdf_release_obj(catalog); + } + if (!page_tree) { + WARN("Page tree not found."); + pdf_close(); + return -1; + } + { + pdf_obj *kids_ref, *kids; + pdf_obj *crop_box; + 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; + + 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); + + if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "MediaBox")))) { + if (bbox) + pdf_release_obj(bbox); + bbox = tmp; + } + if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "BleedBox")))) { + if (!rect_equal(tmp, bbox)) { + if (bbox) + pdf_release_obj(bbox); + bbox = tmp; + } + } + if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "TrimBox")))) { + if (!rect_equal(tmp, bbox)) { + if (bbox) + pdf_release_obj(bbox); + bbox = 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; + } + } + if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "CropBox")))) { + if (crop_box) + pdf_release_obj(crop_box); + crop_box = tmp; + } + } + if (crop_box) { + pdf_release_obj(bbox); + bbox = crop_box; + } + } + + if (!bbox) { + WARN("No BoundingBox information available."); + pdf_release_obj(page_tree); + pdf_close(); + return -1; + } + + *llx = (int)pdf_number_value(pdf_get_array(bbox, 0)); + *lly = (int)pdf_number_value(pdf_get_array(bbox, 1)); + *urx = (int)pdf_number_value(pdf_get_array(bbox, 2)); + *ury = (int)pdf_number_value(pdf_get_array(bbox, 3)); + + pdf_close(); + return 0; +} + +static void do_pdf (FILE *fp, char *filename) +{ + int llx, lly, urx, ury; + + if (pdf_get_info(fp, &llx, &lly, &urx, &ury) < 0) { + fprintf (stderr, "%s does not look like a PDF file...\n", filename); + return; + } + write_xbb(filename, llx, lly, urx, ury); + return; +} + +FILE *inputfile; + +int main (int argc, char *argv[]) +{ + mem_debug_init(); + + pdf_set_version(5); + 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; + case 'v': + verbose = 1; + argc -= 1; + argv += 1; + break; + case 'h': + usage(); + argc -= 1; + argv += 1; + break; + default: + usage(); + } + } + for (; argc > 0; argc--, argv++) { + 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; + } + if (check_for_jpeg(inputfile)) { + do_jpeg(inputfile, kpse_file_name); + MFCLOSE(inputfile); + continue; + } + if (check_for_pdf(inputfile)) { + do_pdf(inputfile, kpse_file_name); + MFCLOSE(inputfile); + continue; + } +#ifdef HAVE_LIBPNG + if (check_for_png(inputfile)) { + do_png(inputfile, kpse_file_name); + MFCLOSE(inputfile); + continue; + } +#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--; } + } + 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; +} + +void pdf_enc_set_label (unsigned long label) +{ + return; +} + +void pdf_encrypt_data (unsigned char *data, unsigned long len) +{ + return; +} |