Skip to content

Commit a333ec0

Browse files
committedDec 21, 2016
Updated to BWIPP 2016-12-16 and a couple of bug fixes (#53, #55)
1 parent 575f410 commit a333ec0

9 files changed

+22101
-22058
lines changed
 

‎README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ See the [Version 1.0 Release Announcement](https://github.com/metafloor/bwip-js/
2828
2929
## Status
3030

31-
* Current bwip-js version is 1.1.1 (2016-09-19)
32-
* Current BWIPP version is 2016-08-29
31+
* Current bwip-js version is 1.2.0 (2016-12-20)
32+
* Current BWIPP version is 2016-12-16
3333
* Node.js compatibility >= v0.10
3434

3535
## Links

‎barcode.ps

348 Bytes
Binary file not shown.

‎bwipjs.js

+16
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,22 @@ BWIPJS.prototype.stroke = function() {
267267
}
268268
this.g_path = [];
269269
}
270+
271+
// Fix sources of rounding error by making the scale-factors integral.
272+
// Currently, only floor is being used.
273+
BWIPJS.prototype.floorscale = function() {
274+
this.g_tsx = Math.floor(this.g_tsx) || 1;
275+
this.g_tsy = Math.floor(this.g_tsy) || 1;
276+
}
277+
BWIPJS.prototype.ceilscale = function() {
278+
this.g_tsx = Math.ceil(this.g_tsx) || 1;
279+
this.g_tsy = Math.ceil(this.g_tsy) || 1;
280+
}
281+
BWIPJS.prototype.roundscale = function() {
282+
this.g_tsx = Math.round(this.g_tsx) || 1;
283+
this.g_tsy = Math.round(this.g_tsy) || 1;
284+
}
285+
270286
BWIPJS.prototype.setextent = function() {
271287
if (!this.g_path.length) // Nothing to do?
272288
return;

‎bwipp-min.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎bwipp.js

+22,055-22,042
Large diffs are not rendered by default.

‎demo.html

100755100644
+12-2
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,16 @@
207207
// Add the alternate text
208208
if (altx) {
209209
opts.alttext = altx;
210+
opts.includetext = true;
211+
}
212+
// We use mm rather than inches for height - except pharmacode2 height
213+
// which is expected to be in mm
214+
if (+opts.height && elt.sym != 'pharmacode2') {
215+
opts.height = opts.height / 25.4 || 0.5;
216+
}
217+
// Likewise, width.
218+
if (+opts.width) {
219+
opts.width = opts.width / 25.4 || 0;
210220
}
211221
// BWIPP does not extend the background color into the
212222
// human readable text. Fix that in the bitmap interface.
@@ -287,7 +297,7 @@
287297
</head><body>
288298
<div id="header">
289299
<div id="bwipjs">bwip-js // Barcode Writer in Pure JavaScript</div>
290-
<div id="version">bwip-js 1.1.1 (2016-09-19) / BWIPP 2016-08-29</div>
300+
<div id="version">bwip-js 1.2.0 (2016-12-20) / BWIPP 2016-12-16</div>
291301
<div id="fonthdr">&#x25bc; Fonts</div>
292302
<div id="fontdiv" style="visibility:hidden">
293303
<div class="inner">
@@ -316,7 +326,7 @@
316326
<tr><th>Barcode Type:
317327
<!-- Do not change the `select id="symbol"` - see develop/mkdesc -->
318328
<td><select id="symbol" style="width:63.5ex">
319-
<!-- Barcode Writer in Pure PostScript - Version 2016-06-03 -->
329+
<!-- Barcode Writer in Pure PostScript - Version 2016-12-16 -->
320330
<option value="auspost">AusPost 4 State Customer Code</option>
321331
<option value="azteccode">Aztec Code</option>
322332
<option value="aztecrune">Aztec Runes</option>

‎lib/symdesc.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// file: bwip-js/lib/symdesc.js
22
//
33
// This code was automatically generated from:
4-
// Barcode Writer in Pure PostScript - Version 2016-06-03
4+
// Barcode Writer in Pure PostScript - Version 2016-12-16
55
//
66
// Copyright (c) 2011-2016 Mark Warren
7-
// Copyright (c) 2004-2014 Terry Burton
7+
// Copyright (c) 2004-2016 Terry Burton
88
//
99
// Licensed MIT. See the LICENSE file in the bwip-js root directory
1010
// for the extended copyright notice.

‎node-bwipjs.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,14 @@ module.exports.toBuffer = function(args, callback) {
9898
opts.includetext = true;
9999
}
100100
// We use mm rather than inches for height - except pharmacode2 height
101-
// is explicitly in mm
102-
if (opts.height && bcid != 'pharmacode2') {
101+
// which is expected to be in mm
102+
if (+opts.height && bcid != 'pharmacode2') {
103103
opts.height = opts.height / 25.4 || 0.5;
104104
}
105+
// Likewise, width
106+
if (+opts.width) {
107+
opts.width = opts.width / 25.4 || 0;
108+
}
105109

106110
// Override the `backgroundcolor` option.
107111
if (opts.backgroundcolor) {
@@ -150,8 +154,8 @@ module.exports.unloadFont = function(fontname) {
150154
freetype.unlink('/' + fontname);
151155
}
152156

153-
module.exports.bwipjs_version = "1.1.1 (2016-09-19)";
154-
module.exports.bwipp_version = "2016-08-29";
157+
module.exports.bwipjs_version = "1.2.0 (2016-12-20)";
158+
module.exports.bwipp_version = "2016-12-16";
155159

156160

157161
// bwipjs Bitmap interface
@@ -184,8 +188,8 @@ function Bitmap(bgcolor) {
184188

185189
// Optional padding. Rotates with the image.
186190
this.pad = function(width, height) {
187-
_padx = width;
188-
_pady = height;
191+
_padx = width|0;
192+
_pady = height|0;
189193
}
190194

191195
this.limit = function(size) {

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bwip-js",
3-
"version": "1.1.1",
3+
"version": "1.2.0",
44
"description": "Barcode generator supporting over 90 types and standards.",
55
"main": "node-bwipjs",
66
"bin": {

0 commit comments

Comments
 (0)
Please sign in to comment.