Skip to content

Commit 5d8b2b8

Browse files
committed
guarddescent for EAN/UPC; guards now descend so height is for nominal bars
1 parent 88f6ef5 commit 5d8b2b8

18 files changed

+114
-47
lines changed

CHANGES

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2026-04-09
2+
3+
* A guarddescent option was added to specify the descent of EAN/UPC guard bars in multiples of the X-dimension.
4+
* EAN/UPC guards now correctly descend below the baseline so that height relates to the nominal bars.
5+
6+
17
2026-04-08
28

39
* Under propspec, the height option now acts as a multiplier on the spec-derived bar height.

src/ean13.ps.src

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ begin
7171
/text1font /Helvetica def
7272
/text1size 12.0 def
7373
/text1xoffset -7.75 def
74-
/text1yoffset -.25 def
74+
/text1yoffset -5.25 def
7575
/height -1.0 def
76+
/guarddescent 5 def
7677
/width 0 def
7778
/addongap 12.0 def
7879
/addontextfont (unset) def
@@ -134,6 +135,8 @@ begin
134135
/ean13 ast /apply_ast //render exec not { //raiseerror exec } if
135136
/resolve_strictspec //render exec
136137

138+
/descent guarddescent modunit mul 72 div def % Guard bar descent
139+
137140
%
138141
% Add checksum digit
139142
%
@@ -227,15 +230,15 @@ begin
227230
/height /resolve_height //render exec dup -1 eq { pop 1.0 } if def
228231

229232
includetext {
230-
/descent 5 modunit mul 72 div def % Guard bar descent: 5X
231-
/bhs [height height 12{height descent sub}repeat height height 12{height descent sub}repeat height height] def
232-
/bbs [0 0 12{descent}repeat 0 0 12{descent}repeat 0 0] def
233+
/guardheight height descent add def
234+
/bhs [guardheight guardheight 12{height}repeat guardheight guardheight 12{height}repeat guardheight guardheight] def
235+
/bbs [descent neg descent neg 12{0}repeat descent neg descent neg 12{0}repeat descent neg descent neg] def
233236
} {
234237
/bhs [30{height}repeat] def
235238
/bbs [30{0}repeat] def
236239
/txt [] def
237240
} ifelse
238-
/guardrightypos 0.0 def
241+
/guardrightypos -5.0 def
239242

240243
%
241244
% Append the addon
@@ -244,6 +247,7 @@ begin
244247
/addopts <<
245248
/includetext true
246249
/height height includetext { 0.15 sub } if
250+
/guarddescent guarddescent
247251
/text1xoffset addontextxoffset null ne {addontextxoffset} {98.25 addongap add} ifelse
248252
addontextyoffset null ne {/text1yoffset addontextyoffset} if
249253
/text1size addontextsize null ne {addontextsize} {text1size} ifelse
@@ -273,7 +277,7 @@ begin
273277
/borderleft 11.0
274278
/borderright addon () eq {7.0} {5.0} ifelse
275279
/bordertop 0.0
276-
/borderbottom 5.0
280+
/borderbottom 5.0 guarddescent modunit mul add
277281
/strictspec strictspec
278282
/loosespec loosespec
279283
/xdim xdim

src/ean13composite.ps.src

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ begin
187187

