--- ChangeLog.orig 2003-02-04 06:46:54.000000000 +0000 +++ ChangeLog 2003-02-03 16:33:09.000000000 +0000 @@ -1,3 +1,27 @@ + +2003-02-03 Egil Kvaleberg + + * font/devps/prologue.ps: Fix for included Postscript that does + a setpagedevice - which is now safely ignored. + + * NEWS: Updated + + * src/devices/grops/ps.cc: Now sets the page size in the generated + document. This is done in two ways: Via a %%-comment for gv and + the like, and via a PageSize and setpagedevice for programs that + understands Postscript proper, like ps2pdf. + + * src/devices/grops/ps.h: New broken-flag to avoid page size + definition, if required. + + * src/devices/grops/grops.man: New broken-flag 16 mentioned + + * doc/Makefile.in: Added -nosetpage flag. Not really necessary due + to the fix in prologue.ps, but cleaner: such information does not + belong in an .eps file. + + * doc/Makefile.sub: See doc/Makefile.in + 2003-01-26 Werner LEMBERG * src/utils/indxbib/indxbib.cc (main) [__EMX__]: Check with --- NEWS.orig 2003-02-04 06:46:59.000000000 +0000 +++ NEWS 2003-02-03 16:30:06.000000000 +0000 @@ -1,6 +1,16 @@ This file describes recent user-visible changes in groff. Bug fixes are not described. There are more details in the man and info pages. +VERSION 1.18.X +============== + +Grops +----- + +o Now emits paper size via %%DocumentMedia and PageSize mechanisms, so + that it is no longer required to tell `gv' or `ps2pdf' about the paper + size. The `broken' flag 16 omits this feature. Patch by address@hidden + VERSION 1.18.2 ============== --- doc/Makefile.in.orig 2003-02-04 06:47:01.000000000 +0000 +++ doc/Makefile.in 2003-01-05 13:31:19.000000000 +0000 @@ -110,7 +110,7 @@ $(MAKEINFO) -I$(srcdir) $(srcdir)/groff.texinfo gnu.eps: gnu.xpm - xpmtoppm $(srcdir)/gnu.xpm | pnmdepth 15 | pnmtops -noturn >$@ + xpmtoppm $(srcdir)/gnu.xpm | pnmdepth 15 | pnmtops -noturn -nosetpage >$@ gnu.png: gnu.xpm xpmtoppm $(srcdir)/gnu.xpm | pnmdepth 15 | pnmtopng >$@ --- doc/Makefile.sub.orig 2003-02-04 06:47:04.000000000 +0000 +++ doc/Makefile.sub 2003-01-05 13:45:20.000000000 +0000 @@ -122,7 +122,7 @@ $(MAKEINFO) -I$(srcdir) $(srcdir)/groff.texinfo gnu.eps: gnu.xpm - xpmtoppm $(srcdir)/gnu.xpm | pnmdepth 15 | pnmtops -noturn -rle >$@ + xpmtoppm $(srcdir)/gnu.xpm | pnmdepth 15 | pnmtops -noturn -nosetpage -rle >$@ gnu.png: gnu.xpm xpmtoppm $(srcdir)/gnu.xpm | pnmdepth 15 | pnmtopng >$@ --- font/devps/prologue.ps.orig 2003-02-04 06:47:06.000000000 +0000 +++ font/devps/prologue.ps 2003-01-05 15:37:59.000000000 +0000 @@ -235,6 +235,12 @@ /CNT countdictstack def userdict begin /showpage {} def + % + % *EK* + % any included setpagedevice should be ignored + % see: http://www.w-beer.de/doc/ps/ + % + /setpagedevice {} def } bind def /PEND { --- src/devices/grops/grops.man.orig 2003-02-04 06:47:10.000000000 +0000 +++ src/devices/grops/grops.man 2003-01-04 19:22:05.000000000 +0000 @@ -159,6 +159,9 @@ this is needed when using Sun's Newsprint with a printer that requires page reversal. . +Add\~16 if no media size information should be included in the document. +This was the behaviour of version 1.18.2 and earlier. +. The default value can be specified by a . .RS --- src/devices/grops/ps.cc.orig 2003-02-04 06:47:13.000000000 +0000 +++ src/devices/grops/ps.cc 2003-01-05 14:33:15.000000000 +0000 @@ -1,5 +1,5 @@ // -*- C++ -*- -/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2002 +/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. Written by James Clark (address@hidden) @@ -19,6 +19,12 @@ with groff; see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* + * PostScript documentation: + * http://www.adobe.com/products/postscript/pdfs/PLRM.pdf + * http://partners.adobe.com/asn/developer/pdfs/tn/5001.DSC_Spec.pdf + */ + #include "driver.h" #include "stringclass.h" #include "cset.h" @@ -536,6 +542,11 @@ void reencode_font(ps_font *); void set_color(color *c, int fill = 0); + const char *media_name(); + int media_width(); + int media_height(); + void media_set(); + public: ps_printer(double); ~ps_printer(); @@ -1139,6 +1150,71 @@ output_hpos = output_vpos = -1; } +const char * ps_printer::media_name() +{ + return "Default"; +} + +int ps_printer::media_width() +{ + /* + * NOTE: + * although paper size is defined as real numbers, it seems to be + * a common convention to round to the nearest postscript unit + * e.g. a4 is really 595.276 by 841.89 but we use 595 by 842 + * + * this is probably a good compromise, especially since the + * Postscript definition specifies that media + * matching should be done within a tolerance of 5 units + */ + return (int)(font::paperwidth*72.0/font::res + 0.5); +} + +int ps_printer::media_height() +{ + return (int)(paper_length*72.0/font::res + 0.5); +} + +void ps_printer::media_set() +{ + /*EK* address@hidden + * + * The setpagedevice implies an erasepage and initgraphics, and + * must thus precede any descriptions for a particular page + * + * NOTE: + * this does not work with ps2pdf when there are included eps + * segments that contain PageSize/setpagedevice + * this might be a bug in ghostscript - must be investigated + * setpagedevice in an .eps is really the wrong concept, anyway + * + * NOTE: + * For the future, this is really the place to insert other + * media selection features, like: + * MediaColor + * MediaPosition + * MediaType + * MediaWeight + * MediaClass + * TraySwitch + * ManualFeed + * InsertSheet + * Duplex + * Collate + * ProcessColorModel + * etc. + */ + if (!(broken_flags & (USE_PS_ADOBE_2_0|NO_PAPERSIZE))) { + out.begin_comment("BeginFeature:") + .comment_arg("*PageSize") + .comment_arg(media_name()) + .end_comment(); + fprintf(out.get_file(), "<< /PageSize [ %d %d ] /ImagingBBox null >> setpagedevice\n", + media_width(), media_height()); + out.simple_comment("EndFeature"); + } +} + void ps_printer::begin_page(int n) { out.begin_comment("Page:") @@ -1151,8 +1227,17 @@ output_line_thickness = -1; output_hpos = output_vpos = -1; ndefined_styles = 0; - out.simple_comment("BeginPageSetup") - .put_symbol("BP") + out.simple_comment("BeginPageSetup"); + +#if 0 + /*EK* address@hidden + * NOTE: + * may decide to do this once per page + */ + media_set(); +#endif + + out.put_symbol("BP") .simple_comment("EndPageSetup"); if (sbuf_color != default_color) set_color(&sbuf_color); @@ -1215,11 +1300,18 @@ out.begin_comment("PageOrder:") .comment_arg("Ascend") .end_comment(); -#if 0 - fprintf(out.get_file(), "%%%%DocumentMedia: () %g %g 0 () ()\n", - font::paperwidth*72.0/font::res, - paper_length*72.0/font::res); -#endif + + if (!(broken_flags & NO_PAPERSIZE)) { /*EK* address@hidden */ + fprintf(out.get_file(), "%%%%DocumentMedia: %s %d %d %d %s %s\n", + media_name(), /* tag name of media */ + media_width(), /* media width */ + media_height(), /* media height */ + 0, /* weight in g/m2 */ + "()", /* paper color, e.g. white */ + "()" /* preprinted form type */ + ); + } + out.begin_comment("Orientation:") .comment_arg(landscape_flag ? "Landscape" : "Portrait") .end_comment(); @@ -1228,12 +1320,30 @@ fprintf(out.get_file(), "%%%%Requirements: numcopies(%d)\n", ncopies); } out.simple_comment("EndComments"); + + if (!(broken_flags & NO_PAPERSIZE)) { /*EK* address@hidden */ + /* gv works fine without this one, but it really should be there */ + out.simple_comment("BeginDefaults"); + fprintf(out.get_file(), "%%%%PageMedia: %s\n", media_name()); + out.simple_comment("EndDefaults"); + } + out.simple_comment("BeginProlog"); rm.output_prolog(out); if (!(broken_flags & NO_SETUP_SECTION)) { out.simple_comment("EndProlog"); out.simple_comment("BeginSetup"); } + +#if 1 + /*EK* address@hidden + * + * define paper (i.e. media) size for entire document here + * this allows ps2pdf to correctly determine page size, for instance + */ + media_set(); +#endif + rm.document_setup(out); out.put_symbol(dict_name) .put_symbol("begin"); --- src/devices/grops/ps.h.orig 2003-02-04 06:47:27.000000000 +0000 +++ src/devices/grops/ps.h 2003-01-05 11:58:51.000000000 +0000 @@ -119,5 +119,6 @@ NO_SETUP_SECTION = 01, STRIP_PERCENT_BANG = 02, STRIP_STRUCTURE_COMMENTS = 04, - USE_PS_ADOBE_2_0 = 010 + USE_PS_ADOBE_2_0 = 010, + NO_PAPERSIZE = 020 /*EK* address@hidden */ };