diff --git a/ChangeLog b/ChangeLog index 332361e4..bad5d32e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,9 @@ Version 2.10.0.9 (dev) not released yet NOTE: previously was silently truncated - PDF417: return warning if specified cols increased NOTE: previously no warning was returned +- Matrix symbols: horizontal boundary bars appear outside any vertical + whitespace + NOTE: previously appeared inside vertical whitespace Changes ------- @@ -47,6 +50,8 @@ Changes - DATAMATRIX: new algorithm for (near-)optimal encoding, props Alex Geller - CLI/GUI/Tcl: add --fast option to select faster but less optimal DATAMATRIX algorithm (previous default) +- Matrix symbols: change horizontal boundary bars to appear outside any + vertical whitespace, as they're decorative rather than functional (#247) Bugs ---- @@ -69,6 +74,7 @@ Bugs - DATAMATRIX: fix mis-encoding of non-encodables in X12 and EDIFACT modes, props Alex Geller - DATAMATRIX: fix mis-encoding of FNC1/GS in EDIFACT in GS1 mode +- Allow for dot overspill in height of vertical box sides (dotty mode) Version 2.10.0 2021-08-14 diff --git a/backend/common.c b/backend/common.c index 00a46df6..2d1ae2cb 100644 --- a/backend/common.c +++ b/backend/common.c @@ -298,6 +298,49 @@ INTERNAL int is_composite(const int symbology) { return symbology >= BARCODE_EANX_CC && symbology <= BARCODE_DBAR_EXPSTK_CC; } +/* Returns 1 if symbology is a matrix design renderable as dots */ +INTERNAL int is_dotty(const int symbology) { + + switch (symbology) { + /* Note MAXICODE and ULTRA absent */ + case BARCODE_QRCODE: + case BARCODE_DATAMATRIX: + case BARCODE_MICROQR: + case BARCODE_HIBC_DM: + case BARCODE_AZTEC: + case BARCODE_HIBC_QR: + case BARCODE_HIBC_AZTEC: + case BARCODE_AZRUNE: + case BARCODE_CODEONE: + case BARCODE_GRIDMATRIX: + case BARCODE_HANXIN: + case BARCODE_DOTCODE: + case BARCODE_UPNQR: + case BARCODE_RMQR: + return 1; + break; + } + + return 0; +} + +/* Returns 1 if symbology has fixed aspect ratio (matrix design) */ +INTERNAL int is_fixed_ratio(const int symbology) { + + if (is_dotty(symbology)) { + return 1; + } + + switch (symbology) { + case BARCODE_MAXICODE: + case BARCODE_ULTRA: + return 1; + break; + } + + return 0; +} + /* Whether next two characters are digits */ INTERNAL int is_twodigits(const unsigned char source[], const int length, const int position) { if ((position + 1 < length) && (source[position] >= '0') && (source[position] <= '9') diff --git a/backend/common.h b/backend/common.h index 84ac4a42..724f2a08 100644 --- a/backend/common.h +++ b/backend/common.h @@ -168,6 +168,8 @@ extern "C" { INTERNAL int is_stackable(const int symbology); INTERNAL int is_extendable(const int symbology); INTERNAL int is_composite(const int symbology); + INTERNAL int is_dotty(const int symbology); + INTERNAL int is_fixed_ratio(const int symbology); INTERNAL int is_twodigits(const unsigned char source[], const int length, const int position); diff --git a/backend/library.c b/backend/library.c index c823ba5c..e4f87103 100644 --- a/backend/library.c +++ b/backend/library.c @@ -393,49 +393,6 @@ static int gs1_compliant(const int symbology) { return check_force_gs1(symbology); } -static int is_dotty(const int symbology) { - /* Returns 1 if symbology is a matrix design renderable as dots */ - - switch (symbology) { - /* Note MAXICODE and ULTRA absent */ - case BARCODE_QRCODE: - case BARCODE_DATAMATRIX: - case BARCODE_MICROQR: - case BARCODE_HIBC_DM: - case BARCODE_AZTEC: - case BARCODE_HIBC_QR: - case BARCODE_HIBC_AZTEC: - case BARCODE_AZRUNE: - case BARCODE_CODEONE: - case BARCODE_GRIDMATRIX: - case BARCODE_HANXIN: - case BARCODE_DOTCODE: - case BARCODE_UPNQR: - case BARCODE_RMQR: - return 1; - break; - } - - return 0; -} - -static int is_fixed_ratio(const int symbology) { - /* Returns 1 if symbology has fixed aspect ratio (matrix design) */ - - if (is_dotty(symbology)) { - return 1; - } - - switch (symbology) { - case BARCODE_MAXICODE: - case BARCODE_ULTRA: - return 1; - break; - } - - return 0; -} - static int supports_eci(const int symbology) { /* Returns 1 if symbology can encode the ECI character */ diff --git a/backend/raster.c b/backend/raster.c index e2f615cc..25ce22fc 100644 --- a/backend/raster.c +++ b/backend/raster.c @@ -668,9 +668,14 @@ static void draw_bind_box(const struct zint_symbol *symbol, unsigned char *pixel const int xoffset_si, const int yoffset_si, const int symbol_height_si, const int dot_overspill_si, const int image_width, const int image_height, const int si) { if (symbol->border_width > 0 && (symbol->output_options & (BARCODE_BOX | BARCODE_BIND))) { + const int horz_outside = is_fixed_ratio(symbol->symbology); const int bwidth_si = symbol->border_width * si; - const int ybind_top = yoffset_si - bwidth_si; - const int ybind_bot = yoffset_si + symbol_height_si + dot_overspill_si; + int ybind_top = yoffset_si - bwidth_si; + int ybind_bot = yoffset_si + symbol_height_si + dot_overspill_si; + if (horz_outside) { + ybind_top = 0; + ybind_bot = image_height - bwidth_si; + } /* Horizontal boundary bars */ if ((symbol->output_options & BARCODE_BOX) || (symbol->symbology != BARCODE_CODABLOCKF && symbol->symbology != BARCODE_HIBC_BLOCKF)) { @@ -686,9 +691,14 @@ static void draw_bind_box(const struct zint_symbol *symbol, unsigned char *pixel if (symbol->output_options & BARCODE_BOX) { /* Vertical side bars */ const int xbox_right = image_width - bwidth_si; - draw_bar(pixelbuf, 0, bwidth_si, yoffset_si, symbol_height_si, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, xbox_right, bwidth_si, yoffset_si, symbol_height_si, image_width, image_height, - DEFAULT_INK); + int box_top = yoffset_si; + int box_height = symbol_height_si + dot_overspill_si; + if (horz_outside) { + box_top = bwidth_si; + box_height = image_height - bwidth_si * 2; + } + draw_bar(pixelbuf, 0, bwidth_si, box_top, box_height, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, xbox_right, bwidth_si, box_top, box_height, image_width, image_height, DEFAULT_INK); } } } diff --git a/backend/tests/data/bmp/ultracode_fg_bg_hvwsp1_box1.bmp b/backend/tests/data/bmp/ultracode_fg_bg_hvwsp1_box1.bmp index e8eca02a..59fe78fc 100644 Binary files a/backend/tests/data/bmp/ultracode_fg_bg_hvwsp1_box1.bmp and b/backend/tests/data/bmp/ultracode_fg_bg_hvwsp1_box1.bmp differ diff --git a/backend/tests/data/emf/ultracode_fg_bg_box2.emf b/backend/tests/data/emf/ultracode_fg_bg_box2.emf index 915704f9..807a675e 100644 Binary files a/backend/tests/data/emf/ultracode_fg_bg_box2.emf and b/backend/tests/data/emf/ultracode_fg_bg_box2.emf differ diff --git a/backend/tests/data/eps/ultra_fg_bg_box_cmyk.eps b/backend/tests/data/eps/ultra_fg_bg_box_cmyk.eps index f2c5ead8..e1434f4c 100644 --- a/backend/tests/data/eps/ultra_fg_bg_box_cmyk.eps +++ b/backend/tests/data/eps/ultra_fg_bg_box_cmyk.eps @@ -12,13 +12,13 @@ newpath 38.00 0.00 TB 0.00 40.00 TR TE 1.00 1.00 0.00 0.00 setcmykcolor -4.00 32.00 TB 0.00 40.00 TR +4.00 34.00 TB 0.00 40.00 TR TE -4.00 2.00 TB 0.00 40.00 TR +4.00 0.00 TB 0.00 40.00 TR TE -26.00 6.00 TB 0.00 4.00 TR +30.00 4.00 TB 0.00 4.00 TR TE -26.00 6.00 TB 36.00 4.00 TR +30.00 4.00 TB 36.00 4.00 TR TE 1.00 0.00 0.00 0.00 setcmykcolor 2.00 28.00 TB 22.00 4.00 TR diff --git a/backend/tests/data/gif/ultra_fgbg_hvwsp1_box1.gif b/backend/tests/data/gif/ultra_fgbg_hvwsp1_box1.gif index 25036164..1043b448 100644 Binary files a/backend/tests/data/gif/ultra_fgbg_hvwsp1_box1.gif and b/backend/tests/data/gif/ultra_fgbg_hvwsp1_box1.gif differ diff --git a/backend/tests/data/pcx/ultra_fg_bg_hvwsp1_box1.pcx b/backend/tests/data/pcx/ultra_fg_bg_hvwsp1_box1.pcx index 060a6de6..f6ee1163 100644 Binary files a/backend/tests/data/pcx/ultra_fg_bg_hvwsp1_box1.pcx and b/backend/tests/data/pcx/ultra_fg_bg_hvwsp1_box1.pcx differ diff --git a/backend/tests/data/png/datamatrix_2.0_hvwsp1_bind1_dotty.png b/backend/tests/data/png/datamatrix_2.0_hvwsp1_bind1_dotty.png index fe9d1724..d8f0f8d5 100644 Binary files a/backend/tests/data/png/datamatrix_2.0_hvwsp1_bind1_dotty.png and b/backend/tests/data/png/datamatrix_2.0_hvwsp1_bind1_dotty.png differ diff --git a/backend/tests/data/png/maxicode_hvwsp1_box2.png b/backend/tests/data/png/maxicode_hvwsp1_box2.png index fece2091..b9a53890 100644 Binary files a/backend/tests/data/png/maxicode_hvwsp1_box2.png and b/backend/tests/data/png/maxicode_hvwsp1_box2.png differ diff --git a/backend/tests/data/png/maxicode_vwsp1_bind1.png b/backend/tests/data/png/maxicode_vwsp1_bind1.png index 2f7cb51f..19cc6864 100644 Binary files a/backend/tests/data/png/maxicode_vwsp1_bind1.png and b/backend/tests/data/png/maxicode_vwsp1_bind1.png differ diff --git a/backend/tests/data/png/ultra_fgalpha_hvwsp1_box1.png b/backend/tests/data/png/ultra_fgalpha_hvwsp1_box1.png index 37f38e12..91af856e 100644 Binary files a/backend/tests/data/png/ultra_fgalpha_hvwsp1_box1.png and b/backend/tests/data/png/ultra_fgalpha_hvwsp1_box1.png differ diff --git a/backend/tests/data/png/ultra_hvwsp1_box1.png b/backend/tests/data/png/ultra_hvwsp1_box1.png index cfa074f7..aa151d43 100644 Binary files a/backend/tests/data/png/ultra_hvwsp1_box1.png and b/backend/tests/data/png/ultra_hvwsp1_box1.png differ diff --git a/backend/tests/data/svg/datamatrix_hvwsp1_bind1_dotty.svg b/backend/tests/data/svg/datamatrix_hvwsp1_bind1_dotty.svg index 32419cc3..2b44a900 100644 --- a/backend/tests/data/svg/datamatrix_hvwsp1_bind1_dotty.svg +++ b/backend/tests/data/svg/datamatrix_hvwsp1_bind1_dotty.svg @@ -8,8 +8,8 @@ - - + + diff --git a/backend/tests/data/svg/datamatrix_vwsp1_bind1_dotty.svg b/backend/tests/data/svg/datamatrix_vwsp1_bind1_dotty.svg index 0c3108c9..2a1dd1d6 100644 --- a/backend/tests/data/svg/datamatrix_vwsp1_bind1_dotty.svg +++ b/backend/tests/data/svg/datamatrix_vwsp1_bind1_dotty.svg @@ -8,8 +8,8 @@ - - + + diff --git a/backend/tests/data/svg/maxicode_vwsp1_bind1.svg b/backend/tests/data/svg/maxicode_vwsp1_bind1.svg index 6aaf1974..d4d10d24 100644 --- a/backend/tests/data/svg/maxicode_vwsp1_bind1.svg +++ b/backend/tests/data/svg/maxicode_vwsp1_bind1.svg @@ -8,8 +8,8 @@ - - + + diff --git a/backend/tests/data/svg/ultra_fgbg_hvwsp2_box3.svg b/backend/tests/data/svg/ultra_fgbg_hvwsp2_box3.svg index 2c4d23b2..4f4b84b9 100644 --- a/backend/tests/data/svg/ultra_fgbg_hvwsp2_box3.svg +++ b/backend/tests/data/svg/ultra_fgbg_hvwsp2_box3.svg @@ -173,9 +173,9 @@ - - - - + + + + diff --git a/backend/tests/data/tif/ultra_fgbg_hvwsp1_box1.tif b/backend/tests/data/tif/ultra_fgbg_hvwsp1_box1.tif index c2d02c46..d199ed98 100644 Binary files a/backend/tests/data/tif/ultra_fgbg_hvwsp1_box1.tif and b/backend/tests/data/tif/ultra_fgbg_hvwsp1_box1.tif differ diff --git a/backend/tests/test_raster.c b/backend/tests/test_raster.c index c7426f5a..3ecc4498 100644 --- a/backend/tests/test_raster.c +++ b/backend/tests/test_raster.c @@ -818,60 +818,71 @@ static void test_output_options(int index, int debug) { /* 22*/ { BARCODE_QRCODE, -1, -1, 3, BARCODE_BIND, 0, 0, "A123", 0, 21, 21, 21, 42, 54, 1, 2, 2 }, /* 23*/ { BARCODE_QRCODE, -1, -1, 3, BARCODE_BIND, 0, 0, "A123", 0, 21, 21, 21, 42, 54, 0, 20, 0 }, /* 24*/ { BARCODE_QRCODE, -1, -1, 3, BARCODE_BOX, 0, 0, "A123", 0, 21, 21, 21, 54, 54, 1, 20, 0 }, - /* 25*/ { BARCODE_QRCODE, -1, -1, -1, -1, 0, 0, "A123", 0, 21, 21, 21, 42, 42, 1, 0, 0 }, - /* 26*/ { BARCODE_QRCODE, 5, -1, -1, -1, 0, 0, "A123", 0, 21, 21, 21, 62, 42, 0, 0, 0 }, - /* 27*/ { BARCODE_QRCODE, 5, -1, 6, -1, 0, 0, "A123", 0, 21, 21, 21, 62, 42, 0, 0, 0 }, - /* 28*/ { BARCODE_QRCODE, 5, -1, 6, BARCODE_BIND, 0, 0, "A123", 0, 21, 21, 21, 62, 66, 1, 0, 0 }, - /* 29*/ { BARCODE_QRCODE, 5, -1, 6, BARCODE_BIND, 0, 0, "A123", 0, 21, 21, 21, 62, 66, 0, 12, 0 }, - /* 30*/ { BARCODE_QRCODE, 5, -1, 6, BARCODE_BOX, 0, 0, "A123", 0, 21, 21, 21, 86, 66, 1, 12, 0 }, - /* 31*/ { BARCODE_QRCODE, -1, -1, -1, BARCODE_DOTTY_MODE, 0, 0, "A123", 0, 21, 21, 21, 43, 43, 1, 1, 1 }, - /* 32*/ { BARCODE_QRCODE, -1, -1, -1, BARCODE_DOTTY_MODE, 0, 0.5, "A123", 0, 21, 21, 21, 43, 43, 1, 1, 1 }, // Scale 0.5 -> 1 - /* 33*/ { BARCODE_QRCODE, -1, -1, -1, BARCODE_DOTTY_MODE, 0, 0, "A123", 0, 21, 21, 21, 43, 43, 0, 2, 2 }, - /* 34*/ { BARCODE_QRCODE, -1, -1, -1, BARCODE_DOTTY_MODE, 0, 0, "A123", 0, 21, 21, 21, 43, 43, 1, 41, 1 }, - /* 35*/ { BARCODE_QRCODE, -1, -1, -1, BARCODE_DOTTY_MODE, 0, 0, "A123", 0, 21, 21, 21, 43, 43, 0, 40, 2 }, - /* 36*/ { BARCODE_QRCODE, -1, -1, 4, BARCODE_DOTTY_MODE, 0, 0, "A123", 0, 21, 21, 21, 43, 43, 1, 1, 1 }, - /* 37*/ { BARCODE_QRCODE, -1, -1, 4, BARCODE_DOTTY_MODE, 0, 0, "A123", 0, 21, 21, 21, 43, 43, 0, 2, 2 }, - /* 38*/ { BARCODE_QRCODE, -1, -1, 4, BARCODE_BIND | BARCODE_DOTTY_MODE, 0, 0, "A123", 0, 21, 21, 21, 43, 59, 1, 2, 2 }, - /* 39*/ { BARCODE_QRCODE, -1, -1, 4, BARCODE_BOX | BARCODE_DOTTY_MODE, 0, 0, "A123", 0, 21, 21, 21, 59, 59, 1, 9, 9 }, - /* 40*/ { BARCODE_QRCODE, 1, -1, 4, BARCODE_BOX | BARCODE_DOTTY_MODE, 0, 0, "A123", 0, 21, 21, 21, 63, 59, 0, 9, 9 }, - /* 41*/ { BARCODE_QRCODE, 1, -1, 4, BARCODE_BOX | BARCODE_DOTTY_MODE, 0, 0, "A123", 0, 21, 21, 21, 63, 59, 1, 0, 0 }, - /* 42*/ { BARCODE_QRCODE, 1, -1, 4, BARCODE_BOX | BARCODE_DOTTY_MODE, 0, 0, "A123", 0, 21, 21, 21, 63, 59, 1, 9, 11 }, - /* 43*/ { BARCODE_QRCODE, 1, 1, 4, BARCODE_BOX | BARCODE_DOTTY_MODE, 0, 0, "A123", 0, 21, 21, 21, 63, 63, 0, 0, 0 }, - /* 44*/ { BARCODE_QRCODE, 1, 1, 4, BARCODE_BOX | BARCODE_DOTTY_MODE, 0, 0, "A123", 0, 21, 21, 21, 63, 63, 1, 9, 13 }, - /* 45*/ { BARCODE_QRCODE, -1, -1, -1, OUT_BUFFER_INTERMEDIATE, 0, 0, "A123", 0, 21, 21, 21, 42, 42, 1, 1, 1 }, - /* 46*/ { BARCODE_QRCODE, -1, -1, -1, OUT_BUFFER_INTERMEDIATE, 0, 0, "A123", 0, 21, 21, 21, 42, 42, 0, 2, 2 }, - /* 47*/ { BARCODE_QRCODE, -1, -1, -1, BARCODE_DOTTY_MODE | OUT_BUFFER_INTERMEDIATE, 0, 0, "A123", 0, 21, 21, 21, 43, 43, 1, 1, 1 }, - /* 48*/ { BARCODE_QRCODE, -1, -1, -1, BARCODE_DOTTY_MODE | OUT_BUFFER_INTERMEDIATE, 0, 0, "A123", 0, 21, 21, 21, 43, 43, 0, 2, 2 }, - /* 49*/ { BARCODE_QRCODE, -1, -1, -1, BARCODE_DOTTY_MODE | OUT_BUFFER_INTERMEDIATE, 180, 0, "A123", 0, 21, 21, 21, 43, 43, 1, 41, 1 }, - /* 50*/ { BARCODE_QRCODE, -1, -1, -1, BARCODE_DOTTY_MODE | OUT_BUFFER_INTERMEDIATE, 180, 0, "A123", 0, 21, 21, 21, 43, 43, 0, 40, 2 }, - /* 51*/ { BARCODE_MAXICODE, -1, -1, -1, -1, 0, 0, "A123", 0, 165, 33, 30, 299, 298, 0, 4, 4 }, - /* 52*/ { BARCODE_MAXICODE, -1, -1, -1, -1, 0, 0, "A123", 0, 165, 33, 30, 299, 298, 1, 4, 14 }, - /* 53*/ { BARCODE_MAXICODE, -1, -1, -1, -1, 270, 0, "A123", 0, 165, 33, 30, 298, 299, 1, 4, 4 }, - /* 54*/ { BARCODE_MAXICODE, -1, -1, -1, -1, 270, 0, "A123", 0, 165, 33, 30, 298, 299, 0, 4, 14 }, - /* 55*/ { BARCODE_MAXICODE, -1, -1, 5, -1, 0, 0, "A123", 0, 165, 33, 30, 299, 298, 0, 0, 0 }, - /* 56*/ { BARCODE_MAXICODE, -1, -1, 5, BARCODE_BIND, 0, 0, "A123", 0, 165, 33, 30, 299, 298 + 50 * 2, 1, 0, 0 }, - /* 57*/ { BARCODE_MAXICODE, -1, -1, 5, BARCODE_BIND, 0, 0, "A123", 0, 165, 33, 30, 299, 298 + 50 * 2, 0, 50, 0 }, - /* 58*/ { BARCODE_MAXICODE, -1, -1, 5, BARCODE_BIND, 0, 0, "A123", 0, 165, 33, 30, 299, 298 + 50 * 2, 0, 347, 50 }, - /* 59*/ { BARCODE_MAXICODE, -1, -1, 5, BARCODE_BIND, 0, 0, "A123", 0, 165, 33, 30, 299, 298 + 50 * 2, 1, 348, 50 }, - /* 60*/ { BARCODE_MAXICODE, -1, -1, 5, BARCODE_BOX, 0, 0, "A123", 0, 165, 33, 30, 299 + 50 * 2, 298 + 50 * 2, 1, 50, 0 }, - /* 61*/ { BARCODE_MAXICODE, -1, -1, 5, BARCODE_BOX, 0, 0, "A123", 0, 165, 33, 30, 299 + 50 * 2, 298 + 50 * 2, 0, 347, 50 }, - /* 62*/ { BARCODE_MAXICODE, -1, -1, -1, -1, 0, 0, "A123", 0, 165, 33, 30, 299, 298, 1, 0, 14 }, - /* 63*/ { BARCODE_MAXICODE, 6, -1, -1, -1, 0, 0, "A123", 0, 165, 33, 30, 299 + 60 * 2, 298, 0, 0, 14 }, - /* 64*/ { BARCODE_MAXICODE, 6, -1, -1, -1, 0, 0, "A123", 0, 165, 33, 30, 299 + 60 * 2, 298, 0, 0, 47 }, - /* 65*/ { BARCODE_MAXICODE, 6, -1, 5, BARCODE_BIND, 0, 0, "A123", 0, 165, 33, 30, 299 + 60 * 2, 298 + 50 * 2, 1, 0, 47 }, - /* 66*/ { BARCODE_MAXICODE, 6, -1, 5, BARCODE_BIND, 0, 0, "A123", 0, 165, 33, 30, 299 + 60 * 2, 298 + 50 * 2, 0, 50, 0 }, - /* 67*/ { BARCODE_MAXICODE, 6, -1, 5, BARCODE_BOX, 0, 0, "A123", 0, 165, 33, 30, 299 + (60 + 50) * 2, 298 + 50 * 2, 1, 50, 0 }, - /* 68*/ { BARCODE_MAXICODE, -1, -1, -1, BARCODE_DOTTY_MODE, 0, 0, "A123", ZINT_ERROR_INVALID_OPTION, -1, -1, -1, -1, -1, -1, -1, -1 }, - /* 69*/ { BARCODE_MAXICODE, -1, -1, -1, OUT_BUFFER_INTERMEDIATE, 0, 0, "A123", 0, 165, 33, 30, 299, 298, 0, 4, 4 }, - /* 70*/ { BARCODE_MAXICODE, -1, -1, -1, OUT_BUFFER_INTERMEDIATE, 0, 0, "A123", 0, 165, 33, 30, 299, 298, 1, 4, 14 }, - /* 71*/ { BARCODE_MAXICODE, -1, -1, -1, OUT_BUFFER_INTERMEDIATE, 270, 0, "A123", 0, 165, 33, 30, 298, 299, 1, 4, 4 }, - /* 72*/ { BARCODE_MAXICODE, -1, -1, -1, OUT_BUFFER_INTERMEDIATE, 270, 0, "A123", 0, 165, 33, 30, 298, 299, 0, 4, 14 }, - /* 73*/ { BARCODE_ITF14, -1, -1, -1, -1, 0, 0, "123", 0, 50, 1, 135, 330, 136, 1, 110, 0 }, - /* 74*/ { BARCODE_ITF14, -1, -1, -1, -1, 90, 0, "123", 0, 50, 1, 135, 136, 330, 1, 0, 110 }, - /* 75*/ { BARCODE_ITF14, -1, -1, 0, -1, 0, 0, "123", 0, 50, 1, 135, 330, 136, 1, 110, 0 }, - /* 76*/ { BARCODE_ITF14, -1, -1, 0, BARCODE_BOX, 0, 0, "123", 0, 50, 1, 135, 310, 116, 0, 100, 0 }, - /* 77*/ { BARCODE_ITF14, -1, -1, -1, OUT_BUFFER_INTERMEDIATE, 0, 0, "123", 0, 50, 1, 135, 330, 136, 1, 110, 0 }, - /* 78*/ { BARCODE_ITF14, -1, -1, -1, OUT_BUFFER_INTERMEDIATE, 90, 0, "123", 0, 50, 1, 135, 136, 330, 1, 0, 110 }, + /* 25*/ { BARCODE_QRCODE, -1, -1, 3, BARCODE_BIND, 0, 0, "A123", 0, 21, 21, 21, 42, 54, 1, 6, 0 }, + /* 26*/ { BARCODE_QRCODE, -1, -1, 3, BARCODE_BIND | BARCODE_QUIET_ZONES, 0, 0, "A123", 0, 21, 21, 21, 58, 70, 0, 6, 0 }, + /* 27*/ { BARCODE_QRCODE, -1, -1, 3, BARCODE_BOX | BARCODE_QUIET_ZONES, 0, 0, "A123", 0, 21, 21, 21, 70, 70, 1, 6, 0 }, + /* 28*/ { BARCODE_QRCODE, -1, -1, -1, -1, 0, 0, "A123", 0, 21, 21, 21, 42, 42, 1, 0, 0 }, + /* 29*/ { BARCODE_QRCODE, 5, -1, -1, -1, 0, 0, "A123", 0, 21, 21, 21, 62, 42, 0, 0, 0 }, + /* 30*/ { BARCODE_QRCODE, 5, -1, 6, -1, 0, 0, "A123", 0, 21, 21, 21, 62, 42, 0, 0, 0 }, + /* 31*/ { BARCODE_QRCODE, 5, -1, 6, BARCODE_BIND, 0, 0, "A123", 0, 21, 21, 21, 62, 66, 1, 0, 0 }, + /* 32*/ { BARCODE_QRCODE, 5, -1, 6, BARCODE_BIND, 0, 0, "A123", 0, 21, 21, 21, 62, 66, 0, 12, 0 }, + /* 33*/ { BARCODE_QRCODE, 5, -1, 6, BARCODE_BOX, 0, 0, "A123", 0, 21, 21, 21, 86, 66, 1, 12, 0 }, + /* 34*/ { BARCODE_QRCODE, 5, -1, 6, BARCODE_BIND, 0, 0, "A123", 0, 21, 21, 21, 62, 66, 1, 12, 10 }, + /* 35*/ { BARCODE_QRCODE, 5, -1, 6, BARCODE_BIND | BARCODE_QUIET_ZONES, 0, 0, "A123", 0, 21, 21, 21, 78, 82, 0, 12, 10 }, + /* 36*/ { BARCODE_QRCODE, 5, -1, 6, BARCODE_BIND | BARCODE_QUIET_ZONES, 0, 0, "A123", 0, 21, 21, 21, 78, 82, 1, 20, 19 }, + /* 37*/ { BARCODE_QRCODE, 5, -1, 6, BARCODE_BOX | BARCODE_QUIET_ZONES, 0, 0, "A123", 0, 21, 21, 21, 102, 82, 0, 20, 19 }, + /* 38*/ { BARCODE_QRCODE, -1, -1, -1, BARCODE_DOTTY_MODE, 0, 0, "A123", 0, 21, 21, 21, 43, 43, 1, 1, 1 }, + /* 39*/ { BARCODE_QRCODE, -1, -1, -1, BARCODE_DOTTY_MODE, 0, 0.5, "A123", 0, 21, 21, 21, 43, 43, 1, 1, 1 }, // Scale 0.5 -> 1 + /* 40*/ { BARCODE_QRCODE, -1, -1, -1, BARCODE_DOTTY_MODE, 0, 0, "A123", 0, 21, 21, 21, 43, 43, 0, 2, 2 }, + /* 41*/ { BARCODE_QRCODE, -1, -1, -1, BARCODE_DOTTY_MODE, 0, 0, "A123", 0, 21, 21, 21, 43, 43, 1, 41, 1 }, + /* 42*/ { BARCODE_QRCODE, -1, -1, -1, BARCODE_DOTTY_MODE, 0, 0, "A123", 0, 21, 21, 21, 43, 43, 0, 40, 2 }, + /* 43*/ { BARCODE_QRCODE, -1, -1, 4, BARCODE_DOTTY_MODE, 0, 0, "A123", 0, 21, 21, 21, 43, 43, 1, 1, 1 }, + /* 44*/ { BARCODE_QRCODE, -1, -1, 4, BARCODE_DOTTY_MODE, 0, 0, "A123", 0, 21, 21, 21, 43, 43, 0, 2, 2 }, + /* 45*/ { BARCODE_QRCODE, -1, -1, 4, BARCODE_BIND | BARCODE_DOTTY_MODE, 0, 0, "A123", 0, 21, 21, 21, 43, 59, 1, 2, 2 }, + /* 46*/ { BARCODE_QRCODE, -1, -1, 4, BARCODE_BOX | BARCODE_DOTTY_MODE, 0, 0, "A123", 0, 21, 21, 21, 59, 59, 1, 9, 9 }, + /* 47*/ { BARCODE_QRCODE, 1, -1, 4, BARCODE_BOX | BARCODE_DOTTY_MODE, 0, 0, "A123", 0, 21, 21, 21, 63, 59, 0, 9, 9 }, + /* 48*/ { BARCODE_QRCODE, 1, -1, 4, BARCODE_BOX | BARCODE_DOTTY_MODE, 0, 0, "A123", 0, 21, 21, 21, 63, 59, 1, 0, 0 }, + /* 49*/ { BARCODE_QRCODE, 1, -1, 4, BARCODE_BOX | BARCODE_DOTTY_MODE, 0, 0, "A123", 0, 21, 21, 21, 63, 59, 0, 8, 11 }, + /* 50*/ { BARCODE_QRCODE, 1, -1, 4, BARCODE_BOX | BARCODE_DOTTY_MODE, 0, 0, "A123", 0, 21, 21, 21, 63, 59, 1, 9, 11 }, + /* 51*/ { BARCODE_QRCODE, 1, 1, 4, BARCODE_BOX | BARCODE_DOTTY_MODE, 0, 0, "A123", 0, 21, 21, 21, 63, 63, 0, 8, 11 }, + /* 52*/ { BARCODE_QRCODE, 1, 1, 4, BARCODE_BOX | BARCODE_DOTTY_MODE, 0, 0, "A123", 0, 21, 21, 21, 63, 63, 0, 9, 11 }, + /* 53*/ { BARCODE_QRCODE, 1, 1, 4, BARCODE_BOX | BARCODE_DOTTY_MODE, 0, 0, "A123", 0, 21, 21, 21, 63, 63, 1, 11, 11 }, + /* 54*/ { BARCODE_QRCODE, -1, -1, -1, OUT_BUFFER_INTERMEDIATE, 0, 0, "A123", 0, 21, 21, 21, 42, 42, 1, 1, 1 }, + /* 55*/ { BARCODE_QRCODE, -1, -1, -1, OUT_BUFFER_INTERMEDIATE, 0, 0, "A123", 0, 21, 21, 21, 42, 42, 0, 2, 2 }, + /* 56*/ { BARCODE_QRCODE, -1, -1, -1, BARCODE_DOTTY_MODE | OUT_BUFFER_INTERMEDIATE, 0, 0, "A123", 0, 21, 21, 21, 43, 43, 1, 1, 1 }, + /* 57*/ { BARCODE_QRCODE, -1, -1, -1, BARCODE_DOTTY_MODE | OUT_BUFFER_INTERMEDIATE, 0, 0, "A123", 0, 21, 21, 21, 43, 43, 0, 2, 2 }, + /* 58*/ { BARCODE_QRCODE, -1, -1, -1, BARCODE_DOTTY_MODE | OUT_BUFFER_INTERMEDIATE, 180, 0, "A123", 0, 21, 21, 21, 43, 43, 1, 41, 1 }, + /* 59*/ { BARCODE_QRCODE, -1, -1, -1, BARCODE_DOTTY_MODE | OUT_BUFFER_INTERMEDIATE, 180, 0, "A123", 0, 21, 21, 21, 43, 43, 0, 40, 2 }, + /* 60*/ { BARCODE_MAXICODE, -1, -1, -1, -1, 0, 0, "A123", 0, 165, 33, 30, 299, 298, 0, 4, 4 }, + /* 61*/ { BARCODE_MAXICODE, -1, -1, -1, -1, 0, 0, "A123", 0, 165, 33, 30, 299, 298, 1, 4, 14 }, + /* 62*/ { BARCODE_MAXICODE, -1, -1, -1, -1, 270, 0, "A123", 0, 165, 33, 30, 298, 299, 1, 4, 4 }, + /* 63*/ { BARCODE_MAXICODE, -1, -1, -1, -1, 270, 0, "A123", 0, 165, 33, 30, 298, 299, 0, 4, 14 }, + /* 64*/ { BARCODE_MAXICODE, -1, -1, 5, -1, 0, 0, "A123", 0, 165, 33, 30, 299, 298, 0, 0, 0 }, + /* 65*/ { BARCODE_MAXICODE, -1, -1, 5, BARCODE_BIND, 0, 0, "A123", 0, 165, 33, 30, 299, 298 + 50 * 2, 1, 0, 0 }, + /* 66*/ { BARCODE_MAXICODE, -1, -1, 5, BARCODE_BIND, 0, 0, "A123", 0, 165, 33, 30, 299, 298 + 50 * 2, 0, 50, 0 }, + /* 67*/ { BARCODE_MAXICODE, -1, -1, 5, BARCODE_BIND, 0, 0, "A123", 0, 165, 33, 30, 299, 298 + 50 * 2, 0, 347, 50 }, + /* 68*/ { BARCODE_MAXICODE, -1, -1, 5, BARCODE_BIND, 0, 0, "A123", 0, 165, 33, 30, 299, 298 + 50 * 2, 1, 348, 50 }, + /* 69*/ { BARCODE_MAXICODE, -1, -1, 5, BARCODE_BOX, 0, 0, "A123", 0, 165, 33, 30, 299 + 50 * 2, 298 + 50 * 2, 1, 50, 0 }, + /* 70*/ { BARCODE_MAXICODE, -1, -1, 5, BARCODE_BOX, 0, 0, "A123", 0, 165, 33, 30, 299 + 50 * 2, 298 + 50 * 2, 0, 347, 50 }, + /* 71*/ { BARCODE_MAXICODE, -1, -1, 5, BARCODE_BIND, 0, 0, "A123", 0, 165, 33, 30, 299, 298 + 50 * 2, 1, 50, 15 }, + /* 72*/ { BARCODE_MAXICODE, -1, -1, 5, BARCODE_BIND | BARCODE_QUIET_ZONES, 0, 0, "A123", 0, 165, 33, 30, 299 + 10 * 2, 298 + (50 + 10) * 2, 0, 50, 15 }, + /* 73*/ { BARCODE_MAXICODE, -1, -1, -1, -1, 0, 0, "A123", 0, 165, 33, 30, 299, 298, 1, 0, 14 }, + /* 74*/ { BARCODE_MAXICODE, 6, -1, -1, -1, 0, 0, "A123", 0, 165, 33, 30, 299 + 60 * 2, 298, 0, 0, 14 }, + /* 75*/ { BARCODE_MAXICODE, 6, -1, -1, -1, 0, 0, "A123", 0, 165, 33, 30, 299 + 60 * 2, 298, 0, 0, 47 }, + /* 76*/ { BARCODE_MAXICODE, 6, -1, 5, BARCODE_BIND, 0, 0, "A123", 0, 165, 33, 30, 299 + 60 * 2, 298 + 50 * 2, 1, 0, 47 }, + /* 77*/ { BARCODE_MAXICODE, 6, -1, 5, BARCODE_BIND, 0, 0, "A123", 0, 165, 33, 30, 299 + 60 * 2, 298 + 50 * 2, 0, 50, 0 }, + /* 78*/ { BARCODE_MAXICODE, 6, -1, 5, BARCODE_BOX, 0, 0, "A123", 0, 165, 33, 30, 299 + (60 + 50) * 2, 298 + 50 * 2, 1, 50, 0 }, + /* 79*/ { BARCODE_MAXICODE, -1, -1, -1, BARCODE_DOTTY_MODE, 0, 0, "A123", ZINT_ERROR_INVALID_OPTION, -1, -1, -1, -1, -1, -1, -1, -1 }, + /* 80*/ { BARCODE_MAXICODE, -1, -1, -1, OUT_BUFFER_INTERMEDIATE, 0, 0, "A123", 0, 165, 33, 30, 299, 298, 0, 4, 4 }, + /* 81*/ { BARCODE_MAXICODE, -1, -1, -1, OUT_BUFFER_INTERMEDIATE, 0, 0, "A123", 0, 165, 33, 30, 299, 298, 1, 4, 14 }, + /* 82*/ { BARCODE_MAXICODE, -1, -1, -1, OUT_BUFFER_INTERMEDIATE, 270, 0, "A123", 0, 165, 33, 30, 298, 299, 1, 4, 4 }, + /* 83*/ { BARCODE_MAXICODE, -1, -1, -1, OUT_BUFFER_INTERMEDIATE, 270, 0, "A123", 0, 165, 33, 30, 298, 299, 0, 4, 14 }, + /* 84*/ { BARCODE_ITF14, -1, -1, -1, -1, 0, 0, "123", 0, 50, 1, 135, 330, 136, 1, 110, 0 }, + /* 85*/ { BARCODE_ITF14, -1, -1, -1, -1, 90, 0, "123", 0, 50, 1, 135, 136, 330, 1, 0, 110 }, + /* 86*/ { BARCODE_ITF14, -1, -1, 0, -1, 0, 0, "123", 0, 50, 1, 135, 330, 136, 1, 110, 0 }, + /* 87*/ { BARCODE_ITF14, -1, -1, 0, BARCODE_BOX, 0, 0, "123", 0, 50, 1, 135, 310, 116, 0, 100, 0 }, + /* 88*/ { BARCODE_ITF14, -1, -1, -1, OUT_BUFFER_INTERMEDIATE, 0, 0, "123", 0, 50, 1, 135, 330, 136, 1, 110, 0 }, + /* 89*/ { BARCODE_ITF14, -1, -1, -1, OUT_BUFFER_INTERMEDIATE, 90, 0, "123", 0, 50, 1, 135, 136, 330, 1, 0, 110 }, }; int data_size = ARRAY_SIZE(data); int i, length, ret; diff --git a/backend/tests/test_vector.c b/backend/tests/test_vector.c index acc357ab..ab283458 100644 --- a/backend/tests/test_vector.c +++ b/backend/tests/test_vector.c @@ -656,28 +656,36 @@ static void test_output_options(int index, int debug) { /* 18*/ { BARCODE_QRCODE, -1, -1, 3, BARCODE_BIND, "A123", 0, 21, 21, 21, 42, 54, 1, 0, 6 }, /* 19*/ { BARCODE_QRCODE, -1, -1, 3, BARCODE_BIND, "A123", 0, 21, 21, 21, 42, 54, 0, 22, 8 }, /* 20*/ { BARCODE_QRCODE, -1, -1, 3, BARCODE_BOX, "A123", 0, 21, 21, 21, 54, 54, 1, 22, 8 }, - /* 21*/ { BARCODE_QRCODE, -1, -1, -1, -1, "A123", 0, 21, 21, 21, 42, 42, 0, 10, 12 }, - /* 22*/ { BARCODE_QRCODE, 5, -1, 6, BARCODE_BIND, "A123", 0, 21, 21, 21, 62, 66, 1, 10, 12 }, - /* 23*/ { BARCODE_QRCODE, 5, -1, 6, BARCODE_BIND, "A123", 0, 21, 21, 21, 62, 66, 0, 22, 12 }, - /* 24*/ { BARCODE_QRCODE, 5, -1, 6, BARCODE_BOX, "A123", 0, 21, 21, 21, 86, 66, 1, 22, 12 }, - /* 25*/ { BARCODE_QRCODE, -1, -1, -1, BARCODE_DOTTY_MODE, "A123", 0, 21, 21, 21, 42, 42, 0, 0, 50 }, - /* 26*/ { BARCODE_QRCODE, -1, -1, 4, BARCODE_DOTTY_MODE, "A123", 0, 21, 21, 21, 42, 42, 0, 0, 50 }, - /* 27*/ { BARCODE_QRCODE, -1, -1, 4, BARCODE_BIND | BARCODE_DOTTY_MODE, "A123", 0, 21, 21, 21, 42, 58, 1, 0, 50 }, - /* 28*/ { BARCODE_QRCODE, -1, -1, 4, BARCODE_BIND | BARCODE_DOTTY_MODE, "A123", 0, 21, 21, 21, 42, 58, 0, 54, 8 }, - /* 29*/ { BARCODE_QRCODE, 1, -1, 4, BARCODE_BOX | BARCODE_DOTTY_MODE, "A123", 0, 21, 21, 21, 62, 58, 1, 54, 8 }, - /* 30*/ { BARCODE_MAXICODE, -1, -1, -1, -1, "A123", 0, 165, 33, 30, 60, 57.733398, 0, 0, 67.7334 }, - /* 31*/ { BARCODE_MAXICODE, -1, -1, 5, -1, "A123", 0, 165, 33, 30, 60, 57.733398, 0, 0, 67.7334 }, - /* 32*/ { BARCODE_MAXICODE, -1, -1, 5, BARCODE_BIND, "A123", 0, 165, 33, 30, 60, 77.733398, 1, 0, 67.7334 }, - /* 33*/ { BARCODE_MAXICODE, -1, -1, 5, BARCODE_BIND, "A123", 0, 165, 33, 30, 60, 77.733398, 0, 70, 10 }, - /* 34*/ { BARCODE_MAXICODE, -1, -1, 5, BARCODE_BOX, "A123", 0, 165, 33, 30, 80, 77.733398, 1, 70, 10 }, - /* 35*/ { BARCODE_MAXICODE, -1, -1, -1, -1, "A123", 0, 165, 33, 30, 60, 57.733398, 0, 0, 67.7334 }, - /* 36*/ { BARCODE_MAXICODE, 6, -1, 5, BARCODE_BIND, "A123", 0, 165, 33, 30, 84, 77.733398, 1, 0, 67.7334 }, - /* 37*/ { BARCODE_MAXICODE, 6, -1, 5, BARCODE_BIND, "A123", 0, 165, 33, 30, 84, 77.733398, 0, 94, 10 }, - /* 38*/ { BARCODE_MAXICODE, 6, -1, 5, BARCODE_BOX, "A123", 0, 165, 33, 30, 104, 77.733398, 1, 94, 10 }, - /* 39*/ { BARCODE_MAXICODE, -1, -1, -1, BARCODE_DOTTY_MODE, "A123", ZINT_ERROR_INVALID_OPTION, -1, -1, -1, -1, -1, -1, -1, -1 }, - /* 40*/ { BARCODE_ITF14, -1, -1, -1, -1, "123", 0, 50, 1, 135, 330, 138.89999, 1, 320, 10 }, - /* 41*/ { BARCODE_ITF14, -1, -1, 0, -1, "123", 0, 50, 1, 135, 330, 138.89999, 1, 320, 10 }, - /* 42*/ { BARCODE_ITF14, -1, -1, 0, BARCODE_BOX, "123", 0, 50, 1, 135, 310, 118.9, 0, 300, 0 }, // No zero-width/height rectangles + /* 21*/ { BARCODE_QRCODE, -1, -1, 3, BARCODE_BIND | BARCODE_QUIET_ZONES, "A123", 0, 21, 21, 21, 58, 70, 0, 0, 6 }, + /* 22*/ { BARCODE_QRCODE, -1, -1, 3, BARCODE_BIND | BARCODE_QUIET_ZONES, "A123", 0, 21, 21, 21, 58, 70, 1, 0, 0 }, + /* 23*/ { BARCODE_QRCODE, -1, -1, 3, BARCODE_BOX | BARCODE_QUIET_ZONES, "A123", 0, 21, 21, 21, 70, 70, 0, 22, 8 }, + /* 24*/ { BARCODE_QRCODE, -1, -1, 3, BARCODE_BOX | BARCODE_QUIET_ZONES, "A123", 0, 21, 21, 21, 70, 70, 1, 30, 16 }, + /* 25*/ { BARCODE_QRCODE, -1, -1, -1, -1, "A123", 0, 21, 21, 21, 42, 42, 0, 10, 12 }, + /* 26*/ { BARCODE_QRCODE, 5, -1, 6, BARCODE_BIND, "A123", 0, 21, 21, 21, 62, 66, 1, 10, 12 }, + /* 27*/ { BARCODE_QRCODE, 5, -1, 6, BARCODE_BIND, "A123", 0, 21, 21, 21, 62, 66, 0, 22, 12 }, + /* 28*/ { BARCODE_QRCODE, 5, -1, 6, BARCODE_BOX, "A123", 0, 21, 21, 21, 86, 66, 1, 22, 12 }, + /* 29*/ { BARCODE_QRCODE, 5, -1, 6, BARCODE_BIND | BARCODE_QUIET_ZONES, "A123", 0, 21, 21, 21, 78, 82, 0, 10, 12 }, + /* 30*/ { BARCODE_QRCODE, 5, -1, 6, BARCODE_BIND | BARCODE_QUIET_ZONES, "A123", 0, 21, 21, 21, 78, 82, 1, 18, 20 }, + /* 31*/ { BARCODE_QRCODE, -1, -1, -1, BARCODE_DOTTY_MODE, "A123", 0, 21, 21, 21, 42, 42, 0, 0, 50 }, + /* 32*/ { BARCODE_QRCODE, -1, -1, 4, BARCODE_DOTTY_MODE, "A123", 0, 21, 21, 21, 42, 42, 0, 0, 50 }, + /* 33*/ { BARCODE_QRCODE, -1, -1, 4, BARCODE_BIND | BARCODE_DOTTY_MODE, "A123", 0, 21, 21, 21, 42, 58, 1, 0, 50 }, + /* 34*/ { BARCODE_QRCODE, -1, -1, 4, BARCODE_BIND | BARCODE_DOTTY_MODE, "A123", 0, 21, 21, 21, 42, 58, 0, 54, 8 }, + /* 35*/ { BARCODE_QRCODE, 1, -1, 4, BARCODE_BOX | BARCODE_DOTTY_MODE, "A123", 0, 21, 21, 21, 62, 58, 1, 54, 8 }, + /* 36*/ { BARCODE_MAXICODE, -1, -1, -1, -1, "A123", 0, 165, 33, 30, 60, 57.733398, 0, 0, 67.7334 }, + /* 37*/ { BARCODE_MAXICODE, -1, -1, 5, -1, "A123", 0, 165, 33, 30, 60, 57.733398, 0, 0, 67.7334 }, + /* 38*/ { BARCODE_MAXICODE, -1, -1, 5, BARCODE_BIND, "A123", 0, 165, 33, 30, 60, 77.733398, 1, 0, 67.7334 }, + /* 39*/ { BARCODE_MAXICODE, -1, -1, 5, BARCODE_BIND, "A123", 0, 165, 33, 30, 60, 77.733398, 0, 70, 10 }, + /* 40*/ { BARCODE_MAXICODE, -1, -1, 5, BARCODE_BOX, "A123", 0, 165, 33, 30, 80, 77.733398, 1, 70, 10 }, + /* 41*/ { BARCODE_MAXICODE, -1, -1, 5, BARCODE_BIND | BARCODE_QUIET_ZONES, "A123", 0, 165, 33, 30, 64, 81.733398, 0, 0, 67.7334 }, + /* 42*/ { BARCODE_MAXICODE, -1, -1, 5, BARCODE_BIND | BARCODE_QUIET_ZONES, "A123", 0, 165, 33, 30, 64, 81.733398, 1, 0, 71.7334 }, + /* 43*/ { BARCODE_MAXICODE, -1, -1, -1, -1, "A123", 0, 165, 33, 30, 60, 57.733398, 0, 0, 67.7334 }, + /* 44*/ { BARCODE_MAXICODE, 6, -1, 5, BARCODE_BIND, "A123", 0, 165, 33, 30, 84, 77.733398, 1, 0, 67.7334 }, + /* 45*/ { BARCODE_MAXICODE, 6, -1, 5, BARCODE_BIND, "A123", 0, 165, 33, 30, 84, 77.733398, 0, 94, 10 }, + /* 46*/ { BARCODE_MAXICODE, 6, -1, 5, BARCODE_BOX, "A123", 0, 165, 33, 30, 104, 77.733398, 1, 94, 10 }, + /* 47*/ { BARCODE_MAXICODE, -1, -1, -1, BARCODE_DOTTY_MODE, "A123", ZINT_ERROR_INVALID_OPTION, -1, -1, -1, -1, -1, -1, -1, -1 }, + /* 48*/ { BARCODE_ITF14, -1, -1, -1, -1, "123", 0, 50, 1, 135, 330, 138.89999, 1, 320, 10 }, + /* 49*/ { BARCODE_ITF14, -1, -1, 0, -1, "123", 0, 50, 1, 135, 330, 138.89999, 1, 320, 10 }, + /* 50*/ { BARCODE_ITF14, -1, -1, 0, BARCODE_BOX, "123", 0, 50, 1, 135, 310, 118.9, 0, 300, 0 }, // No zero-width/height rectangles }; int data_size = ARRAY_SIZE(data); int i, length, ret; diff --git a/backend/vector.c b/backend/vector.c index 193b8829..9900047b 100644 --- a/backend/vector.c +++ b/backend/vector.c @@ -878,42 +878,50 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_ } // Bind/box - if (symbol->border_width > 0) { - if (symbol->output_options & (BARCODE_BOX | BARCODE_BIND)) { - const float ybind_top = yoffset - symbol->border_width; - // Following equivalent to yoffset + symbol->height + dot_overspill except for BARCODE_MAXICODE - const float ybind_bot = vector->height - textoffset - boffset; - // Top - rect = vector_plot_create_rect(symbol, 0.0f, ybind_top, vector->width, symbol->border_width); - if (!rect) return ZINT_ERROR_MEMORY; - if (!(symbol->output_options & BARCODE_BOX) - && (symbol->symbology == BARCODE_CODABLOCKF || symbol->symbology == BARCODE_HIBC_BLOCKF)) { - /* CodaBlockF bind - does not extend over horizontal whitespace */ - rect->x = xoffset; - rect->width -= xoffset + roffset; - } - vector_plot_add_rect(symbol, rect, &last_rectangle); - // Bottom - rect = vector_plot_create_rect(symbol, 0.0f, ybind_bot, vector->width, symbol->border_width); - if (!rect) return ZINT_ERROR_MEMORY; - if (!(symbol->output_options & BARCODE_BOX) - && (symbol->symbology == BARCODE_CODABLOCKF || symbol->symbology == BARCODE_HIBC_BLOCKF)) { - /* CodaBlockF bind - does not extend over horizontal whitespace */ - rect->x = xoffset; - rect->width -= xoffset + roffset; - } - vector_plot_add_rect(symbol, rect, &last_rectangle); + if (symbol->border_width > 0 && (symbol->output_options & (BARCODE_BOX | BARCODE_BIND))) { + const int horz_outside = is_fixed_ratio(symbol->symbology); + float ybind_top = yoffset - symbol->border_width; + // Following equivalent to yoffset + symbol->height + dot_overspill except for BARCODE_MAXICODE + float ybind_bot = vector->height - textoffset - boffset; + if (horz_outside) { + ybind_top = 0; + ybind_bot = vector->height - symbol->border_width; } + // Top + rect = vector_plot_create_rect(symbol, 0.0f, ybind_top, vector->width, symbol->border_width); + if (!rect) return ZINT_ERROR_MEMORY; + if (!(symbol->output_options & BARCODE_BOX) + && (symbol->symbology == BARCODE_CODABLOCKF || symbol->symbology == BARCODE_HIBC_BLOCKF)) { + /* CodaBlockF bind - does not extend over horizontal whitespace */ + rect->x = xoffset; + rect->width -= xoffset + roffset; + } + vector_plot_add_rect(symbol, rect, &last_rectangle); + // Bottom + rect = vector_plot_create_rect(symbol, 0.0f, ybind_bot, vector->width, symbol->border_width); + if (!rect) return ZINT_ERROR_MEMORY; + if (!(symbol->output_options & BARCODE_BOX) + && (symbol->symbology == BARCODE_CODABLOCKF || symbol->symbology == BARCODE_HIBC_BLOCKF)) { + /* CodaBlockF bind - does not extend over horizontal whitespace */ + rect->x = xoffset; + rect->width -= xoffset + roffset; + } + vector_plot_add_rect(symbol, rect, &last_rectangle); if (symbol->output_options & BARCODE_BOX) { const float xbox_right = vector->width - symbol->border_width; + float box_top = yoffset; // Following equivalent to symbol->height except for BARCODE_MAXICODE - const float box_height = vector->height - textoffset - dot_overspill - yoffset - boffset; + float box_height = vector->height - textoffset - dot_overspill - yoffset - boffset; + if (horz_outside) { + box_top = symbol->border_width; + box_height = vector->height - symbol->border_width * 2; + } // Left - rect = vector_plot_create_rect(symbol, 0.0f, yoffset, symbol->border_width, box_height); + rect = vector_plot_create_rect(symbol, 0.0f, box_top, symbol->border_width, box_height); if (!rect) return ZINT_ERROR_MEMORY; vector_plot_add_rect(symbol, rect, &last_rectangle); // Right - rect = vector_plot_create_rect(symbol, xbox_right, yoffset, symbol->border_width, box_height); + rect = vector_plot_create_rect(symbol, xbox_right, box_top, symbol->border_width, box_height); if (!rect) return ZINT_ERROR_MEMORY; vector_plot_add_rect(symbol, rect, &last_rectangle); } diff --git a/docs/manual.txt b/docs/manual.txt index d6e68538..409a1034 100644 --- a/docs/manual.txt +++ b/docs/manual.txt @@ -471,7 +471,7 @@ symbol by corrupting a scan if the scanning beam strays off the top or bottom of the symbol. Zint can also put a border right around the symbol and its horizontal whitespace with the --box option. -The width of the boundary or box can be specified using the --border switch. +The width of the boundary or box must be specified using the --border switch. For example: zint --box --border=10 -w 10 -d "This" @@ -480,6 +480,11 @@ gives a box with a width 10 times the X-dimension of the symbol. Note that when specifying a box, horizontal whitespace is usually required in order to create a quiet zone between the barcode and the sides of the box. +For linear symbols, horizontal boundary bars appear tight against the barcode, +inside any vertical whitespace (or text). For matrix symbols, however, where +they are decorative rather than functional, boundary bars appear outside any +whitespace. + Codablock-F, Code 16K and Code 49 always have boundary bars, and default to particular horizontal whitespace values. Special considerations apply to ITF-14 - see the specific section 6.1.2.6 for that symbology.