summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlgs/Resource/Init/gs_epsf.ps
diff options
context:
space:
mode:
authorReinhard Kotucha <reinhard.kotucha@web.de>2021-04-09 21:01:58 +0000
committerReinhard Kotucha <reinhard.kotucha@web.de>2021-04-09 21:01:58 +0000
commitcb14c16722533ee99b36a2e6efd9a6e4820954a3 (patch)
treef5cb5fbac1ea978af4cc1ea0f5d04d51bc1d01e0 /Master/tlpkg/tlgs/Resource/Init/gs_epsf.ps
parent94f0fd38b17b225048a0756ea6f03bbca0c30c7e (diff)
Upgrade gs-9.53.3 -> gs-9.54.0
git-svn-id: svn://tug.org/texlive/trunk@58805 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/tlgs/Resource/Init/gs_epsf.ps')
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_epsf.ps76
1 files changed, 66 insertions, 10 deletions
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_epsf.ps b/Master/tlpkg/tlgs/Resource/Init/gs_epsf.ps
index cf020751a08..47b68bba9be 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_epsf.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_epsf.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2020 Artifex Software, Inc.
+% Copyright (C) 2001-2021 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -29,6 +29,7 @@
% After %%HiResBoundingBox processed, state is 3 if OK or 4 if cropped.
% After %%EndComments processed, state is 5.
/EPSBoundingBoxState 5 def
+/EPSBoundingBoxString () def % set if either BoundingBox is seen (even if invalid)
/EPSBoundingBoxSetState {
//systemdict /EPSBoundingBoxState 3 -1 roll .forceput
} .bind executeonly odef % .forceput must be bound and hidden
@@ -60,7 +61,10 @@
/EPSBoundingBoxFitPage { % llx lly urx ury --
EPSDEBUG { (gs_epsf.ps: Rescaling EPS to fit page\n) print flush } if
clippath pathbbox newpath % ellx elly eurx eury pllx plly purx pury
-
+ EPSDEBUG {
+ (Page Coordinates: LLX: ) print 3 index =print (, LLY: ) print
+ 2 index =print (, URX: ) print 1 index =print (, URY: ) print dup = flush
+ } if
% Convert box corners to coordinates of the center and box sizes
2 { % loop doing the page coordinates, the the EPS bbox coordinates
3 -1 roll exch % ... llx urx lly ury
@@ -82,7 +86,19 @@
% Find orientation of the best fit. Square pages or files don't rotate.
2 copy sub % edx ecx edy ecy pdx pdy pdx-pdy
- 6 index 5 index sub mul % edx ecx edy ecy pdx pdy (pdx-pdy)*(edx-edy)
+ EPSDEBUG {
+ (pdx: ) print 2 index =print (, pdy: ) print 1 index =print
+ (, pdx-pdy: ) print dup = flush
+ } if
+ 6 index 5 index sub
+ EPSDEBUG {
+ (edx: ) print 7 index =print (, edy: ) print 5 index =print
+ (, edx-edy: ) print dup = flush
+ } if
+ mul % edx ecx edy ecy pdx pdy (pdx-pdy)*(edx-edy)
+ EPSDEBUG {
+ (product: ) print dup = flush
+ } if
0 lt {
90 rotate
exch
@@ -100,15 +116,17 @@
} bind executeonly odef
/EPSBoundingBoxProcess { % (llx lly urx ury) state --
+ % The following 'lt' check prioritzies HiResBoundingBox over BoundingBox
+ % even if HiResBoundingBox occurs first in the EPS file.
//systemdict /EPSBoundingBoxState get 1 index lt {
- exch EPSBoundingBoxParse
+ % save the BBoxString for possible FitPage when EndComments is seen
+ exch dup //systemdict /EPSBoundingBoxString 3 -1 roll .forceput
+ EPSBoundingBoxParse
{
//systemdict /EPSCrop known {
EPSBoundingBoxCrop
} {
- //systemdict /EPSFitPage known {
- EPSBoundingBoxFitPage
- } {
+ //systemdict /EPSFitPage known not {
% Warn if some of the EPS file will be clipped
clippath pathbbox newpath
{ % context for exit
@@ -124,10 +142,17 @@
flush
1 add
} if
+ } {
+ pop pop pop pop
} ifelse
} ifelse
EPSBoundingBoxSetState
} {
+ % improperly formed BoundingBox string.
+ QUIET not {
+ (\n **** Warning: BoundingBox values are invalid and will be ignored: ') print
+ EPSBoundBoxString print (') = flush
+ } if
pop % state
} ifelse
} {
@@ -135,6 +160,25 @@
} ifelse
} bind executeonly odef
+% Perform anchorsearch on the strings in the array until a match is found.
+/anchorsearchforany { % haystack [needle1 ...] --> post needle true
+ % --> haystack false
+ false 3 1 roll % false haystack [...]
+ { % false haystack needle
+ dup 3 1 roll % false needle haystack needle
+ anchorsearch {
+ % false needle post needle
+ pop % false needle post
+ 3 1 roll % post false needle
+ exch not exch % post true needle
+ exit
+ } {
+ % false needle haystack
+ exch pop % false haystack
+ } ifelse
+ } forall
+ exch % haystack false | post needle true
+} bind def
/ProcessEPSComment { % file comment -- file comment
/EPSBoundingBoxState .systemvar 3 lt {
@@ -188,12 +232,23 @@
} ifelse
} ifelse
} {
- (%%EndComments) anchorsearch {
- pop pop
+ {(%%EndComments) (%%BeginProlog) (%%BeginSetup)} anchorsearchforany {
+ EPSDEBUG { (EPSComment processing finished, encountered: ) print dup = } if
+ pop pop % discard the strings from the anchorsearch
+ % We may have seen BoundingBox or HiResBounfingBox. If so and if EPSFitPage
+ % is set, then we do the transformation here to scale and center the page,
+ % rotating if needed (and AllowFitPageRotation is true -- the default.)
+ //systemdict /EPSFitPage known
+ //systemdict /EPSBoundingBoxState get 0 gt
+ and {
+ EPSBoundingBoxString EPSBoundingBoxParse {
+ EPSBoundingBoxFitPage
+ } if
+ } if
% Ignore any following comments
5 EPSBoundingBoxSetState
} {
- pop
+ pop % Not %%EndComments -- ignore it
} ifelse
} ifelse
} if
@@ -310,6 +365,7 @@ end
/.runnoepsf
/.runEPS
/EPSBoundingBoxSetState
+ /EPSBoundingBoxString
/EPSBoundingBoxCrop
/EPSBoundingBoxFitPage
/EPSBoundingBoxParse