Skip to content

Commit 9f028b7

Browse files
committed
Various: Comments
1 parent 4e1791d commit 9f028b7

File tree

3 files changed

+54
-11
lines changed

3 files changed

+54
-11
lines changed

src/hibccode128.ps.src

Lines changed: 9 additions & 6 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
%
@@ -45,10 +45,8 @@ dup /renlinear dup /uk.co.terryburton.bwipp findresource put
4545
dup /code128 dup /uk.co.terryburton.bwipp findresource put
4646
begin
4747

48-
% Module-level definitions for hibccode128
4948
/hibccode128.barchars (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%) readonly def
5049

51-
% Lazy initialization of lookup dictionaries
5250
/hibccode128.latevars dup 1 dict def load /init {
5351

5452
currentglobal
@@ -74,11 +72,10 @@ begin
7472

7573
/hibccode128 {
7674

77-
//hibccode128.latevars /init get exec
78-
79-
20 dict begin % Confine variables to local scope
75+
20 dict begin
8076

8177
/ctx null def
78+
8279
/dontdraw false def
8380
/textfont /Courier def
8481
/textsize 10.0 def
@@ -89,11 +86,15 @@ begin
8986
//processoptions exec /options exch def
9087
/barcode exch def
9188

89+
//hibccode128.latevars /init get exec
90+
9291
barcode () eq {
9392
/bwipp.hibccode128emptyData (The data must not be empty) //raiseerror exec
9493
} if
9594

95+
%
9696
% Validate the input
97+
%
9798
0 1 barcode length 1 sub {
9899
barcode exch 1 getinterval charvals exch known not {
99100
/bwipp.hibccode128badCharacter (HIBC Code 128 must contain only digits, capital letters, spaces and the symbols -.$/+%) //raiseerror exec
@@ -125,7 +126,9 @@ begin
125126
text barlen 2 add barcode barlen 1 add get dup 32 eq {pop 95} if put
126127
text barlen 3 add 42 put
127128

129+
%
128130
% Get the result of encoding with code128
131+
%
129132
options (dontdraw) true put
130133
options (validatecheck) false put
131134
/args barcode options //code128 exec def

src/renlinear.ps.src

Lines changed: 20 additions & 3 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
%
@@ -54,9 +54,11 @@ begin
5454

5555
/renlinear {
5656

57-
20 dict begin % Confine variables to local scope
57+
20 dict begin
5858

59+
%
5960
% Default options
61+
%
6062
/sbs [] def
6163
/bhs [] def
6264
/bbs [] def
@@ -120,8 +122,9 @@ begin
120122
bordercolor (unset) eq { ctx /default_bordercolor 2 copy known {get /bordercolor exch def} {pop pop} ifelse } if
121123
} { pop } ifelse
122124

125+
%
123126
% Input validation
124-
127+
%
125128
textxalign (unset) ne {
126129
//renlinear.xalignopts textxalign known not {
127130
/bwipp.renlinearBadTextxalign (textxalign must be offleft, left, center, right or offright) //raiseerror exec
@@ -158,7 +161,9 @@ begin
158161
/bwipp.renlinearBadTextsize (extratextsize must be greater than zero and less that 25) //raiseerror exec
159162
} if
160163

164+
%
161165
% Create bar elements and put them into the bars array
166+
%
162167
/bars sbs length 1 add 2 idiv array def
163168
/pixx 0 def /pixy 0 def
164169
0 1 sbs length 1 add 2 idiv 2 mul 2 sub {
@@ -185,12 +190,16 @@ begin
185190

186191
currentpoint translate
187192

193+
%
188194
% Force symbol to given width
195+
%
189196
width 0 ne {
190197
width 72 mul pixx div 1 scale
191198
} if
192199

200+
%
193201
% Set RGB or CMYK color, or some other color by name
202+
%
194203
/setanycolor {
195204
/anycolor exch def
196205
anycolor length 1 lt {
@@ -228,7 +237,9 @@ begin
228237
} if
229238
} def
230239

240+
%
231241
% Display the border and background
242+
%
232243
showborder showbearer or {
233244
/tl [ borderleft borderwidth 2 div add neg pixy bordertop add borderwidth 2 div add ] def
234245
/tr [ pixx borderright add borderwidth 2 div add pixy bordertop add borderwidth 2 div add ] def
@@ -263,7 +274,9 @@ begin
263274
grestore
264275
} if } ifelse
265276

277+
%
266278
% Display the bars for elements in the bars array
279+
%
267280
gsave
268281
barcolor (unset) ne { barcolor setanycolor } if
269282
newpath
@@ -283,10 +296,14 @@ begin
283296
fill
284297
grestore
285298

299+
%
286300
% Display the text
301+
%
287302
//rendertext exec
288303

304+
%
289305
% Display the guard elements
306+
%
290307
guardwhitespace {
291308
0.75 setlinewidth
292309
guardleftpos 0 ne {

src/renmatrix.ps.src

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,9 @@ begin
116116
bordercolor (unset) eq { ctx /default_bordercolor 2 copy known {get /bordercolor exch def} {pop pop} ifelse } if
117117
} { pop } ifelse
118118

119+
%
119120
% Input validation
120-
121+
%
121122
textxalign (unset) ne {
122123
//renmatrix.xalignopts textxalign known not {
123124
/bwipp.renmatrixBadTextxalign (textxalign must be offleft, left, center, right or offright) //raiseerror exec
@@ -178,8 +179,10 @@ begin
178179
/left {dir 4 ne {x y dir cput [x y]} if /x x 1 sub def /dir 4 def} def
179180
/up {dir 8 ne {x y dir cput [x y]} if /y y 1 sub def /dir 8 def} def
180181

182+
%
183+
% Walk the outline of a region emitting edge coordinates of the path
184+
%
181185
/trace {
182-
% Walk the outline of a region emitting edge coordinates of the path
183186
/y exch def /x exch def
184187
% dir 1:right 2:down 4:left 8:up
185188
/dir x 1 add y 1 add xyget 1 eq {8} {4} ifelse def
@@ -206,7 +209,9 @@ begin
206209

207210
} def
208211

212+
%
209213
% Set RGB or CMYK color, or some other color by name
214+
%
210215
/setanycolor {
211216
/anycolor exch def
212217
anycolor length 1 lt {
@@ -244,7 +249,9 @@ begin
244249
} if
245250
} def
246251

252+
%
247253
% Plot a layer of single colour
254+
%
248255
/drawlayer {
249256

250257
/pixsorig pixs def
@@ -263,10 +270,14 @@ begin
263270
/pixx pixx 2 add def
264271
/pixy pixy 2 add def
265272

273+
%
266274
% Cache of visited corners for each direction
275+
%
267276
/cache [ pixs length {0} repeat ] def
268277

278+
%
269279
% Construct paths by tracing regions avoiding duplication by using the cache
280+
%
270281
/paths [
271282
0 1 pixy 2 sub {
272283
/j exch def
@@ -287,11 +298,15 @@ begin
287298
} for
288299
] def
289300

301+
%
290302
% Revert the bitmap size
303+
%
291304
/pixx pixx 2 sub def
292305
/pixy pixy 2 sub def
293306

307+
%
294308
% Draw the image
309+
%
295310
newpath
296311
paths {
297312
/p exch def
@@ -346,10 +361,14 @@ begin
346361
/inkspreadh inkspreadh 2 div def
347362
/inkspreadv inkspreadv 2 div def
348363

364+
%
349365
% Force symbol to given width
366+
%
350367
width pixx div 72 mul height pixy div 72 mul scale
351368

369+
%
352370
% Display the border and background
371+
%
353372
showborder {
354373
/tl [ borderleft borderwidth 2 div add neg pixy bordertop add borderwidth 2 div add ] def
355374
/tr [ pixx borderright add borderwidth 2 div add pixy bordertop add borderwidth 2 div add ] def
@@ -375,7 +394,9 @@ begin
375394
grestore
376395
} if
377396

397+
%
378398
% Display the matrix
399+
%
379400
colormap (unset) eq {
380401
/colormap << 1 barcolor >> def
381402
} if
@@ -388,7 +409,9 @@ begin
388409
] dotty {drawlayerdots} {drawlayer} ifelse
389410
} forall
390411

412+
%
391413
% Display the text
414+
%
392415
//rendertext exec
393416

394417
grestore

0 commit comments

Comments
 (0)