188188
% Main symbol bars extend to full height connecting to separator; add-on bars keep their height
189189
/linheight 0 bhsrow { ceiling cvi 2 copy lt { exch } if pop } forall def
190+
/lindescent 0 bbsrow { floor cvi 2 copy gt { exch } if pop } forall def
191+
txt { dup 2 get lindescent neg add 2 exch put } forall
190192
/mainbars nbars def
191193
0 1 sbs length 1 sub {
192194
dup sbs exch get type /realtype eq { 1 add 2 idiv /mainbars exch def exit } { pop } ifelse
@@ -197,7 +199,7 @@ begin
197199
/rowbuf pixx string def
198200
/prevrow () def /linrowmult 72 array def /lri 0 def
199201
/linpixs [
200-
linheight 1 sub -1 0 {
202+
linheight 1 sub -1 lindescent {
201203
/y exch def
202204
/p 0 def
203205
linpad { rowbuf p 3 -1 roll put /p p 1 add def } forall
@@ -246,13 +248,13 @@ begin
246248
2 copy lt { exch } if pop dup 0 lt { pop 0 } if
247249
def
248250
/bordertop 1 def
249-
/borderbottom linsym /borderbottom 2 copy known { get } { pop pop 0 } ifelse def
251+
/borderbottom linsym /borderbottom 2 copy known { get } { pop pop 0 } ifelse lindescent add def
250252

251253
% Guard positions adjusted for linear offset within matrix
252254
/guardleftpos linsym /guardleftpos 2 copy known { get linpad length 1 add sub } { pop pop 0 } ifelse def
253-
/guardleftypos linsym /guardleftypos 2 copy known { get } { pop pop 0 } ifelse def
255+
/guardleftypos linsym /guardleftypos 2 copy known { get lindescent neg add } { pop pop 0 } ifelse def
254256
/guardrightpos linsym /guardrightpos 2 copy known { get linpad length 1 add linwidth add pixx sub add } { pop pop 0 } ifelse def
255-
/guardrightypos linsym /guardrightypos 2 copy known { get } { pop pop 0 } ifelse def
257+
/guardrightypos linsym /guardrightypos 2 copy known { get lindescent neg add } { pop pop 0 } ifelse def
256258

257259
% Height is already applied to the linear bars via bhs; don't let renmatrix rescale
258260
options /height undef

src/ean2.ps.src

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ begin
6969
/text1xoffset 3.25 def
7070
/text1yoffset null def % sentinel realtype
7171
/height -1.0 def
72+
/guarddescent 5 def
7273
/width 0 def
7374

7475
/propspec false def
@@ -112,6 +113,8 @@ begin
112113

113114
/height /resolve_height //render exec dup -1 eq { pop 0.7 } if def
114115

116+
/descent guarddescent modunit mul 72 div def % Guard bar descent
117+
115118
text1yoffset null eq {
116119
/text1yoffset height 72 mul 5.75 add def
117120
} if
@@ -158,8 +161,8 @@ begin
158161
<<
159162
/ren /renlinear
160163
/sbs [sbs {48 sub} forall]
161-
/bhs [12{height}repeat]
162-
/bbs [12{0}repeat]
164+
/bhs [12{height descent add}repeat]
165+
/bbs [12{descent neg}repeat]
163166
includetext {
164167
/txt txt
165168
} if

src/ean5.ps.src

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ begin
7272
/text1xoffset 3.25 def
7373
/text1yoffset null def % realtype sentinel
7474
/height -1.0 def
75+
/guarddescent 5 def
7576
/width 0 def
7677

7778
/propspec false def
@@ -115,6 +116,8 @@ begin
115116

116117
/height /resolve_height //render exec dup -1 eq { pop 0.7 } if def
117118

119+
/descent guarddescent modunit mul 72 div def % Guard bar descent
120+
118121
text1yoffset null eq {
119122
/text1yoffset height 72 mul 5.75 add def
120123
} if
@@ -172,8 +175,8 @@ begin
172175
<<
173176
/ren /renlinear
174177
/sbs [sbs {48 sub} forall]
175-
/bhs [16 {height} repeat]
176-
/bbs [16 {0} repeat]
178+
/bhs [16 {height descent add} repeat]
179+
/bbs [16 {descent neg} repeat]
177180
includetext {
178181
/txt txt
179182
} if

src/ean8.ps.src

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ begin
6868
/text1font /Helvetica def
6969
/text1size 12.0 def
7070
/text1xoffset 7.25 def
71-
/text1yoffset -0.25 def
71+
/text1yoffset -5.25 def
7272
/height -1.0 def
73+
/guarddescent 5 def
7374
/width 0 def
7475

7576
/propspec false def
@@ -136,6 +137,8 @@ begin
136137
/ean8 ast /apply_ast //render exec not { //raiseerror exec } if
137138
/resolve_strictspec //render exec
138139

140+
/descent guarddescent modunit mul 72 div def % Guard bar descent
141+
139142
%
140143
% Add checksum digit
141144
%
@@ -211,15 +214,15 @@ begin
211214
/height /resolve_height //render exec dup -1 eq { pop 1.0 } if def
212215

213216
includetext {
214-
/descent 5 modunit mul 72 div def % Guard bar descent: 5X
215-
/bhs [height height 8{height descent sub}repeat height height 8{height descent sub}repeat height height] def
216-
/bbs [0 0 8{descent}repeat 0 0 8{descent}repeat 0 0] def
217+
/guardheight height descent add def
218+
/bhs [guardheight guardheight 8{height}repeat guardheight guardheight 8{height}repeat guardheight guardheight] def
219+
/bbs [descent neg descent neg 8{0}repeat descent neg descent neg 8{0}repeat descent neg descent neg] def
217220
} {
218221
/bhs [22{height}repeat] def
219222
/bbs [22{0}repeat] def
220223
/txt [] def
221224
} ifelse
222-
/guardrightypos 0.0 def
225+
/guardrightypos -5.0 def
223226

224227
%
225228
% Append the addon
@@ -228,6 +231,7 @@ begin
228231
/addopts <<
229232
/includetext true
230233
/height height includetext { 0.15 sub } if
234+
/guarddescent guarddescent
231235
/text1xoffset addontextxoffset null ne {addontextxoffset} {70.25 addongap add} ifelse
232236
addontextyoffset null ne {/text1yoffset addontextyoffset} if
233237
/text1size addontextsize null ne {addontextsize} {text1size} ifelse
@@ -253,12 +257,13 @@ begin
253257
/txt txt
254258
/opt options
255259
/guardleftpos 7.0
260+
/guardleftypos -5.0
256261
/guardrightpos addon () eq {7.0} {5.0} ifelse
257262
/guardrightypos guardrightypos
258263
/borderleft 7.0
259264
/borderright addon () eq {7.0} {5.0} ifelse
260265
/bordertop 0.0
261-
/borderbottom 5.0
266+
/borderbottom 5.0 guarddescent modunit mul add
262267
/strictspec strictspec
263268
/loosespec loosespec
264269
/xdim xdim

src/ean8composite.ps.src

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ begin
183183

184184
% Main symbol bars extend to full height connecting to separator; add-on bars keep their height
185185
/linheight 0 bhsrow { ceiling cvi 2 copy lt { exch } if pop } forall def
186+
/lindescent 0 bbsrow { floor cvi 2 copy gt { exch } if pop } forall def
187+
txt { dup 2 get lindescent neg add 2 exch put } forall
186188
/mainbars nbars def
187189
0 1 sbs length 1 sub {
188190
dup sbs exch get type /realtype eq { 1 add 2 idiv /mainbars exch def exit } { pop } ifelse
@@ -193,7 +195,7 @@ begin
193195
/rowbuf pixx string def
194196
/prevrow () def /linrowmult 72 array def /lri 0 def
195197
/linpixs [
196-
linheight 1 sub -1 0 {
198+
linheight 1 sub -1 lindescent {
197199
/y exch def
198200
/p 0 def
199201
linpad { rowbuf p 3 -1 roll put /p p 1 add def } forall
@@ -242,13 +244,13 @@ begin
242244
2 copy lt { exch } if pop dup 0 lt { pop 0 } if
243245
def
244246
/bordertop 1 def
245-
/borderbottom linsym /borderbottom 2 copy known { get } { pop pop 0 } ifelse def
247+
/borderbottom linsym /borderbottom 2 copy known { get } { pop pop 0 } ifelse lindescent add def
246248

247249
% Guard positions adjusted for linear offset within matrix
248250
/guardleftpos linsym /guardleftpos 2 copy known { get linpad length 1 add sub } { pop pop 0 } ifelse def
249-
/guardleftypos linsym /guardleftypos 2 copy known { get } { pop pop 0 } ifelse def
251+
/guardleftypos linsym /guardleftypos 2 copy known { get lindescent neg add } { pop pop 0 } ifelse def
250252
/guardrightpos linsym /guardrightpos 2 copy known { get linpad length 1 add linwidth add pixx sub add } { pop pop 0 } ifelse def
251-
/guardrightypos linsym /guardrightypos 2 copy known { get } { pop pop 0 } ifelse def
253+
/guardrightypos linsym /guardrightypos 2 copy known { get lindescent neg add } { pop pop 0 } ifelse def
252254

253255
% Height is already applied to the linear bars via bhs; don't let renmatrix rescale
254256
options /height undef

src/isbn.ps.src

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ begin
310310
/isbntextxoffset isbn length 9 eq {-1.0} {-12.0} ifelse def
311311
} if
312312
isbntextyoffset null eq {
313-
/isbntextyoffset args (bhs) get 0 get 72 mul 3 add def
313+
/isbntextyoffset args (bhs) get 2 get 72 mul 3 add def
314314
} if
315315
args (txt) known {
316316
/txt args (txt) get def

src/ismn.ps.src

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ begin
289289
/ismntextxoffset ismntxt length 18 eq {-1.0} {-12.0} ifelse def
290290
} if
291291
ismntextyoffset null eq {
292-
/ismntextyoffset args (bhs) get 0 get 72 mul 3 add def
292+
/ismntextyoffset args (bhs) get 2 get 72 mul 3 add def
293293
} if
294294
args (txt) known {
295295
/txt args (txt) get def

src/issn.ps.src

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ begin
233233
%
234234
includetext {
235235
issntextxoffset null eq {/issntextxoffset 10.0 def} if
236-
issntextyoffset null eq {/issntextyoffset args (bhs) get 0 get 72 mul 3 add def} if
236+
issntextyoffset null eq {/issntextyoffset args (bhs) get 2 get 72 mul 3 add def} if
237237
args (txt) known {
238238
/txt args (txt) get def
239239
/newtxt txt length 1 add array def

0 commit comments

Comments
 (0)