Skip to content

Commit 111c759

Browse files
committed
renlinear: make zero-width sbs elements independent of barratio/spaceratio
1 parent c214589 commit 111c759

2 files changed

Lines changed: 46 additions & 2 deletions

File tree

src/renlinear.ps.src

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,10 @@ begin
150150
0 1 sbs length 1 add 2 idiv 2 mul 2 sub {
151151
/i exch def
152152
i 2 mod 0 eq { % i is even
153-
/d sbs i get barratio mul barratio sub 1 add def % d = digit*r-r+1
153+
/d sbs i get dup 0 eq
154+
{ pop 0 } % 0 is zero-width regardless of ratio
155+
{ barratio mul barratio sub 1 add } % d = digit*r-r+1
156+
ifelse def
154157
sbs i get 0 ne {
155158
/h bhs i 2 idiv get 72 mul def % Height from bhs
156159
/c d 2 div pixx add def % Centre of the bar = pixx + d/2
@@ -162,7 +165,10 @@ begin
162165
bars i 2 idiv -1 put % Dummy entry
163166
} ifelse
164167
} {
165-
/d sbs i get spaceratio mul spaceratio sub 1 add def % d = digit*r-r+1
168+
/d sbs i get dup 0 eq
169+
{ pop 0 } % 0 is zero-width regardless of ratio
170+
{ spaceratio mul spaceratio sub 1 add } % d = digit*r-r+1
171+
ifelse def
166172
} ifelse
167173
/pixx pixx d add def % pixx += d
168174
} for

tests/ps_tests/renlinear.ps.test

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,44 @@
175175
72 4.5 0 1
176176
] debugIsEqual
177177

178+
%
179+
% Zero-width bar is zero-width regardless of barratio (does not shift pixx)
180+
%
181+
{
182+
0 0 moveto
183+
<<
184+
/ren /renlinear
185+
/sbs [1 1 0 1 1]
186+
/bhs [1 1 1]
187+
/bbs [0 0 0]
188+
/inkspread 0
189+
/barratio 2
190+
/opt << /debugbars true >>
191+
>> renlinear
192+
} [
193+
72 0.5 0 1
194+
72 3.5 0 1
195+
] debugIsEqual
196+
197+
%
198+
% Zero-width space is zero-width regardless of spaceratio (does not shift pixx)
199+
%
200+
{
201+
0 0 moveto
202+
<<
203+
/ren /renlinear
204+
/sbs [1 0 1]
205+
/bhs [1 1]
206+
/bbs [0 0]
207+
/inkspread 0
208+
/spaceratio 2
209+
/opt << /debugbars true >>
210+
>> renlinear
211+
} [
212+
72 0.5 0 1
213+
72 1.5 0 1
214+
] debugIsEqual
215+
178216
%
179217
% DataBar Omnidirectional
180218
%

0 commit comments

Comments
 (0)