Skip to content

Commit 31cfbd0

Browse files
committed
kix: Uplift
1 parent 5217fc2 commit 31cfbd0

1 file changed

Lines changed: 44 additions & 29 deletions

File tree

src/kix.ps.src

Lines changed: 44 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
% Barcode Writer in Pure PostScript
22
% https://bwipp.terryburton.co.uk
33
%
4-
% Copyright (c) 2004-2024 Terry Burton
4+
% Copyright (c) 2004-2025 Terry Burton
55
%
66
% $Id$
77
%
@@ -38,20 +38,53 @@
3838
currentglobal
3939
true setglobal
4040
/setpacking where {pop currentpacking true setpacking} if
41-
10 dict
42-
dup /loadctx dup /uk.co.terryburton.bwipp findresource put
43-
dup /unloadctx dup /uk.co.terryburton.bwipp findresource put
41+
50 dict
4442
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
4543
dup /processoptions dup /uk.co.terryburton.bwipp findresource put
4644
dup /renlinear dup /uk.co.terryburton.bwipp findresource put
4745
begin
46+
47+
/kix.encs [
48+
(0033) (0123) (0132) (1023) (1032) (1122)
49+
(0213) (0303) (0312) (1203) (1212) (1302)
50+
(0231) (0321) (0330) (1221) (1230) (1320)
51+
(2013) (2103) (2112) (3003) (3012) (3102)
52+
(2031) (2121) (2130) (3021) (3030) (3120)
53+
(2211) (2301) (2310) (3201) (3210) (3300)
54+
] readonly def
55+
56+
/kix.barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ) readonly def
57+
58+
/kix.latevars dup 1 dict def load /init {
59+
60+
currentglobal
61+
true setglobal
62+
63+
//kix.latevars begin
64+
65+
/charvals 36 dict def
66+
0 1 35 {
67+
charvals exch dup //kix.barchars exch 1 getinterval exch put
68+
} for
69+
/charvals charvals readonly def
70+
71+
/init { //kix.latevars {def} forall } def
72+
73+
end
74+
75+
//kix.latevars /init get exec
76+
77+
setglobal
78+
79+
} bind put
80+
4881
/kix {
4982

83+
5084
20 dict begin
5185

52-
/ctx null def
5386
/dontdraw false def
54-
/includetext false def % Enable/disable text
87+
/includetext false def
5588
/textfont /Courier def
5689
/textsize 10.0 def
5790
/textyoffset -7.0 def
@@ -60,30 +93,15 @@ begin
6093
//processoptions exec /options exch def
6194
/barcode exch def
6295

96+
//kix.latevars /init get exec
97+
6398
barcode () eq {
6499
/bwipp.kixEmptyData (The data must not be empty) //raiseerror exec
65100
} if
66101

67-
/kix //loadctx exec
68-
69-
{
70-
% Create an array containing the character mappings
71-
/encs
72-
[ (0033) (0123) (0132) (1023) (1032) (1122)
73-
(0213) (0303) (0312) (1203) (1212) (1302)
74-
(0231) (0321) (0330) (1221) (1230) (1320)
75-
(2013) (2103) (2112) (3003) (3012) (3102)
76-
(2031) (2121) (2130) (3021) (3030) (3120)
77-
(2211) (2301) (2310) (3201) (3210) (3300)
78-
] def
79-
80-
% Create a string of the available characters
81-
/barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ) def
82-
/charvals 36 dict def
83-
0 1 35 {charvals exch dup barchars exch 1 getinterval exch put} for
84-
} ctxdef
85-
102+
%
86103
% Validate the input
104+
%
87105
0 1 barcode length 1 sub {
88106
barcode exch 1 getinterval charvals exch known not {
89107
/bwipp.kixBadCharacter (KIX must contain only capital letters and digits) //raiseerror exec
@@ -97,7 +115,7 @@ begin
97115
0 1 barlen 1 sub {
98116
/i exch def
99117
/indx charvals barcode i 1 getinterval get def
100-
encstr i 4 mul encs indx get putinterval
118+
encstr i 4 mul //kix.encs indx get putinterval
101119
txt i [barcode i 1 getinterval i 4 mul 3.312 mul textyoffset textfont textsize] put
102120
} for
103121

@@ -124,7 +142,6 @@ begin
124142
} if
125143
} for
126144

127-
% Return the arguments
128145
<<
129146
/ren /renlinear
130147
/bbs bbs
@@ -138,8 +155,6 @@ begin
138155

139156
dontdraw not //renlinear if
140157

141-
//unloadctx exec
142-
143158
end
144159

145160
}

0 commit comments

Comments
 (0)