diff -Nru libpostscript-file-perl-2.11+dfsg/Changes libpostscript-file-perl-2.20+dfsg/Changes --- libpostscript-file-perl-2.11+dfsg/Changes 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/Changes 2012-02-11 18:23:30.000000000 +0000 @@ -1,5 +1,29 @@ Revision history for Perl extension PostScript::File. +2.20 February 11, 2012 + API improvements: + + - Added use_functions method, which selects functions from a + library provided by new module PostScript::File::Functions. + - Added set_min_langlevel method + - Added all_comments strip type + - Renamed methods add_function, get_functions, & has_function + to add_procset, get_procsets, & has_procset. The old names + are still available for backwards compatibility, but their + use is deprecated. + + - Multi-line string literals are now protected from + comment/whitespace stripping. + - Fixed bug: add_preview might strip the preview + - Fixed bug: check_tilde treated "0" like the empty string + - Private methods bbox_comment, pre_pages, post_pages, & + print_file were renamed. You shouldn't have been using them + anyway. + - The get_ordinal method is now private. While it was + formerly documented, it unnecessarily exposed the internals + and had no real use. + - The documentation has been cleaned up. + 2.11 October 11, 2011 Improvements to word wrapping provided by Metrics objects: diff -Nru libpostscript-file-perl-2.11+dfsg/debian/changelog libpostscript-file-perl-2.20+dfsg/debian/changelog --- libpostscript-file-perl-2.11+dfsg/debian/changelog 2011-10-16 13:13:25.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/debian/changelog 2012-02-12 14:16:23.000000000 +0000 @@ -1,3 +1,12 @@ +libpostscript-file-perl (2.20+dfsg-1) unstable; urgency=low + + * New upstream release. + * Refresh fix-pod-spelling.patch. + * Update years of upstream and packaging copyright. + * Add libfont-afm-perl to Suggests. + + -- gregor herrmann Sun, 12 Feb 2012 15:16:07 +0100 + libpostscript-file-perl (2.11+dfsg-1) unstable; urgency=low [ Salvatore Bonaccorso ] diff -Nru libpostscript-file-perl-2.11+dfsg/debian/control libpostscript-file-perl-2.20+dfsg/debian/control --- libpostscript-file-perl-2.11+dfsg/debian/control 2011-10-16 13:13:25.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/debian/control 2012-02-12 14:16:23.000000000 +0000 @@ -16,6 +16,7 @@ Package: libpostscript-file-perl Architecture: all Depends: ${perl:Depends}, ${misc:Depends} +Suggests: libfont-afm-perl Description: module for creating Adobe PostScript files PostScript::File is a Perl module capable of producing the outline for an Adobe PostScript file. It provides convenient routines for writing PostScript diff -Nru libpostscript-file-perl-2.11+dfsg/debian/copyright libpostscript-file-perl-2.20+dfsg/debian/copyright --- libpostscript-file-perl-2.11+dfsg/debian/copyright 2011-10-16 13:13:25.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/debian/copyright 2012-02-12 14:16:23.000000000 +0000 @@ -10,7 +10,7 @@ repack.stub) and is automatically run on upgrade by uscan. Files: * -Copyright: 2009-2011, Christopher J. Madsen +Copyright: 2009-2012, Christopher J. Madsen 2002-2003, Christopher P Willmot License: Artistic or GPL-1+ @@ -26,7 +26,7 @@ Copyright: 2006, Vincent Danjean 2007, Damyan Ivanov 2009-2010, Jonathan Yu - 2010-2011, gregor herrmann + 2010-2012, gregor herrmann 2011, Chris Butler License: Artistic or GPL-1+ diff -Nru libpostscript-file-perl-2.11+dfsg/debian/patches/fix-pod-spelling.patch libpostscript-file-perl-2.20+dfsg/debian/patches/fix-pod-spelling.patch --- libpostscript-file-perl-2.11+dfsg/debian/patches/fix-pod-spelling.patch 2011-10-16 13:13:25.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/debian/patches/fix-pod-spelling.patch 2012-02-12 14:16:23.000000000 +0000 @@ -1,19 +1,22 @@ Description: fix POD spelling -Author: Jonathan Yu Origin: vendor Forwarded: no +Author: Jonathan Yu +Reviewed-by: gregor herrmann +Last-Update: 2012-02-12 + --- a/lib/PostScript/File.pm +++ b/lib/PostScript/File.pm -@@ -2147,7 +2147,7 @@ +@@ -2711,7 +2711,7 @@ Setting this to C or C also causes the document to be encoded in that character set. Any strings you add to the document --that have the UTF8 flag set will be reencoded automatically. Strings -+that have the UTF8 flag set will be re-encoded automatically. Strings - that do not have the UTF8 flag are expected to be in the correct +-that have the UTF-8 flag set will be reencoded automatically. Strings ++that have the UTF-8 flag set will be re-encoded automatically. Strings + that do not have the UTF-8 flag are expected to be in the correct character set already. This means that you should be able to set this to C, use Unicode characters in your code and the "-iso" -@@ -2162,7 +2162,7 @@ +@@ -2726,7 +2726,7 @@ L For backwards compatibility with versions of PostScript::File older @@ -21,22 +24,22 @@ +than 1.05, setting this to C re-encodes the fonts, but does not do any character set translation in the document. - =head2 Initialization keys -@@ -2202,7 +2202,7 @@ + =head3 Initialization keys +@@ -2745,7 +2745,7 @@ - =head3 font_suffix + =head4 font_suffix -This string is appended to each font name as it is reencoded. (Default: "-iso") +This string is appended to each font name as it is re-encoded. (Default: "-iso") The string value is appended to these to make the new names. -@@ -2890,7 +2890,7 @@ - Code added here is output before each page. As there is no special provision for %%Page... DSC comments, they - should be included here. - --Note that any settings defined here will be active for each page seperately. Use B if you want to -+Note that any settings defined here will be active for each page separately. Use B if you want to - carry settings from one page to another. +@@ -3238,7 +3238,7 @@ + page. + + Also note that any settings defined here will be active for each page +-seperately. Use L if you want to carry settings from one ++separately. Use L if you want to carry settings from one + page to another. + - =head2 get_page( [page] ) diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Functions.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Functions.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Functions.pm 1970-01-01 00:00:00.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Functions.pm 2012-02-11 18:23:30.000000000 +0000 @@ -0,0 +1,593 @@ +#--------------------------------------------------------------------- +package PostScript::File::Functions; +# +# Copyright 2012 Christopher J. Madsen +# +# Author: Christopher J. Madsen +# Created: 2 Feb 2012 +# +# This program is free software; you can redistribute it and/or modify +# it under the same terms as Perl itself. +# +# 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 either the +# GNU General Public License or the Artistic License for more details. +# +# ABSTRACT: Collection of useful PostScript functions +#--------------------------------------------------------------------- + +use 5.008; +use strict; +use warnings; + +our $VERSION = '2.20'; +# This file is part of PostScript-File 2.20 (February 11, 2012) + +use Carp qw(croak); +use PostScript::File 2.20 (); # strip method + +# Constant indexes of the arrayrefs in the _functions hash: +sub _id_ () { 0 } ## no critic +sub _code_ () { 1 } ## no critic +sub _requires_ () { 2 } ## no critic + +#===================================================================== +# Initialization: +# +# Subclasses should call __PACKAGE__->_init_module(\*DATA); + +sub _init_module +{ + my ($class, $fh) = @_; + + my $function = $class->_functions; + my @keys; + my $routine; + + while (<$fh>) { + if (/^%-+$/) { + PostScript::File::->strip(all_comments => $routine); + next unless $routine; + $routine =~ m!^/(\w+)! or die "Can't find name in $routine"; + push @keys, $1; + $function->{$1} = [ undef, $routine ]; + $routine = ''; + } + + $routine .= $_; + } # end while + + my $id = 'A'; + $id .= 'A' while @keys > 26 ** length $id; + + my $re = join('|', @keys); + $re = qr/\b($re)\b/; + + for my $name (@keys) { + my $f = $function->{$name}; + $$f[_id_] = $id++; + + my %req; + + $req{$_} = 1 for $$f[_code_] =~ m/$re/g; + delete $req{$name}; + + $$f[_requires_] = [ keys %req ] if %req; + } # end for each $f in @keys + + close $fh; + + 1; +} # end _init_module +#===================================================================== + + +sub new +{ + my ($class) = @_; + + # Create the object: + bless {}, $class; +} # end new + +#--------------------------------------------------------------------- +# The hash of available functions (class attribute): +# +# This is automatically per-class, so subclasses normally don't need +# to override it. + +{ +my %functions; +sub _functions +{ + my $self = shift; + + $functions{ref($self) || $self} ||= {}; +} # end _functions +} # end scope of %functions + +#--------------------------------------------------------------------- + + +sub add +{ + my ($self, @names) = @_; + + my $available = $self->_functions; + + while (@names) { + my $name = shift @names; + + croak "$name is not an available function" unless $available->{$name}; + $self->{$name} = 1; + + next unless my $need = $available->{$name}[_requires_]; + push @names, grep { not $self->{$_} } @$need; + } # end while @names to add + + return $self; +} # end add +#--------------------------------------------------------------------- + + +sub generate_procset +{ + my ($self, $name) = @_; + + my @list = sort { $a->[_id_] cmp $b->[_id_] } + @{ $self->_functions }{ keys %$self }; + + my $code = join('', map { $_->[_code_] } @list); + + my $blkid = join('', map { $_->[_id_] } @list); + + unless (defined $name) { + $name = ref $self; + $name =~ s/::/_/g; + } + + return wantarray + ? ("$name-$blkid", $code, $self->VERSION) + : $code; +} # end generate_procset +#--------------------------------------------------------------------- + + +sub add_to_file +{ + my $self = shift; + my $ps = shift; + + $ps->add_procset( $self->generate_procset(@_) ); +} # end add_to_file + +#===================================================================== +# Package Return Value: + +__PACKAGE__->_init_module(\*DATA); + +#use YAML::Tiny; print Dump(\%function); + +=head1 NAME + +PostScript::File::Functions - Collection of useful PostScript functions + +=head1 VERSION + +This document describes version 2.20 of +PostScript::File::Functions, released February 11, 2012 +as part of PostScript-File version 2.20. + +=head1 SYNOPSIS + + use PostScript::File; + + my $ps = PostScript::File->new; + $ps->use_functions(qw( setColor showCenter )); + $ps->add_to_page("1 setColor\n" . + "400 400 (Hello, World!) showCenter\n"); + +=head1 DESCRIPTION + +PostScript::File::Functions provides a library of handy PostScript +functions that can be used in documents created with PostScript::File. +You don't normally use this module directly; PostScript::File's +C method loads it automatically. + +=head1 POSTSCRIPT FUNCTIONS + +=head2 boxPath + + LEFT TOP RIGHT BOTTOM boxPath + +Given the coordinates of the sides of a box, this creates a new, +closed path starting at the bottom right corner, across to the +bottom left, up to the top left, over to the top right, and then +back to the bottom right. + +=head2 clipBox + + LEFT TOP RIGHT BOTTOM clipBox + +This clips to the box defined by the coordinates. + +=head2 drawBox + + LEFT TOP RIGHT BOTTOM drawBox + +This calls L to and then strokes the path using the current +pen. + +=head2 fillBox + + LEFT TOP RIGHT BOTTOM COLOR fillBox + +This fills the path created by L with C, which can +be anything accepted by L. + +=head2 hLine + + WIDTH X Y hline + +Stroke a horizontal line with the current pen with the left endpoint +at position C, extending C points rightwards. + +=head2 setColor + + RGB-ARRAY|BW-NUMBER setColor + +This combines C and C into a single function. +You can provide either an array of 3 numbers for C, or +a single number for C. The L +function was designed to format the parameter to this function. + +=head2 showCenter + + X Y STRING showCenter + +This prints C centered horizontally at position X using +baseline Y and the current font. + +=head2 showLeft + + X Y STRING showLeft + +This prints C left justified at position X using baseline Y +and the current font. + +=head2 showLines + + X Y LINES SPACING FUNC showLines + +This calls C for each element of C, which should be an +array of strings. C is called with C on the +stack, and it must pop those off. C is subtracted from +C after every line. C will normally be C, +C, or C. + +=head2 showRight + + X Y STRING showRight + +This prints C right justified at position X using baseline Y +and the current font. + +=head2 vLine + + HEIGHT X Y vline + +Stroke a vertical line with the current pen with the bottom endpoint +at position C, extending C points upwards. + +=head1 METHODS + +While you don't normally deal with PostScript::File::Functions objects +directly, it is possible. The following methods are available: + + + +=head2 new + + $funcs = PostScript::File::Functions->new; + +The constructor takes no parameters. + + +=head2 add + + $funcs->add('functionRequested', ...); + +Add one or more functions to the procset to be generated. All +dependencies of the requsted functions are added automatically. See +L for the list of available functions. + + +=head2 add_to_file + + $funcs->add_to_file($ps, $basename); + +This is short for + + $ps->add_procset( $funcs->generate_procset($basename) ); + +C<$ps> should normally be a PostScript::File object. +See L. + + +=head2 generate_procset + + ($name, $code, $version) = $funcs->generate_procset($basename); + +This collects the requsted functions into a block of PostScript code. + +C<$name> is a suitable name for the procset, created by appending the +ids of the requsted functions to C<$basename>. If C<$basename> is +omitted, it defaults to the class name with C<::> replaced by C<_>. + +C<$code> is a block of PostScript code that defines the functions. It +contains no comments or excess whitespace. + +C<$version> is the version number of the procset. + +In scalar context, returns C<$code>. + +=head1 DIAGNOSTICS + +=over + +=item C<< %s is not an available function >> + +You requsted a function that this version of +PostScript::File::Functions doesn't provide. + + +=back + +=head1 CONFIGURATION AND ENVIRONMENT + +PostScript::File::Functions requires no configuration files or environment variables. + +=head1 INCOMPATIBILITIES + +None reported. + +=head1 BUGS AND LIMITATIONS + +No bugs have been reported. + +=head1 AUTHOR + +Christopher J. Madsen S >>> + +Please report any bugs or feature requests +to S >>> +or through the web interface at +L<< http://rt.cpan.org/Public/Bug/Report.html?Queue=PostScript-File >>. + +You can follow or contribute to PostScript-File's development at +L<< http://github.com/madsen/postscript-file >>. + +=head1 COPYRIGHT AND LICENSE + +This software is copyright (c) 2012 by Christopher J. Madsen. + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +=head1 DISCLAIMER OF WARRANTY + +BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER +EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE +ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH +YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL +NECESSARY SERVICING, REPAIR, OR CORRECTION. + +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENSE, BE +LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, +OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE +THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + +=cut + +__DATA__ + +%--------------------------------------------------------------------- +% Set the color: RGB-ARRAY|BW-NUMBER setColor +% +% This combines C and C into a single function. +% You can provide either an array of 3 numbers for C, or +% a single number for C. The L +% function was designed to format the parameter to this function. + +/setColor +{ + dup type (arraytype) eq { + % We have an array, so it's RGB: + aload pop + setrgbcolor + }{ + % Otherwise, it must be a gray level: + setgray + } ifelse +} bind def + +%--------------------------------------------------------------------- +% Create a rectangular path: LEFT TOP RIGHT BOTTOM boxPath +% +% Given the coordinates of the sides of a box, this creates a new, +% closed path starting at the bottom right corner, across to the +% bottom left, up to the top left, over to the top right, and then +% back to the bottom right. + +/boxPath +{ + % stack L T R B + newpath + 2 copy moveto % move to BR + 3 index exch lineto % line to BL + % stack L T R + 1 index + % stack L T R T + 4 2 roll + % stack R T L T + lineto % line to TL + lineto % line to TR + closepath +} bind def + +%--------------------------------------------------------------------- +% Clip to a rectangle: LEFT TOP RIGHT BOTTOM clipBox +% +% This clips to the box defined by the coordinates. + +/clipBox { boxPath clip } bind def + +%--------------------------------------------------------------------- +% Draw a rectangle: LEFT TOP RIGHT BOTTOM drawBox +% +% This calls L to and then strokes the path using the current +% pen. + +/drawBox { boxPath stroke } bind def + +%--------------------------------------------------------------------- +% Fill a box with color: LEFT TOP RIGHT BOTTOM COLOR fillBox +% +% This fills the path created by L with C, which can +% be anything accepted by L. + +/fillBox +{ + gsave + setColor + boxPath + fill + grestore +} bind def + +%--------------------------------------------------------------------- +% Print text centered at a point: X Y STRING showCenter +% +% This prints C centered horizontally at position X using +% baseline Y and the current font. + +/showCenter +{ + newpath + 0 0 moveto + % stack X Y STRING + dup 4 1 roll % Put a copy of STRING on bottom + % stack STRING X Y STRING + false charpath flattenpath pathbbox % Compute bounding box of STRING + % stack STRING X Y Lx Ly Ux Uy + pop exch pop % Discard Y values (... Lx Ux) + add 2 div neg % Compute X offset + % stack STRING X Y Ox + 0 % Use 0 for y offset + newpath + moveto + rmoveto + show +} bind def + +%--------------------------------------------------------------------- +% Print left justified text: X Y STRING showLeft +% +% This prints C left justified at position X using baseline Y +% and the current font. + +/showLeft +{ + newpath + 3 1 roll % STRING X Y + moveto + show +} bind def + +%--------------------------------------------------------------------- +% Print right justified text: X Y STRING showRight +% +% This prints C right justified at position X using baseline Y +% and the current font. + +/showRight +{ + newpath + 0 0 moveto + % stack X Y STRING + dup 4 1 roll % Put a copy of STRING on bottom + % stack STRING X Y STRING + false charpath flattenpath pathbbox % Compute bounding box of STRING + % stack STRING X Y Lx Ly Ux Uy + pop exch pop % Discard Y values (... Lx Ux) + add neg % Compute X offset + % stack STRING X Y Ox + 0 % Use 0 for y offset + newpath + moveto + rmoveto + show +} bind def + +%--------------------------------------------------------------------- +% Print text on multiple lines: X Y LINES SPACING FUNC showLines +% +% This calls C for each element of C, which should be an +% array of strings. C is called with C on the +% stack, and it must pop those off. C is subtracted from +% C after every line. C will normally be C, +% C, or C. + +/showLines +{ + cvx % convert name of FUNC to executable function + 5 2 roll % stack SPACING FUNC X Y LINES + { % stack SPACING FUNC X Y STRING + 2 index % stack SPACING FUNC X Y STRING X + 2 index % stack SPACING FUNC X Y STRING X Y + 6 index sub % subtract SPACING from Y + 5 2 roll % stack SPACING FUNC X Y' X Y STRING + 5 index exec % execute FUNC; stack SPACING FUNC X Y' + } forall + pop pop pop pop +} bind def + +%--------------------------------------------------------------------- +% Stroke a horizontal line: WIDTH X Y hline +% +% Stroke a horizontal line with the current pen with the left endpoint +% at position C, extending C points rightwards. + +/hLine +{ + newpath + moveto + 0 rlineto stroke +} bind def + +%--------------------------------------------------------------------- +% Stroke a vertical line: HEIGHT X Y vline +% +% Stroke a vertical line with the current pen with the bottom endpoint +% at position C, extending C points upwards. + +/vLine +{ + newpath + moveto + 0 exch rlineto stroke +} bind def + +%--------------------------------------------------------------------- +%EOF diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/cp1252/Courier/BoldOblique.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/cp1252/Courier/BoldOblique.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/cp1252/Courier/BoldOblique.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/cp1252/Courier/BoldOblique.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::cp1252::Courier::BoldOblique; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Courier-BoldOblique'} ||= { 'ascender' => 626, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/cp1252/Courier/Bold.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/cp1252/Courier/Bold.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/cp1252/Courier/Bold.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/cp1252/Courier/Bold.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::cp1252::Courier::Bold; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Courier-Bold'} ||= { 'ascender' => 626, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/cp1252/Courier/Oblique.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/cp1252/Courier/Oblique.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/cp1252/Courier/Oblique.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/cp1252/Courier/Oblique.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::cp1252::Courier::Oblique; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Courier-Oblique'} ||= { 'ascender' => 629, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/cp1252/Courier.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/cp1252/Courier.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/cp1252/Courier.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/cp1252/Courier.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::cp1252::Courier; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Courier'} ||= { 'ascender' => 629, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/cp1252/Helvetica/BoldOblique.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/cp1252/Helvetica/BoldOblique.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/cp1252/Helvetica/BoldOblique.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/cp1252/Helvetica/BoldOblique.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::cp1252::Helvetica::BoldOblique; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Helvetica-BoldOblique'} ||= { 'ascender' => 718, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/cp1252/Helvetica/Bold.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/cp1252/Helvetica/Bold.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/cp1252/Helvetica/Bold.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/cp1252/Helvetica/Bold.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::cp1252::Helvetica::Bold; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Helvetica-Bold'} ||= { 'ascender' => 718, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/cp1252/Helvetica/Oblique.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/cp1252/Helvetica/Oblique.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/cp1252/Helvetica/Oblique.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/cp1252/Helvetica/Oblique.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::cp1252::Helvetica::Oblique; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Helvetica-Oblique'} ||= { 'ascender' => 718, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/cp1252/Helvetica.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/cp1252/Helvetica.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/cp1252/Helvetica.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/cp1252/Helvetica.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::cp1252::Helvetica; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Helvetica'} ||= { 'ascender' => 718, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/cp1252/Times/BoldItalic.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/cp1252/Times/BoldItalic.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/cp1252/Times/BoldItalic.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/cp1252/Times/BoldItalic.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::cp1252::Times::BoldItalic; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Times-BoldItalic'} ||= { 'ascender' => 699, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/cp1252/Times/Bold.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/cp1252/Times/Bold.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/cp1252/Times/Bold.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/cp1252/Times/Bold.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::cp1252::Times::Bold; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Times-Bold'} ||= { 'ascender' => 676, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/cp1252/Times/Italic.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/cp1252/Times/Italic.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/cp1252/Times/Italic.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/cp1252/Times/Italic.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::cp1252::Times::Italic; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Times-Italic'} ||= { 'ascender' => 683, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/cp1252/Times/Roman.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/cp1252/Times/Roman.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/cp1252/Times/Roman.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/cp1252/Times/Roman.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::cp1252::Times::Roman; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Times-Roman'} ||= { 'ascender' => 683, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Courier/BoldOblique.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Courier/BoldOblique.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Courier/BoldOblique.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Courier/BoldOblique.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::iso_8859_1::Courier::BoldOblique; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Courier-BoldOblique'} ||= { 'ascender' => 626, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Courier/Bold.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Courier/Bold.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Courier/Bold.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Courier/Bold.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::iso_8859_1::Courier::Bold; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Courier-Bold'} ||= { 'ascender' => 626, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Courier/Oblique.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Courier/Oblique.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Courier/Oblique.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Courier/Oblique.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::iso_8859_1::Courier::Oblique; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Courier-Oblique'} ||= { 'ascender' => 629, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Courier.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Courier.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Courier.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Courier.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::iso_8859_1::Courier; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Courier'} ||= { 'ascender' => 629, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Helvetica/BoldOblique.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Helvetica/BoldOblique.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Helvetica/BoldOblique.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Helvetica/BoldOblique.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::iso_8859_1::Helvetica::BoldOblique; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Helvetica-BoldOblique'} ||= { 'ascender' => 718, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Helvetica/Bold.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Helvetica/Bold.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Helvetica/Bold.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Helvetica/Bold.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::iso_8859_1::Helvetica::Bold; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Helvetica-Bold'} ||= { 'ascender' => 718, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Helvetica/Oblique.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Helvetica/Oblique.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Helvetica/Oblique.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Helvetica/Oblique.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::iso_8859_1::Helvetica::Oblique; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Helvetica-Oblique'} ||= { 'ascender' => 718, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Helvetica.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Helvetica.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Helvetica.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Helvetica.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::iso_8859_1::Helvetica; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Helvetica'} ||= { 'ascender' => 718, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Times/BoldItalic.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Times/BoldItalic.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Times/BoldItalic.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Times/BoldItalic.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::iso_8859_1::Times::BoldItalic; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Times-BoldItalic'} ||= { 'ascender' => 699, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Times/Bold.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Times/Bold.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Times/Bold.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Times/Bold.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::iso_8859_1::Times::Bold; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Times-Bold'} ||= { 'ascender' => 676, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Times/Italic.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Times/Italic.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Times/Italic.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Times/Italic.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::iso_8859_1::Times::Italic; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Times-Italic'} ||= { 'ascender' => 683, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Times/Roman.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Times/Roman.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Times/Roman.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/iso_8859_1/Times/Roman.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::iso_8859_1::Times::Roman; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Times-Roman'} ||= { 'ascender' => 683, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/Loader.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/Loader.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/Loader.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/Loader.pm 2012-02-11 18:23:30.000000000 +0000 @@ -18,12 +18,13 @@ #--------------------------------------------------------------------- use 5.008; -our $VERSION = '2.02'; ## no critic -# This file is part of PostScript-File 2.11 (October 11, 2011) +our $VERSION = '2.20'; ## no critic +# This file is part of PostScript-File 2.20 (February 11, 2012) use strict; use warnings; use Carp 'confess'; +# RECOMMEND PREREQ: Font::AFM use Font::AFM; use PostScript::File 2.00 (); @@ -257,9 +258,9 @@ =head1 VERSION -This document describes version 2.02 of -PostScript::File::Metrics::Loader, released October 11, 2011 -as part of PostScript-File version 2.11. +This document describes version 2.20 of +PostScript::File::Metrics::Loader, released February 11, 2012 +as part of PostScript-File version 2.20. =head1 DESCRIPTION @@ -279,6 +280,14 @@ =head1 SUBROUTINES +=head2 get_encoding_vector + + PostScript::File::Metrics::Loader::get_encoding_vector($encoding) + +This returns the encoding vector for C<$encoding>, an arrayref of 256 +glyph names. + + =head2 load PostScript::File::Metrics::Loader::load($font, \@encodings) @@ -287,14 +296,6 @@ width tables for each of the C<@encodings>. The metrics are stored into the hashes used internally by PostScript::File::Metrics. - -=head2 get_encoding_vector - - PostScript::File::Metrics::Loader::get_encoding_vector($encoding) - -This returns the encoding vector for C<$encoding>, an arrayref of 256 -glyph names. - =head1 DIAGNOSTICS =over @@ -381,17 +382,17 @@ Christopher J. Madsen S >>> -Please report any bugs or feature requests to -S >>>, +Please report any bugs or feature requests +to S >>> or through the web interface at -L +L<< http://rt.cpan.org/Public/Bug/Report.html?Queue=PostScript-File >>. You can follow or contribute to PostScript-File's development at L<< http://github.com/madsen/postscript-file >>. =head1 COPYRIGHT AND LICENSE -This software is copyright (c) 2011 by Christopher J. Madsen. +This software is copyright (c) 2012 by Christopher J. Madsen. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/std/Courier/BoldOblique.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/std/Courier/BoldOblique.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/std/Courier/BoldOblique.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/std/Courier/BoldOblique.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::std::Courier::BoldOblique; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Courier-BoldOblique'} ||= { 'ascender' => 626, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/std/Courier/Bold.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/std/Courier/Bold.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/std/Courier/Bold.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/std/Courier/Bold.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::std::Courier::Bold; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Courier-Bold'} ||= { 'ascender' => 626, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/std/Courier/Oblique.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/std/Courier/Oblique.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/std/Courier/Oblique.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/std/Courier/Oblique.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::std::Courier::Oblique; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Courier-Oblique'} ||= { 'ascender' => 629, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/std/Courier.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/std/Courier.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/std/Courier.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/std/Courier.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::std::Courier; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Courier'} ||= { 'ascender' => 629, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/std/Helvetica/BoldOblique.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/std/Helvetica/BoldOblique.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/std/Helvetica/BoldOblique.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/std/Helvetica/BoldOblique.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::std::Helvetica::BoldOblique; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Helvetica-BoldOblique'} ||= { 'ascender' => 718, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/std/Helvetica/Bold.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/std/Helvetica/Bold.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/std/Helvetica/Bold.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/std/Helvetica/Bold.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::std::Helvetica::Bold; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Helvetica-Bold'} ||= { 'ascender' => 718, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/std/Helvetica/Oblique.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/std/Helvetica/Oblique.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/std/Helvetica/Oblique.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/std/Helvetica/Oblique.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::std::Helvetica::Oblique; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Helvetica-Oblique'} ||= { 'ascender' => 718, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/std/Helvetica.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/std/Helvetica.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/std/Helvetica.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/std/Helvetica.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::std::Helvetica; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Helvetica'} ||= { 'ascender' => 718, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/std/Times/BoldItalic.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/std/Times/BoldItalic.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/std/Times/BoldItalic.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/std/Times/BoldItalic.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::std::Times::BoldItalic; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Times-BoldItalic'} ||= { 'ascender' => 699, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/std/Times/Bold.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/std/Times/Bold.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/std/Times/Bold.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/std/Times/Bold.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::std::Times::Bold; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Times-Bold'} ||= { 'ascender' => 676, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/std/Times/Italic.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/std/Times/Italic.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/std/Times/Italic.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/std/Times/Italic.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::std::Times::Italic; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Times-Italic'} ||= { 'ascender' => 683, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/std/Times/Roman.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/std/Times/Roman.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/std/Times/Roman.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/std/Times/Roman.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::std::Times::Roman; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Times-Roman'} ||= { 'ascender' => 683, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/sym/Symbol.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/sym/Symbol.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics/sym/Symbol.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics/sym/Symbol.pm 2012-02-11 18:23:30.000000000 +0000 @@ -6,7 +6,7 @@ package PostScript::File::Metrics::sym::Symbol; our $VERSION = '2.01'; -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) $PostScript::File::Metrics::Info{'Symbol'} ||= { 'ascender' => undef, diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File/Metrics.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File/Metrics.pm 2012-02-11 18:23:30.000000000 +0000 @@ -19,7 +19,7 @@ use 5.008; our $VERSION = '2.11'; ## no critic -# This file is part of PostScript-File 2.11 (October 11, 2011) +# This file is part of PostScript-File 2.20 (February 11, 2012) use strict; use warnings; @@ -320,8 +320,8 @@ =head1 VERSION This document describes version 2.11 of -PostScript::File::Metrics, released October 11, 2011 -as part of PostScript-File version 2.11. +PostScript::File::Metrics, released February 11, 2012 +as part of PostScript-File version 2.20. =head1 SYNOPSIS @@ -601,17 +601,17 @@ Christopher J. Madsen S >>> -Please report any bugs or feature requests to -S >>>, +Please report any bugs or feature requests +to S >>> or through the web interface at -L +L<< http://rt.cpan.org/Public/Bug/Report.html?Queue=PostScript-File >>. You can follow or contribute to PostScript-File's development at L<< http://github.com/madsen/postscript-file >>. =head1 COPYRIGHT AND LICENSE -This software is copyright (c) 2011 by Christopher J. Madsen. +This software is copyright (c) 2012 by Christopher J. Madsen. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. diff -Nru libpostscript-file-perl-2.11+dfsg/lib/PostScript/File.pm libpostscript-file-perl-2.20+dfsg/lib/PostScript/File.pm --- libpostscript-file-perl-2.11+dfsg/lib/PostScript/File.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/lib/PostScript/File.pm 2012-02-11 18:23:30.000000000 +0000 @@ -15,19 +15,19 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either the # GNU General Public License or the Artistic License for more details. # -# ABSTRACT: Base class for creating Adobe PostScript files +# ABSTRACT: Class for creating Adobe PostScript files #--------------------------------------------------------------------- use 5.008; -our $VERSION = '2.11'; ## no critic -# This file is part of PostScript-File 2.11 (October 11, 2011) +our $VERSION = '2.20'; ## no critic +# This file is part of PostScript-File 2.20 (February 11, 2012) use strict; use warnings; use Carp 'croak'; use File::Spec (); use Scalar::Util 'openhandle'; -use Exporter 'import'; +use Exporter 5.57 'import'; our %EXPORT_TAGS = (metrics_methods => [qw( encode_text decode_text convert_hyphens set_auto_hyphen @@ -47,11 +47,6 @@ ## use critic # global constants -our %strip_re = ( - none => qr{\A\z}, # remove nothing - space => qr{^\s+}m, # remove leading spaces - comments => qr{^\s*(?:%(?![!%]).*\n)?}m, # remove single line comments -); our %encoding_def; # defined near _set_reencode our ($t1ascii, $ttftotype42); @@ -126,7 +121,6 @@ Symbol ); - # 5.008-compatible version of defined-or: sub _def { for (@_) { return $_ if defined $_ } undef } @@ -236,7 +230,6 @@ } - sub newpage { my ($o, $page) = @_; my $oldpage = $o->{page}[$o->{p}]; @@ -258,8 +251,14 @@ } -sub pre_pages { +sub _pre_pages +{ my ($o, $landscape, $clipping, $filename) = @_; + + if (my $use_functions = $o->{use_functions}) { + $use_functions->add_to_file($o); + } + my $docSupplied = $o->{DocSupplied}; ## Thanks to Johan Vromans for the ISOLatin1Encoding. my $fonts = ""; @@ -339,7 +338,7 @@ # Prepare the PostScript file my $postscript = $o->{eps} ? "\%!PS-Adobe-3.0 EPSF-3.0\n" : "\%!PS-Adobe-3.0\n"; if ($o->{eps}) { - $postscript .= $o->bbox_comment('', $o->{bbox}); + $postscript .= $o->_bbox_comment('', $o->{bbox}); } if ($o->{headings}) { require Sys::Hostname; @@ -607,11 +606,12 @@ end END_DEBUG_OFF + my $ver = sprintf('%g', $VERSION); my $supplied = ""; if ($landscapefn or $clipfn or $errorfn or $debugfn) { - $docSupplied .= "\%\%+ procset PostScript_File $VERSION 0\n"; + $docSupplied .= "\%\%+ procset PostScript_File $ver 0\n"; $supplied .= $o->_here_doc(<{page}->[$p]; my @pbox = $o->get_page_bounding_box($page); $o->set_bounding_box(@pbox); - $postscript .= $o->pre_pages($o->{pagelandsc}[$p], $o->{pageclip}[$p], $epsfile); + $postscript .= $o->_pre_pages($o->{pagelandsc}[$p], $o->{pageclip}[$p], $epsfile); $postscript .= "landscape\n" if ($o->{pagelandsc}[$p]); $postscript .= "$pbox[0] $pbox[1] $pbox[2] $pbox[3] cliptobox\n" if ($o->{pageclip}[$p]); $postscript .= "$debugbegin\n"; $postscript .= $o->{Pages}->[$p]; $postscript .= "$debugend\n"; - $postscript .= $o->post_pages(); + $postscript .= $o->_post_pages(); - push @pages, $o->print_file( $fh || $epsfile, $postscript ); + push @pages, $o->_print_file( $fh || $epsfile, $postscript ); $p++; } while ($p < $o->{pagecount}); @@ -782,17 +783,17 @@ my $psfile = $o->{filename}; $psfile .= defined($o->{file_ext}) ? $o->{file_ext} : '.ps' if defined $psfile; - my $postscript = $o->pre_pages($landscape, $clipping, $psfile); + my $postscript = $o->_pre_pages($landscape, $clipping, $psfile); for (my $p = 0; $p < $o->{pagecount}; $p++) { my $page = $o->{page}->[$p]; my @pbox = $o->get_page_bounding_box($page); my ($landscape, $pagebb); if ($o->{pagelandsc}[$p]) { $landscape = "landscape"; - $pagebb = $o->bbox_comment(Page => [ @pbox[1,0,3,2] ]); + $pagebb = $o->_bbox_comment(Page => [ @pbox[1,0,3,2] ]); } else { $landscape = ""; - $pagebb = $o->bbox_comment(Page => \@pbox); + $pagebb = $o->_bbox_comment(Page => \@pbox); } my $cliptobox = $o->{pageclip}[$p] ? "$pbox[0] $pbox[1] $pbox[2] $pbox[3] cliptobox" : ""; $postscript .= $o->_here_doc(<post_pages(); - return $o->print_file( $fh || $psfile, $postscript ); + $postscript .= $o->_post_pages(); + return $o->_print_file( $fh || $psfile, $postscript ); } } @@ -845,7 +846,7 @@ # Create a BoundingBox: comment, # and a HiRes version if the box has a fractional part: -sub bbox_comment +sub _bbox_comment { my ($o, $type, $bbox) = @_; @@ -858,9 +859,9 @@ } # end if fractional bbox "%%${type}BoundingBox: $comment\n"; -} # end bbox_comment +} # end _bbox_comment -sub print_file +sub _print_file { my $o = shift; my $filename = shift; @@ -883,9 +884,10 @@ } else { return $_[0]; } # end else no filename -} # end print_file +} # end _print_file # Internal method, used by output() # Expects file name and contents +#--------------------------------------------------------------------- sub get_auto_hyphen { @@ -922,6 +924,7 @@ sub get_eps { my $o = shift; return $o->{eps}; } + sub get_paper { my $o = shift; return $o->{paper}; @@ -956,6 +959,7 @@ } } + sub get_width { my $o = shift; return $o->{width}; @@ -976,6 +980,7 @@ } } + sub get_height { my $o = shift; return $o->{height}; @@ -995,6 +1000,7 @@ } } + sub get_landscape { my $o = shift; return $o->{landscape}; @@ -1011,6 +1017,7 @@ } } + sub get_clipping { my $o = shift; return $o->{clipping}; @@ -1128,6 +1135,7 @@ 65533 => pack(C => 0x3F), # U+FFFD REPLACEMENT CHARACTER ); + sub encode_text { my $o = shift; @@ -1151,6 +1159,7 @@ } } # end encode_text + sub decode_text { my $o = shift; # $text, $preserve_minus @@ -1167,6 +1176,7 @@ } } # end decode_text + sub convert_hyphens { my $o = shift; @@ -1224,33 +1234,96 @@ $metrics; } # end get_metrics +#--------------------------------------------------------------------- + sub get_strip { my $o = shift; return $o->{strip_type}; } +my $eolRE = qr/(?>\r\n?|\n)/; +my $noeolRE = qr/[^\r\n]/; +my $nonwsRE = qr/[^ \t\r\n]/; + +my %strip_re = ( + none => 0, # remove nothing + space => qr{\G^\s+}m, # remove leading spaces + # remove leading spaces and single line comments (except %% and %!): + comments => qr{\G^(?:\s+|%(?![!%])(?:$noeolRE)*(?:$eolRE))}mo, + # remove leading spaces and all comments (except %% and %!): + all_comments => qr{\G (?: ^\s+ + | ^% (?![!%]) (?:$noeolRE)* (?:$eolRE) + | [ \t]*%(?![!%]) (?:$noeolRE)* ) + }mox, +); # end strip_re + sub set_strip { my ($o, $strip) = @_; if (not defined $strip) { $strip = 'space' } else { $strip = lc $strip } - $o->{strip} = $strip_re{$strip} + defined($o->{strip} = $strip_re{$strip}) or croak "Invalid strip type $strip"; $o->{strip_type} = $strip; } +#sub chkpt +#{ +# my $at = substr($_, pos(), 5); +# $at =~ s/([^ -~])/sprintf '\x%02X', ord $1 /eg; +# printf "%d: %s\n", pos(), $at; +#} # end chkpt + +sub strip +{ + my $o = shift; + + my $re; + if (@_ > 1) { + my $strip = shift; + defined($re = $strip_re{$strip}) + or croak "Invalid strip type $strip"; + } else { + $re = $o->{strip}; + } + + return unless $re; + + my $pos; + + for (@_) { + next unless defined $_; + pos() = 0; + while (pos() < length) { + next if m/\G<~[^~]*~>/gc + or m/\G\( (?: [^\\)]+ | \\. )* \)/sgcx; + $pos = pos(); + if (s/$re//m) { + pos() = $pos; + } else { + pos() = $pos; + m/\G[ \t]*(?:$eolRE|(?:$nonwsRE)+(?:$eolRE)?)/ogc; + die "Infinite loop" if pos() == $pos; + } + } + } # end for @_ + + return; +} # end strip +#--------------------------------------------------------------------- + sub get_page_landscape { my $o = shift; - my $p = $o->get_ordinal( shift ); + my $p = $o->_get_ordinal( shift ); return $o->{pagelandsc}[$p]; } sub set_page_landscape { my $o = shift; - my $p = (@_ == 2) ? $o->get_ordinal(shift) : $o->{p}; + my $p = (@_ == 2) ? $o->_get_ordinal(shift) : $o->{p}; my $landscape = (!!shift) + 0; $o->{pagelandsc}[$p] = 0 unless (defined $o->{pagelandsc}[$p]); if ($o->{pagelandsc}[$p] != $landscape) { @@ -1260,16 +1333,18 @@ $o->{pagelandsc}[$p] = $landscape; } +#--------------------------------------------------------------------- + sub get_page_clipping { my $o = shift; - my $p = $o->get_ordinal( shift ); + my $p = $o->_get_ordinal( shift ); return $o->{pageclip}[$p]; } sub set_page_clipping { my $o = shift; - my $p = (@_ == 2) ? $o->get_ordinal(shift) : $o->{p}; + my $p = (@_ == 2) ? $o->_get_ordinal(shift) : $o->{p}; $o->{pageclip}[$p] = (!!shift) + 0; } @@ -1302,26 +1377,38 @@ return $o->{order}; } + sub get_title { my $o = shift; return $o->{title}; } + sub get_version { my $o = shift; return $o->{version}; } + sub get_langlevel { my $o = shift; return $o->{langlevel}; } +sub set_min_langlevel +{ + my ($o, $level) = @_; + $o->{langlevel} = $level unless ($o->{langlevel} || 0) >= $level; + return $o->{langlevel}; +} + + sub get_extensions { my $o = shift; return $o->{extensions}; } + sub get_bounding_box { my $o = shift; return @{$o->{bbox}}; @@ -1346,9 +1433,10 @@ return $bb->[3] - $bb->[1]; } # end get_printable_height + sub get_page_bounding_box { my $o = shift; - my $p = $o->get_ordinal( shift ); + my $p = $o->_get_ordinal( shift ); return @{$o->{pagebbox}[$p]}; } @@ -1356,7 +1444,7 @@ my $o = shift; my $page = (@_ == 5) ? shift : ""; if (@_ == 4) { - my $p = $o->get_ordinal($page); + my $p = $o->_get_ordinal($page); $o->{pagebbox}[$p] = [ @_ ]; $o->set_page_clipping($page, 1); } @@ -1366,23 +1454,24 @@ sub get_page_printable_width { my $o = shift; - my $bb = $o->{pagebbox}[$o->get_ordinal( shift )]; + my $bb = $o->{pagebbox}[$o->_get_ordinal( shift )]; return $bb->[2] - $bb->[0]; } # end get_page_printable_width sub get_page_printable_height { my $o = shift; - my $bb = $o->{pagebbox}[$o->get_ordinal( shift )]; + my $bb = $o->{pagebbox}[$o->_get_ordinal( shift )]; return $bb->[3] - $bb->[1]; } # end get_page_printable_height + sub set_page_margins { my $o = shift; my $page = (@_ == 5) ? shift : ""; if (@_ == 4) { my ($left, $bottom, $right, $top) = @_; - my $p = $o->get_ordinal($page); + my $p = $o->_get_ordinal($page); if ($o->{pagelandsc}[$p]) { $o->{pagebbox}[$p] = [ $left, $bottom, $o->{height}-$right, $o->{width}-$top ]; } else { @@ -1392,8 +1481,25 @@ } } +# =method-access get_ordinal +# +# $index = $ps->get_ordinal( [$page] ) +# +# Returns the internal number for the page label specified. (Default: +# current page) +# +# Example +# +# Say pages are labeled "i", "ii", "iii, "iv", "1", "2", "3". +# +# get_ordinal("i") == 0 +# get_ordinal("iv") == 3 +# get_ordinal("1") == 4 +# +# =cut -sub get_ordinal { +sub _get_ordinal +{ my ($o, $page) = @_; if ($page) { for (my $i = 0; $i <= $o->{pagecount}; $i++) { @@ -1435,13 +1541,12 @@ } - - sub get_comments { my $o = shift; return $o->{Comments}; } + sub add_comment { my ($o, $entry) = @_; $o->{Comments} .= "\%\%$entry\n" if defined($entry); @@ -1453,17 +1558,16 @@ return $o->{Preview}; } + sub add_preview { - my ($o, $width, $height, $depth, $lines, $entry) = @_; - if (defined $entry) { - $entry =~ s/$o->{strip}//gm; - $o->{Preview} = $o->_here_doc(<strip(space => $entry); + $o->{Preview} = + "%%BeginPreview: $width $height $depth $lines\n$entry%%EndPreview\n"; + } +} # end add_preview sub get_defaults { @@ -1471,6 +1575,7 @@ return $o->{Defaults}; } + sub add_default { my ($o, $entry) = @_; $o->{Defaults} .= "\%\%$entry\n" if defined($entry); @@ -1509,7 +1614,7 @@ } # end unless Document or Feature if (defined($resource)) { - $resource =~ s/$o->{strip}//gm; + $o->strip($resource); $name = $o->quote_text($name); $o->{DocSupplied} .= $o->encode_text("\%\%+ $suptype $name\n") if $suptype; @@ -1533,16 +1638,19 @@ } -sub get_functions { + +sub get_procsets +{ my $o = shift; return $o->{Functions}; } -sub add_function { +sub add_procset +{ my ($o, $name, $entry, $version, $revision) = @_; if (defined($name) and defined($entry)) { - return if $o->has_function($name); - $entry =~ s/$o->{strip}//gm; + return if $o->has_procset($name); + $o->strip($entry); $name = sprintf('%s %g %d', $o->quote_text($name), $version||0, $revision||0); $o->{DocSupplied} .= $o->encode_text("\%\%+ procset $name\n"); @@ -1557,12 +1665,34 @@ } -sub has_function { +sub has_procset +{ my ($o, $name) = @_; $name = $o->quote_text($name); return ($o->{DocSupplied} =~ /^\%\%\+ procset \Q$name\E /m); } +# Retain the old names for backwards compatibility: +*add_function = \&add_procset; +*get_functions = \&get_procsets; +*has_function = \&has_procset; + + +sub use_functions +{ + my $o = shift; + + ( + $o->{use_functions} ||= do { + require PostScript::File::Functions; + + PostScript::File::Functions->new; + } + )->add(@_); + + return $o; +} # end use_functions + sub embed_document { @@ -1616,7 +1746,7 @@ open($in, '-|:raw', $ttftotype42, $filename) or croak "Unable to run $ttftotype42 $filename: $!"; # Type 42 was introduced in LanguageLevel 2: - $o->{langlevel} = 2 unless ($o->{langlevel} || 0) >= 2; + $o->set_min_langlevel(2); } my $content = do { local $/; <$in> }; # Read entire file @@ -1652,14 +1782,16 @@ } # end foreach $res } # end need_resource + sub get_setup { my $o = shift; return $o->{Setup}; } + sub add_setup { my ($o, $entry) = @_; - $entry =~ s/$o->{strip}//gm; + $o->strip($entry); $o->{Setup} .= $o->encode_text($entry) if (defined $entry); } @@ -1669,9 +1801,10 @@ return $o->{PageSetup}; } + sub add_page_setup { my ($o, $entry) = @_; - $entry =~ s/$o->{strip}//gm; + $o->strip($entry); $o->{PageSetup} .= $o->encode_text($entry) if (defined $entry); } @@ -1679,23 +1812,24 @@ sub get_page { my $o = shift; my $page = shift || $o->get_page_label(); - my $ord = $o->get_ordinal($page); + my $ord = $o->_get_ordinal($page); return $o->{Pages}->[$ord]; } + sub add_to_page { my $o = shift; my $page = (@_ == 2) ? shift : ""; my $entry = shift || ""; if ($page) { - my $ord = $o->get_ordinal($page); + my $ord = $o->_get_ordinal($page); if (($ord == $o->{p}) and ($page ne $o->{page}[$ord])) { $o->newpage($page); } else { $o->{p} = $ord; } } - $entry =~ s/$o->{strip}//gm; + $o->strip($entry); $o->{Pages}[$o->{p}] .= $o->encode_text($entry); } @@ -1705,9 +1839,10 @@ return $o->{PageTrailer}; } + sub add_page_trailer { my ($o, $entry) = @_; - $entry =~ s/$o->{strip}//gm; + $o->strip($entry); $o->{PageTrailer} .= $o->encode_text($entry) if (defined $entry); } @@ -1717,13 +1852,13 @@ return $o->{Trailer}; } + sub add_trailer { my ($o, $entry) = @_; - $entry =~ s/$o->{strip}//gm; + $o->strip($entry); $o->{Trailer} .= $o->encode_text($entry) if (defined $entry); } - #============================================================================= @@ -1744,7 +1879,7 @@ my ($o, $text) = @_; if ($o->{strip_type} ne 'none') { - $text =~ s/$o->{strip}//gm; + $o->strip($text); } elsif ($text =~ /^([ \t]+)/) { my $space = $1; @@ -1760,6 +1895,7 @@ my $page = shift; return ++$page; } +#--------------------------------------------------------------------- our $roman_max = 40; @@ -1776,6 +1912,7 @@ my $pos = $roman{$page}; return $roman[++$pos]; } +#--------------------------------------------------------------------- sub check_file ($;$$) { ## no critic (ProhibitSubroutinePrototypes) @@ -1824,7 +1961,7 @@ sub check_tilde ($) { ## no critic (ProhibitSubroutinePrototypes) my ($dir) = @_; - $dir = "" unless $dir; + $dir = "" unless defined $dir; $dir =~ s{^~([^/]*)}{$1 ? (getpwnam($1))[7] : ($ENV{HOME} || $ENV{LOGDIR} || (getpwuid($>))[7]) }ex; return $dir; } @@ -1846,7 +1983,7 @@ return $arg; } } - +#--------------------------------------------------------------------- my %special = ( "\n" => '\n', "\r" => '\r', "\t" => '\t', "\b" => '\b', @@ -1895,26 +2032,27 @@ =head1 NAME -PostScript::File - Base class for creating Adobe PostScript files +PostScript::File - Class for creating Adobe PostScript files =head1 VERSION -This document describes version 2.11 of -PostScript::File, released October 11, 2011 -as part of PostScript-File version 2.11. +This document describes version 2.20 of PostScript::File, +released February 11, 2012 as part of PostScript-File version 2.20. -=head1 SYNOPSIS +Attributes and methods added since version 2.00 are marked with the +version they were added in (e.g. "(v2.10)"). Because there were +significant API changes in 2.00, I recommend that any code using +PostScript::File specify a minimum version of at least 2. - use PostScript::File qw(check_tilde check_file - incpage_label incpage_roman); +=head1 SYNOPSIS =head2 Simplest -An 'hello world' program: +A 'hello world' program: - use PostScript::File; + use PostScript::File 2; - my $ps = PostScript::File->new(); + my $ps = PostScript::File->new(reencode => 'cp1252'); $ps->add_to_page( <output( "~/test" ); + $ps->output( "test" ); =head2 All options @@ -1969,51 +2107,51 @@ =head1 DESCRIPTION -This module is designed to support other PostScript:: modules. For top level modules that output -something useful, see - - PostScript::Calendar - PostScript::Report - PostScript::Graph::Bar - PostScript::Graph::Stock - PostScript::Graph::XY - -An outline Adobe PostScript file is constructed. Functions allow access to each of Adobe's Document -Structuring Convention (DSC) sections and control how the pages are constructed. It is possible to -construct and output files in either normal PostScript (*.ps files) or as Encapsulated PostScript (*.epsf or -*.epsi files). By default a minimal file is output, but support for font encoding, PostScript error reporting and -debugging can be built in if required. +PostScript::File is a class that writes PostScript files following +Adobe's Document Structuring Conventions (DSC). You should be +familiar with the DSC if you're using this class directly; consult the +I +linked to in L. + +There are also a number of modules that build upon PostScript::File to +produce various kinds of documents without requiring knowledge of +PostScript. These are listed in L. + +It is possible to construct and output files in either normal +PostScript (*.ps files) or as Encapsulated PostScript (*.epsf or +*.epsi files). By default a minimal file is output, but support for +font encoding, PostScript error reporting and debugging can be built +in if required. Documents can typically be built using only these functions: new The constructor, with many options - add_function Add PostScript functions to the prolog + add_procset Add PostScript functions to the prolog add_to_page Add PostScript to construct each page newpage Begins a new page in the document output Construct the file and saves it The rest of the module involves fine-tuning this. Some settings only really make sense when given once, while -others can control each page independently. See B for the functions that duplicate option settings, they all -have B counterparts. The following provide additional support. +others can control each page independently. See C for the functions that duplicate option settings, they all +have C counterparts. The following provide additional support. get/set_bounding_box get/set_page_bounding_box get/set_page_clipping get/set_page_landscape set_page_margins - get_ordinal get_pagecount draw_bounding_box clip_bounding_box -The functions which insert entries into each of the DSC sections all begin with 'add_'. They also have B +The functions which insert entries into each of the DSC sections all begin with 'add_'. They also have C counterparts. add_comment add_preview add_default add_resource - add_function + add_procset add_setup add_page_setup add_to_page @@ -2051,7 +2189,7 @@ To make it easier to handle strings containing HYPHEN-MINUS, PostScript::File provides the L attribute. When this is -true (the default when using C or C), the L +true (the default when using C or C), the L method will automatically translate HYPHEN-MINUS to either HYPHEN or MINUS SIGN. (This happens only when C is called as an object method.) @@ -2060,395 +2198,724 @@ and followed by a digit, or it's followed by a currency symbol, it's translated to MINUS SIGN. Otherwise, it's translated to HYPHEN. -=head1 CONSTRUCTOR +=head1 ATTRIBUTES -=head2 new( options ) +Unlike many classes that use the same method for reading and writing +an attribute's value, PostScript::File has separate methods for +reading and writing. The read accessor is prefixed with C, and +the write accessor is prefixed with C. If no write accessor is +mentioned, then the attribute is read-only. -Create a new PostScript::File object, either a set of pages or an Encapsulated PostScript (EPS) file. Options are -hash keys and values. All values should be in the native PostScript units of 1/72 inch. -Example - $ps = PostScript::File->new( - eps => 1, - landscape => 1, - width => 216, - height => 288, - left => 36, - right => 44, - clipping => 1 ); +=head3 auto_hyphen -This creates an Encapsulated PostScript document, 4 by 3 inch pages printing landscape with left and right margins of -around half an inch. The width is always the shortest side, even in landscape mode. 3*72=216 and 4*72=288. -Being in landscape mode, these would be swapped. The bounding box used for clipping would then be from -(50,0) to (244,216). + $ps = PostScript::File->new( auto_hyphen => $translate ) -C may be a single hash reference instead of an options list, but the hash must have the same structure. -This is more convenient when used as a base class. + $translate = $ps->get_auto_hyphen -In addition, the following keys are recognized. + $ps->set_auto_hyphen( $translate ) -=head2 File size keys +If C<$translate> is a true value, then L will do automatic +hyphen-minus translation when called as an object method (but only if +the document uses character set translation). (Default: true) +See L. -There are four options which control how much gets put into the resulting file. -=head3 debug +=head3 clipping -=over 6 + $ps = PostScript::File->new( clipping => $clipping ) -=item undef + $clipping = $ps->get_clipping -No debug code is added to the file. Of course there must be no calls to debug functions in the PostScript code. + $ps->set_clipping( $clipping ) -=item 0 +If C<$clipping> is true, printing will be clipped to each page's +bounding box. This is the document's default value. Each page has +its own L attribute, which is initialized to this +default value when the page is created. (Default: false) -B functions are replaced by dummy functions which do nothing. -=item 1 +=head3 eps -A range of functions are added to the file to support debugging PostScript. This switch is similar to the 'C' -C macro in that debugging statements may be left in the PostScript code but their effect is removed. + $ps = PostScript::File->new( eps => $eps ) -Of course, being an interpreted language, it is not quite the same as the calls still takes up space - they just -do nothing. See L for details of the functions. + $eps = $ps->get_eps -=item 2 +C<$eps> is true if this is an Encapsulated PostScript document. +False indicates an ordinary PostScript document. -Loads the debug functions and gives some reassuring output at the start and a stack dump at the end of each page. -A mark is placed on the stack at the beginning of each page and 'cleartomark' is given at the end, avoiding -potential C errors. Note, however, that if the page does not end with a clean stack, it will fail -when debugging is turned off. +=head3 extensions -=back + $ps = PostScript::File->new( extensions => $extensions ) -=head3 errors + $extensions = $ps->get_extensions -PostScript has a nasty habit of failing silently. Setting this to 1 prints fatal error messages on the bottom left -of the paper. For user functions, a PostScript function B is defined. This expects a message -string on the stack, which it prints before stopping. (Default: 1) +The PostScript extensions required by this document, for use in the +C<%%Extensions> DSC comment. (Default: C, meaning omit the +C<%%Extensions> comment) -=head3 headings -Enable PostScript comments such as the date of creation and user's name. +=head3 file_ext -=head3 reencode + $ps = PostScript::File->new( file_ext => $file_ext ) -Requests that a font re-encode function be added and that the fonts -used by this document get re-encoded in the specified encoding. -The only allowed values are C, C, and -C. In most cases, you should set this to -C, even if you are not using Windows. + $file_ext = $ps->get_file_ext -The list of fonts to re-encode comes from the L parameter, -the L method, and all fonts added using L -or L. The Symbol font is never re-encoded, because it -uses a non-standard character set. + $ps->set_file_ext( $file_ext ) -Setting this to C or C also causes the document to -be encoded in that character set. Any strings you add to the document -that have the UTF8 flag set will be reencoded automatically. Strings -that do not have the UTF8 flag are expected to be in the correct -character set already. This means that you should be able to set this -to C, use Unicode characters in your code and the "-iso" -versions of the fonts, and just have it do the right thing. +If C<$file_ext> is undef (the default), then the extension is set +automatically based on the output type. C<.ps> will be added for +ordinary PostScript files. EPS files have an extension of C<.epsf> +without or C<.epsi> with a preview image. -Windows code page 1252 (aka WinLatin1) is a superset of the printable -characters in iso-8859-1 (aka Latin1). It adds a number of characters -that are not in Latin1, especially common punctuation marks like the -curly quotation marks, en & em dashes, Euro sign, and ellipsis. These -characters exist in the standard PostScript fonts, but there's no easy -way to access them when using the standard or ISOLatin1 encodings. -L +If C<$file_ext> is the empty string, then no +extension will be added to the filename. Otherwise, it should be a +string like '.ps' or '.eps'. (But setting this has no effect on the +actual type of the output file, only its name.) -For backwards compatibility with versions of PostScript::File older -than 1.05, setting this to C reencodes the fonts, -but does not do any character set translation in the document. -=head2 Initialization keys +=head3 filename -There are a few initialization settings that are only relevant when the file object is constructed. + $ps = PostScript::File->new( file => $file, [dir => $dir] ) -=head3 bottom + $filename = $ps->get_filename -The margin in from the paper's bottom edge, specifying the non-printable area. Remember to specify C if -that is what is wanted. (Default: 28) + $ps->set_filename( $file, [$dir] ) -=head3 clip_command +=over 4 -The bounding box is used for clipping if this is set to "clip" or is drawn with "stroke". This also makes the -whole page area available for debugging output. (Default: "clip"). +=item C<$file> -=head3 clipping +An optional fully qualified path-and-file, a simple file name, the +empty string (which stands for the special file C<< File::Spec->devnull >>), +or C (which indicates the document has no associated filename). -Set whether printing will be clipped to the file's bounding box. (Default: 0) +=item C<$dir> -=head3 dir +An optional directory name. If present (and C<$file> is not already +an absolute path), it is prepended to C<$file>. If no C<$file> was +specified, C<$dir> is ignored. -An optional directory for the output file. See . -If no C is specified, C is ignored. +=back -=head3 eps +The base filename for the output file(s). When the filename is set, +if that filename includes a directory component, the directories are +created immediately (if they don't already exist). -Set to 1 to produce Encapsulated PostScript. B returns the value set here. (Default: 0) +See L for details on how the filename extension is handled. -=head3 file +If L has been set, multiple pages will have the page label +appended to the file name. -The name of the output file. See . +Example: -=head3 file_ext + $ps = PostScript::File->new( eps => 1 ); + $ps->set_filename( "pics", "~/book" ); + $ps->newpage("vi"); + ... draw page + $ps->newpage("7"); + ... draw page + $ps->newpage(); + ... draw page + $ps->output(); -The extension for the output file. See . +The three pages for user 'chris' on a Unix system would be: -=head3 font_suffix + /home/chris/book/pics-vi.epsf + /home/chris/book/pics-7.epsf + /home/chris/book/pics-8.epsf -This string is appended to each font name as it is reencoded. (Default: "-iso") +It would be wise to use C explicitly for each page if using multiple pages in EPS files. -The string value is appended to these to make the new names. -Example +=head3 incpage_handler - $ps = PostScript::File->new( - font_suffix => "-iso", - reencode => "ISOLatin1Encoding" - ); + $ps = PostScript::File->new( incpage_handler => \&handler ) -"Courier" still has the standard mapping while "Courier-iso" includes the additional European characters. + $handler = $ps->get_incpage_handler -=head3 height + $ps->set_incpage_handler( [\&handler] ) -Set the page height, the longest edge of the paper. (Default taken from C) +The function used to increment the page label when creating a new +page. C<\&handler> is a reference to a subroutine that takes the +current page label as its only argument and returns the new label. -The paper size is set to "Custom". B and B return the values set here. +This module provides the L (which uses Perl's +autoincrement operator) and L (which handles lowercase +Roman numberals from i to xxxix, 1-39) functions for use as +C. (Default: C<\&incpage_label>) -=head3 landscape -Set whether the page is oriented horizontally (C<1>) or vertically (C<0>). (Default: 0) +=head3 langlevel -In landscape mode the coordinates are rotated 90 degrees and the origin moved to the bottom left corner. Thus the -coordinate system appears the same to the user, with the origin at the bottom left. + $ps = PostScript::File->new( langlevel => $langlevel ) -=head3 left + $langlevel = $ps->get_langlevel -The margin in from the paper's left edge, specifying the non-printable area. -Remember to specify C if that is what is wanted. (Default: 28) + $ps->set_min_langlevel( $langlevel ) # added in v2.20 -=head3 need_fonts +The level of the PostScript language used in this document, for use in +the C<%%LanguageLevel> DSC comment. The L method +can be used to raise the language level, but it cannot be decreased. +(Default: C, meaning omit the C<%%LanguageLevel> comment) -An arrayref of font names required by this document. This is -equivalent to calling C<< $ps->need_resource(font => @$arrayref) >>. -See L for details. -=head3 paper +=head3 order -Set the paper size of each page. A document can be created using a standard paper size without -having to remember the size of paper using PostScript points. Valid choices are currently A0, A1, A2, A3, A4, A5, -A6, A7, A8, A9, B0, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, Executive, Folio, 'Half-Letter', Letter, 'US-Letter', -Legal, 'US-Legal', Tabloid, 'SuperB', Ledger, 'Comm #10 Envelope', 'Envelope-Monarch', 'Envelope-DL', -'Envelope-C5', 'EuroPostcard'. (Default: "A4") + $ps = PostScript::File->new( order => $order ) -You can also give a string in the form 'WIDTHxHEIGHT', where WIDTH and -HEIGHT are numbers (in points). This sets the paper size to "Custom". + $order = $ps->get_order -This also sets C and C. B returns the value set here. +The order the pages are defined in the document, for use in the +C<%%PageOrder> DSC comment. It must be one of "Ascend", "Descend" or +"Special" (meaning a document manager must not reorder the pages). +The default is C, meaning omit the C<%%PageOrder> comment. -=head3 right -The margin in from the paper's right edge. It is a positive offset, so C will leave a half inch no-go -margin on the right hand side of the page. Remember to specify C if that is what is wanted. (Default: 28) +=head3 strip (attribute) -=head3 top + $ps = PostScript::File->new( strip => $strip ) -The margin in from the paper's top edge. It is a positive offset, so C will leave a half inch no-go -margin at the top of the page. Remember to specify C if that is what is wanted. (Default: 28) + $strip = $ps->get_strip -=head3 width + $ps->set_strip( $strip ) -Set the page width, the shortest edge of the paper. (Default taken from C) +Determine whether the PostScript code is filtered. C<$strip> must be +one of the following values: +C strips leading spaces so the user can indent freely without +increasing the file size. C removes lines beginning with +'%' as well. C (v2.20) also removes +comments that aren't at the beginning of a line. +See also the L method, which actually does +the filtering described here. -=head2 Debugging support keys +Passing C or omitting C<$strip> sets it to the default value, +C. -This makes most sense in the PostScript code rather than perl. However, it is convenient to be able to set -defaults for the output position and so on. See L for further details. -=head3 db_active +=head3 title -Set to 0 to temporarily suppress the debug output. (Default: 1) + $ps = PostScript::File->new( title => $title ) -=head3 db_base + $title = $ps->get_title -Debug printing will not occur below this point. (Default: 6) +The document's title for use in the C<%%Title> DSC comment. The +default (C) means to use the document's filename as the title. +If no filename is available when the document is output, the +C<%%Title> comment wil be omitted. -=head3 db_bufsize -The size of string buffers used. Output must be no longer than this. (Default: 256) +=head3 version -=head3 db_color + $ps = PostScript::File->new( version => $version ) -This is the whole PostScript command (with any parameters) to specify the colour of the text printed by the debug -routines. (Default: "0 setgray") + $version = $ps->get_version -=head3 db_font +The document's version for use in the C<%%Version> DSC comment. The +C<$version> should be a string in the form S>, where +C is a floating point number and C is an unsigned +integer. (Default: C, meaning omit the C<%%Version> comment) -The name of the font to use. (Default: "Courier") - Courier - Courier-Bold - Courier-BoldOblique - Courier-Oblique - Helvetica - Helvetica-Bold - Helvetica-BoldOblique - Helvetica-Oblique - Times-Roman - Times-Bold - Times-BoldItalic - Times-Italic - Symbol +=head2 Paper Size and Margins -=head3 db_fontsize +These attributes are interrelated, and changing one may change the +others. -The size of the font. PostScript uses its own units, but they are almost points. (Default: 10) -=head3 db_xgap +=head3 bounding_box -Typically, the output comprises single values such as a column showing the stack contents. C specifies -the width of each column. By default, this is calculated to allow 4 columns across the page. + ( $llx, $lly, $urx, $ury ) = $ps->get_bounding_box -=head3 db_xpos + $ps->set_bounding_box( $llx, $lly, $urx, $ury ) -The left edge, where debug output starts. (Default: 6) +The bounding box for the whole document. The lower left corner is +S>, and the upper right corner is S>. -=head3 db_xtab +Setting the bounding box automatically enables clipping. Call +C<< $ps->set_clipping(0) >> afterwards to undo that. -The amount indented by C. (Default: 10) +The default C is calculated from the paper size (taken +from the L, L, and L attributes) and the +L, L, L, and L margins. -=head3 db_ytop +Each page also has an individual L, which is +initialized from the document's C when the page is +created. -The top line of debugging output. Defaults to 6 below the top of the page. -=head2 Error handling keys +=head3 height -If C is set, the position of any fatal error message can be controlled with the following options. Each -value is placed into a PostScript variable of the same name, so they can be overridden from within the code if -necessary. + $ps = PostScript::File->new( height => $height ) -=head3 errfont + $height = $ps->get_height -The name of the font used to show the error message. (Default: "Courier-Bold") + $ps->set_height( $height ) -=head3 errmsg +The page height in points. This is normally the longer dimension of the +paper. Note that in landscape mode this is actually the width of the +bounding box. -The error message comprises two lines. The second is the name of the PostScript error. This sets the first line. -(Default: "ERROR:") +Setting this sets L to "Custom" and the L is +expanded to the full height. -=head3 errsize -Size of the error message font. (Default: 12) +=head3 landscape -=head3 errx + $ps = PostScript::File->new( landscape => $landscape ) -X position of the error message on the page. (Default: (72)) + $landscape = $ps->get_landscape -=head3 erry + $ps->set_landscape( $landscape ) -Y position of the error message on the page. (Default: (72)) +If C<$landscape> is true, the page is rotated 90 degrees +counter-clockwise, swapping the meaning of height & width. (Default: false) -=head2 Document structure +In landscape mode the coordinates are rotated 90 degrees and the origin moved to the bottom left corner. Thus the +coordinate system appears the same to the user, with the origin at the bottom left. -There are options which only affect the DSC comments. They all have B functions which return the -values set here, e.g. B returns the value given to the title option. -=head3 extensions +=head3 paper -Declare and PostScript language extensions that need to be available. (No default) + $ps = PostScript::File->new( paper => $paper_size ) -=head3 langlevel + $paper_size = $ps->get_paper -Set the PostScript language level. (No default) + $ps->set_paper( $paper_size ) -=head3 order +Set the paper size of each page. A document can be created using a +standard paper size without having to remember the size of paper using +PostScript points. Valid choices are currently A0, A1, A2, A3, A4, A5, +A6, A7, A8, A9, B0, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, +Executive, Folio, Half-Letter, Letter, US-Letter, Legal, +US-Legal, Tabloid, SuperB, Ledger, 'Comm #10 Envelope', +Envelope-Monarch, Envelope-DL, Envelope-C5, and EuroPostcard. +(Default: "A4") -Set the order the pages are defined in the document. It should one of -"Ascend", "Descend" or "Special" if a document manager must not -reorder the pages. (No default) +You can also give a string in the form 'WIDTHxHEIGHT', where WIDTH and +HEIGHT are numbers (in points). This sets the paper size to "Custom". -=head3 title +Setting this also sets L, L, and L +to the full height and width of the paper. -Set the document's title as recorded in PostScript's Document Structuring Conventions. (No default) -=head3 version +=head3 width -Set the document's version as recorded in PostScript's Document Structuring Conventions. This should be a string -with a major, minor and revision numbers. For example "1.5 8" signifies revision 8 of version 1.5. (No default) + $ps = PostScript::File->new( width => $width ) -=head2 Miscellaneous + $width = $ps->get_width -A few options that may be changed between pages or set here for the first page. + $ps->set_width( $width ) -=head3 incpage_handler +The page width in points. This is normally the shorter dimension of +the paper. Note that in landscape mode this is actually the height of +the bounding box. -Set the initial value for the function which increments page labels. See L. +Setting this sets L to "Custom" and the L is +expanded to the full width. -=head3 newpage -Normally, an initial page is created automatically (using the label -specified by C). But starting with PostScript::File 2.10, you -can pass S 0 >>> to override this. This makes for more -natural loops: +=head2 Page Attributes - use PostScript::File 2.10; - my $ps = PostScript::File->new(newpage => 0); - for (@pages) { - $ps->newpage; # don't need "unless first page" - ... - } +The following attributes can have a different value for every page. +You can't set them directly in the constructor, but they all have a +document-wide default value that each page inherits when it is created. +When accessing or setting them, C<$page> is the page label. If +C<$page> is omitted, it defaults to the current page. -It's important to require PostScript::File 2.10 if you do this, because -older versions would produce an initial blank page. -If you don't pass a page label to the first call to C, it -will be taken from the C option. After the first page, the page -label will increment as specified by L. +=head3 page_bounding_box -=head3 page + ( $llx, $lly, $urx, $ury ) = $ps->get_page_bounding_box( [$page] ) -Set the label (text or number) for the initial page. See L. (Default: "1") + $ps->set_page_bounding_box( [$page,] $llx, $lly, $urx, $ury ) -=head3 strip +The bounding box for this page. The lower left corner is +S>, and the upper right corner is S>. -Set whether the PostScript code is filtered. C strips leading spaces so the user can indent freely -without increasing the file size. C remove lines beginning with '%' as well. C does no filtering. (Default: "space") +Note that calling C automatically enables +clipping for that page. If this isn't what you want, call +C<< $ps->set_page_clipping(0) >> afterwards. -=head3 auto_hyphen +When a page is created, C is initialized from the +document's L attribute. -Controls whether the L method does hyphen-minus translation as -described in L. This can only be enabled -when the document is using character set translation. (Default: 1). -=head1 MAIN METHODS +=head3 page_clipping -=head2 newpage( [page] ) + $clipping = $ps->get_page_clipping( [$page] ) -Generate a new PostScript page, unless in a EPS file when it is ignored. + $ps->set_page_clipping( [[$page,] $clipping] ) -If C is not specified the page number is increased each time a new page is requested. +If C<$clipping> is true, printing will be clipped to this page's +bounding box. (Default: false) -C can be a string or a number. If anything other than a simple integer, you probably should register -your own counting function with B. Of course there is no need to do this if a page string is -given to every B call. +When a page is created, C is initialized from the +document's L attribute. -=head2 output( [filename [, dir]] ) -If C is an open filehandle, write the PostScript document to -that filehandle and return nothing. +=head3 page_label -If a filename has been given either here, to C, or to -C, write the PostScript document to that file and return -its pathname. + $ps = PostScript::File->new( page => $page ) -If no filename has been given, or C is undef, return the -PostScript document as a string. + $page = $ps->get_page_label + + $ps->set_page_label( [$page] ) + +The label for the current page (used in the C<%%Page> comment). (Default: "1") + +Unlike the other page attributes, you can only access the C of +the current page. (Since pages are specified by label, it makes no +sense to ask for the label of a different page.) + +When a page is created, C is initialized by passing the +previous page's label to the L. For the first page, +it's initialized from the C given to the constructor. + + +=head3 page_landscape + + $landscape = $ps->get_page_landscape( [$page] ) + + $ps->set_page_landscape( [[$page,] $landscape] ) + +If C<$landscape> is true, this page is using landscape mode. (Default: +false) + +When a page is created, C is initialized from the +document's L attribute. + +=head1 METHODS + +Note: In the following descriptions, C<[]> are used to denote optional +parameters, I array references. + + +=head2 Constructor + + +=head3 new + + $ps = PostScript::File->new(options) + +Create a new PostScript::File object, either a set of pages or an Encapsulated PostScript (EPS) file. Options are +hash keys and values. All values should be in the native PostScript units of 1/72 inch. + +Example + + $ps = PostScript::File->new( + eps => 1, + landscape => 1, + width => 216, + height => 288, + left => 36, + right => 44, + clipping => 1, + ); + +This creates an Encapsulated PostScript document, 4 by 3 inch pages printing landscape with left and right margins of +around half an inch. The width is always the shortest side, even in landscape mode. 3*72=216 and 4*72=288. +Being in landscape mode, these would be swapped. The bounding box used for clipping would then be from +(50,0) to (244,216). + +C may be a single hash reference instead of an options list, but the hash must have the same structure. +This is more convenient when used as a base class. + +The following keys are recognized options: + +=head3 Attributes + +The following attributes can be set through the constructor: +L, L, L, L, L, +L, L, L, L, +L, L, L, L, +L, L, L, and L. + +=head3 File size keys + +There are four options which control how much gets put into the resulting file. + +=head4 debug + +=over 6 + +=item C + +No debug code is added to the file. Of course there must be no calls +to debug functions in the PostScript code. This is the default. + +=item C<0> + +B functions are replaced by dummy functions which do nothing. + +=item C<1> + +A range of functions are added to the file to support debugging PostScript. This switch is similar to the 'C' +C macro in that debugging statements may be left in the PostScript code but their effect is removed. + +Of course, being an interpreted language, it is not quite the same as the calls still takes up space - they just +do nothing. See L for details of the functions. + +=item C<2> + +Loads the debug functions and gives some reassuring output at the start and a stack dump at the end of each page. + +A mark is placed on the stack at the beginning of each page and 'cleartomark' is given at the end, avoiding +potential C errors. Note, however, that if the page does not end with a clean stack, it will fail +when debugging is turned off. + +=back + +=head4 errors + +PostScript has a nasty habit of failing silently. If C is +true, code that prints fatal error messages on the bottom left of the +paper is added to the file. For user functions, a PostScript function +B is defined. This expects a message string on the +stack, which it prints before stopping. (Default: true) + +=head4 headings + +If true, add PostScript DSC comments recording the date of creation and user's +name. (Default: false) + +The comments inserted when C is true are: + + %%For: USER@HOSTNAME + %%Creator: Perl module PostScript::File v2.20 + %%CreationDate: Sun Jan 1 00:00:00 2012 + %%DocumentMedia: US-Letter 612 792 80 ( ) ( ) + +USER comes from C, and HOSTNAME comes from +L. The DocumentMedia values come from the +L. The +DocumentMedia comment is omitted from EPS files. + +If you want different values, leave C false and use +L to add whatever you want. + +=head4 reencode + +Requests that a font re-encode function be added and that the fonts +used by this document get re-encoded in the specified encoding. +The only allowed values are C, C, and +C. You should almost always set this to C, +even if you are not using Windows. + +The list of fonts to re-encode comes from the L parameter, +the L method, and all fonts added using L +or L. The Symbol font is never re-encoded, because it +uses a non-standard character set. + +Setting this to C or C also causes the document to +be encoded in that character set. Any strings you add to the document +that have the UTF-8 flag set will be reencoded automatically. Strings +that do not have the UTF-8 flag are expected to be in the correct +character set already. This means that you should be able to set this +to C, use Unicode characters in your code and the "-iso" +versions of the fonts, and just have it do the right thing. + +Windows code page 1252 (a.k.a. WinLatin1) is a superset of the printable +characters in ISO-8859-1 (a.k.a. Latin1). It adds a number of characters +that are not in Latin1, especially common punctuation marks like the +curly quotation marks, en & em dashes, Euro sign, and ellipsis. These +characters exist in the standard PostScript fonts, but there's no easy +way to access them when using the standard or ISOLatin1 encodings. +L + +For backwards compatibility with versions of PostScript::File older +than 1.05, setting this to C reencodes the fonts, +but does not do any character set translation in the document. + +=head3 Initialization keys + +There are a few initialization settings that are only relevant when the file object is constructed. + +=head4 bottom + +The margin in from the paper's bottom edge, specifying the non-printable area. Remember to specify C if +that is what is wanted. (Default: 28) + +=head4 clip_command + +The bounding box is used for clipping if this is set to "clip" or is drawn with "stroke". This also makes the +whole page area available for debugging output. (Default: "clip"). + +=head4 font_suffix + +This string is appended to each font name as it is reencoded. (Default: "-iso") + +The string value is appended to these to make the new names. + +Example: + + $ps = PostScript::File->new( + font_suffix => "-iso", + reencode => "cp1252" + ); + +"Courier" still has the standard mapping while "Courier-iso" includes the additional European characters. + +=head4 left + +The margin in from the paper's left edge, specifying the non-printable area. +Remember to specify C if that is what is wanted. (Default: 28) + +=head4 need_fonts + +An arrayref of font names required by this document. This is +equivalent to calling C<< $ps->need_resource(font => @$arrayref) >>. +See L for details. + +=head4 newpage + +(v2.10) Normally, an initial page is created automatically (using the label +specified by C). But starting with PostScript::File 2.10, you +can pass S 0 >>> to override this. This makes for more +natural loops: + + use PostScript::File 2.10; + my $ps = PostScript::File->new(newpage => 0); + for (@pages) { + $ps->newpage; # don't need "unless first page" + ... + } + +It's important to require PostScript::File 2.10 if you do this, because +older versions would produce an initial blank page. + +If you don't pass a page label to the first call to C, it +will be taken from the C option. After the first page, the page +label will increment as specified by L. + +=head4 right + +The margin in from the paper's right edge. It is a positive offset, so C will leave a half inch no-go +margin on the right hand side of the page. Remember to specify C if that is what is wanted. (Default: 28) + +=head4 top + +The margin in from the paper's top edge. It is a positive offset, so C will leave a half inch no-go +margin at the top of the page. Remember to specify C if that is what is wanted. (Default: 28) + +=head3 Debugging support keys + +This makes most sense in the PostScript code rather than Perl. However, it is convenient to be able to set +defaults for the output position and so on. See L for further details. + +=head4 db_active + +Set to 0 to temporarily suppress the debug output. (Default: 1) + +=head4 db_base + +Debug printing will not occur below this point. (Default: 6) + +=head4 db_bufsize + +The size of string buffers used. Output must be no longer than this. (Default: 256) + +=head4 db_color + +This is the whole PostScript command (with any parameters) to specify the colour of the text printed by the debug +routines. (Default: "0 setgray") + +=head4 db_font + +The name of the font to use. (Default: "Courier") + + Courier + Courier-Bold + Courier-BoldOblique + Courier-Oblique + Helvetica + Helvetica-Bold + Helvetica-BoldOblique + Helvetica-Oblique + Times-Roman + Times-Bold + Times-BoldItalic + Times-Italic + Symbol + +=head4 db_fontsize + +The size of the font. PostScript uses its own units, but they are almost points. (Default: 10) + +=head4 db_xgap + +Typically, the output comprises single values such as a column showing the stack contents. C specifies +the width of each column. By default, this is calculated to allow 4 columns across the page. + +=head4 db_xpos + +The left edge, where debug output starts. (Default: 6) + +=head4 db_xtab + +The amount indented by C. (Default: 10) + +=head4 db_ytop + +The top line of debugging output. Defaults to 6 below the top of the page. + +=head3 Error handling keys + +If C is set, the position of any fatal error message can be controlled with the following options. Each +value is placed into a PostScript variable of the same name, so they can be overridden from within the code if +necessary. + +=head4 errfont + +The name of the font used to show the error message. (Default: "Courier-Bold") + +=head4 errmsg + +The error message comprises two lines. The second is the name of the PostScript error. This sets the first line. +(Default: "ERROR:") + +=head4 errsize + +Size of the error message font. (Default: 12) + +=head4 errx + +X position of the error message on the page. (Default: (72)) + +=head4 erry + +Y position of the error message on the page. (Default: (72)) + + +=head2 Main Methods + + +=head3 newpage + + $ps->newpage( [$page] ) + +Generate a new PostScript page, unless in a EPS file when it is ignored. + +If C<$page> is not specified the previous page's label is incremented +using the L. + + +=head3 output + + $ps->output( [$file, [$dir]] ) + +If C<$file> is an open filehandle, write the PostScript document to +that filehandle and return nothing. + +If a filename has been given either here, to C, or to +C, write the PostScript document to that file and return +its pathname. (C<$file> and C<$dir> have the same meaning here as +they do in L.) + +If no filename has been given, or C<$file> is undef, return the +PostScript document as a string. In C mode, each page of the document becomes a separate EPS file. In list context, returns a list of these files (either the pathname or @@ -2460,295 +2927,459 @@ Use this option whenever output is required to disk. The current PostScript document in memory is not cleared, and can still be extended or output again. -=head2 as_string + +=head3 as_string + + $postscript_code = $ps->as_string This returns the PostScript document as a string. It is equivalent to C<< $ps->output(undef) >>. -=head2 testable_output( [verbatim] ) + +=head3 testable_output + + $postscript_code = $ps->testable_output( [$verbatim] ) This returns the PostScript document as a string, but with the -PostScript::File generated code removed (unless C is true). +PostScript::File generated code removed (unless C<$verbatim> is true). This is intended for use in test scripts, so they won't see changes in the output caused by different versions of PostScript::File. The PostScript code returned by this method will probably not work in a PostScript interpreter. -If C is true, this is equivalent to C<< $ps->output(undef) >>. +If C<$verbatim> is true, this is equivalent to C<< $ps->output(undef) >>. + + +=head2 Access Methods + +Use these C and C methods to access a PostScript::File object's data. + + +=head3 get_metrics + + $metrics = $ps->get_metrics( $font, [$size, [$encoding]] ) + +Construct a L object for C<$font>. +The C<$encoding> is normally determined automatically from the font +name and the document's encoding. The default C<$size> is 1000. + +If this document uses L, and the font ends with +L, then the Metrics object will use that encoding. +Otherwise, the encoding is C (except for the Symbol font, which +always uses C). + +No matter what encoding the font uses, the Metrics object will always +use the same Unicode translation setting as this document. It also +inherits the current value of the L attribute. + + +=head3 set_min_langlevel + + $new_langlevel = $ps->set_min_langlevel( $langlevel ) + +(v2.20) Set the L attribute of this document to +C<$langlevel>, but only if the current level is less than +C<$langlevel>. It returns the value of C, which will be +greater than or equal to C<$langlevel>. + + +=head3 set_page_margins + + $ps->set_page_margins( [$page,] $left, $bottom, $right, $top ) + +This sets the L based on the paper size and the +specified margins. It also automatically enables clipping for the +page. If this isn't what you want, call C<< $ps->set_page_clipping(0) >> +afterwards. + + +=head3 get_page_printable_height + + $height = $ps->get_page_printable_height( [$page] ) + +(v2.10) Returns the height of the page's bounding box (S>). + + +=head3 get_page_printable_width + + $width = $ps->get_page_printable_width( [$page] ) + +(v2.10) Returns the width of the page's bounding box (S>. + + +=head3 get_page_variable + + $value = $ps->get_page_variable( $key ) + +Retrieve a user defined value previously assigned by L. + + +=head3 set_page_variable + + $ps->set_page_variable( $key, $value ) + +Assign a user defined hash key and value only valid on the current +page. Provided to keep track of states within the PostScript code, +such as which styles are currently active. PostScript::File does not +use this (except to clear it at the start of each page). It is +recommended that C<$key> is the module name to avoid clashes. The +C<$value> could then be a hash holding any number of user variables. + + +=head3 get_pagecount + + $pages = $ps->get_pagecount + +Returns the number of pages currently in the document. + + +=head3 get_printable_height + + $height = $ps->get_printable_height + +(v2.10) Returns the height of the document's bounding box (S>). + + +=head3 get_printable_width + + $width = $ps->get_printable_width + +(v2.10) Returns the width of the document's bounding box (S>). + + +=head3 get_variable + + $value = $ps->get_variable( $key ) + +Retrieve a user defined value previously assigned by L. + + +=head3 set_variable + + $ps->set_variable( $key, $value ) + +Assign a user defined hash key and value. Provided to keep track of +states within the PostScript code, such as which dictionaries are +currently open. PostScript::File does not use this - it is provided +for client programs. It is recommended that C<$key> is the module +name to avoid clashes. The C<$value> could then be a hash holding any +number of user variables. + + +=head2 Content Methods + + +=head3 add_comment + + $ps->add_comment( $comment ) + +Append a comment to the document's DSC comments section. Most of the +required and recommended comments are set directly from the document's +attributes, so this method should rarely be needed. It is provided +for completeness so that comments not otherwise supported can be +added. C<$comment> should contain the bare PostScript DSC name and +value, with additional lines merely prefixed by C<+>. It should NOT +end with a newline. + +Programs written for older versions of PostScript::File might use this +to add a C comment. That is now deprecated; +you should use L instead. + +Examples: + + $ps->add_comment("ProofMode: NotifyMe"); + $ps->add_comment("Requirements: manualfeed"); + + +=head3 get_comments + + $comments = $ps->get_comments + +Retrieve any extra DSC comments added by L. -=head1 ACCESS METHODS -Use these B and B methods to access a PostScript::File object's data. +=head3 add_default -=head2 get_auto_hyphen() + $ps->add_default( $default ) -=head2 set_auto_hyphen( translate ) +Use this to append a PostScript DSC comment to the Defaults section. +These would be typically values like C or +C. The format is the same as for L. -If translate is a true value, then L will do automatic -hyphen-minus translation when called as an object method (but only if -the document uses character set translation). -See L. -=head2 get_filename() +=head3 get_defaults -=head2 set_filename( file, [dir] ) + $comments = $ps->get_defaults -=over 4 +Returns the contents of the DSC Defaults section, if any. -=item C -An optional fully qualified path-and-file, a simple file name, or "" which stands for the special file -File::Spec->devnull(). +=head3 embed_document -=item C + $code = $ps->embed_document( $filename ) -An optional directory C. If present (and C is not already an absolute path), it is prepended to -C. If no C was specified, C is ignored. +This reads the contents of C<$filename>, which should be a PostScript +file. It returns a string with the contents of the file surrounded by +C<%%BeginDocument> and C<%%EndDocument> comments, and adds +C<$filename> to the list of document supplied resources. -=back +You must pass the returned string to add_to_page or some other method +that will actually include it in the document. -Specify the root file name for the output file(s) and ensure the resulting absolute path exists. This should not -include any extension. C<.ps> will be added for ordinary PostScript files. EPS files have an extension of -C<.epsf> without or C<.epsi> with a preview image. -(Unless you set the extension manually; see L.) -If C has been set, multiple pages will have the page label appended to the file name. +=head3 embed_font -Example + $font_name = $ps->embed_font( $filename, [$type] ) - $ps = PostScript::File->new( eps => 1 ); - $ps->set_filename( "pics", "~/book" ); - $ps->newpage("vi"); - ... draw page - $ps->newpage("7"); - ... draw page - $ps->newpage(); - ... draw page - $ps->output(); +This reads the contents of C<$filename>, which must contain a +PostScript font. It calls L to add the font to the +document, and returns the name of the font (without a leading slash). -The three pages for user 'chris' on a unix system would be: +If C<$type> is omitted, the C<$filename>'s extension is used as the +type. Type names are not case sensitive. The currently supported +types are: - /home/chris/book/pics-vi.epsf - /home/chris/book/pics-7.epsf - /home/chris/book/pics-8.epsf +=over -It would be wise to use B explicitly for each page if using multiple pages in EPS files. +=item PFA -=head2 get_file_ext() +A PostScript font in ASCII format -=head2 set_file_ext( file_ext ) +=item PFB -If the C is undef (the default), then the extension is set -automatically based on the output type, as explained under -L. If C is the empty string, then no -extension will be added to the filename. Otherwise, it should be a -string like '.ps' or '.eps'. (But setting this has no effect on the -actual type of the output file, only its name.) +A PostScript font in binary format. This requires the t1ascii program +from L. (You can set +C<$PostScript::File::t1ascii> to the name of the program to use. It +defaults to F.) -=head2 get_metrics( font, [size, [encoding]] ) +=item TTF -Construct a L object for C. The -C is normally determined automatically from the font name -and the document's encoding. The default C is 1000. +A TrueType font. This requires the ttftotype42 program from +L. (You can set +C<$PostScript::File::ttftotype42> to the name of the program to use. +It defaults to F.) -If this document uses L, and the font ends with -L, then the Metrics object will use that encoding. -Otherwise, the encoding is C (except for the Symbol font, which -always uses C). +Since TrueType (a.k.a. Type42) font support was introduced in PostScript +level 2, embedding a TTF font automatically sets C to 2 +(unless it was already set to a higher level). Be aware that not all +printers can handle Type42 fonts. (Even PostScript level 2 printers +need not support them.) Ghostscript does support Type42 fonts (when +compiled with the C option). -No matter what encoding the font uses, the Metrics object will always -use the same Unicode translation setting as this document. It also -inherits the current value of the L attribute. +=back -=head2 get_strip -=head2 set_strip( "none" | "space" | "comments" ) +=head3 need_resource + + $ps->need_resource( $type, @resources ) + +This adds resources to the DocumentNeededResources comment. C<$type> +is one of C, C, C, C
, C, or +C (case sensitive). + +Any number of resources (of a single type) may be added in one call. +For most types, C<$resource[N]> is just the resource name. But for +C, each element of C<@resources> should be an arrayref of 3 elements: +C<[$name, $version, $revision]>. Names that contain special characters +such as spaces will be quoted automatically. -Determine whether the PostScript code is filtered. C strips leading spaces so the user can indent freely -without increasing the file size. C remove lines beginning with '%' as well. +If C is never called for the C type (and +L is not used), it assumes the document requires all 13 of +the standard PostScript fonts: Courier, Courier-Bold, +Courier-BoldOblique, Courier-Oblique, Helvetica, Helvetica-Bold, +Helvetica-BoldOblique, Helvetica-Oblique, Times-Roman, Times-Bold, +Times-BoldItalic, Times-Italic, and Symbol. But this behaviour is +deprecated; a document should explicitly list the fonts it requires. +If you don't use any of the standard fonts, pass S [] >>> +to the constructor (or call C<< $ps->need_resource('font') >>) to +indicate that. -=head2 get_page_landscape( [page] ) -=head2 set_page_landscape( [[page,] landscape] ) +=head3 add_to_page -Inspect and change whether the page specified is oriented horizontally (C<1>) or vertically (C<0>). The default -is the global setting as returned by B. If C is omitted, the current page is assumed. + $ps->add_to_page( [$page,] $code ) -=head2 get_page_clipping( [page] ) +This appends C<$code> to the specified C<$page>, which can be any page +label. (Default: the current page) -=head2 set_page_clipping( [[page,] clipping] ) +If the specified C<$page> does not exist, a new page is added with +that label. Note that this is added on the end, not in the order you +might expect. So adding "vi" to page set "iii, iv, v, 6, 7, 8" would +create a new page after "8" not after "v". -Inspect and change whether printing will be clipped to the page's bounding box. (Default: 0) +Examples -=head2 get_page_label() + $ps->add_to_page( <add_to_page( "3", <. -=head2 get_incpage_handler() +=head3 get_page -=head2 set_incpage_handler( [handler] ) + $code = $ps->get_page( [$page] ) -Inspect and change the function used to increment the page number or label. The following suitable values for -C refer to functions defined in the module: +Returns the PostScript code from the body of the page. - \&PostScript::File::incpage_label - \&PostScript::File::incpage_roman -The default (B) increments numbers and letters, the other one handles roman numerals up to -39. C should be a reference to a subroutine that takes the current page label as its only argument and -returns the new one. Use this to increment pages using roman numerals or custom orderings. +=head3 add_page_setup -=head2 get_bounding_box() + $ps->add_page_setup( $code ) -=head2 set_bounding_box( x0, y0, x1, y1 ) +Appends C<$code> to the DSC PageSetup section. Note that this is a +document-global value, although the code will be repeated on each +page. -Inspect or change the bounding box for the whole document, showing only the area inside. +Also note that any settings defined here will be active for each page +seperately. Use L if you want to carry settings from one +page to another. -Setting the bounding box enables clipping. Call L with -0 afterwards to undo that. -=head2 get_printable_width() +=head3 get_page_setup -=head2 get_printable_height() + $setup = $ps->get_page_setup -These return the width or height of the document's bounding box -(S> or S>, respectively). These methods were -added in version 2.10. +Returns the contents of the DSC PageSetup section, if any. Note that +this is a document-global value, although the code will be repeated on +each page. -=head2 get_page_bounding_box( [page] ) -=head2 set_page_bounding_box( [page], x0, y0, x1, y1 ) +=head3 add_page_trailer -Inspect or change the bounding box for a specified page. If C is not specified, the current page is -assumed, otherwise it should be a page label already given to B or B. The page bounding -box defaults to the paper area. + $ps->add_page_trailer( $code ) -Note that calling C automatically enables -clipping for the page. If this isn't what you want, call -L with 0 afterwards. +Appends C<$code> to the DSC PageTrailer section. Note that this is a +document-global value, although the code will be repeated on each +page. -=head2 get_page_printable_width( [page] ) +Code added here is output after each page. It may refer to settings +made during L or L. -=head2 get_page_printable_height( [page] ) -These return the width or height of the specified page's bounding box -(S> or S>, respectively). If C is not -specified, the current page is assumed. These methods were added in -version 2.10. +=head3 get_page_trailer -=head2 set_page_margins( [page], left, bottom, right, top ) + $code = $ps->get_page_trailer -An alternative way of changing a single page's bounding box. Unlike the options given to B, the parameters here -are the gaps around the image, not the paper. So C will set the left side in by half an inch, this might -be a short side if C is set. +Returns the contents of the DSC PageTrailer section, if any. Note that +this is a document-global value, although the code will be repeated on +each page. -Note that this automatically enables clipping for the page. If this isn't what you want, call -B with 0. -=head2 get_ordinal( [page] ) +=head3 add_preview -Return the internal number for the page label specified. (Default: current page) + $ps->add_preview( $width, $height, $depth, $lines, $preview ) -Example +Sets the EPSI format preview for this document - an ASCII +representation of a bitmap. Only EPS files should have a preview, but +that is not enforced. If an EPS file has a preview it becomes an EPSI +file rather than EPSF. -Say pages are numbered "i", "ii", "iii, "iv", "1", "2", "3". - get_ordinal("i") == 0 - get_ordinal("iv") == 3 - get_ordinal("1") == 4 +=head3 get_preview -=head2 get_pagecount() + $preview = $ps->get_preview -Return the number of pages currently known. +Returns the EPSI preview of the document, if any, including the +C<%%BeginPreview> and C<%%EndPreview> comments. -=head2 set_variable( key, value ) -Assign a user defined hash key and value. Provided to keep track of states within the PostScript code, such as -which dictionaries are currently open. PostScript::File does not use this - it is provided for client programs. -It is recommended that C is the module name to avoid clashes. This entry could then be a hash holding any -number of user variables. +=head3 add_procset -=head2 get_variable + $ps->add_procset( $name, $code, [$version, [$revision]] ) -Retrieve a user defined value. +(v2.20) Add a ProcSet containing user defined functions to the PostScript +prolog. C<$name> is an arbitrary identifier of this resource. C<$code> +is a block of PostScript code, usually from a 'here' document. If the +document already contains ProcSet C<$name> (as reported by +C, then C does nothing. -=head2 set_page_variable( key, value ) +C<$version> is a real number, and C<$revision> is an unsigned integer. +They both default to 0. PostScript::File does not make any use of +these, but a PostScript document manager may assume that a procset +with a higher revision number may be substituted for a procset with +the same name and version but a lower revision. -Assign a user defined hash key and value only valid on the current page. Provided to keep track of states within -the PostScript code, such as which styles are currently active. PostScript::File does not use this (except to -clear it at the start of each page). It is recommended that C is the module name to avoid clashes. This entry -could then be a hash holding any number of user variables. +Returns true if the ProcSet was added, or false if it already existed. -=head2 get_page_variable +Example -Retrieve a user defined value. + $ps->add_procset( "My_Functions", < (in common with the others) will return I user defined functions possibly +including those added by other classes. -Most of the required and recommended comments are set directly, so this function should rarely be needed. It is -provided for completeness so that comments not otherwise supported can be added. The comment should -be the bare PostScript DSC name and value, with additional lines merely prefixed by C<+>. -Programs written for older versions of PostScript::File might use this -to add a C comment. That is now deprecated; -you should use L instead. +=head3 has_procset -Example + $exists = $ps->has_procset( $name ) - $ps->add_comment("ProofMode: NotifyMe"); - $ps->add_comment("Requirements: manualfeed"); +(v2.20) This returns true if C<$name> has already been included in the +file. The name should be identical to that given to +L. -=head2 get_preview() +=for Pod::Coverage +add_function +get_functions +has_function -=head2 add_preview( width, height, depth, lines, preview ) -Use this to add a Preview in EPSI format - an ASCII representation of a bitmap. If an EPS file has a preview it -becomes an EPSI file rather than EPSF. +=head3 get_procsets -=head2 get_defaults() + $code = $ps->get_procsets -=head2 add_default( default ) +(v2.20) Return all the procsets defined in this document. -Use this to add any PostScript DSC comments to the Defaults section. These would be typically values like -PageCustomColors: or PageRequirements:. -=head2 get_resources() +=head3 add_resource -=head2 add_resource( type, name, params, resource ) + $ps->add_resource( $type, $name, $params, $resource ) =over 4 -=item C +=item C<$type> A string indicating the DSC type of the resource. It should be one of C, C, C, C, C, C, or C (case sensitive). -=item C +=item C<$name> An arbitrary identifier of this resource. (For a Font, it must be the PostScript name of the font, without a leading slash.) -=item C +=item C<$params> Some resource types require parameters. See the Adobe documentation for details. -=item C +=item C<$resource> A string containing the PostScript code. Probably best provided a 'here' document. =back -Use this to add fonts or images (although you may prefer L -or L). B is provided for functions. +Use this to add fonts or images (although you may prefer L +or L). L is provided for functions. Example @@ -2757,184 +3388,251 @@ ...PostScript resource definition END_FILE1 -Note that B returns I resources added, including those added by any inheriting modules. -=head2 get_functions() +=head3 get_resources -=head2 add_function( name, code, [version, [revision]] ) + $resources = $ps->get_resources -Add a ProcSet containing user defined functions to the PostScript -prolog. Despite the name, it is better to add related functions in -the same code section. C is an arbitrary identifier of this -resource. Best used with a 'here' document. If the document already -contains ProcSet C (as reported by C, then -C does nothing. - -C is a real number, and C is an integer. They both -default to 0. PostScript::File does not make any use of these, but a -PostScript document manager may assume that a procset with a higher -revision number may be substituted for a procset with the same name -and version but a lower revision. +Returns all resources provided by this document. This does not +include procsets. -Returns true if the ProcSet was added, or false if it already existed. -Example +=head3 add_setup - $ps->add_function( "My_Functions", <add_setup( $code ) - % foo does this... - /foo { - ... definition of foo - } bind def +This appends C<$code> to the DSC Setup section. Use this for +C, C or other settings that initialize the +device or document. - % bar does that... - /bar { - ... definition of bar - } bind def - END_FUNCTIONS -Note that B (in common with the others) will return I user defined functions possibly -including those added by other classes. +=head3 get_setup -=head2 has_function( name ) + $setup = $ps->get_setup -This returns true if C has already been included in the file. The name -should identical to that given to L. +Returns the contents of the DSC Setup section, if any. -=head2 embed_document( filename ) -This reads the contents of C, which should be a PostScript -file. It returns a string with the contents of the file surrounded by -%%BeginDocument and %%EndDocument comments, and adds C to -the list of document supplied resources. +=head3 add_trailer -You must pass the returned string to add_to_page or some other method -that will actually include it in the document. + $ps->add_trailer( $code ) -=head2 embed_font( filename, [type] ) +Appends C<$code> to the document's DSC Trailer section. Use this for +any tidying up after all the pages are output. -This reads the contents of C, which must contain a -PostScript font. It calls L to add the font to the -document, and returns the name of the font (without a leading slash). -If C is omitted, the C's extension is used as the -type. Type names are not case sensitive. The currently supported -types are: +=head3 get_trailer -=over + $code = $ps->get_trailer -=item PFA +Returns the contents of the document's DSC Trailer section, if any. -A PostScript font in ASCII format -=item PFB +=head3 use_functions -A PostScript font in binary format. This requires the t1ascii program -from L. (You can set -C<$PostScript::File::t1ascii> to the name of the program to use. It -defaults to F.) + $ps->use_functions( @function_names ) -=item TTF +This requests that the PostScript functions listed in +C<@function_names> be included in this document. See +L for a list of available functions. -A TrueType font. This requires the ttftotype42 program from -L. (You can set -C<$PostScript::File::ttftotype42> to the name of the program to use. -It defaults to F.) -Since TrueType (aka Type42) font support was introduced in PostScript -level 2, embedding a TTF font automatically sets C to 2 -(unless it was already set to a higher level). Be aware that not all -printers can handle Type42 fonts. (Even PostScript level 2 printers -need not support them.) Ghostscript does support Type42 fonts (when -compiled with the C option). +=head2 Text Processing Methods + + + +=head3 convert_hyphens + + $converted_text = $ps->convert_hyphens( $text ) + +Converts any HYPHEN-MINUS (U+002D) characters in C<$text> to either +HYPHEN (U+2010) or MINUS SIGN (U+2212) according to the rules +described in L. This has the side-effect +of setting the UTF-8 flag on C<$converted_text>. + +If C<$text> does not have the UTF-8 flag set, it is assumed to be in +the document's character encoding. + +If C<$text> does not contain any HYPHEN-MINUS characters, it is +returned as-is. + + +=head3 decode_text + + $text = $ps->decode_text( $encoded_text, [$preserve_minus] ) + +This is the inverse of L. It converts C<$encoded_text> +from the document's character encoding into Unicode. If +C<$encoded_text> already has the UTF-8 flag set, or the document is +not using character translation, then it returns C<$encoded_text> +as-is. + +If the optional argument C<$preserve_minus> is true (and +C<$encoded_text> is not being returned as-is), then any HYPHEN-MINUS +(U+002D) characters in C<$encoded_text> are decoded as MINUS SIGN +(U+2212). This ensures that C will treat them as minus +signs instead of hyphens. + + +=head3 encode_text + + $encoded_text = $ps->encode_text( $text ) + +This returns C<$text> converted to the document's character encoding. +If C<$text> does not have the UTF-8 flag set, or the document is not +using character translation, then it returns C<$text> as-is. + + +=head3 pstr + + $code = $ps->pstr( $string, [$nowrap] ) + + $code = PostScript::File->pstr( $string, [$nowrap] ) + + $code = pstr( $string ) + +Converts the string to a PostScript string literal. If the result is +more than 240 characters, it will be broken into multiple lines. (A +PostScript file should not contain lines with more than 255 +characters.) + +When called as a class or object method, +you can pass a second parameter C<$nowrap>. If this optional parameter +is true, then the string will not be wrapped, no matter how long it is. + +When called as an object method, C will do automatic +hyphen-minus translation if L is true. This has the +side-effect of setting the UTF-8 flag on the returned string. (If the +UTF-8 flag was not set on the input string, it will be decoded using +the document's character set.) See L. +For this reason, C should normally be called as an object method. + + +=head3 strip (method) + + $ps->strip( $code ) + + $ps->strip( $strip => @code ) + +The C method filters PostScript code according to the value of +C<$strip>, which can be any valid value for the L +attribute. The code is modified in-place; there is no return value. +If C<$code> is C, it is left unchanged. + +When called with a single argument, strips C<$code> according to the +current value of the C attribute. + +=head1 SUBROUTINES + +=head2 array_as_string + + $code = array_as_string( @array ) + +Converts a Perl array to a PostScript array literal. The array +elements are used as-is. If you want an array of strings, you should +do something like: + + $code = array_as_string( map { $ps->pstr($_) } @array ) + + +=head2 check_file + + $pathname = check_file( $file, [$dir, [$create]] ) + +=over 4 + +=item C<$file> + +An optional fully qualified path-and-file or a simple file name. If +omitted or the empty string, the special file C<< File::Spec->devnull >> +is returned. + +=item C<$dir> + +An optional directory path. If defined (and C<$file> is not already +an absolute path), it is prepended to C<$file>. + +=item C<$create> + +If true, create the file if it doesn't exist already. (Default: false) =back -=head2 need_resource( type, resource... ) +This converts a filename and optional directory to an absolute path, +and then creates any directories that don't already exist. Any +leading C<~> is expanded to the user's home directory using +L. -This adds a resource to the DocumentNeededResources comment. C -is one of C, C, C, C, C, or -C (case sensitive). +If C<$create> is true, and C<$pathname> does not exist, it is created +as an empty file. -Any number of resources (of a single type) may be added in one call. -For most types, C is just the resource name. But for -C, each C should be an arrayref of 3 elements: -C<[name, version, revision]>. Names that contain special characters -such as spaces will be quoted automatically. +L is used throughout so file access should be portable. -If C is never called for the C type (and -C is not used), it assumes the document requires all 13 of -the standard PostScript fonts: Courier, Courier-Bold, -Courier-BoldOblique, Courier-Oblique, Helvetica, Helvetica-Bold, -Helvetica-BoldOblique, Helvetica-Oblique, Times-Roman, Times-Bold, -Times-BoldItalic, Times-Italic, and Symbol. But this behaviour is -deprecated; a document should explicitly list the fonts it requires. -If you don't use any of the standard fonts, pass C<< need_fonts => [] >> -to the constructor (or call C<< $ps->need_resource('font') >>) to -indicate that. -=head2 get_setup() +=head2 check_tilde -=head2 add_setup( code ) + $expanded_path = check_tilde( $path ) -Direct access to the C<%%Begin(End)Setup> section. Use this for C, C or other settings -that initialize the device or document. +Expands a leading C<~> or C<~user> in C<$path> to the home directory. -=head2 get_page_setup() -=head2 add_page_setup( code ) +=head2 incpage_label -Code added here is output before each page. As there is no special provision for %%Page... DSC comments, they -should be included here. + $next_label = incpage_label( $label ) -Note that any settings defined here will be active for each page seperately. Use B if you want to -carry settings from one page to another. +This function applies Perl's autoincrement operator to C<$label> and +returns the result. (This means that the magic string autoincrement +applies to values that match C.) -=head2 get_page( [page] ) +This function is the default value of the L attribute. -=head2 add_to_page( [page], code ) -The main function for building the PostScript output. C can be any label, typically one given to -B. (Default: current page) +=head2 incpage_roman -If C is not recognized, a new page is added with that label. Note that this is added on the end, not in the -order you might expect. So adding "vi" to page set "iii, iv, v, 6, 7, 8" would create a new page after "8" not -after "v". + $next_label = incpage_roman( $label ) -Examples +This function increments lower case Roman numerals. C<$label> must be +a value between "i" and "xxxviii" (1 to 38), and C<$next_label> will +be "ii" to "xxxix" (2 to 39). That should be quite enough for +numbering the odd preface. - $ps->add_to_page( < +attribute: - $ps->add_to_page( "3", <set_incpage_handler( \&PostScript::File::incpage_roman ) + + +=head2 quote_text + + $quoted = quote_text( $string ) -The first example adds code onto the end of the current page. The second one either adds additional code to page -3 if it exists, or starts a new one. + $quoted = PostScript::File->quote_text( $string ) -=head2 get_page_trailer() + $quoted = $ps->quote_text( $string ) -=head2 add_page_trailer( code ) +Quotes the string if it contains special characters, making it +suitable for a DSC comment. Strings without special characters are +returned unchanged. + +This may also be called as a class or object method, but it does not +do hyphen-minus translation, even if L is true. -Code added here is output after each page. It may refer to settings made during B or -B. -=head2 get_trailer() +=head2 str -=head2 add_trailer( code ) + $code = str( $value ) -Add code to the PostScript C<%%Trailer> section. Use this for any tidying up after all the pages are output. +If C<$value> is an arrayref, returns C. +Otherwise, returns C<$value> as-is. This function was designed to +simplify passing colors to the PostScript function +L, which expects either an RGB +array or a greyscale decimal. =head1 POSTSCRIPT DEBUGGING SUPPORT This section documents the PostScript functions which provide debugging output. Please note that any clipping or bounding boxes will also hide the debugging output which by default starts at the top left of the page. Typical -B options required for debugging would include the following. +C options required for debugging would include the following. $ps = PostScript::File->new ( errors => "page", @@ -2943,10 +3641,10 @@ The debugging output is printed on the page being drawn. In practice this works fine, especially as it is possible to move the output around. Where the text appears is controlled by a number of PostScript variables, -most of which may also be given as options to B. +most of which may also be given as options to C. The main controller is C which needs to be non-zero for any output to be seen. It might be useful to -set this to 0 in B, then at some point in your code enable it. Remember that the C dictionary +set this to 0 in C, then at some point in your code enable it. Remember that the C dictionary needs to be selected in order for any of its variables to be changed. This is better done with C but it illustrates the point. @@ -2968,8 +3666,8 @@ =head3 x0 y0 x1 y1 B -This function is only available if 'clipping' is set. By calling the perl method B (and -resetting with B) it is possible to use this to identify areas on the page. +This function is only available if 'clipping' is set. By calling the Perl method C (and +resetting with C) it is possible to use this to identify areas on the page. $ps->draw_bounding_box(); $ps->add_to_page( < variables (including function names) are defined within their own dictionary (C). But -this can be ignored by all calls originating from within code passed to B (usually including -B code) as the dictionary is automatically put on the stack before each page and taken off as each +this can be ignored by all calls originating from within code passed to C (usually including +C code) as the dictionary is automatically put on the stack before each page and taken off as each finishes. =head3 any B @@ -2999,7 +3697,7 @@ This shows top C items on the stack. It requires a number and a string on the stack, which it removes. It prints out C then the top C items on the stack, assuming there are that many. It can be used to do -a labelled stack dump. Note that if B was given the option C 2>, There will always be a '--mark--' +a labelled stack dump. Note that if C was given the option C 2>, There will always be a '--mark--' entry at the base of the stack. See L. count (at this point) db_nshow @@ -3033,7 +3731,7 @@ top= 111 next= 222 It is important that the output does not exceed the string buffer size. The default is 256, but it can be changed -by giving B the option C. +by giving C the option C. =head3 x y msg B @@ -3082,93 +3780,17 @@ Moves output left by C. No stack requirements. -=head1 EXPORTED FUNCTIONS - -No functions are exported by default, they must be named as required. - - use PostScript::File qw( - check_tilde check_file - incpage_label incpage_roman - array_as_string str - ); - -=head2 incpage_label( label ) - -The default function for B which just increases the number passed to it. A useful side -effect is that letters are also incremented. - -=head2 incpage_roman( label ) - -An alternative function for B which increments lower case roman numerals. It only handles -values from "i" to "xxxix", but that should be quite enough for numbering the odd preface. - -=head2 check_file( file, [dir, [create]] ) - -=over 4 - -=item C - -An optional fully qualified path-and-file or a simple file name. If omitted, the special file -File::Spec->devnull() is returned. - -=item C +=for Pod::Coverage +clip_bounding_box +draw_bounding_box -An optional directory C. If present (and C is not already an absolute path), it is prepended to -C. +=head1 EXPORTS -=item C +No functions are exported by default. All the functions listed in +L may be exported by request. -If non-zero, ensure the file exists. It may be necessary to set C to "" or undef. - -=back - -This ensures the filename returned is valid and in a directory tree which is created if it doesn't exist. - -Any leading '~' is expanded to the users home directory. If no absolute directory is given either as part of -C, it is placed within the current directory. Intervening directories are always created. If C is -set, C is created as an empty file, possible erasing any previous file of the same name. - -L is used throughout so file access should be portable. - -=head2 check_tilde( dir ) - -Expands any leading '~' to the home directory. - -=head2 array_as_string( array ) - -Converts a perl array to its PostScript representation. - -=head2 str( arrayref ) - -Converts the referenced array to a string representation suitable for PostScript code. If C is not an -array reference, it is passed through unchanged. This function was designed to simplify passing colours for the -PostScript function b which expects either an RGB array or a greyscale decimal. See -L. - -=head2 pstr( string ) - -Converts the string to a string representation suitable for PostScript -code. If the result is more than 240 characters, it will be broken -into multiple lines. (A PostScript file should not contain lines with -more than 255 characters.) - -This may also be called as a class or object method. In this case, -you can pass a second parameter C. If this optional parameter -is true, then the string will not be wrapped. - -When called as an object method, C will do automatic -hyphen-minus translation if L is true. This has the -side-effect of setting the UTF8 flag on the returned string. (If the -UTF8 flag was not set on the input string, it will be decoded using -the document's character set.) See L. - -=head2 quote_text( string ) - -Quotes the string if it contains special characters, making it -suitable for a DSC comment. Strings without special characters are -returned unchanged. - -This may also be called as a class or object method. +In addition, the C method may be exported as a subroutine, but +this usage is deprecated. =head1 BUGS AND LIMITATIONS @@ -3198,7 +3820,7 @@ Copyright 2002, 2003 Christopher P Willmot. All rights reserved. -Copyright 2011 Christopher J. Madsen. All rights reserved. +Copyright 2012 Christopher J. Madsen. All rights reserved. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. @@ -3207,18 +3829,65 @@ I and I published by Adobe, 1992. L +Version 3.0> published by Adobe, 1992. +L L, for PDF or PNG output. +L, for creating monthly calendars. + +L, for creating tabular reports. + +L, for printing schedules in a grid format. + +L, for printing TV listings in a grid format. + L, L, L, L, -L. +L, L. -L. -L. + + + +=for Pod::Coverage +get_auto_hyphen +get_bounding_box +get_clipping +get_eps +get_extensions +get_file_ext +get_filename +get_height +get_incpage_handler +get_landscape +get_langlevel +get_order +get_page_bounding_box +get_page_clipping +get_page_label +get_page_landscape +get_paper +get_strip +get_title +get_version +get_width +set_auto_hyphen +set_bounding_box +set_clipping +set_file_ext +set_filename +set_height +set_incpage_handler +set_landscape +set_page_bounding_box +set_page_clipping +set_page_label +set_page_landscape +set_paper +set_strip +set_width =head1 DISCLAIMER OF WARRANTY diff -Nru libpostscript-file-perl-2.11+dfsg/LICENSE libpostscript-file-perl-2.20+dfsg/LICENSE --- libpostscript-file-perl-2.11+dfsg/LICENSE 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/LICENSE 2012-02-11 18:23:30.000000000 +0000 @@ -1,4 +1,4 @@ -This software is copyright (c) 2011 by Christopher J. Madsen. +This software is copyright (c) 2012 by Christopher J. Madsen. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. @@ -12,7 +12,7 @@ --- The GNU General Public License, Version 1, February 1989 --- -This software is Copyright (c) 2011 by Christopher J. Madsen. +This software is Copyright (c) 2012 by Christopher J. Madsen. This is free software, licensed under: @@ -22,7 +22,7 @@ Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + 51 Franklin St, Suite 500, Boston, MA 02110-1335 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -272,7 +272,7 @@ --- The Artistic License 1.0 --- -This software is Copyright (c) 2011 by Christopher J. Madsen. +This software is Copyright (c) 2012 by Christopher J. Madsen. This is free software, licensed under: diff -Nru libpostscript-file-perl-2.11+dfsg/Makefile.PL libpostscript-file-perl-2.20+dfsg/Makefile.PL --- libpostscript-file-perl-2.11+dfsg/Makefile.PL 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/Makefile.PL 2012-02-11 18:23:30.000000000 +0000 @@ -9,14 +9,12 @@ my %WriteMakefileArgs = ( - "ABSTRACT" => "Base class for creating Adobe PostScript files", + "ABSTRACT" => "Class for creating Adobe PostScript files", "AUTHOR" => "Christopher J. Madsen ", "BUILD_REQUIRES" => { "FindBin" => 0, "List::Util" => 0, - "Test::More" => "0.88", - "charnames" => 0, - "constant" => 0 + "Test::More" => "0.88" }, "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => "6.30" @@ -28,12 +26,12 @@ "PREREQ_PM" => { "Carp" => 0, "Encode" => "2.21", - "Exporter" => 0, + "Exporter" => "5.57", "File::Spec" => 0, "Scalar::Util" => 0, "Sys::Hostname" => 0 }, - "VERSION" => "2.11", + "VERSION" => "2.20", "test" => { "TESTS" => "t/*.t" } diff -Nru libpostscript-file-perl-2.11+dfsg/MANIFEST libpostscript-file-perl-2.20+dfsg/MANIFEST --- libpostscript-file-perl-2.11+dfsg/MANIFEST 2011-10-16 13:09:06.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/MANIFEST 2012-02-12 14:05:11.000000000 +0000 @@ -12,6 +12,7 @@ examples/minimal.pl examples/symbol.pl lib/PostScript/File.pm +lib/PostScript/File/Functions.pm lib/PostScript/File/Metrics.pm lib/PostScript/File/Metrics/Loader.pm lib/PostScript/File/Metrics/cp1252/Courier.pm @@ -51,6 +52,7 @@ lib/PostScript/File/Metrics/std/Times/Italic.pm lib/PostScript/File/Metrics/std/Times/Roman.pm lib/PostScript/File/Metrics/sym/Symbol.pm +t/00-all_prereqs.t t/00-load.t t/10-simple.t t/20-eps.t diff -Nru libpostscript-file-perl-2.11+dfsg/META.json libpostscript-file-perl-2.20+dfsg/META.json --- libpostscript-file-perl-2.11+dfsg/META.json 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/META.json 2012-02-11 18:23:30.000000000 +0000 @@ -1,10 +1,10 @@ { - "abstract" : "Base class for creating Adobe PostScript files", + "abstract" : "Class for creating Adobe PostScript files", "author" : [ "Christopher J. Madsen " ], "dynamic_config" : 0, - "generated_by" : "Dist::Zilla version 4.300002, CPAN::Meta::Converter version 2.110930", + "generated_by" : "Dist::Zilla version 4.300006, CPAN::Meta::Converter version 2.113640", "license" : [ "perl_5" ], @@ -20,10 +20,13 @@ } }, "runtime" : { + "recommends" : { + "Font::AFM" : 0 + }, "requires" : { "Carp" : 0, "Encode" : "2.21", - "Exporter" : 0, + "Exporter" : "5.57", "File::Spec" : 0, "Scalar::Util" : 0, "Sys::Hostname" : 0, @@ -32,15 +35,12 @@ }, "test" : { "recommends" : { - "File::Temp" : "0.15", - "Font::AFM" : 0 + "File::Temp" : "0.15" }, "requires" : { "FindBin" : 0, "List::Util" : 0, - "Test::More" : "0.88", - "charnames" : 0, - "constant" : 0 + "Test::More" : "0.88" }, "suggests" : { "Test::Differences" : 0 @@ -55,194 +55,186 @@ "web" : "http://github.com/madsen/postscript-file" } }, - "version" : "2.11", + "version" : "2.20", "x_Dist_Zilla" : { "plugins" : [ { + "class" : "tools::FixupPSFilePOD", + "name" : "=tools::FixupPSFilePOD", + "version" : "2.20" + }, + { + "class" : "tools::ExtractFunctionDocs", + "name" : "=tools::ExtractFunctionDocs", + "version" : "2.20" + }, + { "class" : "Dist::Zilla::Plugin::VersionFromModule", - "name" : "@Filter/VersionFromModule", + "name" : "CJM/VersionFromModule", "version" : "0.08" }, { "class" : "Dist::Zilla::Plugin::GatherDir", - "name" : "@Filter/GatherDir", - "version" : "4.300002" + "name" : "CJM/GatherDir", + "version" : "4.300006" }, { "class" : "Dist::Zilla::Plugin::PruneCruft", - "name" : "@Filter/PruneCruft", - "version" : "4.300002" + "name" : "CJM/PruneCruft", + "version" : "4.300006" }, { "class" : "Dist::Zilla::Plugin::ManifestSkip", - "name" : "@Filter/ManifestSkip", - "version" : "4.300002" + "name" : "CJM/ManifestSkip", + "version" : "4.300006" }, { "class" : "Dist::Zilla::Plugin::MetaJSON", - "name" : "@Filter/MetaJSON", - "version" : "4.300002" + "name" : "CJM/MetaJSON", + "version" : "4.300006" }, { "class" : "Dist::Zilla::Plugin::MetaYAML", - "name" : "@Filter/MetaYAML", - "version" : "4.300002" + "name" : "CJM/MetaYAML", + "version" : "4.300006" }, { "class" : "Dist::Zilla::Plugin::License", - "name" : "@Filter/License", - "version" : "4.300002" + "name" : "CJM/License", + "version" : "4.300006" + }, + { + "class" : "Dist::Zilla::Plugin::Test::PrereqsFromMeta", + "name" : "CJM/Test::PrereqsFromMeta", + "version" : "4.04" }, { "class" : "Dist::Zilla::Plugin::PodSyntaxTests", - "name" : "@Filter/PodSyntaxTests", - "version" : "4.300002" + "name" : "CJM/PodSyntaxTests", + "version" : "4.300006" }, { "class" : "Dist::Zilla::Plugin::ExtraTests", - "name" : "@Filter/ExtraTests", - "version" : "4.300002" + "name" : "CJM/ExtraTests", + "version" : "4.300006" }, { "class" : "Dist::Zilla::Plugin::PodLoom", "config" : { "Pod::Loom version" : "0.05" }, - "name" : "@Filter/PodLoom", - "version" : "4.00" + "name" : "CJM/PodLoom", + "version" : "4.10" }, { "class" : "Dist::Zilla::Plugin::MakeMaker", - "name" : "@Filter/MakeMaker", - "version" : "4.300002" + "name" : "CJM/MakeMaker", + "version" : "4.300006" }, { "class" : "Dist::Zilla::Plugin::MetaConfig", - "name" : "@Filter/MetaConfig", - "version" : "4.300002" + "name" : "CJM/MetaConfig", + "version" : "4.300006" }, { "class" : "Dist::Zilla::Plugin::MatchManifest", - "name" : "@Filter/MatchManifest", + "name" : "CJM/MatchManifest", "version" : "4.00" }, { + "class" : "Dist::Zilla::Plugin::RecommendedPrereqs", + "name" : "CJM/RecommendedPrereqs", + "version" : "4.06" + }, + { + "class" : "Dist::Zilla::Plugin::CheckPrereqsIndexed", + "name" : "CJM/CheckPrereqsIndexed", + "version" : "0.006" + }, + { "class" : "Dist::Zilla::Plugin::GitVersionCheckCJM", - "name" : "@Filter/GitVersionCheckCJM", - "version" : "3.05" + "name" : "CJM/GitVersionCheckCJM", + "version" : "4.03" }, { "class" : "Dist::Zilla::Plugin::TemplateCJM", - "name" : "@Filter/TemplateCJM", - "version" : "3.05" + "name" : "CJM/TemplateCJM", + "version" : "4.00" }, { "class" : "Dist::Zilla::Plugin::Repository", - "name" : "@Filter/Repository", + "name" : "CJM/Repository", "version" : "0.18" }, { "class" : "Dist::Zilla::Plugin::Git::Check", - "name" : "@Filter/@Git/Check", - "version" : "1.110500" + "name" : "CJM/@Git/Check", + "version" : "1.112510" }, { "class" : "Dist::Zilla::Plugin::Git::Commit", - "name" : "@Filter/@Git/Commit", - "version" : "1.110500" + "name" : "CJM/@Git/Commit", + "version" : "1.112510" }, { "class" : "Dist::Zilla::Plugin::Git::Tag", - "name" : "@Filter/@Git/Tag", - "version" : "1.110500" + "name" : "CJM/@Git/Tag", + "version" : "1.112510" }, { "class" : "Dist::Zilla::Plugin::Git::Push", - "name" : "@Filter/@Git/Push", - "version" : "1.110500" + "name" : "CJM/@Git/Push", + "version" : "1.112510" }, { "class" : "Dist::Zilla::Plugin::TestRelease", - "name" : "@Filter/TestRelease", - "version" : "4.300002" + "name" : "CJM/TestRelease", + "version" : "4.300006" }, { "class" : "Dist::Zilla::Plugin::UploadToCPAN", - "name" : "@Filter/UploadToCPAN", - "version" : "4.300002" + "name" : "CJM/UploadToCPAN", + "version" : "4.300006" }, { "class" : "Dist::Zilla::Plugin::ArchiveRelease", - "name" : "@Filter/ArchiveRelease", - "version" : "3.01" + "name" : "CJM/ArchiveRelease", + "version" : "4.00" }, { "class" : "Dist::Zilla::Plugin::AutoPrereqs", "name" : "AutoPrereqs", - "version" : "4.300002" - }, - { - "class" : "Dist::Zilla::Plugin::Prereqs", - "config" : { - "Dist::Zilla::Plugin::Prereqs" : { - "phase" : "runtime", - "type" : "requires" - } - }, - "name" : "Prereqs", - "version" : "4.300002" - }, - { - "class" : "Dist::Zilla::Plugin::Prereqs", - "config" : { - "Dist::Zilla::Plugin::Prereqs" : { - "phase" : "test", - "type" : "recommends" - } - }, - "name" : "TestRecommends", - "version" : "4.300002" - }, - { - "class" : "Dist::Zilla::Plugin::Prereqs", - "config" : { - "Dist::Zilla::Plugin::Prereqs" : { - "phase" : "test", - "type" : "suggests" - } - }, - "name" : "TestSuggests", - "version" : "4.300002" + "version" : "4.300006" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":InstallModules", - "version" : "4.300002" + "version" : "4.300006" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":IncModules", - "version" : "4.300002" + "version" : "4.300006" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":TestFiles", - "version" : "4.300002" + "version" : "4.300006" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExecFiles", - "version" : "4.300002" + "version" : "4.300006" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ShareFiles", - "version" : "4.300002" + "version" : "4.300006" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":MainModule", - "version" : "4.300002" + "version" : "4.300006" } ], "zilla" : { @@ -250,7 +242,7 @@ "config" : { "is_trial" : "0" }, - "version" : "4.300002" + "version" : "4.300006" } } } diff -Nru libpostscript-file-perl-2.11+dfsg/META.yml libpostscript-file-perl-2.20+dfsg/META.yml --- libpostscript-file-perl-2.11+dfsg/META.yml 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/META.yml 2012-02-11 18:23:30.000000000 +0000 @@ -1,183 +1,179 @@ --- -abstract: 'Base class for creating Adobe PostScript files' +abstract: 'Class for creating Adobe PostScript files' author: - 'Christopher J. Madsen ' build_requires: FindBin: 0 List::Util: 0 Test::More: 0.88 - charnames: 0 - constant: 0 configure_requires: ExtUtils::MakeMaker: 6.30 dynamic_config: 0 -generated_by: 'Dist::Zilla version 4.300002, CPAN::Meta::Converter version 2.110930' +generated_by: 'Dist::Zilla version 4.300006, CPAN::Meta::Converter version 2.113640' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: PostScript-File +recommends: + Font::AFM: 0 requires: Carp: 0 Encode: 2.21 - Exporter: 0 + Exporter: 5.57 File::Spec: 0 Scalar::Util: 0 Sys::Hostname: 0 perl: 5.008 resources: repository: git://github.com/madsen/postscript-file.git -version: 2.11 +version: 2.20 x_Dist_Zilla: plugins: - + class: tools::FixupPSFilePOD + name: '=tools::FixupPSFilePOD' + version: 2.20 + - + class: tools::ExtractFunctionDocs + name: '=tools::ExtractFunctionDocs' + version: 2.20 + - class: Dist::Zilla::Plugin::VersionFromModule - name: '@Filter/VersionFromModule' + name: CJM/VersionFromModule version: 0.08 - class: Dist::Zilla::Plugin::GatherDir - name: '@Filter/GatherDir' - version: 4.300002 + name: CJM/GatherDir + version: 4.300006 - class: Dist::Zilla::Plugin::PruneCruft - name: '@Filter/PruneCruft' - version: 4.300002 + name: CJM/PruneCruft + version: 4.300006 - class: Dist::Zilla::Plugin::ManifestSkip - name: '@Filter/ManifestSkip' - version: 4.300002 + name: CJM/ManifestSkip + version: 4.300006 - class: Dist::Zilla::Plugin::MetaJSON - name: '@Filter/MetaJSON' - version: 4.300002 + name: CJM/MetaJSON + version: 4.300006 - class: Dist::Zilla::Plugin::MetaYAML - name: '@Filter/MetaYAML' - version: 4.300002 + name: CJM/MetaYAML + version: 4.300006 - class: Dist::Zilla::Plugin::License - name: '@Filter/License' - version: 4.300002 + name: CJM/License + version: 4.300006 + - + class: Dist::Zilla::Plugin::Test::PrereqsFromMeta + name: CJM/Test::PrereqsFromMeta + version: 4.04 - class: Dist::Zilla::Plugin::PodSyntaxTests - name: '@Filter/PodSyntaxTests' - version: 4.300002 + name: CJM/PodSyntaxTests + version: 4.300006 - class: Dist::Zilla::Plugin::ExtraTests - name: '@Filter/ExtraTests' - version: 4.300002 + name: CJM/ExtraTests + version: 4.300006 - class: Dist::Zilla::Plugin::PodLoom config: Pod::Loom version: 0.05 - name: '@Filter/PodLoom' - version: 4.00 + name: CJM/PodLoom + version: 4.10 - class: Dist::Zilla::Plugin::MakeMaker - name: '@Filter/MakeMaker' - version: 4.300002 + name: CJM/MakeMaker + version: 4.300006 - class: Dist::Zilla::Plugin::MetaConfig - name: '@Filter/MetaConfig' - version: 4.300002 + name: CJM/MetaConfig + version: 4.300006 - class: Dist::Zilla::Plugin::MatchManifest - name: '@Filter/MatchManifest' + name: CJM/MatchManifest version: 4.00 - + class: Dist::Zilla::Plugin::RecommendedPrereqs + name: CJM/RecommendedPrereqs + version: 4.06 + - + class: Dist::Zilla::Plugin::CheckPrereqsIndexed + name: CJM/CheckPrereqsIndexed + version: 0.006 + - class: Dist::Zilla::Plugin::GitVersionCheckCJM - name: '@Filter/GitVersionCheckCJM' - version: 3.05 + name: CJM/GitVersionCheckCJM + version: 4.03 - class: Dist::Zilla::Plugin::TemplateCJM - name: '@Filter/TemplateCJM' - version: 3.05 + name: CJM/TemplateCJM + version: 4.00 - class: Dist::Zilla::Plugin::Repository - name: '@Filter/Repository' + name: CJM/Repository version: 0.18 - class: Dist::Zilla::Plugin::Git::Check - name: '@Filter/@Git/Check' - version: 1.110500 + name: CJM/@Git/Check + version: 1.112510 - class: Dist::Zilla::Plugin::Git::Commit - name: '@Filter/@Git/Commit' - version: 1.110500 + name: CJM/@Git/Commit + version: 1.112510 - class: Dist::Zilla::Plugin::Git::Tag - name: '@Filter/@Git/Tag' - version: 1.110500 + name: CJM/@Git/Tag + version: 1.112510 - class: Dist::Zilla::Plugin::Git::Push - name: '@Filter/@Git/Push' - version: 1.110500 + name: CJM/@Git/Push + version: 1.112510 - class: Dist::Zilla::Plugin::TestRelease - name: '@Filter/TestRelease' - version: 4.300002 + name: CJM/TestRelease + version: 4.300006 - class: Dist::Zilla::Plugin::UploadToCPAN - name: '@Filter/UploadToCPAN' - version: 4.300002 + name: CJM/UploadToCPAN + version: 4.300006 - class: Dist::Zilla::Plugin::ArchiveRelease - name: '@Filter/ArchiveRelease' - version: 3.01 + name: CJM/ArchiveRelease + version: 4.00 - class: Dist::Zilla::Plugin::AutoPrereqs name: AutoPrereqs - version: 4.300002 - - - class: Dist::Zilla::Plugin::Prereqs - config: - Dist::Zilla::Plugin::Prereqs: - phase: runtime - type: requires - name: Prereqs - version: 4.300002 - - - class: Dist::Zilla::Plugin::Prereqs - config: - Dist::Zilla::Plugin::Prereqs: - phase: test - type: recommends - name: TestRecommends - version: 4.300002 - - - class: Dist::Zilla::Plugin::Prereqs - config: - Dist::Zilla::Plugin::Prereqs: - phase: test - type: suggests - name: TestSuggests - version: 4.300002 + version: 4.300006 - class: Dist::Zilla::Plugin::FinderCode name: ':InstallModules' - version: 4.300002 + version: 4.300006 - class: Dist::Zilla::Plugin::FinderCode name: ':IncModules' - version: 4.300002 + version: 4.300006 - class: Dist::Zilla::Plugin::FinderCode name: ':TestFiles' - version: 4.300002 + version: 4.300006 - class: Dist::Zilla::Plugin::FinderCode name: ':ExecFiles' - version: 4.300002 + version: 4.300006 - class: Dist::Zilla::Plugin::FinderCode name: ':ShareFiles' - version: 4.300002 + version: 4.300006 - class: Dist::Zilla::Plugin::FinderCode name: ':MainModule' - version: 4.300002 + version: 4.300006 zilla: class: Dist::Zilla::Dist::Builder config: is_trial: 0 - version: 4.300002 + version: 4.300006 diff -Nru libpostscript-file-perl-2.11+dfsg/README libpostscript-file-perl-2.20+dfsg/README --- libpostscript-file-perl-2.11+dfsg/README 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/README 2012-02-11 18:23:30.000000000 +0000 @@ -1,4 +1,4 @@ -PostScript::File version 2.11, released October 11, 2011 +PostScript::File version 2.20, released February 11, 2012 This module produces the outline for an Adobe PostScript file. It provides convenient routines for writing PostScript directly, including reporting @@ -35,7 +35,7 @@ perl 5.008 Carp Encode 2.21 - Exporter + Exporter 5.57 File::Spec Scalar::Util Sys::Hostname @@ -43,19 +43,31 @@ CHANGES - Here's what's new in version 2.11 of PostScript::File: + Here's what's new in version 2.20 of PostScript::File: (See the file "Changes" for the full revision history.) - Improvements to word wrapping provided by Metrics objects: + API improvements: - - Added optional \%param to wrap method - - Added set_wrap_chars method - - You can now use ZERO WIDTH SPACE (U+200B) to allow breaking - a line at any point. - - Fixed bug: wrap method didn't wrap after hyphens. - By default, it now wraps after hyphens, dashes, and forward - slashes. - - Word wrapping now has tests + - Added use_functions method, which selects functions from a + library provided by new module PostScript::File::Functions. + - Added set_min_langlevel method + - Added all_comments strip type + - Renamed methods add_function, get_functions, & has_function + to add_procset, get_procsets, & has_procset. The old names + are still available for backwards compatibility, but their + use is deprecated. + + - Multi-line string literals are now protected from + comment/whitespace stripping. + - Fixed bug: add_preview might strip the preview + - Fixed bug: check_tilde treated "0" like the empty string + - Private methods bbox_comment, pre_pages, post_pages, & + print_file were renamed. You shouldn't have been using them + anyway. + - The get_ordinal method is now private. While it was + formerly documented, it unnecessarily exposed the internals + and had no real use. + - The documentation has been cleaned up. diff -Nru libpostscript-file-perl-2.11+dfsg/t/00-all_prereqs.t libpostscript-file-perl-2.20+dfsg/t/00-all_prereqs.t --- libpostscript-file-perl-2.11+dfsg/t/00-all_prereqs.t 1970-01-01 00:00:00.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/t/00-all_prereqs.t 2012-02-11 18:23:30.000000000 +0000 @@ -0,0 +1,91 @@ +#!perl + +use strict; +use warnings; + +# This doesn't use Test::More because I don't want to clutter %INC +# with modules that aren't prerequisites. + +my $test = 0; + +sub ok ($$) +{ + my ($ok, $name) = @_; + + printf "%sok %d - %s\n", ($ok ? '' : 'not '), ++$test, $name; + + return $ok; +} # end ok + +END { + ok(0, 'unknown failure') unless $test; + print "1..$test\n"; +} + +sub get_version +{ + my ($package) = @_; + + local $@; + my $version = eval { $package->VERSION }; + + defined $version ? $version : 'undef'; +} # end get_version + +TEST: { + ok(open(META, ') { + last if /^\s*"prereqs" : \{\s*\z/; + } # end while + + ok(defined $_, 'found prereqs') or last TEST; + + while () { + last if /^\s*\},?\s*\z/; + ok(/^\s*"(.+)" : \{\s*\z/, "found phase $1") or last TEST; + my $phase = $1; + + while () { + last if /^\s*\},?\s*\z/; + ok(/^\s*"(.+)" : \{\s*\z/, "found relationship $phase $1") or last TEST; + my $rel = $1; + + while () { + last if /^\s*\},?\s*\z/; + ok(/^\s*"([^"]+)"\s*:\s*(\S+?),?\s*\z/, "found prereq $1") + or last TEST; + my ($prereq, $version) = ($1, $2); + + next if $phase ne 'runtime' or $prereq eq 'perl'; + + my $loaded = eval "require $prereq; $prereq->VERSION($version); 1"; + if ($rel eq 'requires') { + ok($loaded, "loaded $prereq $version") + or printf STDERR "\n# Got: %s %s\n# Wanted: %s %s\n", + $prereq, get_version($prereq), $prereq, $version; + } else { + ok(1, ($loaded ? 'loaded' : 'failed to load') . " $prereq $version"); + } + } # end while in prerequisites + } # end while in relationship + } # end while in phase + + close META; + + # Print version of all loaded modules: + if ($ENV{AUTOMATED_TESTING}) { + print STDERR "# Listing %INC\n"; + + my @packages = grep { s/\.pm\Z// and do { s![\\/]!::!g; 1 } } sort keys %INC; + + my $len = 0; + for (@packages) { $len = length if length > $len } + $len = 68 if $len > 68; + + for my $package (@packages) { + printf STDERR "# %${len}s %s\n", $package, get_version($package); + } + } # end if AUTOMATED_TESTING +} # end TEST + diff -Nru libpostscript-file-perl-2.11+dfsg/t/00-load.t libpostscript-file-perl-2.20+dfsg/t/00-load.t --- libpostscript-file-perl-2.11+dfsg/t/00-load.t 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/t/00-load.t 2012-02-11 18:23:30.000000000 +0000 @@ -1,13 +1,15 @@ #! /usr/bin/perl #--------------------------------------------------------------------- -use Test::More tests => 3; +use Test::More tests => 4; BEGIN { use_ok('PostScript::File'); + use_ok('PostScript::File::Functions'); use_ok('PostScript::File::Metrics'); SKIP: { + # RECOMMEND PREREQ: Font::AFM eval { require Font::AFM }; skip "Font::AFM not installed", 1 if $@; diff -Nru libpostscript-file-perl-2.11+dfsg/t/10-simple.t libpostscript-file-perl-2.20+dfsg/t/10-simple.t --- libpostscript-file-perl-2.11+dfsg/t/10-simple.t 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/t/10-simple.t 2012-02-11 18:23:30.000000000 +0000 @@ -6,6 +6,7 @@ use File::Spec (); BEGIN { + # RECOMMEND PREREQ: File::Temp 0.15 - need tempdir eval "use File::Temp 0.15 'tempdir';"; plan skip_all => "File::Temp 0.15 required for testing" if $@; diff -Nru libpostscript-file-perl-2.11+dfsg/t/20-eps.t libpostscript-file-perl-2.20+dfsg/t/20-eps.t --- libpostscript-file-perl-2.11+dfsg/t/20-eps.t 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/t/20-eps.t 2012-02-11 18:23:30.000000000 +0000 @@ -6,6 +6,7 @@ use File::Spec (); BEGIN { + # RECOMMEND PREREQ: File::Temp 0.15 - need tempdir eval "use File::Temp 0.15 'tempdir';"; plan skip_all => "File::Temp 0.15 required for testing" if $@; diff -Nru libpostscript-file-perl-2.11+dfsg/t/30-debug.t libpostscript-file-perl-2.20+dfsg/t/30-debug.t --- libpostscript-file-perl-2.11+dfsg/t/30-debug.t 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/t/30-debug.t 2012-02-11 18:23:30.000000000 +0000 @@ -6,6 +6,7 @@ use File::Spec (); BEGIN { + # RECOMMEND PREREQ: File::Temp 0.15 - need tempdir eval "use File::Temp 0.15 'tempdir';"; plan skip_all => "File::Temp 0.15 required for testing" if $@; diff -Nru libpostscript-file-perl-2.11+dfsg/t/40-pages.t libpostscript-file-perl-2.20+dfsg/t/40-pages.t --- libpostscript-file-perl-2.11+dfsg/t/40-pages.t 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/t/40-pages.t 2012-02-11 18:23:30.000000000 +0000 @@ -6,6 +6,7 @@ use File::Spec (); BEGIN { + # RECOMMEND PREREQ: File::Temp 0.15 - need tempdir eval "use File::Temp 0.15 'tempdir';"; plan skip_all => "File::Temp 0.15 required for testing" if $@; diff -Nru libpostscript-file-perl-2.11+dfsg/t/60-content.t libpostscript-file-perl-2.20+dfsg/t/60-content.t --- libpostscript-file-perl-2.11+dfsg/t/60-content.t 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/t/60-content.t 2012-02-11 18:23:30.000000000 +0000 @@ -24,15 +24,20 @@ use Test::More; -my $diff; -BEGIN { $diff = eval "use Test::Differences; 1" } - -# Not all versions of Test::Differences support changing the style: -eval { Test::Differences::unified_diff() }; +# Load Test::Differences, if available: +BEGIN { + # SUGGEST PREREQ: Test::Differences + if (eval "use Test::Differences; 1") { + # Not all versions of Test::Differences support changing the style: + eval { Test::Differences::unified_diff() } + } else { + *eq_or_diff = \&is; # Just use "is" instead + } +} # end BEGIN use PostScript::File (); -my $psVer = PostScript::File->VERSION; +my $psVer = sprintf('%g', PostScript::File->VERSION); my $generateResults; @@ -42,7 +47,7 @@ open(OUT, '>', '/tmp/60-content.t') or die $!; printf OUT "#%s\n\n__DATA__\n", '=' x 69; } else { - plan tests => 20 * 3; + plan tests => 24 * 3; } my ($name, %param, @methods); @@ -66,8 +71,8 @@ $expected .= $_; } - $expected =~ s{procset PostScript_File 0 0} - {procset PostScript_File $psVer 0}g; + $expected =~ s{(procset PostScript_File(?:[-_]\S+)?) 0 0} + {$1 $psVer 0}g; # Run the test: my $ps = PostScript::File->new(%param); @@ -81,20 +86,15 @@ $expected = $ps->output; # Suppress version numbers: - $expected =~ s{procset PostScript_File \Q$psVer\E 0} - {procset PostScript_File 0 0}g; + $expected =~ s{(procset PostScript_File(?:[-_]\S+)?) \Q$psVer\E 0} + {$1 0 0}g; print OUT "$expected---\n"; - } elsif ($diff) { - eq_or_diff($ps->output, $expected, $name); # if Test::Differences + } else { + eq_or_diff($ps->output, $expected, $name); # Calling output again should produce exactly the same output: eq_or_diff($ps->output, $expected, "repeat $name"); eq_or_diff(output_to_fh($ps), $expected, "$name to filehandle"); - } else { - is($ps->output, $expected, $name); # fall back to Test::More - # Calling output again should produce exactly the same output: - is($ps->output, $expected, "repeat $name"); - is(output_to_fh($ps), $expected, "$name to filehandle"); } # Clean up: @@ -106,7 +106,7 @@ $name = $1; } # end elsif test name (:: name) else { - die "Unrecognized line $_" if /\S/; + die "Unrecognized line $_" if /\S/ and not /^# /; } } # end while @@ -1658,3 +1658,146 @@ showpage %%EOF --- + + +:: use functions +errors: 0 +paper: 'Letter' +->use_functions(qw(drawBox)); +=== +%!PS-Adobe-3.0 +%%Orientation: Portrait +%%DocumentSuppliedResources: +%%+ procset PostScript_File_Functions-BD 0 0 +%%EndComments +%%BeginProlog +%%BeginResource: procset PostScript_File_Functions-BD 0 0 +/boxPath +{ +newpath +2 copy moveto +3 index exch lineto +1 index +4 2 roll +lineto +lineto +closepath +} bind def +/drawBox { boxPath stroke } bind def +%%EndResource +%%EndProlog +%%Page: 1 1 +%%PageBoundingBox: 28 28 584 764 +%%BeginPageSetup +/pagelevel save def +userdict begin +%%EndPageSetup +%%PageTrailer +end +pagelevel restore +showpage +%%EOF +--- + + +:: use more functions +errors: 0 +paper: 'Letter' +->use_functions(qw(clipBox)); +->use_functions(qw(setColor)); +=== +%!PS-Adobe-3.0 +%%Orientation: Portrait +%%DocumentSuppliedResources: +%%+ procset PostScript_File_Functions-ABC 0 0 +%%EndComments +%%BeginProlog +%%BeginResource: procset PostScript_File_Functions-ABC 0 0 +/setColor +{ +dup type (arraytype) eq { +aload pop +setrgbcolor +}{ +setgray +} ifelse +} bind def +/boxPath +{ +newpath +2 copy moveto +3 index exch lineto +1 index +4 2 roll +lineto +lineto +closepath +} bind def +/clipBox { boxPath clip } bind def +%%EndResource +%%EndProlog +%%Page: 1 1 +%%PageBoundingBox: 28 28 584 764 +%%BeginPageSetup +/pagelevel save def +userdict begin +%%EndPageSetup +%%PageTrailer +end +pagelevel restore +showpage +%%EOF +--- + + +:: preview +errors: 0 +eps: 1 +paper: 'Letter' +strip: 'comments' +->add_preview(1,2,3,4, "%line1\n%line2\n"); +=== +%!PS-Adobe-3.0 EPSF-3.0 +%%BoundingBox: 28 28 584 764 +%%Orientation: Portrait +%%EndComments +%%BeginPreview: 1 2 3 4 +%line1 +%line2 +%%EndPreview +%%BeginProlog +%%EndProlog +userdict begin +end +%%EOF +--- + + +:: preview with all_comments +errors: 0 +eps: 1 +strip: 'all_comments' +paper: 'Letter' +->add_preview(1,2,3,4, "%line1\n%line2\n"); +->add_to_page("(testing) show %comment\n"); +=== +%!PS-Adobe-3.0 EPSF-3.0 +%%BoundingBox: 28 28 584 764 +%%Orientation: Portrait +%%EndComments +%%BeginPreview: 1 2 3 4 +%line1 +%line2 +%%EndPreview +%%BeginProlog +%%EndProlog +userdict begin +(testing) show +end +%%EOF +--- + +# Local Variables: +# coding: windows-1252 +# compile-command: "perl 60-content.t gen" +# End: diff -Nru libpostscript-file-perl-2.11+dfsg/t/65-testable.t libpostscript-file-perl-2.20+dfsg/t/65-testable.t --- libpostscript-file-perl-2.11+dfsg/t/65-testable.t 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/t/65-testable.t 2012-02-11 18:23:30.000000000 +0000 @@ -24,11 +24,16 @@ use Test::More; -my $diff; -BEGIN { $diff = eval "use Test::Differences; 1" } - -# Not all versions of Test::Differences support changing the style: -eval { Test::Differences::unified_diff() }; +# Load Test::Differences, if available: +BEGIN { + # SUGGEST PREREQ: Test::Differences + if (eval "use Test::Differences; 1") { + # Not all versions of Test::Differences support changing the style: + eval { Test::Differences::unified_diff() } + } else { + *eq_or_diff = \&is; # Just use "is" instead + } +} # end BEGIN use PostScript::File (); @@ -42,10 +47,11 @@ open(OUT, '>', '/tmp/65-testable.t') or die $!; printf OUT "#%s\n\n__DATA__\n", '=' x 69; } else { - plan tests => 12 * 2; + plan tests => 14 * 2; } my ($name, %param, @methods); +my $builder = Test::More->builder; while () { @@ -78,15 +84,16 @@ $expected = $ps->testable_output; print OUT "$expected---\n"; - } elsif ($diff) { - eq_or_diff($ps->testable_output, $expected, $name); # if Test::Differences - # Calling output again should produce exactly the same output: - eq_or_diff($ps->testable_output, $expected, "repeat $name"); } else { - is($ps->testable_output, $expected, $name); # fall back to Test::More + my $todo = ($name =~ s/^TODO +//); + $builder->todo_start('') if $todo; + + eq_or_diff($ps->testable_output, $expected, $name); # Calling output again should produce exactly the same output: - is($ps->testable_output, $expected, "repeat $name"); - } + eq_or_diff($ps->testable_output, $expected, "repeat $name"); + + $builder->todo_end if $todo; + } # end else running tests # Clean up: @methods = (); @@ -97,7 +104,7 @@ $name = $1; } # end elsif test name (:: name) else { - die "Unrecognized line $_" if /\S/; + die "Unrecognized line $_" if /\S/ and not /^# /; } } # end while @@ -886,3 +893,67 @@ showpage %%EOF --- + + +:: do not strip whitespace in strings +paper: 'US-Letter' +->add_to_page("( don't strip this\n 4 spaces\n)\n do strip this\n"); +=== +%!PS-Adobe-3.0 +%%Orientation: Portrait +%%DocumentNeededResources: +%%+ font Courier-Bold +%%DocumentSuppliedResources: +%%EndComments +%%BeginProlog +%%EndProlog +%%Page: 1 1 +%%PageBoundingBox: 28 28 584 764 +%%BeginPageSetup +/pagelevel save def +userdict begin +%%EndPageSetup +( don't strip this + 4 spaces +) +do strip this +%%PageTrailer +end +pagelevel restore +showpage +%%EOF +--- + + +:: do not strip comments in strings +strip: 'comments' +paper: 'US-Letter' +->add_to_page("(% don't strip this\n % not this either\n% nor this)\n% do strip this\n"); +=== +%!PS-Adobe-3.0 +%%Orientation: Portrait +%%DocumentNeededResources: +%%+ font Courier-Bold +%%DocumentSuppliedResources: +%%EndComments +%%BeginProlog +%%EndProlog +%%Page: 1 1 +%%PageBoundingBox: 28 28 584 764 +%%BeginPageSetup +/pagelevel save def +userdict begin +%%EndPageSetup +(% don't strip this + % not this either +% nor this) +%%PageTrailer +end +pagelevel restore +showpage +%%EOF +--- + +# Local Variables: +# compile-command: "perl 65-testable.t gen" +# End: diff -Nru libpostscript-file-perl-2.11+dfsg/t/Font_Test.pm libpostscript-file-perl-2.20+dfsg/t/Font_Test.pm --- libpostscript-file-perl-2.11+dfsg/t/Font_Test.pm 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/t/Font_Test.pm 2012-02-11 18:23:30.000000000 +0000 @@ -22,7 +22,7 @@ use strict; use warnings; -use Exporter 'import'; +use Exporter 5.57 'import'; use constant number_of_tests => 275; use Test::More tests => number_of_tests; @@ -69,6 +69,7 @@ SKIP: { my $testsInBlock = number_of_tests - 2; + # RECOMMEND PREREQ: Font::AFM # Construct the Font::AFM object, or skip the remaining tests: eval { require Font::AFM }; diff -Nru libpostscript-file-perl-2.11+dfsg/t/release-pod-coverage.t libpostscript-file-perl-2.20+dfsg/t/release-pod-coverage.t --- libpostscript-file-perl-2.11+dfsg/t/release-pod-coverage.t 2011-10-12 01:46:59.000000000 +0000 +++ libpostscript-file-perl-2.20+dfsg/t/release-pod-coverage.t 2012-02-11 18:23:30.000000000 +0000 @@ -11,17 +11,17 @@ use Test::More; -eval "use Test::Pod::Coverage 1.04"; -plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" - if $@; +eval "use Test::Pod::Coverage 1.08; 1" +or plan skip_all => "Test::Pod::Coverage 1.08 required for testing POD coverage"; -plan tests => 3; +eval "use Pod::Coverage::TrustPod 0.100001; 1" +or plan skip_all => "Pod::Coverage::TrustPod 0.100001 required for testing POD coverage"; -TODO: { - local $TODO = "documentation unfinished"; +my $opts = { coverage_class => 'Pod::Coverage::TrustPod' }; - pod_coverage_ok('PostScript::File'); -} +plan tests => 4; -pod_coverage_ok('PostScript::File::Metrics'); -pod_coverage_ok('PostScript::File::Metrics::Loader'); +pod_coverage_ok('PostScript::File', $opts); +pod_coverage_ok('PostScript::File::Functions', $opts); +pod_coverage_ok('PostScript::File::Metrics', $opts); +pod_coverage_ok('PostScript::File::Metrics::Loader', $opts);