Skip to content

Commit 4107cb6

Browse files
committed
Update to 4.3.2
1 parent 085dfa0 commit 4107cb6

15 files changed

+161
-84
lines changed

demo/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ or as SVG (all platforms).
1414
1515
## Status
1616

17-
* Current bwip-js version is 4.3.0 (2024-03-12)
17+
* Current bwip-js version is 4.3.1 (2024-03-16)
1818
* Current BWIPP version is 2024-01-03
1919
* Node.js compatibility: 0.12+
2020
* Browser compatibility: Edge, Firefox, Chrome

demo/dist/bwip-js-gen.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Type definitions for bwip-js 4.3.1 (2024-03-16)
1+
// Type definitions for bwip-js 4.3.2 (2024-03-19)
22
//
33
// THIS DEFINITION FILE IS MACHINE GENERATED - DO NOT EDIT
44
//

demo/dist/bwip-js-gen.mjs

+22-11
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import { bwipp_auspost,bwipp_azteccode,bwipp_azteccodecompact,bwipp_aztecrune,bwipp_bc412,bwipp_channelcode,bwipp_codablockf,bwipp_code11,bwipp_code128,bwipp_code16k,bwipp_code2of5,bwipp_code32,bwipp_code39,bwipp_code39ext,bwipp_code49,bwipp_code93,bwipp_code93ext,bwipp_codeone,bwipp_coop2of5,bwipp_daft,bwipp_databarexpanded,bwipp_databarexpandedcomposite,bwipp_databarexpandedstacked,bwipp_databarexpandedstackedcomposite,bwipp_databarlimited,bwipp_databarlimitedcomposite,bwipp_databaromni,bwipp_databaromnicomposite,bwipp_databarstacked,bwipp_databarstackedcomposite,bwipp_databarstackedomni,bwipp_databarstackedomnicomposite,bwipp_databartruncated,bwipp_databartruncatedcomposite,bwipp_datalogic2of5,bwipp_datamatrix,bwipp_datamatrixrectangular,bwipp_datamatrixrectangularextension,bwipp_dotcode,bwipp_ean13,bwipp_ean13composite,bwipp_ean14,bwipp_ean2,bwipp_ean5,bwipp_ean8,bwipp_ean8composite,bwipp_flattermarken,bwipp_gs1_128,bwipp_gs1_128composite,bwipp_gs1_cc,bwipp_gs1datamatrix,bwipp_gs1datamatrixrectangular,bwipp_gs1dldatamatrix,bwipp_gs1dlqrcode,bwipp_gs1dotcode,bwipp_gs1northamericancoupon,bwipp_gs1qrcode,bwipp_hanxin,bwipp_hibcazteccode,bwipp_hibccodablockf,bwipp_hibccode128,bwipp_hibccode39,bwipp_hibcdatamatrix,bwipp_hibcdatamatrixrectangular,bwipp_hibcmicropdf417,bwipp_hibcpdf417,bwipp_hibcqrcode,bwipp_iata2of5,bwipp_identcode,bwipp_industrial2of5,bwipp_interleaved2of5,bwipp_isbn,bwipp_ismn,bwipp_issn,bwipp_itf14,bwipp_jabcode,bwipp_japanpost,bwipp_kix,bwipp_leitcode,bwipp_mailmark,bwipp_mands,bwipp_matrix2of5,bwipp_maxicode,bwipp_micropdf417,bwipp_microqrcode,bwipp_msi,bwipp_onecode,bwipp_pdf417,bwipp_pdf417compact,bwipp_pharmacode,bwipp_pharmacode2,bwipp_planet,bwipp_plessey,bwipp_posicode,bwipp_postnet,bwipp_pzn,bwipp_qrcode,bwipp_rationalizedCodabar,bwipp_raw,bwipp_rectangularmicroqrcode,bwipp_royalmail,bwipp_sscc18,bwipp_swissqrcode,bwipp_symbol,bwipp_telepen,bwipp_telepennumeric,bwipp_ultracode,bwipp_upca,bwipp_upcacomposite,bwipp_upce,bwipp_upcecomposite,bwipp_lookup,bwipp_encode,BWIPP_VERSION } from './bwipp.mjs';
3434

