-
-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathcode93ext.ps.src
145 lines (131 loc) · 5.08 KB
/
code93ext.ps.src
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
% Barcode Writer in Pure PostScript
% https://bwipp.terryburton.co.uk
%
% Copyright (c) 2004-2024 Terry Burton
%
% $Id$
%
% Permission is hereby granted, free of charge, to any
% person obtaining a copy of this software and associated
% documentation files (the "Software"), to deal in the
% Software without restriction, including without
% limitation the rights to use, copy, modify, merge,
% publish, distribute, sublicense, and/or sell copies of
% the Software, and to permit persons to whom the Software
% is furnished to do so, subject to the following
% conditions:
%
% The above copyright notice and this permission notice
% shall be included in all copies or substantial portions
% of the Software.
%
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
% KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
% THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
% PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
% THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
% DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
% CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
% CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
% IN THE SOFTWARE.
% --BEGIN ENCODER code93ext--
% --REQUIRES preamble loadctx unloadctx raiseerror processoptions parseinput renlinear code93--
% --DESC: Code 93 Extended
% --EXAM: Code93 Ext!
% --EXOP: includetext includecheck
% --RNDR: renlinear
/setpacking where {pop currentpacking true setpacking} if
10 dict
dup /loadctx dup /uk.co.terryburton.bwipp findresource put
dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
dup /processoptions dup /uk.co.terryburton.bwipp findresource put
dup /parseinput dup /uk.co.terryburton.bwipp findresource put
dup /renlinear dup /uk.co.terryburton.bwipp findresource put
dup /code93 dup /uk.co.terryburton.bwipp findresource put
begin
/code93ext {
20 dict begin
/ctx null def
/dontdraw false def
/includetext false def
/parse false def
//processoptions exec /options exch def
/barcode exch def
/code93ext //loadctx exec
% Parse ordinals of the form ^NNN to ASCII
/fncvals <<
/parse parse
/parseonly true
/parsefnc false
>> def
/barcode barcode fncvals //parseinput exec def
/barlen barcode length def
options (parse) undef
% Extended alphabet to non-extended alphabet
{
/extencs
[ (^SFT%U) (^SFT$A) (^SFT$B) (^SFT$C) (^SFT$D) (^SFT$E) (^SFT$F) (^SFT$G)
(^SFT$H) (^SFT$I) (^SFT$J) (^SFT$K) (^SFT$L) (^SFT$M) (^SFT$N) (^SFT$O)
(^SFT$P) (^SFT$Q) (^SFT$R) (^SFT$S) (^SFT$T) (^SFT$U) (^SFT$V) (^SFT$W)
(^SFT$X) (^SFT$Y) (^SFT$Z) (^SFT%A) (^SFT%B) (^SFT%C) (^SFT%D) (^SFT%E)
( ) (^SFT/A) (^SFT/B) (^SFT/C) ($) (%) (^SFT/F) (^SFT/G)
(^SFT/H) (^SFT/I) (^SFT/J) (+) (^SFT/L) (-) (.) (/)
(0) (1) (2) (3) (4) (5) (6) (7)
(8) (9) (^SFT/Z) (^SFT%F) (^SFT%G) (^SFT%H) (^SFT%I) (^SFT%J)
(^SFT%V) (A) (B) (C) (D) (E) (F) (G)
(H) (I) (J) (K) (L) (M) (N) (O)
(P) (Q) (R) (S) (T) (U) (V) (W)
(X) (Y) (Z) (^SFT%K) (^SFT%L) (^SFT%M) (^SFT%N) (^SFT%O)
(^SFT%W) (^SFT+A) (^SFT+B) (^SFT+C) (^SFT+D) (^SFT+E) (^SFT+F) (^SFT+G)
(^SFT+H) (^SFT+I) (^SFT+J) (^SFT+K) (^SFT+L) (^SFT+M) (^SFT+N) (^SFT+O)
(^SFT+P) (^SFT+Q) (^SFT+R) (^SFT+S) (^SFT+T) (^SFT+U) (^SFT+V) (^SFT+W)
(^SFT+X) (^SFT+Y) (^SFT+Z) (^SFT%P) (^SFT%Q) (^SFT%R) (^SFT%S) (^SFT%T)
] def
} ctxdef
/newcode barlen 6 mul string def
/newtext barlen 6 mul string def
/j 0 def /k 0 def
0 1 barlen 1 sub {
/i exch def
barcode i get
dup 127 gt {
pop /bwipp.code93extbadCharacter (Code 93 Extended only support ASCII characters with values 0 to 127) //raiseerror exec
} if
extencs exch get /extchar exch def
/extlen extchar length def
newcode j extchar putinterval
newtext k barcode i get dup dup 32 lt exch 127 eq or { pop 32 } if put
extlen 1 ne { newtext k 1 add 32 put } if
/j j extlen add def
/k k extlen 1 eq {1} {2} ifelse add def
} for
/newcode newcode 0 j getinterval def
/newtext newtext 0 k getinterval def
% Get the result of encoding with code93
options (dontdraw) true put
options (parsefnc) true put
/args newcode options //code93 exec def
% Replace chars in /txt with chars in newtext
includetext {
/txt args (txt) get def
0 1 newtext length 1 sub {
/i exch def
/txtentry txt i get def
txtentry 0 newtext i 1 getinterval put
txt i txtentry put
} for
args (txt) txt put
} if
args (opt) options put
args
dontdraw not //renlinear if
//unloadctx exec
end
}
[/barcode] {null def} forall
bind def
/code93ext dup load /uk.co.terryburton.bwipp defineresource pop
end
/setpacking where {pop setpacking} if
% --END ENCODER code93ext--