|
| 1 | +% Barcode Writer in Pure PostScript |
| 2 | +% https://bwipp.terryburton.co.uk |
| 3 | +% |
| 4 | +% Copyright (c) 2004-2025 Terry Burton |
| 5 | + |
| 6 | +% vim: set ts=4 sw=4 et : |
| 7 | + |
| 8 | +/renlinear dup /uk.co.terryburton.bwipp findresource cvx def |
| 9 | + |
| 10 | +% |
| 11 | +% Single bar: width 1 |
| 12 | +% |
| 13 | +{ |
| 14 | + 0 0 moveto |
| 15 | + << |
| 16 | + /ren /renlinear |
| 17 | + /sbs [1] |
| 18 | + /bhs [1] |
| 19 | + /bbs [0] |
| 20 | + /inkspread 0 |
| 21 | + /opt << /debugbars true >> |
| 22 | + >> renlinear |
| 23 | +} [ |
| 24 | + 72 0.5 0 1 |
| 25 | +] debugIsEqual |
| 26 | + |
| 27 | +% |
| 28 | +% Two bars: width 1, space 1, width 1 |
| 29 | +% |
| 30 | +{ |
| 31 | + 0 0 moveto |
| 32 | + << |
| 33 | + /ren /renlinear |
| 34 | + /sbs [1 1 1] |
| 35 | + /bhs [1 1] |
| 36 | + /bbs [0 0] |
| 37 | + /inkspread 0 |
| 38 | + /opt << /debugbars true >> |
| 39 | + >> renlinear |
| 40 | +} [ |
| 41 | + 72 0.5 0 1 |
| 42 | + 72 2.5 0 1 |
| 43 | +] debugIsEqual |
| 44 | + |
| 45 | +% |
| 46 | +% Three bars: width 2, space 1, width 1, space 1, width 3 |
| 47 | +% |
| 48 | +{ |
| 49 | + 0 0 moveto |
| 50 | + << |
| 51 | + /ren /renlinear |
| 52 | + /sbs [2 1 1 1 3] |
| 53 | + /bhs [1 1 1] |
| 54 | + /bbs [0 0 0] |
| 55 | + /inkspread 0 |
| 56 | + /opt << /debugbars true >> |
| 57 | + >> renlinear |
| 58 | +} [ |
| 59 | + 72 1 0 2 |
| 60 | + 72 3.5 0 1 |
| 61 | + 72 6.5 0 3 |
| 62 | +] debugIsEqual |
| 63 | + |
| 64 | +% |
| 65 | +% Bars with varying heights |
| 66 | +% |
| 67 | +{ |
| 68 | + 0 0 moveto |
| 69 | + << |
| 70 | + /ren /renlinear |
| 71 | + /sbs [1 1 1 1 1] |
| 72 | + /bhs [1 0.5 2] |
| 73 | + /bbs [0 0 0] |
| 74 | + /inkspread 0 |
| 75 | + /opt << /debugbars true >> |
| 76 | + >> renlinear |
| 77 | +} [ |
| 78 | + 72 0.5 0 1 |
| 79 | + 36 2.5 0 1 |
| 80 | + 144 4.5 0 1 |
| 81 | +] debugIsEqual |
| 82 | + |
| 83 | +% |
| 84 | +% Bars with varying baselines |
| 85 | +% |
| 86 | +{ |
| 87 | + 0 0 moveto |
| 88 | + << |
| 89 | + /ren /renlinear |
| 90 | + /sbs [1 1 1 1 1] |
| 91 | + /bhs [1 1 1] |
| 92 | + /bbs [0 0.5 1] |
| 93 | + /inkspread 0 |
| 94 | + /opt << /debugbars true >> |
| 95 | + >> renlinear |
| 96 | +} [ |
| 97 | + 72 0.5 0 1 |
| 98 | + 72 2.5 36 1 |
| 99 | + 72 4.5 72 1 |
| 100 | +] debugIsEqual |
| 101 | + |
| 102 | +% |
| 103 | +% Zero-width bar |
| 104 | +% |
| 105 | +{ |
| 106 | + 0 0 moveto |
| 107 | + << |
| 108 | + /ren /renlinear |
| 109 | + /sbs [1 1 0 1 1] |
| 110 | + /bhs [1 1 1] |
| 111 | + /bbs [0 0 0] |
| 112 | + /inkspread 0 |
| 113 | + /opt << /debugbars true >> |
| 114 | + >> renlinear |
| 115 | +} [ |
| 116 | + 72 0.5 0 1 |
| 117 | + 72 3.5 0 1 |
| 118 | +] debugIsEqual |
| 119 | + |
| 120 | +% |
| 121 | +% Wide bars with wide spaces |
| 122 | +% |
| 123 | +{ |
| 124 | + 0 0 moveto |
| 125 | + << |
| 126 | + /ren /renlinear |
| 127 | + /sbs [3 2 3 2 3] |
| 128 | + /bhs [1 1 1] |
| 129 | + /bbs [0 0 0] |
| 130 | + /inkspread 0 |
| 131 | + /opt << /debugbars true >> |
| 132 | + >> renlinear |
| 133 | +} [ |
| 134 | + 72 1.5 0 3 |
| 135 | + 72 6.5 0 3 |
| 136 | + 72 11.5 0 3 |
| 137 | +] debugIsEqual |
| 138 | + |
| 139 | +% |
| 140 | +% Bar ratio |
| 141 | +% |
| 142 | +{ |
| 143 | + 0 0 moveto |
| 144 | + << |
| 145 | + /ren /renlinear |
| 146 | + /sbs [2 1 2] |
| 147 | + /bhs [1 1] |
| 148 | + /bbs [0 0] |
| 149 | + /inkspread 0 |
| 150 | + /barratio 2 |
| 151 | + /opt << /debugbars true >> |
| 152 | + >> renlinear |
| 153 | +} [ |
| 154 | + 72 1.5 0 3 |
| 155 | + 72 5.5 0 3 |
| 156 | +] debugIsEqual |
| 157 | + |
| 158 | +% |
| 159 | +% Space ratios |
| 160 | +% |
| 161 | +{ |
| 162 | + 0 0 moveto |
| 163 | + << |
| 164 | + /ren /renlinear |
| 165 | + /sbs [1 2 1] |
| 166 | + /bhs [1 1] |
| 167 | + /bbs [0 0] |
| 168 | + /inkspread 0 |
| 169 | + /spaceratio 2 |
| 170 | + /opt << /debugbars true >> |
| 171 | + >> renlinear |
| 172 | +} [ |
| 173 | + 72 0.5 0 1 |
| 174 | + 72 4.5 0 1 |
| 175 | +] debugIsEqual |
| 176 | + |
| 177 | +% |
| 178 | +% DataBar Omnidirectional |
| 179 | +% |
| 180 | +{ |
| 181 | + 0 0 moveto |
| 182 | + << |
| 183 | + /ren /renlinear |
| 184 | + /sbs [1 5 1 1 1 5 1 1 1 2 3 8 1 1 4 3 1 1 1 1 2 2 3 4 1 1 2 2 1 1 1 1 4 7 2 5 1 2 1 2 1 1 3 1 1] |
| 185 | + /bhs [0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5] |
| 186 | + /bbs [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] |
| 187 | + /inkspread 0 |
| 188 | + /opt << /debugbars true >> |
| 189 | + >> renlinear |
| 190 | +} [ |
| 191 | + 36 0.5 0 1 36 6.5 0 1 36 8.5 0 1 36 14.5 0 1 36 16.5 0 1 36 20.5 0 3 |
| 192 | + 36 30.5 0 1 36 34 0 4 36 39.5 0 1 36 41.5 0 1 36 44 0 2 36 48.5 0 3 |
| 193 | + 36 54.5 0 1 36 57 0 2 36 60.5 0 1 36 62.5 0 1 36 66 0 4 36 76 0 2 |
| 194 | + 36 82.5 0 1 36 85.5 0 1 36 88.5 0 1 36 91.5 0 3 36 94.5 0 1 |
| 195 | +] debugIsEqual |
| 196 | + |
0 commit comments