3535
// exports.js
36-
const BWIPJS_VERSION = '4.3.1 (2024-03-16)';
36+
const BWIPJS_VERSION = '4.3.2 (2024-03-19)';
3737

3838

3939
// bwipjs.toSVG(options)
@@ -1491,6 +1491,11 @@ function DrawingSVG() {
14911491
var clips = [];
14921492
var lines = {};
14931493

1494+
// We adjust the drawing coordinates by 0.5px when stroke width is odd.
1495+
// But this creates an odd effect with scale. When scale is even, we
1496+
// need to add 0.5; when scale is odd, subtract 0.5.
1497+
var scalex, scaley;
1498+
14941499
// Magic number to approximate an ellipse/circle using 4 cubic beziers.
14951500
var ELLIPSE_MAGIC = 0.55228475 - 0.00045;
14961501

@@ -1511,6 +1516,8 @@ function DrawingSVG() {
15111516

15121517
// Make no adjustments
15131518
scale(sx, sy) {
1519+
scalex = sx;
1520+
scaley = sy;
15141521
},
15151522
// Measure text.
15161523
// `font` is the font name typically OCR-A or OCR-B.
@@ -1577,34 +1584,37 @@ function DrawingSVG() {
15771584
// Unconnected stroked lines are used to draw the bars in linear barcodes.
15781585
// No line cap should be applied. These lines are always orthogonal.
15791586
line(x0, y0, x1, y1, lw, rgb) {
1580-
// Try to get non-blurry lines...
15811587
x0 = x0|0;
15821588
y0 = y0|0;
15831589
x1 = x1|0;
15841590
y1 = y1|0;
1585-
lw = Math.round(lw);
1591+
lw = Math.round(lw) || 1;
15861592

15871593
// Try to keep the lines "crisp" by using with the SVG line drawing spec to
1588-
// our advantage.
1594+
// our advantage and adjust the coordinates by half pixel when stroke width
1595+
// is odd. Work around an odd effect with scale. When scale is even, we
1596+
// need to add 0.5; when scale is odd, subtract 0.5.
15891597
if (lw & 1) {
15901598
if (x0 == x1) {
1591-
x0 += 0.5;
1592-
x1 += 0.5;
1599+
let dx = (scalex&1) ? -0.5 : 0.5;
1600+
x0 += dx;
1601+
x1 += dx;
15931602
}
15941603
if (y0 == y1) {
1595-
y0 += 0.5;
1596-
y1 += 0.5;
1604+
let dy = (scaley&1) ? -0.5 : 0.5;
1605+
y0 += dy;
1606+
y1 += dy;
15971607
}
15981608
}
1599-
// The svg path does not include the start pixel, but the bwip-js drawing does.
1609+
// The svg path does not include the start pixel, but the built-in drawing does.
16001610
if (x0 == x1) {
16011611
y0++;
16021612
} else if (y0 == y1) {
16031613
x0++;
16041614
}
16051615

16061616
// Group together all lines of the same width and emit as single paths.
1607-
// Dramatically reduces resulting text size.
1617+
// Dramatically reduces the svg text size.
16081618
var key = '' + lw + '#' + rgb;
16091619
if (!lines[key]) {
16101620
lines[key] = '<path stroke="#' + rgb + '" stroke-width="' + lw + '" d="';
@@ -1661,7 +1671,8 @@ function DrawingSVG() {
16611671
'Z';
16621672
},
16631673
// PostScript's default fill rule is non-zero but there are never intersecting
1664-
// regions so use even-odd as it is easier to work with.
1674+
// regions. The built-in drawing uses even-odd for simplicity - we match that
1675+
// to be consistent.
16651676
fill(rgb) {
16661677
if (path) {
16671678
svg += path + '" fill="#' + rgb + '" fill-rule="evenodd"' +

demo/dist/bwip-js-min.js

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

demo/dist/bwip-js-node.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Type definitions for bwip-js 4.3.1 (2024-03-16)
1+
// Type definitions for bwip-js 4.3.2 (2024-03-19)
22
//
33
// THIS DEFINITION FILE IS MACHINE GENERATED - DO NOT EDIT
44
//

demo/dist/bwip-js-node.js

+22-11
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333

3434
// exports.js
35-
const BWIPJS_VERSION = '4.3.1 (2024-03-16)';
35+
const BWIPJS_VERSION = '4.3.2 (2024-03-19)';
3636

3737
var url = require('url');
3838
var PNG_ZLIB = require('zlib');
@@ -42027,6 +42027,11 @@ function DrawingSVG() {
4202742027
var clips = [];
4202842028
var lines = {};
4202942029

42030+
// We adjust the drawing coordinates by 0.5px when stroke width is odd.
42031+
// But this creates an odd effect with scale. When scale is even, we
42032+
// need to add 0.5; when scale is odd, subtract 0.5.
42033+
var scalex, scaley;
42034+
4203042035
// Magic number to approximate an ellipse/circle using 4 cubic beziers.
4203142036
var ELLIPSE_MAGIC = 0.55228475 - 0.00045;
4203242037

@@ -42047,6 +42052,8 @@ function DrawingSVG() {
4204742052

4204842053
// Make no adjustments
4204942054
scale(sx, sy) {
42055+
scalex = sx;
42056+
scaley = sy;
4205042057
},
4205142058
// Measure text.
4205242059
// `font` is the font name typically OCR-A or OCR-B.
@@ -42113,34 +42120,37 @@ function DrawingSVG() {
4211342120
// Unconnected stroked lines are used to draw the bars in linear barcodes.
4211442121
// No line cap should be applied. These lines are always orthogonal.
4211542122
line(x0, y0, x1, y1, lw, rgb) {
42116-
// Try to get non-blurry lines...
4211742123
x0 = x0|0;
4211842124
y0 = y0|0;
4211942125
x1 = x1|0;
4212042126
y1 = y1|0;
42121-
lw = Math.round(lw);
42127+
lw = Math.round(lw) || 1;
4212242128

4212342129
// Try to keep the lines "crisp" by using with the SVG line drawing spec to
42124-
// our advantage.
42130+
// our advantage and adjust the coordinates by half pixel when stroke width
42131+
// is odd. Work around an odd effect with scale. When scale is even, we
42132+
// need to add 0.5; when scale is odd, subtract 0.5.
4212542133
if (lw & 1) {
4212642134
if (x0 == x1) {
42127-
x0 += 0.5;
42128-
x1 += 0.5;
42135+
let dx = (scalex&1) ? -0.5 : 0.5;
42136+
x0 += dx;
42137+
x1 += dx;
4212942138
}
4213042139
if (y0 == y1) {
42131-
y0 += 0.5;
42132-
y1 += 0.5;
42140+
let dy = (scaley&1) ? -0.5 : 0.5;
42141+
y0 += dy;
42142+
y1 += dy;
4213342143
}
4213442144
}
42135-
// The svg path does not include the start pixel, but the bwip-js drawing does.
42145+
// The svg path does not include the start pixel, but the built-in drawing does.
4213642146
if (x0 == x1) {
4213742147
y0++;
4213842148
} else if (y0 == y1) {
4213942149
x0++;
4214042150
}
4214142151

4214242152
// Group together all lines of the same width and emit as single paths.
42143-
// Dramatically reduces resulting text size.
42153+
// Dramatically reduces the svg text size.
4214442154
var key = '' + lw + '#' + rgb;
4214542155
if (!lines[key]) {
4214642156
lines[key] = '<path stroke="#' + rgb + '" stroke-width="' + lw + '" d="';
@@ -42197,7 +42207,8 @@ function DrawingSVG() {
4219742207
'Z';
4219842208
},
4219942209
// PostScript's default fill rule is non-zero but there are never intersecting
42200-
// regions so use even-odd as it is easier to work with.
42210+
// regions. The built-in drawing uses even-odd for simplicity - we match that
42211+
// to be consistent.
4220142212
fill(rgb) {
4220242213
if (path) {
4220342214
svg += path + '" fill="#' + rgb + '" fill-rule="evenodd"' +

demo/dist/bwip-js-node.mjs

+22-11
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import { bwipp_auspost,bwipp_azteccode,bwipp_azteccodecompact,bwipp_aztecrune,bwipp_bc412,bwipp_channelcode,bwipp_codablockf,bwipp_code11,bwipp_code128,bwipp_code16k,bwipp_code2of5,bwipp_code32,bwipp_code39,bwipp_code39ext,bwipp_code49,bwipp_code93,bwipp_code93ext,bwipp_codeone,bwipp_coop2of5,bwipp_daft,bwipp_databarexpanded,bwipp_databarexpandedcomposite,bwipp_databarexpandedstacked,bwipp_databarexpandedstackedcomposite,bwipp_databarlimited,bwipp_databarlimitedcomposite,bwipp_databaromni,bwipp_databaromnicomposite,bwipp_databarstacked,bwipp_databarstackedcomposite,bwipp_databarstackedomni,bwipp_databarstackedomnicomposite,bwipp_databartruncated,bwipp_databartruncatedcomposite,bwipp_datalogic2of5,bwipp_datamatrix,bwipp_datamatrixrectangular,bwipp_datamatrixrectangularextension,bwipp_dotcode,bwipp_ean13,bwipp_ean13composite,bwipp_ean14,bwipp_ean2,bwipp_ean5,bwipp_ean8,bwipp_ean8composite,bwipp_flattermarken,bwipp_gs1_128,bwipp_gs1_128composite,bwipp_gs1_cc,bwipp_gs1datamatrix,bwipp_gs1datamatrixrectangular,bwipp_gs1dldatamatrix,bwipp_gs1dlqrcode,bwipp_gs1dotcode,bwipp_gs1northamericancoupon,bwipp_gs1qrcode,bwipp_hanxin,bwipp_hibcazteccode,bwipp_hibccodablockf,bwipp_hibccode128,bwipp_hibccode39,bwipp_hibcdatamatrix,bwipp_hibcdatamatrixrectangular,bwipp_hibcmicropdf417,bwipp_hibcpdf417,bwipp_hibcqrcode,bwipp_iata2of5,bwipp_identcode,bwipp_industrial2of5,bwipp_interleaved2of5,bwipp_isbn,bwipp_ismn,bwipp_issn,bwipp_itf14,bwipp_jabcode,bwipp_japanpost,bwipp_kix,bwipp_leitcode,bwipp_mailmark,bwipp_mands,bwipp_matrix2of5,bwipp_maxicode,bwipp_micropdf417,bwipp_microqrcode,bwipp_msi,bwipp_onecode,bwipp_pdf417,bwipp_pdf417compact,bwipp_pharmacode,bwipp_pharmacode2,bwipp_planet,bwipp_plessey,bwipp_posicode,bwipp_postnet,bwipp_pzn,bwipp_qrcode,bwipp_rationalizedCodabar,bwipp_raw,bwipp_rectangularmicroqrcode,bwipp_royalmail,bwipp_sscc18,bwipp_swissqrcode,bwipp_symbol,bwipp_telepen,bwipp_telepennumeric,bwipp_ultracode,bwipp_upca,bwipp_upcacomposite,bwipp_upce,bwipp_upcecomposite,bwipp_lookup,bwipp_encode,BWIPP_VERSION } from './bwipp.mjs';
3434

3535
// exports.js
36-
const BWIPJS_VERSION = '4.3.1 (2024-03-16)';
36+
const BWIPJS_VERSION = '4.3.2 (2024-03-19)';
3737

3838
import url from 'url';
3939
import PNG_ZLIB from 'zlib';
@@ -1781,6 +1781,11 @@ function DrawingSVG() {
17811781
var clips = [];
17821782
var lines = {};
17831783

1784+
// We adjust the drawing coordinates by 0.5px when stroke width is odd.
1785+
// But this creates an odd effect with scale. When scale is even, we
1786+
// need to add 0.5; when scale is odd, subtract 0.5.
1787+
var scalex, scaley;
1788+
17841789
// Magic number to approximate an ellipse/circle using 4 cubic beziers.
17851790
var ELLIPSE_MAGIC = 0.55228475 - 0.00045;
17861791

@@ -1801,6 +1806,8 @@ function DrawingSVG() {
18011806

18021807
// Make no adjustments
18031808
scale(sx, sy) {
1809+
scalex = sx;
1810+
scaley = sy;
18041811
},
18051812
// Measure text.
18061813
// `font` is the font name typically OCR-A or OCR-B.
@@ -1867,34 +1874,37 @@ function DrawingSVG() {
18671874
// Unconnected stroked lines are used to draw the bars in linear barcodes.
18681875
// No line cap should be applied. These lines are always orthogonal.
18691876
line(x0, y0, x1, y1, lw, rgb) {
1870-
// Try to get non-blurry lines...
18711877
x0 = x0|0;
18721878
y0 = y0|0;
18731879
x1 = x1|0;
18741880
y1 = y1|0;
1875-
lw = Math.round(lw);
1881+
lw = Math.round(lw) || 1;
18761882

18771883
// Try to keep the lines "crisp" by using with the SVG line drawing spec to
1878-
// our advantage.
1884+
// our advantage and adjust the coordinates by half pixel when stroke width
1885+
// is odd. Work around an odd effect with scale. When scale is even, we
1886+
// need to add 0.5; when scale is odd, subtract 0.5.
18791887
if (lw & 1) {
18801888
if (x0 == x1) {
1881-
x0 += 0.5;
1882-
x1 += 0.5;
1889+
let dx = (scalex&1) ? -0.5 : 0.5;
1890+
x0 += dx;
1891+
x1 += dx;
18831892
}
18841893
if (y0 == y1) {
1885-
y0 += 0.5;
1886-
y1 += 0.5;
1894+
let dy = (scaley&1) ? -0.5 : 0.5;
1895+
y0 += dy;
1896+
y1 += dy;
18871897
}
18881898
}
1889-
// The svg path does not include the start pixel, but the bwip-js drawing does.
1899+
// The svg path does not include the start pixel, but the built-in drawing does.
18901900
if (x0 == x1) {
18911901
y0++;
18921902
} else if (y0 == y1) {
18931903
x0++;
18941904
}
18951905

18961906
// Group together all lines of the same width and emit as single paths.
1897-
// Dramatically reduces resulting text size.
1907+
// Dramatically reduces the svg text size.
18981908
var key = '' + lw + '#' + rgb;
18991909
if (!lines[key]) {
19001910
lines[key] = '<path stroke="#' + rgb + '" stroke-width="' + lw + '" d="';
@@ -1951,7 +1961,8 @@ function DrawingSVG() {
19511961
'Z';
19521962
},
19531963
// PostScript's default fill rule is non-zero but there are never intersecting
1954-
// regions so use even-odd as it is easier to work with.
1964+
// regions. The built-in drawing uses even-odd for simplicity - we match that
1965+
// to be consistent.
19551966
fill(rgb) {
19561967
if (path) {
19571968
svg += path + '" fill="#' + rgb + '" fill-rule="evenodd"' +

demo/dist/bwip-js-rn.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Type definitions for bwip-js 4.3.1 (2024-03-16)
1+
// Type definitions for bwip-js 4.3.2 (2024-03-19)
22
//
33
// THIS DEFINITION FILE IS MACHINE GENERATED - DO NOT EDIT
44
//

0 commit comments

Comments
 (0)