]> git.lizzy.rs Git - plan9front.git/blob - sys/lib/ghostscript/gs_fform.ps
update colemak kbmap, simpler version with scroll working (thanks jeremy)
[plan9front.git] / sys / lib / ghostscript / gs_fform.ps
1 %    Copyright (C) 1995, 1996, 1998, 1999 Aladdin Enterprises.  All rights reserved.
2
3 % This software is provided AS-IS with no warranty, either express or
4 % implied.
5
6 % This software is distributed under license and may not be copied,
7 % modified or distributed except as expressly authorized under the terms
8 % of the license contained in the file LICENSE in this distribution.
9
10 % For more information about licensing, please refer to
11 % http://www.ghostscript.com/licensing/. For information on
12 % commercial licensing, go to http://www.artifex.com/licensing/ or
13 % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14 % San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15
16 % $Id: gs_fform.ps,v 1.4 2002/02/21 21:49:28 giles Exp $
17 % Form caching implemented in PostScript.
18
19 % This implementation doesn't do the right thing about halftone or
20 % Pattern phase, but the Pattern cache doesn't either....
21
22 % The Form cache key is the Form dictionary; the value is an array
23 % of 2 elements [CTM pattern_instance].
24 %
25 % In order to prevent restore from clearing the cache, we explicitly
26 % push the cache entries on the stack before a restore and reinstall them.
27 currentglobal false setglobal
28 /.formcachedict 20 dict def     % must be local
29 true setglobal
30 /restore {
31   mark .formcachedict { } forall
32   counttomark 1 add index { //restore } .internalstopped
33     { cleartomark //restore }
34     { counttomark 2 idiv { .formcachedict 3 1 roll put } repeat pop pop }
35   ifelse
36 } bind odef
37
38 /.execform1 {
39   dup /Implementation known not {
40     dup /FormType get 1 ne { /rangecheck signalerror } if
41                 % The Implementation is a Pattern that will draw the form.
42     currentglobal 1 index gcheck setglobal
43                 % Stack: form global
44     10 dict begin
45       /PatternType 1 def
46       /PaintType 1 def  % colored
47       /TilingType 1 def % irrelevant
48                 % Copy the BBox to the correct VM.
49       /BBox 2 index /BBox get 4 array copy exch 1 index def
50                 % Set XStep and YStep to very large numbers,
51                 % so we won't get multiple copies of the form.
52       /XStep 1 index dup 2 get exch 0 get sub 100 mul def
53       /YStep exch dup 3 get exch 1 get sub 100 mul def
54       /PaintProc 2 index /PaintProc get def
55     currentdict end readonly
56                 % Stack: form global impl
57     exch setglobal
58     1 index /Implementation 3 -1 roll .forceput
59   } if
60   .formcachedict 1 index .knownget {
61                 % Check whether we can use the cached value.
62                 % Stack: form cachevalue
63     matrix currentmatrix true 0 1 3 {
64                 % Stack: form cachevalue curmat true index
65       3 index 0 get 1 index get exch 3 index exch get ne {
66         pop pop false exit
67       } if
68     } for exch pop
69   } {
70     false
71   } ifelse not
72   {             % Make a new cache entry.
73     gsave
74     matrix currentmatrix dup 4 0 put dup 5 0 put dup setmatrix
75                 % Stack: form mat
76     1 index /Implementation get
77     2 index /Matrix get
78     makepattern 2 array astore
79     .formcachedict 2 index 2 index put
80     grestore
81   } if
82                 % Stack: form cachevalue
83   -1 0 0 transform
84   2 { exch round cvi } repeat .setscreenphase
85   1 get setpattern
86   /BBox get aload pop
87   exch 3 index sub exch 2 index sub rectfill
88 } .bind odef    % must bind .forceput
89
90 .formtypes 1 /.execform1 load put
91
92 setglobal