Skip to content

Commit a5f0152

Browse files
committed
Composite: Switch to usematrix and remove old multi-render path
1 parent cd23e6f commit a5f0152

17 files changed

Lines changed: 963 additions & 1181 deletions

src/databarexpandedcomposite.ps.src

Lines changed: 57 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
% --DESC: GS1 DataBar Expanded Composite
3737
% --EXAM: (01)09521234543213(3103)001234|(91)1A2B3C4D5E
3838
% --EXOP:
39-
% --RNDR: renlinear renmatrix
39+
% --RNDR: renmatrix
4040
% --FMLY: GS1 Composite Symbols
4141
currentglobal
4242
true setglobal
@@ -47,7 +47,6 @@ dup /processoptions dup /uk.co.terryburton.bwipp findresource put
4747
dup /databarexpanded dup /uk.co.terryburton.bwipp findresource put
4848
dup /gs1-cc dup /uk.co.terryburton.bwipp findresource put
4949
dup /gs1process dup /uk.co.terryburton.bwipp findresource put
50-
dup /renlinear dup /uk.co.terryburton.bwipp findresource put
5150
dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
5251
begin
5352
/databarexpandedcomposite {
@@ -56,7 +55,6 @@ begin
5655
{
5756

5857
/dontdraw false def
59-
/usematrix false def
6058
/parse false def
6159
/dontlint false def
6260
/lintreqs true def
@@ -69,8 +67,6 @@ begin
6967
/uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not
7068
def
7169

72-
_render not { /usematrix true def } if
73-
7470
%
7571
% Split the linear and composite parts
7672
%
@@ -102,7 +98,7 @@ begin
10298
linear options //databarexpanded exec
10399
dup (sbs) get /linsbs exch def
104100
dup (bhs) get 0 get 72 mul /linheight exch def
105-
usematrix not { //renlinear exec } { /linsym exch def } ifelse
101+
/linsym exch def
106102

107103
%
108104
% Plot the separator
@@ -134,86 +130,65 @@ begin
134130
69 98 bot length 13 sub {} for
135131
] {sepfinder} forall
136132

137-
usematrix not {
133+
comp options //gs1-cc exec /compsym exch def
134+
/ccpixs compsym /pixs get def
135+
/ccpixx compsym /pixx get def
138136

139-
currentpoint
137+
/linpixs [ 0 % Begin with left guard space
138+
linsbs { cvi 1 index 0 eq {{1}} {{0}} ifelse repeat } forall % Alternates i 1/0's
139+
] def
140+
/sep [ 0 sep aload pop ] def % Offset by 1
140141

141-
%
142-
% Plot the 2D part
143-
%
144-
1 linheight 1 add rmoveto comp options //gs1-cc exec //renmatrix exec
142+
/linheight linheight cvi def
143+
/diff linpixs length ccpixx sub def % Minimum linpixs length is 102, ccpixx is 99
144+
/ccrpad [ diff 2 sub {0} repeat ] def
145+
/pixs [
146+
0 ccpixx ccpixs length 1 sub {
147+
/i exch def
148+
0 0 ccpixs i ccpixx getinterval aload pop ccrpad aload pop
149+
} for
150+
sep aload pop linheight { linpixs aload pop } repeat
151+
] def
145152

146-
linheight add moveto <<
147-
/ren /renmatrix
148-
/pixs sep
149-
/pixx sep length
150-
/pixy 1
151-
/height 1 72 div
152-
/width sep length 72 div
153-
/opt options
154-
>> //renmatrix exec
153+
/pixx linpixs length def
155154

156-
} {
157-
comp options //gs1-cc exec /compsym exch def
158-
/ccpixs compsym /pixs get def
159-
/ccpixx compsym /pixx get def
160-
161-
/linpixs [ 0 % Begin with left guard space
162-
linsbs { cvi 1 index 0 eq {{1}} {{0}} ifelse repeat } forall % Alternates i 1/0's
163-
] def
164-
/sep [ 0 sep aload pop ] def % Offset by 1
165-
166-
/linheight linheight cvi def
167-
/diff linpixs length ccpixx sub def % Minimum linpixs length is 102, ccpixx is 99
168-
/ccrpad [ diff 2 sub {0} repeat ] def
169-
/pixs [
170-
0 ccpixx ccpixs length 1 sub {
171-
/i exch def
172-
0 0 ccpixs i ccpixx getinterval aload pop ccrpad aload pop
173-
} for
174-
sep aload pop linheight { linpixs aload pop } repeat
175-
] def
176-
177-
/pixx linpixs length def
178-
179-
/txt [
180-
linsym /txt 2 copy known { get {
181-
aload pop 4 -1 roll pixx linpixs length sub 1 add add 4 1 roll 5 array astore
182-
} forall } { pop pop } ifelse
183-
] def
184-
185-
/pixy pixs length pixx idiv def
186-
187-
/borderleft
188-
linsym /borderleft 2 copy known { get } { pop pop 10 } ifelse pixx linpixs length sub 1 add sub
189-
1 2 sub % CC QZ; left inset 2
190-
2 copy lt { exch } if pop dup 0 lt { pop 0 } if
191-
def
192-
/borderright
193-
linsym /borderright 2 copy known { get } { pop pop 10 } ifelse % right inset 0
194-
1 ccrpad length sub % CC QZ; right inset ccrpad
195-
2 copy lt { exch } if pop dup 0 lt { pop 0 } if
196-
def
197-
/bordertop 1 def
198-
/borderbottom linsym /borderbottom 2 copy known { get } { pop pop 0 } ifelse def
199-
200-
<<
201-
/ren /renmatrix
202-
/pixs pixs
203-
/pixx pixx
204-
/pixy pixy
205-
/height pixy 72 div
206-
/width pixx 72 div
207-
/borderleft borderleft
208-
/borderright borderright
209-
/bordertop bordertop
210-
/borderbottom borderbottom
211-
/txt txt
212-
/opt options
213-
>>
214-
215-
_render //renmatrix if
216-
} ifelse
155+
/txt [
156+
linsym /txt 2 copy known { get {
157+
aload pop 4 -1 roll pixx linpixs length sub 1 add add 4 1 roll 5 array astore
158+
} forall } { pop pop } ifelse
159+
] def
160+
161+
/pixy pixs length pixx idiv def
162+
163+
/borderleft
164+
linsym /borderleft 2 copy known { get } { pop pop 10 } ifelse pixx linpixs length sub 1 add sub
165+
1 2 sub % CC QZ; left inset 2
166+
2 copy lt { exch } if pop dup 0 lt { pop 0 } if
167+
def
168+
/borderright
169+
linsym /borderright 2 copy known { get } { pop pop 10 } ifelse % right inset 0
170+
1 ccrpad length sub % CC QZ; right inset ccrpad
171+
2 copy lt { exch } if pop dup 0 lt { pop 0 } if
172+
def
173+
/bordertop 1 def
174+
/borderbottom linsym /borderbottom 2 copy known { get } { pop pop 0 } ifelse def
175+
176+
<<
177+
/ren /renmatrix
178+
/pixs pixs
179+
/pixx pixx
180+
/pixy pixy
181+
/height pixy 72 div
182+
/width pixx 72 div
183+
/borderleft borderleft
184+
/borderright borderright
185+
/bordertop bordertop
186+
/borderbottom borderbottom
187+
/txt txt
188+
/opt options
189+
>>
190+
191+
_render //renmatrix if
217192

218193
} stopped {end stop} if
219194
end

src/databarexpandedstackedcomposite.ps.src

Lines changed: 55 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
% --DESC: GS1 DataBar Expanded Stacked Composite
3737
% --EXAM: (01)09521234543213(10)ABCDEF|(21)12345678
3838
% --EXOP: segments=4
39-
% --RNDR: renmatrix renlinear
39+
% --RNDR: renmatrix
4040
% --FMLY: GS1 Composite Symbols
4141
currentglobal
4242
true setglobal
@@ -58,7 +58,6 @@ begin
5858
{
5959

6060
/dontdraw false def
61-
/usematrix false def
6261
/parse false def
6362
/dontlint false def
6463
/lintreqs true def
@@ -71,8 +70,6 @@ begin
7170
/uk.co.terryburton.bwipp._dontdraw dup where {exch get} {pop false} ifelse or not
7271
def
7372

74-
_render not { /usematrix true def } if
75-
7673
%
7774
% Split the linear and composite parts
7875
%
@@ -104,7 +101,8 @@ begin
104101
linear options //databarexpandedstacked exec
105102
dup (pixs) get 0 2 index (pixx) get getinterval /bot exch def
106103
dup (pixy) get /linheight exch def
107-
usematrix not { //renmatrix exec } { /pixs get /linpixs exch def } ifelse
104+
/linsym exch def
105+
/linpixs linsym /pixs get def
108106

109107
%
110108
% Plot the separator
@@ -133,55 +131,59 @@ begin
133131
70 98 bot length 13 sub {} for
134132
] {sepfinder} forall
135133

136-
usematrix not {
137-
138-
currentpoint
139-
140-
%
141-
% Plot the 2D part
142-
%
143-
bot 0 get 0 eq {2} {0} ifelse linheight 1 add rmoveto
144-
comp options //gs1-cc exec //renmatrix exec
134+
comp options //gs1-cc exec /compsym exch def
135+
/ccpixs compsym /pixs get def
136+
/ccpixx compsym /pixx get def
145137

146-
linheight add moveto <<
147-
/ren /renmatrix
148-
/pixs sep
149-
/pixx sep length
150-
/pixy 1
151-
/height 1 72 div
152-
/width sep length 72 div
153-
/opt options
154-
>> //renmatrix exec
155-
156-
} {
157-
comp options //gs1-cc exec /compsym exch def
158-
/ccpixs compsym /pixs get def
159-
/ccpixx compsym /pixx get def
160-
161-
/pixx sep length def
162-
/cclpad [ pixx ccpixx sub 1 add 2 idiv {0} repeat ] def % Add 1 to allow for odd difference
163-
/ccrpad [ pixx ccpixx sub 2 idiv {0} repeat ] def
164-
/pixs [
165-
0 ccpixx ccpixs length 1 sub { % Centre align composite
166-
/i exch def
167-
cclpad aload pop ccpixs i ccpixx getinterval aload pop ccrpad aload pop
168-
} for
169-
sep aload pop linpixs aload pop
170-
] def
171-
172-
/pixy pixs length pixx idiv def
173-
<<
174-
/ren /renmatrix
175-
/pixs pixs
176-
/pixx pixx
177-
/pixy pixy
178-
/height pixy 72 div
179-
/width pixx 72 div
180-
/opt options
181-
>>
182-
183-
_render //renmatrix if
184-
} ifelse
138+
/pixx sep length def
139+
/cclpad [ pixx ccpixx sub 1 add 2 idiv {0} repeat ] def % Add 1 to allow for odd difference
140+
/ccrpad [ pixx ccpixx sub 2 idiv {0} repeat ] def
141+
/pixs [
142+
0 ccpixx ccpixs length 1 sub { % Centre align composite
143+
/i exch def
144+
cclpad aload pop ccpixs i ccpixx getinterval aload pop ccrpad aload pop
145+
} for
146+
sep aload pop linpixs aload pop
147+
] def
148+
149+
/txt [
150+
linsym /txt 2 copy known { get {
151+
aload pop 5 array astore % No x offset needed; linear at column 0
152+
} forall } { pop pop } ifelse
153+
] def
154+
155+
/pixy pixs length pixx idiv def
156+
157+
% Quiet zone borders: T=2D, L/R=max(1D,2D), B=1D
158+
/borderleft
159+
linsym /borderleft 2 copy known { get } { pop pop 0 } ifelse % linear left inset 0
160+
1 cclpad length sub % CC QZ; left inset cclpad
161+
2 copy lt { exch } if pop dup 0 lt { pop 0 } if
162+
def
163+
/borderright
164+
linsym /borderright 2 copy known { get } { pop pop 0 } ifelse % linear right inset 0
165+
1 ccrpad length sub % CC QZ; right inset ccrpad
166+
2 copy lt { exch } if pop dup 0 lt { pop 0 } if
167+
def
168+
/bordertop 1 def
169+
/borderbottom linsym /borderbottom 2 copy known { get } { pop pop 0 } ifelse def
170+
171+
<<
172+
/ren /renmatrix
173+
/pixs pixs
174+
/pixx pixx
175+
/pixy pixy
176+
/height pixy 72 div
177+
/width pixx 72 div
178+
/borderleft borderleft
179+
/borderright borderright
180+
/bordertop bordertop
181+
/borderbottom borderbottom
182+
/txt txt
183+
/opt options
184+
>>
185+
186+
_render //renmatrix if
185187

186188
} stopped {end stop} if
187189
end

0 commit comments

Comments
 (0)