diff --git a/backend/output.c b/backend/output.c index 1426ec98..a8534b3f 100644 --- a/backend/output.c +++ b/backend/output.c @@ -1,7 +1,7 @@ /* output.c - Common routines for raster/vector libzint - the open source barcode library - Copyright (C) 2020 Robin Stuart + Copyright (C) 2020 - 2021 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -418,8 +418,8 @@ INTERNAL void output_set_whitespace_offsets(struct zint_symbol *symbol, int *xof *roffset += symbol->border_width; } - *yoffset = qz_top; - *boffset = qz_bottom; + *yoffset = symbol->whitespace_height + qz_top; + *boffset = symbol->whitespace_height + qz_bottom; if (symbol->output_options & (BARCODE_BOX | BARCODE_BIND)) { *yoffset += symbol->border_width; *boffset += symbol->border_width; diff --git a/backend/raster.c b/backend/raster.c index 49ff13a9..5f9d1d38 100644 --- a/backend/raster.c +++ b/backend/raster.c @@ -733,21 +733,22 @@ static int plot_raster_maxicode(struct zint_symbol *symbol, const int rotate_ang draw_bullseye(pixelbuf, image_width, image_height, hex_width, hex_height, hx_start, hx_end, hex_image_height, xoffset, yoffset, scaler); - if (symbol->border_width > 0) { + if (symbol->border_width > 0 && (symbol->output_options & (BARCODE_BOX | BARCODE_BIND))) { + /* boundary bars */ const int border_scaled = (int) floorf(symbol->border_width * scaler); - if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) { - /* boundary bars */ - draw_bar(pixelbuf, 0, image_width, 0, border_scaled, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, 0, image_width, hex_image_height + border_scaled, border_scaled, image_width, - image_height, DEFAULT_INK); - } + const int vwhitesp_scaled = (int) floorf(symbol->whitespace_height * scaler); + const int ybind_top = hex_image_height + border_scaled + vwhitesp_scaled; + draw_bar(pixelbuf, 0, image_width, vwhitesp_scaled, border_scaled, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, 0, image_width, ybind_top, border_scaled, image_width, image_height, DEFAULT_INK); if (symbol->output_options & BARCODE_BOX) { /* side bars */ const int whitesp_scaled = (int) floorf(symbol->whitespace_width * scaler); - draw_bar(pixelbuf, 0, border_scaled, 0, image_height, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, hex_image_width + border_scaled + whitesp_scaled * 2, border_scaled, 0, image_height, - image_width, image_height, DEFAULT_INK); + const int xbox_right = hex_image_width + border_scaled + whitesp_scaled * 2; + const int ybox_top = border_scaled + vwhitesp_scaled; + const int ylen = image_height - (border_scaled + vwhitesp_scaled) * 2; + draw_bar(pixelbuf, 0, border_scaled, ybox_top, ylen, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, xbox_right, border_scaled, ybox_top, ylen, image_width, image_height, DEFAULT_INK); } } @@ -767,6 +768,38 @@ static int plot_raster_maxicode(struct zint_symbol *symbol, const int rotate_ang return error_number; } +/* Draw binding or box */ +static void draw_bind_box(struct zint_symbol *symbol, unsigned char *pixelbuf, const int xoffset, const int roffset, + const int textoffset, const int overspill_scaled, 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 bwidth = symbol->border_width * si; + const int ybind_bottom = (textoffset + symbol->whitespace_height) * si; + const int ybind_top = (textoffset + symbol->whitespace_height + symbol->height) * si + overspill_scaled + bwidth; + /* Horizontal boundary bars */ + if ((symbol->output_options & BARCODE_BOX) + || (symbol->symbology != BARCODE_CODABLOCKF && symbol->symbology != BARCODE_HIBC_BLOCKF)) { + /* Box or not CodaBlockF */ + const int xlen = (symbol->width + xoffset + roffset) * si + overspill_scaled; + draw_bar(pixelbuf, 0, xlen, ybind_bottom, bwidth, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, 0, xlen, ybind_top, bwidth, image_width, image_height, DEFAULT_INK); + } else { + /* CodaBlockF bind - does not extend over horizontal whitespace */ + const int xlen = symbol->width * si; + draw_bar(pixelbuf, xoffset * si, xlen, ybind_bottom, bwidth, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, xoffset * si, xlen, ybind_top, bwidth, image_width, image_height, DEFAULT_INK); + } + if (symbol->output_options & BARCODE_BOX) { + /* Vertical side bars */ + const int ylen = (symbol->height + symbol->border_width * 2) * si; + const int ybox = (textoffset + symbol->whitespace_height) * si; + const int xbox_right = (symbol->width + xoffset + roffset - symbol->border_width) * si + overspill_scaled; + draw_bar(pixelbuf, 0, bwidth, ybox, ylen, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, xbox_right, bwidth, ybox, ylen, image_width, image_height, DEFAULT_INK); + } + } +} + static int plot_raster_dotty(struct zint_symbol *symbol, const int rotate_angle, const int file_type) { float scaler = 2 * symbol->scale; unsigned char *scaled_pixelbuf; @@ -824,7 +857,8 @@ static int plot_raster_dotty(struct zint_symbol *symbol, const int rotate_angle, } } - // TODO: bind/box + draw_bind_box(symbol, scaled_pixelbuf, xoffset, roffset, 0 /*textoffset*/, dot_overspill_scaled, + scale_width, scale_height, (int) floorf(scaler)); error_number = save_raster_image_to_file(symbol, scale_height, scale_width, scaled_pixelbuf, rotate_angle, file_type); if (rotate_angle || file_type != OUT_BUFFER || !(symbol->output_options & OUT_BUFFER_INTERMEDIATE)) { @@ -967,7 +1001,7 @@ static int plot_raster_default(struct zint_symbol *symbol, const int rotate_angl } memset(pixelbuf, DEFAULT_PAPER, (size_t) image_width * image_height); - default_text_posn = image_height - (textoffset - text_gap) * si; + default_text_posn = image_height - (textoffset - text_gap + symbol->whitespace_height) * si; row_height = 0.0f; row_posn = textoffset + boffset; /* Bottom up */ @@ -1212,7 +1246,7 @@ static int plot_raster_default(struct zint_symbol *symbol, const int rotate_angl xoffset -= comp_offset; // Binding and boxes - if ((symbol->output_options & BARCODE_BIND) != 0) { + if (symbol->output_options & BARCODE_BIND) { if ((symbol->rows > 1) && (is_stackable(symbol->symbology) == 1)) { float sep_height = 1.0f; if (symbol->option_3 > 0 && symbol->option_3 <= 4) { @@ -1235,29 +1269,8 @@ static int plot_raster_default(struct zint_symbol *symbol, const int rotate_angl } } } - if (symbol->border_width > 0) { - if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) { - /* boundary bars */ - if ((symbol->output_options & BARCODE_BOX) || (symbol->symbology != BARCODE_CODABLOCKF && symbol->symbology != BARCODE_HIBC_BLOCKF)) { - draw_bar(pixelbuf, 0, (symbol->width + xoffset + roffset) * si, - textoffset * si, symbol->border_width * si, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, 0, (symbol->width + xoffset + roffset) * si, - (textoffset + symbol->height + symbol->border_width) * si, symbol->border_width * si, image_width, image_height, DEFAULT_INK); - } else { - draw_bar(pixelbuf, xoffset * si, symbol->width * si, - textoffset * si, symbol->border_width * si, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, xoffset * si, symbol->width * si, - (textoffset + symbol->height + symbol->border_width) * si, symbol->border_width * si, image_width, image_height, DEFAULT_INK); - } - } - if ((symbol->output_options & BARCODE_BOX)) { - /* side bars */ - draw_bar(pixelbuf, 0, symbol->border_width * si, - textoffset * si, (symbol->height + (2 * symbol->border_width)) * si, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, (symbol->width + xoffset + roffset - symbol->border_width) * si, symbol->border_width * si, - textoffset * si, (symbol->height + (2 * symbol->border_width)) * si, image_width, image_height, DEFAULT_INK); - } - } + + draw_bind_box(symbol, pixelbuf, xoffset, roffset, textoffset, 0 /*overspill*/, image_width, image_height, si); if (!half_int_scaling) { scale_width = image_width * scaler; diff --git a/backend/tests/data/bmp/pdf417comp_hvwsp2.bmp b/backend/tests/data/bmp/pdf417comp_hvwsp2.bmp new file mode 100644 index 00000000..88cd08bb Binary files /dev/null and b/backend/tests/data/bmp/pdf417comp_hvwsp2.bmp differ diff --git a/backend/tests/data/emf/itf14_bold.emf b/backend/tests/data/emf/itf14_bold.emf index bd967497..32ea1e85 100644 Binary files a/backend/tests/data/emf/itf14_bold.emf and b/backend/tests/data/emf/itf14_bold.emf differ diff --git a/backend/tests/data/png/codablockf_hvwsp2.png b/backend/tests/data/png/codablockf_hvwsp2.png new file mode 100644 index 00000000..237ddbf2 Binary files /dev/null and b/backend/tests/data/png/codablockf_hvwsp2.png differ diff --git a/backend/tests/data/png/codablockf_hvwsp2_box2.png b/backend/tests/data/png/codablockf_hvwsp2_box2.png new file mode 100644 index 00000000..5d1d3ef0 Binary files /dev/null and b/backend/tests/data/png/codablockf_hvwsp2_box2.png differ diff --git a/backend/tests/data/png/code128_egrave_bold_hvwsp2_box2.png b/backend/tests/data/png/code128_egrave_bold_hvwsp2_box2.png new file mode 100644 index 00000000..2149dbb4 Binary files /dev/null and b/backend/tests/data/png/code128_egrave_bold_hvwsp2_box2.png differ diff --git a/backend/tests/data/png/datamatrix_2.0_bind1_dotty.png b/backend/tests/data/png/datamatrix_2.0_bind1_dotty.png new file mode 100644 index 00000000..392ed92d Binary files /dev/null and b/backend/tests/data/png/datamatrix_2.0_bind1_dotty.png 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 new file mode 100644 index 00000000..fe9d1724 Binary files /dev/null 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 new file mode 100644 index 00000000..fece2091 Binary files /dev/null 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 new file mode 100644 index 00000000..2f7cb51f Binary files /dev/null and b/backend/tests/data/png/maxicode_vwsp1_bind1.png differ diff --git a/backend/tests/data/svg/codablockf_hvwsp2.svg b/backend/tests/data/svg/codablockf_hvwsp2.svg new file mode 100644 index 00000000..ee39ad1f --- /dev/null +++ b/backend/tests/data/svg/codablockf_hvwsp2.svg @@ -0,0 +1,63 @@ + + + + Zint Generated Symbol + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/backend/tests/data/svg/codablockf_hvwsp2_box2.svg b/backend/tests/data/svg/codablockf_hvwsp2_box2.svg new file mode 100644 index 00000000..1c0606a8 --- /dev/null +++ b/backend/tests/data/svg/codablockf_hvwsp2_box2.svg @@ -0,0 +1,65 @@ + + + + Zint Generated Symbol + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/backend/tests/data/svg/code128_egrave_bold_box3.svg b/backend/tests/data/svg/code128_egrave_bold_box3.svg index 23d66bcd..f592b81e 100644 --- a/backend/tests/data/svg/code128_egrave_bold_box3.svg +++ b/backend/tests/data/svg/code128_egrave_bold_box3.svg @@ -41,8 +41,8 @@ - - + + Égjpqy diff --git a/backend/tests/data/svg/code128_egrave_bold_hvwsp2_box2.svg b/backend/tests/data/svg/code128_egrave_bold_hvwsp2_box2.svg new file mode 100644 index 00000000..45a78718 --- /dev/null +++ b/backend/tests/data/svg/code128_egrave_bold_hvwsp2_box2.svg @@ -0,0 +1,51 @@ + + + + Zint Generated Symbol + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Égjpqy + + + diff --git a/backend/tests/data/svg/code128_egrave_bold_hvwsp3.svg b/backend/tests/data/svg/code128_egrave_bold_hvwsp3.svg new file mode 100644 index 00000000..e95f3ec6 --- /dev/null +++ b/backend/tests/data/svg/code128_egrave_bold_hvwsp3.svg @@ -0,0 +1,47 @@ + + + + Zint Generated Symbol + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Égjpqy + + + diff --git a/backend/tests/data/svg/datamatrix_hvwsp1_bind1_dotty.svg b/backend/tests/data/svg/datamatrix_hvwsp1_bind1_dotty.svg new file mode 100644 index 00000000..89fc6eb9 --- /dev/null +++ b/backend/tests/data/svg/datamatrix_hvwsp1_bind1_dotty.svg @@ -0,0 +1,219 @@ + + + + Zint Generated Symbol + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/backend/tests/data/svg/datamatrix_vwsp1_bind1_dotty.svg b/backend/tests/data/svg/datamatrix_vwsp1_bind1_dotty.svg new file mode 100644 index 00000000..c05ca1f2 --- /dev/null +++ b/backend/tests/data/svg/datamatrix_vwsp1_bind1_dotty.svg @@ -0,0 +1,219 @@ + + + + Zint Generated Symbol + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/backend/tests/data/svg/maxicode_box2.svg b/backend/tests/data/svg/maxicode_box2.svg index 8f3d3098..9fcad603 100644 --- a/backend/tests/data/svg/maxicode_box2.svg +++ b/backend/tests/data/svg/maxicode_box2.svg @@ -10,8 +10,8 @@ - - + + diff --git a/backend/tests/data/svg/maxicode_vwsp1_bind1.svg b/backend/tests/data/svg/maxicode_vwsp1_bind1.svg new file mode 100644 index 00000000..232db3dd --- /dev/null +++ b/backend/tests/data/svg/maxicode_vwsp1_bind1.svg @@ -0,0 +1,382 @@ + + + + Zint Generated Symbol + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/backend/tests/test_bmp.c b/backend/tests/test_bmp.c index 454f34de..28bfe3c9 100644 --- a/backend/tests/test_bmp.c +++ b/backend/tests/test_bmp.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2020 Robin Stuart + Copyright (C) 2020 - 2021 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -120,6 +120,7 @@ static void test_print(int index, int generate, int debug) { struct item { int symbology; int whitespace_width; + int whitespace_height; int option_1; int option_2; char *fgcolour; @@ -128,8 +129,9 @@ static void test_print(int index, int generate, int debug) { char* expected_file; }; struct item data[] = { - /* 0*/ { BARCODE_PDF417, 5, -1, -1, "147AD0", "FC9630", "123", "../data/bmp/pdf417_fg_bg.bmp" }, - /* 1*/ { BARCODE_ULTRA, 5, -1, -1, "147AD0", "FC9630", "123", "../data/bmp/ultracode_fg_bg.bmp" }, + /* 0*/ { BARCODE_PDF417, 5, -1, -1, -1, "147AD0", "FC9630", "123", "../data/bmp/pdf417_fg_bg.bmp" }, + /* 1*/ { BARCODE_ULTRA, 5, -1, -1, -1, "147AD0", "FC9630", "123", "../data/bmp/ultracode_fg_bg.bmp" }, + /* 2*/ { BARCODE_PDF417COMP, 2, 2, -1, -1, "", "", "123", "../data/bmp/pdf417comp_hvwsp2.bmp" }, }; int data_size = ARRAY_SIZE(data); @@ -156,6 +158,9 @@ static void test_print(int index, int generate, int debug) { if (data[i].whitespace_width != -1) { symbol->whitespace_width = data[i].whitespace_width; } + if (data[i].whitespace_height != -1) { + symbol->whitespace_height = data[i].whitespace_height; + } if (*data[i].fgcolour) { strcpy(symbol->fgcolour, data[i].fgcolour); } @@ -171,8 +176,9 @@ static void test_print(int index, int generate, int debug) { assert_zero(ret, "i:%d %s ZBarcode_Print %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, ret); if (generate) { - printf(" /*%3d*/ { %s, %d, %d, %d, \"%s\", \"%s\", \"%s\", \"%s\"},\n", - i, testUtilBarcodeName(data[i].symbology), data[i].whitespace_width, data[i].option_1, data[i].option_2, data[i].fgcolour, data[i].bgcolour, + printf(" /*%3d*/ { %s, %d, %d, %d, %d, \"%s\", \"%s\", \"%s\", \"%s\"},\n", + i, testUtilBarcodeName(data[i].symbology), data[i].whitespace_width, data[i].whitespace_height, + data[i].option_1, data[i].option_2, data[i].fgcolour, data[i].bgcolour, testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].expected_file); ret = rename(symbol->outfile, data[i].expected_file); assert_zero(ret, "i:%d rename(%s, %s) ret %d != 0\n", i, symbol->outfile, data[i].expected_file, ret); diff --git a/backend/tests/test_png.c b/backend/tests/test_png.c index 5fd8adb2..5c3fc111 100644 --- a/backend/tests/test_png.c +++ b/backend/tests/test_png.c @@ -120,6 +120,7 @@ static void test_print(int index, int generate, int debug) { int border_width; int output_options; int whitespace_width; + int whitespace_height; int show_hrt; int option_1; int option_2; @@ -133,49 +134,56 @@ static void test_print(int index, int generate, int debug) { char *comment; }; struct item data[] = { - /* 0*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, 0, 0, "", "", "Égjpqy", "", "../data/png/code128_egrave_bold.png", "" }, - /* 1*/ { BARCODE_CODE128, UNICODE_MODE, 3, BOLD_TEXT | BARCODE_BOX, -1, -1, -1, -1, 0, 0, "", "", "Égjpqy", "", "../data/png/code128_egrave_bold_box3.png", "" }, - /* 2*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, -1, 3, -1, 0, 0, "", "", "[00]030123456789012340", "[02]13012345678909[37]24[10]1234567ABCDEFG", "../data/png/gs1_128_cc_fig12.png", "" }, - /* 3*/ { BARCODE_CODABLOCKF, -1, 3, -1, -1, -1, 3, -1, 0, 0, "", "", "AAAAAAAAA", "", "../data/png/codablockf_3rows.png", "" }, - /* 4*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "9771384524017+12", "", "../data/png/ean13_2addon_ggs_5.2.2.5.1-2.png", "" }, - /* 5*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "9780877799306+54321", "", "../data/png/ean13_5addon_ggs_5.2.2.5.2-2.png", "" }, - /* 6*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, 1, -1, 0, 0, "", "", "123456789012+12", "[91]123456789012345678901", "../data/png/ean13_cc_2addon_cca_4x4.png", "" }, - /* 7*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, 2, -1, 0, 0, "", "", "123456789012+54321", "[91]1234567890", "../data/png/ean13_cc_5addon_ccb_3x4.png", "" }, - /* 8*/ { BARCODE_EANX_CC, -1, -1, -1, -1, 0, 2, -1, 0, 0, "", "", "123456789012+54321", "[91]1234567890", "../data/png/ean13_cc_5addon_ccb_3x4_notext.png", "" }, - /* 9*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "012345678905+24", "", "../data/png/upca_2addon_ggs_5.2.6.6-5.png", "" }, - /* 10*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "614141234417+12345", "", "../data/png/upca_5addon.png", "" }, - /* 11*/ { BARCODE_UPCA, -1, -1, -1, -1, 0, -1, -1, 0, 0, "", "", "614141234417+12345", "", "../data/png/upca_5addon_notext.png", "" }, - /* 12*/ { BARCODE_UPCA, -1, 3, BARCODE_BIND, -1, -1, -1, -1, 0, 0, "", "", "614141234417+12345", "", "../data/png/upca_5addon_bind3.png", "" }, - /* 13*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, 1, -1, 0, 0, "", "", "12345678901+12", "[91]123456789", "../data/png/upca_cc_2addon_cca_3x4.png", "" }, - /* 14*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, 2, -1, 0, 0, "", "", "12345678901+12121", "[91]1234567890123", "../data/png/upca_cc_5addon_ccb_4x4.png", "" }, - /* 15*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, 0, 2, -1, 0, 0, "", "", "12345678901+12121", "[91]1234567890123", "../data/png/upca_cc_5addon_ccb_4x4_notext.png", "" }, - /* 16*/ { BARCODE_UPCA_CC, -1, 3, BARCODE_BIND, -1, -1, 2, -1, 0, 0, "", "", "12345678901+12121", "[91]1234567890123", "../data/png/upca_cc_5addon_ccb_4x4_bind3.png", "" }, - /* 17*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "1234567+12", "", "../data/png/upce_2addon.png", "" }, - /* 18*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "1234567+12345", "", "../data/png/upce_5addon.png", "" }, - /* 19*/ { BARCODE_UPCE, -1, -1, SMALL_TEXT, -1, -1, -1, -1, 0, 0, "", "", "1234567+12345", "", "../data/png/upce_5addon_small.png", "" }, - /* 20*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, 1, -1, 0, 0, "", "", "0654321+89", "[91]1", "../data/png/upce_cc_2addon_cca_5x2.png", "" }, - /* 21*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, 2, -1, 0, 0, "", "", "1876543+56789", "[91]12345", "../data/png/upce_cc_5addon_ccb_8x2.png", "" }, - /* 22*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, 0, 2, -1, 0, 0, "", "", "1876543+56789", "[91]12345", "../data/png/upce_cc_5addon_ccb_8x2_notext.png", "" }, - /* 23*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "1234567+12", "", "../data/png/ean8_2addon.png", "" }, - /* 24*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "1234567+12345", "", "../data/png/ean8_5addon.png", "" }, - /* 25*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "9876543+65", "[91]1234567", "../data/png/ean8_cc_2addon_cca_4x3.png", "" }, - /* 26*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "9876543+74083", "[91]123456789012345678", "../data/png/ean8_cc_5addon_ccb_8x3.png", "" }, - /* 27*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "12345", "", "../data/png/ean5.png", "" }, - /* 28*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "12", "", "../data/png/ean2.png", "" }, - /* 29*/ { BARCODE_CODE39, -1, -1, SMALL_TEXT, -1, -1, -1, -1, 0, 0, "", "", "123", "", "../data/png/code39_small.png", "" }, - /* 30*/ { BARCODE_POSTNET, -1, -1, -1, -1, -1, -1, -1, 0, 3.5, "", "", "12345", "", "../data/png/postnet_zip.png", "300 dpi, using 1/43in X, 300 / 43 / 2 = ~3.5 scale" }, - /* 31*/ { BARCODE_PDF417, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "CFCECDCC", "12345", "", "../data/png/pdf417_bgalpha.png", "" }, - /* 32*/ { BARCODE_PDF417, -1, -1, -1, -1, -1, -1, -1, 0, 0, "30313233", "", "12345", "", "../data/png/pdf417_fgalpha.png", "" }, - /* 33*/ { BARCODE_PDF417, -1, -1, -1, -1, -1, -1, -1, 0, 0, "20212244", "CFCECDCC", "12345", "", "../data/png/pdf417_bgfgalpha.png", "" }, - /* 34*/ { BARCODE_ULTRA, -1, -1, -1, 2, -1, -1, -1, 0, 0, "0000007F", "FF000033", "12345", "", "../data/png/ultra_bgfgalpha.png", "" }, - /* 35*/ { BARCODE_ULTRA, -1, -1, -1, 2, -1, -1, -1, 0, 0, "", "FF000033", "12345", "", "../data/png/ultra_bgalpha.png", "" }, - /* 36*/ { BARCODE_ULTRA, -1, -1, -1, 2, -1, -1, -1, 0, 0, "0000007F", "FF0000", "12345", "", "../data/png/ultra_fgalpha.png", "" }, - /* 37*/ { BARCODE_ULTRA, -1, -1, -1, -1, -1, -1, -1, 0, 0, "0000007F", "", "12345", "", "../data/png/ultra_fgalpha_nobg.png", "" }, - /* 38*/ { BARCODE_ULTRA, -1, -1, -1, -1, -1, -1, -1, 0, 0.5f, "", "", "1", "", "../data/png/ultra_odd.png", "" }, - /* 39*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, 0, 0.5f, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "../data/png/maxicode_0.5.png", "6 dpmm, 150 dpi" }, - /* 40*/ { BARCODE_MAXICODE, -1, 1, BARCODE_BOX, 3, -1, -1, -1, 0, 0.7f, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "../data/png/maxicode_0.7_wsp3_box1.png", "8 dpmm, 200 dpi" }, - /* 41*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, 0, 1.4f, "1111117F", "EEEEEEEE", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "../data/png/maxicode_1.4_bgfgalpha.png", "16 dpmm, 400 dpi" }, - /* 42*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, 0, 2.1f, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "../data/png/maxicode_2.1.png", "24 dpmm, 600 dpi" }, + /* 0*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, -1, 0, 0, "", "", "Égjpqy", "", "../data/png/code128_egrave_bold.png", "" }, + /* 1*/ { BARCODE_CODE128, UNICODE_MODE, 3, BOLD_TEXT | BARCODE_BOX, -1, -1, -1, -1, -1, 0, 0, "", "", "Égjpqy", "", "../data/png/code128_egrave_bold_box3.png", "" }, + /* 2*/ { BARCODE_CODE128, UNICODE_MODE, 2, BOLD_TEXT | BARCODE_BOX, 2, 2, -1, -1, -1, 0, 0, "", "", "Égjpqy", "", "../data/png/code128_egrave_bold_hvwsp2_box2.png", "" }, + /* 3*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, -1, -1, 3, -1, 0, 0, "", "", "[00]030123456789012340", "[02]13012345678909[37]24[10]1234567ABCDEFG", "../data/png/gs1_128_cc_fig12.png", "" }, + /* 4*/ { BARCODE_CODABLOCKF, -1, 3, -1, -1, -1, -1, 3, -1, 0, 0, "", "", "AAAAAAAAA", "", "../data/png/codablockf_3rows.png", "" }, + /* 5*/ { BARCODE_CODABLOCKF, -1, -1, -1, 2, 2, -1, -1, -1, 0, 0, "", "", "AAAAAAAAA", "", "../data/png/codablockf_hvwsp2.png", "" }, + /* 6*/ { BARCODE_CODABLOCKF, -1, 2, BARCODE_BOX, 2, 2, -1, -1, -1, 0, 0, "", "", "AAAAAAAAA", "", "../data/png/codablockf_hvwsp2_box2.png", "" }, + /* 7*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "9771384524017+12", "", "../data/png/ean13_2addon_ggs_5.2.2.5.1-2.png", "" }, + /* 8*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "9780877799306+54321", "", "../data/png/ean13_5addon_ggs_5.2.2.5.2-2.png", "" }, + /* 9*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, 1, -1, 0, 0, "", "", "123456789012+12", "[91]123456789012345678901", "../data/png/ean13_cc_2addon_cca_4x4.png", "" }, + /* 10*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, 2, -1, 0, 0, "", "", "123456789012+54321", "[91]1234567890", "../data/png/ean13_cc_5addon_ccb_3x4.png", "" }, + /* 11*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, 0, 2, -1, 0, 0, "", "", "123456789012+54321", "[91]1234567890", "../data/png/ean13_cc_5addon_ccb_3x4_notext.png", "" }, + /* 12*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "012345678905+24", "", "../data/png/upca_2addon_ggs_5.2.6.6-5.png", "" }, + /* 13*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "614141234417+12345", "", "../data/png/upca_5addon.png", "" }, + /* 14*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, 0, -1, -1, 0, 0, "", "", "614141234417+12345", "", "../data/png/upca_5addon_notext.png", "" }, + /* 15*/ { BARCODE_UPCA, -1, 3, BARCODE_BIND, -1, -1, -1, -1, -1, 0, 0, "", "", "614141234417+12345", "", "../data/png/upca_5addon_bind3.png", "" }, + /* 16*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, -1, 1, -1, 0, 0, "", "", "12345678901+12", "[91]123456789", "../data/png/upca_cc_2addon_cca_3x4.png", "" }, + /* 17*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, -1, 2, -1, 0, 0, "", "", "12345678901+12121", "[91]1234567890123", "../data/png/upca_cc_5addon_ccb_4x4.png", "" }, + /* 18*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, 0, 2, -1, 0, 0, "", "", "12345678901+12121", "[91]1234567890123", "../data/png/upca_cc_5addon_ccb_4x4_notext.png", "" }, + /* 19*/ { BARCODE_UPCA_CC, -1, 3, BARCODE_BIND, -1, -1, -1, 2, -1, 0, 0, "", "", "12345678901+12121", "[91]1234567890123", "../data/png/upca_cc_5addon_ccb_4x4_bind3.png", "" }, + /* 20*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "1234567+12", "", "../data/png/upce_2addon.png", "" }, + /* 21*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "1234567+12345", "", "../data/png/upce_5addon.png", "" }, + /* 22*/ { BARCODE_UPCE, -1, -1, SMALL_TEXT, -1, -1, -1, -1, -1, 0, 0, "", "", "1234567+12345", "", "../data/png/upce_5addon_small.png", "" }, + /* 23*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, -1, 1, -1, 0, 0, "", "", "0654321+89", "[91]1", "../data/png/upce_cc_2addon_cca_5x2.png", "" }, + /* 24*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, -1, 2, -1, 0, 0, "", "", "1876543+56789", "[91]12345", "../data/png/upce_cc_5addon_ccb_8x2.png", "" }, + /* 25*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, 0, 2, -1, 0, 0, "", "", "1876543+56789", "[91]12345", "../data/png/upce_cc_5addon_ccb_8x2_notext.png", "" }, + /* 26*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "1234567+12", "", "../data/png/ean8_2addon.png", "" }, + /* 27*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "1234567+12345", "", "../data/png/ean8_5addon.png", "" }, + /* 28*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "9876543+65", "[91]1234567", "../data/png/ean8_cc_2addon_cca_4x3.png", "" }, + /* 29*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "9876543+74083", "[91]123456789012345678", "../data/png/ean8_cc_5addon_ccb_8x3.png", "" }, + /* 30*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "12345", "", "../data/png/ean5.png", "" }, + /* 31*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "12", "", "../data/png/ean2.png", "" }, + /* 32*/ { BARCODE_CODE39, -1, -1, SMALL_TEXT, -1, -1, -1, -1, -1, 0, 0, "", "", "123", "", "../data/png/code39_small.png", "" }, + /* 33*/ { BARCODE_POSTNET, -1, -1, -1, -1, -1, -1, -1, -1, 0, 3.5, "", "", "12345", "", "../data/png/postnet_zip.png", "300 dpi, using 1/43in X, 300 / 43 / 2 = ~3.5 scale" }, + /* 34*/ { BARCODE_PDF417, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "CFCECDCC", "12345", "", "../data/png/pdf417_bgalpha.png", "" }, + /* 35*/ { BARCODE_PDF417, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "30313233", "", "12345", "", "../data/png/pdf417_fgalpha.png", "" }, + /* 36*/ { BARCODE_PDF417, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "20212244", "CFCECDCC", "12345", "", "../data/png/pdf417_bgfgalpha.png", "" }, + /* 37*/ { BARCODE_ULTRA, -1, -1, -1, 2, -1, -1, -1, -1, 0, 0, "0000007F", "FF000033", "12345", "", "../data/png/ultra_bgfgalpha.png", "" }, + /* 38*/ { BARCODE_ULTRA, -1, -1, -1, 2, -1, -1, -1, -1, 0, 0, "", "FF000033", "12345", "", "../data/png/ultra_bgalpha.png", "" }, + /* 39*/ { BARCODE_ULTRA, -1, -1, -1, 2, -1, -1, -1, -1, 0, 0, "0000007F", "FF0000", "12345", "", "../data/png/ultra_fgalpha.png", "" }, + /* 40*/ { BARCODE_ULTRA, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "0000007F", "", "12345", "", "../data/png/ultra_fgalpha_nobg.png", "" }, + /* 41*/ { BARCODE_ULTRA, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0.5f, "", "", "1", "", "../data/png/ultra_odd.png", "" }, + /* 42*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0.5f, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "../data/png/maxicode_0.5.png", "6 dpmm, 150 dpi" }, + /* 43*/ { BARCODE_MAXICODE, -1, 1, BARCODE_BOX, 3, -1, -1, -1, -1, 0, 0.7f, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "../data/png/maxicode_0.7_wsp3_box1.png", "8 dpmm, 200 dpi" }, + /* 44*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1.4f, "1111117F", "EEEEEEEE", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "../data/png/maxicode_1.4_bgfgalpha.png", "16 dpmm, 400 dpi" }, + /* 45*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, -1, 0, 2.1f, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "../data/png/maxicode_2.1.png", "24 dpmm, 600 dpi" }, + /* 46*/ { BARCODE_MAXICODE, -1, 2, BARCODE_BOX, 1, 1, -1, -1, -1, 0, 0, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "../data/png/maxicode_hvwsp1_box2.png", "" }, + /* 47*/ { BARCODE_MAXICODE, -1, 1, BARCODE_BIND, -1, 1, -1, -1, -1, 0, 0, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "../data/png/maxicode_vwsp1_bind1.png", "" }, + /* 48*/ { BARCODE_DATAMATRIX, -1, 1, BARCODE_BIND | BARCODE_DOTTY_MODE, -1, -1, -1, -1, -1, 0, 2.0f, "", "", "1234", "", "../data/png/datamatrix_2.0_bind1_dotty.png", "" }, + /* 49*/ { BARCODE_DATAMATRIX, -1, 1, BARCODE_BIND | BARCODE_DOTTY_MODE, 1, 1, -1, -1, -1, 0, 2.0f, "", "", "1234", "", "../data/png/datamatrix_2.0_hvwsp1_bind1_dotty.png", "" }, }; int data_size = ARRAY_SIZE(data); @@ -215,6 +223,9 @@ static void test_print(int index, int generate, int debug) { if (data[i].whitespace_width != -1) { symbol->whitespace_width = data[i].whitespace_width; } + if (data[i].whitespace_height != -1) { + symbol->whitespace_height = data[i].whitespace_height; + } if (*data[i].fgcolour) { strcpy(symbol->fgcolour, data[i].fgcolour); } @@ -237,9 +248,9 @@ static void test_print(int index, int generate, int debug) { assert_zero(ret, "i:%d %s ZBarcode_Print %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, ret); if (generate) { - printf(" /*%3d*/ { %s, %s, %d, %s, %d, %d, %d, %d, %d, %.5g, \"%s\",\"%s\", \"%s\", \"%s\", \"%s\", \"%s\" },\n", + printf(" /*%3d*/ { %s, %s, %d, %s, %d, %d, %d, %d, %d, %d, %.5g, \"%s\",\"%s\", \"%s\", \"%s\", \"%s\", \"%s\" },\n", i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].border_width, testUtilOutputOptionsName(data[i].output_options), - data[i].whitespace_width, data[i].show_hrt, data[i].option_1, data[i].option_2, data[i].height, data[i].scale, data[i].fgcolour, data[i].bgcolour, + data[i].whitespace_width, data[i].whitespace_height, data[i].show_hrt, data[i].option_1, data[i].option_2, data[i].height, data[i].scale, data[i].fgcolour, data[i].bgcolour, testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].composite, data[i].expected_file, data[i].comment); ret = rename(symbol->outfile, data[i].expected_file); assert_zero(ret, "i:%d rename(%s, %s) ret %d != 0\n", i, symbol->outfile, data[i].expected_file, ret); diff --git a/backend/tests/test_raster.c b/backend/tests/test_raster.c index 7190bef5..b18be636 100644 --- a/backend/tests/test_raster.c +++ b/backend/tests/test_raster.c @@ -257,7 +257,7 @@ static void test_buffer(int index, int generate, int debug) { for (int i = 0; i < data_size; i++) { if (index != -1 && i != index) continue; - if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d\n", i); + if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d\n", i); // ZINT_DEBUG_TEST_PRINT 16 struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); @@ -281,7 +281,7 @@ static void test_buffer(int index, int generate, int debug) { assert_zero(ret, "i:%d ZBarcode_Buffer(%s) ret %d != 0 (%s)\n", i, testUtilBarcodeName(data[i].symbology), ret, symbol->errtxt); assert_nonnull(symbol->bitmap, "i:%d ZBarcode_Buffer(%s) bitmap NULL\n", i, testUtilBarcodeName(data[i].symbology)); - if (index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) testUtilBitmapPrint(symbol, NULL, NULL); + if (index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) testUtilBitmapPrint(symbol, NULL, NULL); // ZINT_DEBUG_TEST_PRINT 16 if (generate) { printf(" /*%3d*/ { %s, \"%s\", \"%s\", %d, %d, %d, %d, %d },\n", @@ -366,7 +366,7 @@ static void test_upcean_hrt(int index, int debug) { for (int i = 0; i < data_size; i++) { if (index != -1 && i != index) continue; - if ((debug & ZINT_DEBUG_TEST_PRINT) && !(debug & ZINT_DEBUG_TEST_LESS_NOISY)) printf("i:%d\n", i); + if ((debug & ZINT_DEBUG_TEST_PRINT) && !(debug & ZINT_DEBUG_TEST_LESS_NOISY)) printf("i:%d\n", i); // ZINT_DEBUG_TEST_PRINT 16 struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); @@ -383,7 +383,7 @@ static void test_upcean_hrt(int index, int debug) { assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret); assert_nonnull(symbol->bitmap, "i:%d (%d) symbol->bitmap NULL\n", i, data[i].symbology); - if (index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) testUtilBitmapPrint(symbol, NULL, NULL); + if (index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) testUtilBitmapPrint(symbol, NULL, NULL); // ZINT_DEBUG_TEST_PRINT 16 assert_equal(symbol->height, data[i].expected_height, "i:%d (%s) symbol->height %d != %d\n", i, testUtilBarcodeName(data[i].symbology), symbol->height, data[i].expected_height); assert_equal(symbol->rows, data[i].expected_rows, "i:%d (%s) symbol->rows %d != %d\n", i, testUtilBarcodeName(data[i].symbology), symbol->rows, data[i].expected_rows); @@ -500,7 +500,7 @@ static void test_row_separator(int index, int debug) { int j, separator_bits_set; - if (index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) testUtilBitmapPrint(symbol, NULL, NULL); + if (index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) testUtilBitmapPrint(symbol, NULL, NULL); // ZINT_DEBUG_TEST_PRINT 16 for (j = data[i].expected_separator_row; j < data[i].expected_separator_row + data[i].expected_separator_height; j++) { separator_bits_set = is_row_column_black(symbol, j, data[i].expected_separator_col); @@ -580,7 +580,7 @@ static void test_stacking(int index, int debug) { int j, separator_bits_set; - if (index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) testUtilBitmapPrint(symbol, NULL, NULL); + if (index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) testUtilBitmapPrint(symbol, NULL, NULL); // ZINT_DEBUG_TEST_PRINT 16 if (data[i].expected_separator_row != -1) { for (j = data[i].expected_separator_row; j < data[i].expected_separator_row + data[i].expected_separator_height; j++) { @@ -613,6 +613,7 @@ static void test_output_options(int index, int debug) { struct item { int symbology; int whitespace_width; + int whitespace_height; int border_width; int output_options; int rotate_angle; @@ -630,78 +631,84 @@ static void test_output_options(int index, int debug) { }; // s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<")) struct item data[] = { - /* 0*/ { BARCODE_CODE128, -1, -1, -1, 0, "A123", 0, 50, 1, 79, 158, 116, 0, 0, 4 }, - /* 1*/ { BARCODE_CODE128, -1, -1, -1, 180, "A123", 0, 50, 1, 79, 158, 116, 0, 115, 4 }, - /* 2*/ { BARCODE_CODE128, -1, 2, -1, 0, "A123", 0, 50, 1, 79, 158, 116, 0, 0, 4 }, - /* 3*/ { BARCODE_CODE128, -1, 2, BARCODE_BIND, 0, "A123", 0, 50, 1, 79, 158, 124, 1, 0, 4 }, - /* 4*/ { BARCODE_CODE128, -1, 2, BARCODE_BIND, 0, "A123", 0, 50, 1, 79, 158, 124, 0, 4, 4 }, - /* 5*/ { BARCODE_CODE128, -1, 2, BARCODE_BOX, 0, "A123", 0, 50, 1, 79, 166, 124, 1, 4, 4 }, - /* 6*/ { BARCODE_CODE128, -1, 0, BARCODE_BIND, 0, "A123", 0, 50, 1, 79, 158, 116, 0, 0, 4 }, - /* 7*/ { BARCODE_CODE128, -1, 0, BARCODE_BOX, 0, "A123", 0, 50, 1, 79, 158, 116, 0, 4, 4 }, - /* 8*/ { BARCODE_CODE128, -1, -1, -1, 0, "A123", 0, 50, 1, 79, 158, 116, 0, 0, 8 }, - /* 9*/ { BARCODE_CODE128, 3, -1, -1, 0, "A123", 0, 50, 1, 79, 170, 116, 1, 0, 8 }, - /* 10*/ { BARCODE_CODE128, 3, 4, -1, 0, "A123", 0, 50, 1, 79, 170, 116, 1, 0, 8 }, - /* 11*/ { BARCODE_CODE128, 3, 4, BARCODE_BIND, 0, "A123", 0, 50, 1, 79, 170, 132, 1, 0, 0 }, - /* 12*/ { BARCODE_CODE128, 3, 4, BARCODE_BIND, 0, "A123", 0, 50, 1, 79, 170, 132, 0, 8, 0 }, - /* 13*/ { BARCODE_CODE128, 3, 4, BARCODE_BOX, 0, "A123", 0, 50, 1, 79, 186, 132, 1, 8, 0 }, - /* 14*/ { BARCODE_CODE128, -1, -1, BARCODE_DOTTY_MODE, 0, "A123", ZINT_ERROR_INVALID_OPTION, -1, -1, -1, -1, -1, -1, -1, -1 }, - /* 15*/ { BARCODE_CODE128, -1, -1, OUT_BUFFER_INTERMEDIATE, 0, "A123", 0, 50, 1, 79, 158, 116, 0, 0, 4 }, - /* 16*/ { BARCODE_CODE128, -1, -1, OUT_BUFFER_INTERMEDIATE, 180, "A123", 0, 50, 1, 79, 158, 116, 0, 115, 4 }, - /* 17*/ { BARCODE_CODE128, 3, 4, BARCODE_BOX | OUT_BUFFER_INTERMEDIATE, 0, "A123", 0, 50, 1, 79, 186, 132, 1, 8, 0 }, - /* 18*/ { BARCODE_QRCODE, -1, -1, -1, 0, "A123", 0, 21, 21, 21, 42, 42, 0, 2, 2 }, - /* 19*/ { BARCODE_QRCODE, -1, -1, -1, 180, "A123", 0, 21, 21, 21, 42, 42, 0, 39, 2 }, - /* 20*/ { BARCODE_QRCODE, -1, 3, -1, 0, "A123", 0, 21, 21, 21, 42, 42, 0, 2, 2 }, - /* 21*/ { BARCODE_QRCODE, -1, 3, BARCODE_BIND, 0, "A123", 0, 21, 21, 21, 42, 54, 1, 2, 2 }, - /* 22*/ { BARCODE_QRCODE, -1, 3, BARCODE_BIND, 0, "A123", 0, 21, 21, 21, 42, 54, 0, 20, 0 }, - /* 23*/ { BARCODE_QRCODE, -1, 3, BARCODE_BOX, 0, "A123", 0, 21, 21, 21, 54, 54, 1, 20, 0 }, - /* 24*/ { BARCODE_QRCODE, -1, -1, -1, 0, "A123", 0, 21, 21, 21, 42, 42, 1, 0, 0 }, - /* 25*/ { BARCODE_QRCODE, 5, -1, -1, 0, "A123", 0, 21, 21, 21, 62, 42, 0, 0, 0 }, - /* 26*/ { BARCODE_QRCODE, 5, 6, -1, 0, "A123", 0, 21, 21, 21, 62, 42, 0, 0, 0 }, - /* 27*/ { BARCODE_QRCODE, 5, 6, BARCODE_BIND, 0, "A123", 0, 21, 21, 21, 62, 66, 1, 0, 0 }, - /* 28*/ { BARCODE_QRCODE, 5, 6, BARCODE_BIND, 0, "A123", 0, 21, 21, 21, 62, 66, 0, 12, 0 }, - /* 29*/ { BARCODE_QRCODE, 5, 6, BARCODE_BOX, 0, "A123", 0, 21, 21, 21, 86, 66, 1, 12, 0 }, - /* 30*/ { BARCODE_QRCODE, -1, -1, BARCODE_DOTTY_MODE, 0, "A123", 0, 21, 21, 21, 43, 43, 1, 1, 1 }, - /* 31*/ { BARCODE_QRCODE, -1, -1, BARCODE_DOTTY_MODE, 0, "A123", 0, 21, 21, 21, 43, 43, 0, 2, 2 }, - /* 32*/ { BARCODE_QRCODE, -1, -1, BARCODE_DOTTY_MODE, 0, "A123", 0, 21, 21, 21, 43, 43, 1, 41, 1 }, - /* 33*/ { BARCODE_QRCODE, -1, -1, BARCODE_DOTTY_MODE, 0, "A123", 0, 21, 21, 21, 43, 43, 0, 40, 2 }, - /* 34*/ { BARCODE_QRCODE, -1, 4, BARCODE_DOTTY_MODE, 0, "A123", 0, 21, 21, 21, 43, 43, 1, 1, 1 }, - /* 35*/ { BARCODE_QRCODE, -1, 4, BARCODE_DOTTY_MODE, 0, "A123", 0, 21, 21, 21, 43, 43, 0, 2, 2 }, - /* 36*/ { BARCODE_QRCODE, -1, 4, BARCODE_BIND | BARCODE_DOTTY_MODE, 0, "A123", 0, 21, 21, 21, 43, 59, -1, -1, -1 }, // TODO: fix (bind/box in dotty mode) - /* 37*/ { BARCODE_QRCODE, 1, 4, BARCODE_BOX | BARCODE_DOTTY_MODE, 0, "A123", 0, 21, 21, 21, 63, 59, -1, -1, -1 }, // TODO: fix (bind/box in dotty mode) - /* 38*/ { BARCODE_QRCODE, -1, -1, OUT_BUFFER_INTERMEDIATE, 0, "A123", 0, 21, 21, 21, 42, 42, 1, 1, 1 }, - /* 39*/ { BARCODE_QRCODE, -1, -1, OUT_BUFFER_INTERMEDIATE, 0, "A123", 0, 21, 21, 21, 42, 42, 0, 2, 2 }, - /* 40*/ { BARCODE_QRCODE, -1, -1, BARCODE_DOTTY_MODE | OUT_BUFFER_INTERMEDIATE, 0, "A123", 0, 21, 21, 21, 43, 43, 1, 1, 1 }, - /* 41*/ { BARCODE_QRCODE, -1, -1, BARCODE_DOTTY_MODE | OUT_BUFFER_INTERMEDIATE, 0, "A123", 0, 21, 21, 21, 43, 43, 0, 2, 2 }, - /* 42*/ { BARCODE_QRCODE, -1, -1, BARCODE_DOTTY_MODE | OUT_BUFFER_INTERMEDIATE, 180, "A123", 0, 21, 21, 21, 43, 43, 1, 41, 1 }, - /* 43*/ { BARCODE_QRCODE, -1, -1, BARCODE_DOTTY_MODE | OUT_BUFFER_INTERMEDIATE, 180, "A123", 0, 21, 21, 21, 43, 43, 0, 40, 2 }, - /* 44*/ { BARCODE_MAXICODE, -1, -1, -1, 0, "A123", 0, 165, 33, 30, 299, 298, 0, 4, 4 }, - /* 45*/ { BARCODE_MAXICODE, -1, -1, -1, 0, "A123", 0, 165, 33, 30, 299, 298, 1, 4, 14 }, - /* 46*/ { BARCODE_MAXICODE, -1, -1, -1, 270, "A123", 0, 165, 33, 30, 298, 299, 1, 4, 4 }, - /* 47*/ { BARCODE_MAXICODE, -1, -1, -1, 270, "A123", 0, 165, 33, 30, 298, 299, 0, 4, 14 }, - /* 48*/ { BARCODE_MAXICODE, -1, 5, -1, 0, "A123", 0, 165, 33, 30, 299, 298, 0, 0, 0 }, - /* 49*/ { BARCODE_MAXICODE, -1, 5, BARCODE_BIND, 0, "A123", 0, 165, 33, 30, 299, 298 + 50 * 2, 1, 0, 0 }, - /* 50*/ { BARCODE_MAXICODE, -1, 5, BARCODE_BIND, 0, "A123", 0, 165, 33, 30, 299, 298 + 50 * 2, 0, 50, 0 }, - /* 51*/ { BARCODE_MAXICODE, -1, 5, BARCODE_BIND, 0, "A123", 0, 165, 33, 30, 299, 298 + 50 * 2, 0, 347, 50 }, - /* 52*/ { BARCODE_MAXICODE, -1, 5, BARCODE_BIND, 0, "A123", 0, 165, 33, 30, 299, 298 + 50 * 2, 1, 348, 50 }, - /* 53*/ { BARCODE_MAXICODE, -1, 5, BARCODE_BOX, 0, "A123", 0, 165, 33, 30, 299 + 50 * 2, 298 + 50 * 2, 1, 50, 0 }, - /* 54*/ { BARCODE_MAXICODE, -1, 5, BARCODE_BOX, 0, "A123", 0, 165, 33, 30, 299 + 50 * 2, 298 + 50 * 2, 0, 347, 50 }, - /* 55*/ { BARCODE_MAXICODE, -1, -1, -1, 0, "A123", 0, 165, 33, 30, 299, 298, 1, 0, 14 }, - /* 56*/ { BARCODE_MAXICODE, 6, -1, -1, 0, "A123", 0, 165, 33, 30, 299 + 60 * 2, 298, 0, 0, 14 }, - /* 57*/ { BARCODE_MAXICODE, 6, -1, -1, 0, "A123", 0, 165, 33, 30, 299 + 60 * 2, 298, 0, 0, 47 }, - /* 58*/ { BARCODE_MAXICODE, 6, 5, BARCODE_BIND, 0, "A123", 0, 165, 33, 30, 299 + 60 * 2, 298 + 50 * 2, 1, 0, 47 }, - /* 59*/ { BARCODE_MAXICODE, 6, 5, BARCODE_BIND, 0, "A123", 0, 165, 33, 30, 299 + 60 * 2, 298 + 50 * 2, 0, 50, 0 }, - /* 60*/ { BARCODE_MAXICODE, 6, 5, BARCODE_BOX, 0, "A123", 0, 165, 33, 30, 299 + (60 + 50) * 2, 298 + 50 * 2, 1, 50, 0 }, - /* 61*/ { BARCODE_MAXICODE, -1, -1, BARCODE_DOTTY_MODE, 0, "A123", ZINT_ERROR_INVALID_OPTION, -1, -1, -1, -1, -1, -1, -1, -1 }, - /* 62*/ { BARCODE_MAXICODE, -1, -1, OUT_BUFFER_INTERMEDIATE, 0, "A123", 0, 165, 33, 30, 299, 298, 0, 4, 4 }, - /* 63*/ { BARCODE_MAXICODE, -1, -1, OUT_BUFFER_INTERMEDIATE, 0, "A123", 0, 165, 33, 30, 299, 298, 1, 4, 14 }, - /* 64*/ { BARCODE_MAXICODE, -1, -1, OUT_BUFFER_INTERMEDIATE, 270, "A123", 0, 165, 33, 30, 298, 299, 1, 4, 4 }, - /* 65*/ { BARCODE_MAXICODE, -1, -1, OUT_BUFFER_INTERMEDIATE, 270, "A123", 0, 165, 33, 30, 298, 299, 0, 4, 14 }, - /* 66*/ { BARCODE_ITF14, -1, -1, -1, 0, "123", 0, 50, 1, 135, 330, 136, 1, 110, 0 }, - /* 67*/ { BARCODE_ITF14, -1, -1, -1, 90, "123", 0, 50, 1, 135, 136, 330, 1, 0, 110 }, - /* 68*/ { BARCODE_ITF14, -1, 0, -1, 0, "123", 0, 50, 1, 135, 330, 136, 1, 110, 0 }, - /* 69*/ { BARCODE_ITF14, -1, 0, BARCODE_BOX, 0, "123", 0, 50, 1, 135, 310, 116, 0, 100, 0 }, - /* 70*/ { BARCODE_ITF14, -1, -1, OUT_BUFFER_INTERMEDIATE, 0, "123", 0, 50, 1, 135, 330, 136, 1, 110, 0 }, - /* 71*/ { BARCODE_ITF14, -1, -1, OUT_BUFFER_INTERMEDIATE, 90, "123", 0, 50, 1, 135, 136, 330, 1, 0, 110 }, + /* 0*/ { BARCODE_CODE128, -1, -1, -1, -1, 0, "A123", 0, 50, 1, 79, 158, 116, 0, 0, 4 }, + /* 1*/ { BARCODE_CODE128, -1, -1, -1, -1, 180, "A123", 0, 50, 1, 79, 158, 116, 0, 115, 4 }, + /* 2*/ { BARCODE_CODE128, -1, -1, 2, -1, 0, "A123", 0, 50, 1, 79, 158, 116, 0, 0, 4 }, + /* 3*/ { BARCODE_CODE128, -1, -1, 2, BARCODE_BIND, 0, "A123", 0, 50, 1, 79, 158, 124, 1, 0, 4 }, + /* 4*/ { BARCODE_CODE128, -1, -1, 2, BARCODE_BIND, 0, "A123", 0, 50, 1, 79, 158, 124, 0, 4, 4 }, + /* 5*/ { BARCODE_CODE128, -1, -1, 2, BARCODE_BOX, 0, "A123", 0, 50, 1, 79, 166, 124, 1, 4, 4 }, + /* 6*/ { BARCODE_CODE128, -1, -1, 0, BARCODE_BIND, 0, "A123", 0, 50, 1, 79, 158, 116, 0, 0, 4 }, + /* 7*/ { BARCODE_CODE128, -1, -1, 0, BARCODE_BOX, 0, "A123", 0, 50, 1, 79, 158, 116, 0, 4, 4 }, + /* 8*/ { BARCODE_CODE128, -1, -1, -1, -1, 0, "A123", 0, 50, 1, 79, 158, 116, 0, 0, 8 }, + /* 9*/ { BARCODE_CODE128, 3, -1, -1, -1, 0, "A123", 0, 50, 1, 79, 170, 116, 1, 0, 8 }, + /* 10*/ { BARCODE_CODE128, 3, 1, -1, -1, 0, "A123", 0, 50, 1, 79, 170, 120, 0, 0, 8 }, + /* 11*/ { BARCODE_CODE128, 3, -1, 4, -1, 0, "A123", 0, 50, 1, 79, 170, 116, 1, 0, 8 }, + /* 12*/ { BARCODE_CODE128, 3, -1, 4, BARCODE_BIND, 0, "A123", 0, 50, 1, 79, 170, 132, 1, 0, 0 }, + /* 13*/ { BARCODE_CODE128, 3, -1, 4, BARCODE_BIND, 0, "A123", 0, 50, 1, 79, 170, 132, 0, 8, 0 }, + /* 14*/ { BARCODE_CODE128, 3, -1, 4, BARCODE_BOX, 0, "A123", 0, 50, 1, 79, 186, 132, 1, 8, 0 }, + /* 15*/ { BARCODE_CODE128, -1, -1, -1, BARCODE_DOTTY_MODE, 0, "A123", ZINT_ERROR_INVALID_OPTION, -1, -1, -1, -1, -1, -1, -1, -1 }, + /* 16*/ { BARCODE_CODE128, -1, -1, -1, OUT_BUFFER_INTERMEDIATE, 0, "A123", 0, 50, 1, 79, 158, 116, 0, 0, 4 }, + /* 17*/ { BARCODE_CODE128, -1, -1, -1, OUT_BUFFER_INTERMEDIATE, 180, "A123", 0, 50, 1, 79, 158, 116, 0, 115, 4 }, + /* 18*/ { BARCODE_CODE128, 3, -1, 4, BARCODE_BOX | OUT_BUFFER_INTERMEDIATE, 0, "A123", 0, 50, 1, 79, 186, 132, 1, 8, 0 }, + /* 19*/ { BARCODE_QRCODE, -1, -1, -1, -1, 0, "A123", 0, 21, 21, 21, 42, 42, 0, 2, 2 }, + /* 20*/ { BARCODE_QRCODE, -1, -1, -1, -1, 180, "A123", 0, 21, 21, 21, 42, 42, 0, 39, 2 }, + /* 21*/ { BARCODE_QRCODE, -1, -1, 3, -1, 0, "A123", 0, 21, 21, 21, 42, 42, 0, 2, 2 }, + /* 22*/ { BARCODE_QRCODE, -1, -1, 3, BARCODE_BIND, 0, "A123", 0, 21, 21, 21, 42, 54, 1, 2, 2 }, + /* 23*/ { BARCODE_QRCODE, -1, -1, 3, BARCODE_BIND, 0, "A123", 0, 21, 21, 21, 42, 54, 0, 20, 0 }, + /* 24*/ { BARCODE_QRCODE, -1, -1, 3, BARCODE_BOX, 0, "A123", 0, 21, 21, 21, 54, 54, 1, 20, 0 }, + /* 25*/ { BARCODE_QRCODE, -1, -1, -1, -1, 0, "A123", 0, 21, 21, 21, 42, 42, 1, 0, 0 }, + /* 26*/ { BARCODE_QRCODE, 5, -1, -1, -1, 0, "A123", 0, 21, 21, 21, 62, 42, 0, 0, 0 }, + /* 27*/ { BARCODE_QRCODE, 5, -1, 6, -1, 0, "A123", 0, 21, 21, 21, 62, 42, 0, 0, 0 }, + /* 28*/ { BARCODE_QRCODE, 5, -1, 6, BARCODE_BIND, 0, "A123", 0, 21, 21, 21, 62, 66, 1, 0, 0 }, + /* 29*/ { BARCODE_QRCODE, 5, -1, 6, BARCODE_BIND, 0, "A123", 0, 21, 21, 21, 62, 66, 0, 12, 0 }, + /* 30*/ { BARCODE_QRCODE, 5, -1, 6, BARCODE_BOX, 0, "A123", 0, 21, 21, 21, 86, 66, 1, 12, 0 }, + /* 31*/ { BARCODE_QRCODE, -1, -1, -1, BARCODE_DOTTY_MODE, 0, "A123", 0, 21, 21, 21, 43, 43, 1, 1, 1 }, + /* 32*/ { BARCODE_QRCODE, -1, -1, -1, BARCODE_DOTTY_MODE, 0, "A123", 0, 21, 21, 21, 43, 43, 0, 2, 2 }, + /* 33*/ { BARCODE_QRCODE, -1, -1, -1, BARCODE_DOTTY_MODE, 0, "A123", 0, 21, 21, 21, 43, 43, 1, 41, 1 }, + /* 34*/ { BARCODE_QRCODE, -1, -1, -1, BARCODE_DOTTY_MODE, 0, "A123", 0, 21, 21, 21, 43, 43, 0, 40, 2 }, + /* 35*/ { BARCODE_QRCODE, -1, -1, 4, BARCODE_DOTTY_MODE, 0, "A123", 0, 21, 21, 21, 43, 43, 1, 1, 1 }, + /* 36*/ { BARCODE_QRCODE, -1, -1, 4, BARCODE_DOTTY_MODE, 0, "A123", 0, 21, 21, 21, 43, 43, 0, 2, 2 }, + /* 37*/ { BARCODE_QRCODE, -1, -1, 4, BARCODE_BIND | BARCODE_DOTTY_MODE, 0, "A123", 0, 21, 21, 21, 43, 59, 1, 2, 2 }, + /* 38*/ { BARCODE_QRCODE, -1, -1, 4, BARCODE_BOX | BARCODE_DOTTY_MODE, 0, "A123", 0, 21, 21, 21, 59, 59, 1, 9, 9 }, + /* 39*/ { BARCODE_QRCODE, 1, -1, 4, BARCODE_BOX | BARCODE_DOTTY_MODE, 0, "A123", 0, 21, 21, 21, 63, 59, 0, 9, 9 }, + /* 40*/ { BARCODE_QRCODE, 1, -1, 4, BARCODE_BOX | BARCODE_DOTTY_MODE, 0, "A123", 0, 21, 21, 21, 63, 59, 1, 0, 0 }, + /* 41*/ { BARCODE_QRCODE, 1, -1, 4, BARCODE_BOX | BARCODE_DOTTY_MODE, 0, "A123", 0, 21, 21, 21, 63, 59, 1, 9, 11 }, + /* 42*/ { BARCODE_QRCODE, 1, 1, 4, BARCODE_BOX | BARCODE_DOTTY_MODE, 0, "A123", 0, 21, 21, 21, 63, 63, 0, 0, 0 }, + /* 43*/ { BARCODE_QRCODE, 1, 1, 4, BARCODE_BOX | BARCODE_DOTTY_MODE, 0, "A123", 0, 21, 21, 21, 63, 63, 1, 9, 13 }, + /* 44*/ { BARCODE_QRCODE, -1, -1, -1, OUT_BUFFER_INTERMEDIATE, 0, "A123", 0, 21, 21, 21, 42, 42, 1, 1, 1 }, + /* 45*/ { BARCODE_QRCODE, -1, -1, -1, OUT_BUFFER_INTERMEDIATE, 0, "A123", 0, 21, 21, 21, 42, 42, 0, 2, 2 }, + /* 46*/ { BARCODE_QRCODE, -1, -1, -1, BARCODE_DOTTY_MODE | OUT_BUFFER_INTERMEDIATE, 0, "A123", 0, 21, 21, 21, 43, 43, 1, 1, 1 }, + /* 47*/ { BARCODE_QRCODE, -1, -1, -1, BARCODE_DOTTY_MODE | OUT_BUFFER_INTERMEDIATE, 0, "A123", 0, 21, 21, 21, 43, 43, 0, 2, 2 }, + /* 48*/ { BARCODE_QRCODE, -1, -1, -1, BARCODE_DOTTY_MODE | OUT_BUFFER_INTERMEDIATE, 180, "A123", 0, 21, 21, 21, 43, 43, 1, 41, 1 }, + /* 49*/ { BARCODE_QRCODE, -1, -1, -1, BARCODE_DOTTY_MODE | OUT_BUFFER_INTERMEDIATE, 180, "A123", 0, 21, 21, 21, 43, 43, 0, 40, 2 }, + /* 50*/ { BARCODE_MAXICODE, -1, -1, -1, -1, 0, "A123", 0, 165, 33, 30, 299, 298, 0, 4, 4 }, + /* 51*/ { BARCODE_MAXICODE, -1, -1, -1, -1, 0, "A123", 0, 165, 33, 30, 299, 298, 1, 4, 14 }, + /* 52*/ { BARCODE_MAXICODE, -1, -1, -1, -1, 270, "A123", 0, 165, 33, 30, 298, 299, 1, 4, 4 }, + /* 53*/ { BARCODE_MAXICODE, -1, -1, -1, -1, 270, "A123", 0, 165, 33, 30, 298, 299, 0, 4, 14 }, + /* 54*/ { BARCODE_MAXICODE, -1, -1, 5, -1, 0, "A123", 0, 165, 33, 30, 299, 298, 0, 0, 0 }, + /* 55*/ { BARCODE_MAXICODE, -1, -1, 5, BARCODE_BIND, 0, "A123", 0, 165, 33, 30, 299, 298 + 50 * 2, 1, 0, 0 }, + /* 56*/ { BARCODE_MAXICODE, -1, -1, 5, BARCODE_BIND, 0, "A123", 0, 165, 33, 30, 299, 298 + 50 * 2, 0, 50, 0 }, + /* 57*/ { BARCODE_MAXICODE, -1, -1, 5, BARCODE_BIND, 0, "A123", 0, 165, 33, 30, 299, 298 + 50 * 2, 0, 347, 50 }, + /* 58*/ { BARCODE_MAXICODE, -1, -1, 5, BARCODE_BIND, 0, "A123", 0, 165, 33, 30, 299, 298 + 50 * 2, 1, 348, 50 }, + /* 59*/ { BARCODE_MAXICODE, -1, -1, 5, BARCODE_BOX, 0, "A123", 0, 165, 33, 30, 299 + 50 * 2, 298 + 50 * 2, 1, 50, 0 }, + /* 60*/ { BARCODE_MAXICODE, -1, -1, 5, BARCODE_BOX, 0, "A123", 0, 165, 33, 30, 299 + 50 * 2, 298 + 50 * 2, 0, 347, 50 }, + /* 61*/ { BARCODE_MAXICODE, -1, -1, -1, -1, 0, "A123", 0, 165, 33, 30, 299, 298, 1, 0, 14 }, + /* 62*/ { BARCODE_MAXICODE, 6, -1, -1, -1, 0, "A123", 0, 165, 33, 30, 299 + 60 * 2, 298, 0, 0, 14 }, + /* 63*/ { BARCODE_MAXICODE, 6, -1, -1, -1, 0, "A123", 0, 165, 33, 30, 299 + 60 * 2, 298, 0, 0, 47 }, + /* 64*/ { BARCODE_MAXICODE, 6, -1, 5, BARCODE_BIND, 0, "A123", 0, 165, 33, 30, 299 + 60 * 2, 298 + 50 * 2, 1, 0, 47 }, + /* 65*/ { BARCODE_MAXICODE, 6, -1, 5, BARCODE_BIND, 0, "A123", 0, 165, 33, 30, 299 + 60 * 2, 298 + 50 * 2, 0, 50, 0 }, + /* 66*/ { BARCODE_MAXICODE, 6, -1, 5, BARCODE_BOX, 0, "A123", 0, 165, 33, 30, 299 + (60 + 50) * 2, 298 + 50 * 2, 1, 50, 0 }, + /* 67*/ { BARCODE_MAXICODE, -1, -1, -1, BARCODE_DOTTY_MODE, 0, "A123", ZINT_ERROR_INVALID_OPTION, -1, -1, -1, -1, -1, -1, -1, -1 }, + /* 68*/ { BARCODE_MAXICODE, -1, -1, -1, OUT_BUFFER_INTERMEDIATE, 0, "A123", 0, 165, 33, 30, 299, 298, 0, 4, 4 }, + /* 69*/ { BARCODE_MAXICODE, -1, -1, -1, OUT_BUFFER_INTERMEDIATE, 0, "A123", 0, 165, 33, 30, 299, 298, 1, 4, 14 }, + /* 70*/ { BARCODE_MAXICODE, -1, -1, -1, OUT_BUFFER_INTERMEDIATE, 270, "A123", 0, 165, 33, 30, 298, 299, 1, 4, 4 }, + /* 71*/ { BARCODE_MAXICODE, -1, -1, -1, OUT_BUFFER_INTERMEDIATE, 270, "A123", 0, 165, 33, 30, 298, 299, 0, 4, 14 }, + /* 72*/ { BARCODE_ITF14, -1, -1, -1, -1, 0, "123", 0, 50, 1, 135, 330, 136, 1, 110, 0 }, + /* 73*/ { BARCODE_ITF14, -1, -1, -1, -1, 90, "123", 0, 50, 1, 135, 136, 330, 1, 0, 110 }, + /* 74*/ { BARCODE_ITF14, -1, -1, 0, -1, 0, "123", 0, 50, 1, 135, 330, 136, 1, 110, 0 }, + /* 75*/ { BARCODE_ITF14, -1, -1, 0, BARCODE_BOX, 0, "123", 0, 50, 1, 135, 310, 116, 0, 100, 0 }, + /* 76*/ { BARCODE_ITF14, -1, -1, -1, OUT_BUFFER_INTERMEDIATE, 0, "123", 0, 50, 1, 135, 330, 136, 1, 110, 0 }, + /* 77*/ { BARCODE_ITF14, -1, -1, -1, OUT_BUFFER_INTERMEDIATE, 90, "123", 0, 50, 1, 135, 136, 330, 1, 0, 110 }, }; int data_size = ARRAY_SIZE(data); @@ -716,6 +723,9 @@ static void test_output_options(int index, int debug) { if (data[i].whitespace_width != -1) { symbol->whitespace_width = data[i].whitespace_width; } + if (data[i].whitespace_height != -1) { + symbol->whitespace_height = data[i].whitespace_height; + } if (data[i].border_width != -1) { symbol->border_width = data[i].border_width; } @@ -729,7 +739,7 @@ static void test_output_options(int index, int debug) { if (ret < 5) { assert_nonnull(symbol->bitmap, "i:%d (%s) symbol->bitmap NULL\n", i, testUtilBarcodeName(data[i].symbology)); - if (index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) testUtilBitmapPrint(symbol, NULL, NULL); + if (index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) testUtilBitmapPrint(symbol, NULL, NULL); // ZINT_DEBUG_TEST_PRINT 16 assert_equal(symbol->height, data[i].expected_height, "i:%d (%s) symbol->height %d != %d\n", i, testUtilBarcodeName(data[i].symbology), symbol->height, data[i].expected_height); assert_equal(symbol->rows, data[i].expected_rows, "i:%d (%s) symbol->rows %d != %d\n", i, testUtilBarcodeName(data[i].symbology), symbol->rows, data[i].expected_rows); @@ -809,7 +819,7 @@ static void test_draw_string_wrap(int index, int debug) { assert_equal(symbol->bitmap_width, data[i].expected_bitmap_width, "i:%d (%d) symbol->bitmap_width %d != %d\n", i, data[i].symbology, symbol->bitmap_width, data[i].expected_bitmap_width); assert_equal(symbol->bitmap_height, data[i].expected_bitmap_height, "i:%d (%d) symbol->bitmap_height %d != %d\n", i, data[i].symbology, symbol->bitmap_height, data[i].expected_bitmap_height); - if (index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) testUtilBitmapPrint(symbol, NULL, NULL); + if (index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) testUtilBitmapPrint(symbol, NULL, NULL); // ZINT_DEBUG_TEST_PRINT 16 ret = ZBarcode_Print(symbol, 0); assert_zero(ret, "i:%d ZBarcode_Print(%d) ret %d != 0\n", i, data[i].symbology, ret); @@ -875,7 +885,7 @@ static void test_code128_utf8(int index, int debug) { assert_equal(symbol->bitmap_width, data[i].expected_bitmap_width, "i:%d (%d) symbol->bitmap_width %d != %d\n", i, BARCODE_CODE128, symbol->bitmap_width, data[i].expected_bitmap_width); assert_equal(symbol->bitmap_height, data[i].expected_bitmap_height, "i:%d (%d) symbol->bitmap_height %d != %d\n", i, BARCODE_CODE128, symbol->bitmap_height, data[i].expected_bitmap_height); - if (index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) testUtilBitmapPrint(symbol, NULL, NULL); + if (index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) testUtilBitmapPrint(symbol, NULL, NULL); // ZINT_DEBUG_TEST_PRINT 16 ret = ZBarcode_Print(symbol, 0); assert_zero(ret, "i:%d ZBarcode_Print(%d) ret %d != 0\n", i, BARCODE_CODE128, ret); @@ -979,7 +989,7 @@ static void test_scale(int index, int debug) { assert_zero(ret, "i:%d ZBarcode_Buffer(%d) ret %d != 0\n", i, data[i].symbology, ret); assert_nonnull(symbol->bitmap, "i:%d (%d) symbol->bitmap NULL\n", i, data[i].symbology); - if (index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) testUtilBitmapPrint(symbol, NULL, NULL); + if (index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) testUtilBitmapPrint(symbol, NULL, NULL); // ZINT_DEBUG_TEST_PRINT 16 assert_equal(symbol->height, data[i].expected_height, "i:%d (%d) symbol->height %d != %d\n", i, data[i].symbology, symbol->height, data[i].expected_height); assert_equal(symbol->rows, data[i].expected_rows, "i:%d (%d) symbol->rows %d != %d\n", i, data[i].symbology, symbol->rows, data[i].expected_rows); @@ -1129,7 +1139,7 @@ static void test_buffer_plot(int index, int generate, int debug) { for (int i = 0; i < data_size; i++) { if (index != -1 && i != index) continue; - if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d\n", i); + if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d\n", i); // ZINT_DEBUG_TEST_PRINT 16 struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); @@ -1156,7 +1166,7 @@ static void test_buffer_plot(int index, int generate, int debug) { assert_zero(ret, "i:%d ZBarcode_Buffer(%s) ret %d != 0 (%s)\n", i, testUtilBarcodeName(data[i].symbology), ret, symbol->errtxt); assert_nonnull(symbol->bitmap, "i:%d ZBarcode_Buffer(%s) bitmap NULL\n", i, testUtilBarcodeName(data[i].symbology)); - if (index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) testUtilBitmapPrint(symbol, NULL, NULL); + if (index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) testUtilBitmapPrint(symbol, NULL, NULL); // ZINT_DEBUG_TEST_PRINT 16 if (generate) { printf(" /*%3d*/ { %s, %d, %d, %d, %s, \"%s\", \"%s\", \"%s\", %d, %d, %d, %d, %d,\n", diff --git a/backend/tests/test_svg.c b/backend/tests/test_svg.c index 6f1bd35c..f060bad5 100644 --- a/backend/tests/test_svg.c +++ b/backend/tests/test_svg.c @@ -49,6 +49,8 @@ static void test_print(int index, int generate, int debug) { int input_mode; int border_width; int output_options; + int whitespace_width; + int whitespace_height; int show_hrt; int option_1; int option_2; @@ -57,40 +59,47 @@ static void test_print(int index, int generate, int debug) { char *expected_file; }; struct item data[] = { - /* 0*/ { BARCODE_CODE128, -1, -1, -1, -1, -1, -1, "<>\"&'", "", "../data/svg/code128_amperands.svg" }, - /* 1*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, "Égjpqy", "", "../data/svg/code128_egrave_bold.svg" }, - /* 2*/ { BARCODE_CODE128, UNICODE_MODE, 3, BOLD_TEXT | BARCODE_BOX, -1, -1, -1, "Égjpqy", "", "../data/svg/code128_egrave_bold_box3.svg" }, - /* 3*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, 3, -1, "[00]030123456789012340", "[02]13012345678909[37]24[10]1234567ABCDEFG", "../data/svg/gs1_128_cc_fig12.svg" }, - /* 4*/ { BARCODE_CODABLOCKF, -1, -1, -1, -1, 3, -1, "AAAAAAAAA", "", "../data/svg/codablockf_3rows.svg" }, - /* 5*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, "9771384524017+12", "", "../data/svg/ean13_2addon_ggs_5.2.2.5.1-2.svg" }, - /* 6*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, "9780877799306+54321", "", "../data/svg/ean13_5addon_ggs_5.2.2.5.2-2.svg" }, - /* 7*/ { BARCODE_EANX_CC, -1, -1, -1, -1, 1, -1, "123456789012+12", "[91]123456789012345678901", "../data/svg/ean13_cc_2addon_cca_4x4.svg" }, - /* 8*/ { BARCODE_EANX_CC, -1, -1, -1, -1, 2, -1, "123456789012+54321", "[91]1234567890", "../data/svg/ean13_cc_5addon_ccb_3x4.svg" }, - /* 9*/ { BARCODE_EANX_CC, -1, -1, -1, 0, 2, -1, "123456789012+54321", "[91]1234567890", "../data/svg/ean13_cc_5addon_ccb_3x4_notext.svg" }, - /* 10*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, -1, "012345678905+24", "", "../data/svg/upca_2addon_ggs_5.2.6.6-5.svg" }, - /* 11*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, -1, "614141234417+12345", "", "../data/svg/upca_5addon.svg" }, - /* 12*/ { BARCODE_UPCA, -1, 3, BARCODE_BIND, -1, -1, -1, "614141234417+12345", "", "../data/svg/upca_5addon_bind3.svg" }, - /* 13*/ { BARCODE_UPCA, -1, -1, SMALL_TEXT | BOLD_TEXT, -1, -1, -1, "614141234417+12345", "", "../data/svg/upca_5addon_small_bold.svg" }, - /* 14*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, 1, -1, "12345678901+12", "[91]123456789", "../data/svg/upca_cc_2addon_cca_3x4.svg" }, - /* 15*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, 2, -1, "12345678901+12121", "[91]1234567890123", "../data/svg/upca_cc_5addon_ccb_4x4.svg" }, - /* 16*/ { BARCODE_UPCA_CC, -1, -1, -1, 0, 2, -1, "12345678901+12121", "[91]1234567890123", "../data/svg/upca_cc_5addon_ccb_4x4_notext.svg" }, - /* 17*/ { BARCODE_UPCA_CC, -1, 3, BARCODE_BIND, -1, 2, -1, "12345678901+12121", "[91]1234567890123", "../data/svg/upca_cc_5addon_ccb_4x4_bind3.svg" }, - /* 18*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, -1, "1234567+12", "", "../data/svg/upce_2addon.svg" }, - /* 19*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, -1, "1234567+12345", "", "../data/svg/upce_5addon.svg" }, - /* 20*/ { BARCODE_UPCE, -1, -1, SMALL_TEXT, -1, -1, -1, "1234567+12345", "", "../data/svg/upce_5addon_small.svg" }, - /* 21*/ { BARCODE_UPCE, -1, -1, -1, 0, -1, -1, "1234567+12345", "", "../data/svg/upce_5addon_notext.svg" }, - /* 22*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, 1, -1, "0654321+89", "[91]1", "../data/svg/upce_cc_2addon_cca_5x2.svg" }, - /* 23*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, 2, -1, "1876543+56789", "[91]12345", "../data/svg/upce_cc_5addon_ccb_8x2.svg" }, - /* 24*/ { BARCODE_UPCE_CC, -1, -1, -1, 0, 2, -1, "1876543+56789", "[91]12345", "../data/svg/upce_cc_5addon_ccb_8x2_notext.svg" }, - /* 25*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, "1234567+12", "", "../data/svg/ean8_2addon.svg" }, - /* 26*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, "1234567+12345", "", "../data/svg/ean8_5addon.svg" }, - /* 27*/ { BARCODE_EANX_CC, -1, -1, -1, -1, 1, -1, "9876543+65", "[91]1234567", "../data/svg/ean8_cc_2addon_cca_4x3.svg" }, - /* 28*/ { BARCODE_EANX_CC, -1, -1, -1, -1, 2, -1, "9876543+74083", "[91]123456789012345678", "../data/svg/ean8_cc_5addon_ccb_8x3.svg" }, - /* 29*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, "12345", "", "../data/svg/ean5.svg" }, - /* 30*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, "12", "", "../data/svg/ean2.svg" }, - /* 31*/ { BARCODE_CODE39, -1, -1, SMALL_TEXT, -1, -1, -1, "123", "", "../data/svg/code39_small.svg" }, - /* 32*/ { BARCODE_POSTNET, -1, -1, -1, -1, -1, -1, "12345", "", "../data/svg/postnet_zip.svg" }, - /* 33*/ { BARCODE_MAXICODE, -1, 2, BARCODE_BOX, -1, -1, -1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "../data/svg/maxicode_box2.svg" }, + /* 0*/ { BARCODE_CODE128, -1, -1, -1, -1, -1, -1, -1, -1, "<>\"&'", "", "../data/svg/code128_amperands.svg" }, + /* 1*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, -1, "Égjpqy", "", "../data/svg/code128_egrave_bold.svg" }, + /* 2*/ { BARCODE_CODE128, UNICODE_MODE, 3, BOLD_TEXT | BARCODE_BOX, -1, -1, -1, -1, -1, "Égjpqy", "", "../data/svg/code128_egrave_bold_box3.svg" }, + /* 3*/ { BARCODE_CODE128, UNICODE_MODE, 2, BOLD_TEXT | BARCODE_BOX, 2, 2, -1, -1, -1, "Égjpqy", "", "../data/svg/code128_egrave_bold_hvwsp2_box2.svg" }, + /* 4*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, 3, 3, -1, -1, -1, "Égjpqy", "", "../data/svg/code128_egrave_bold_hvwsp3.svg" }, + /* 5*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, -1, -1, 3, -1, "[00]030123456789012340", "[02]13012345678909[37]24[10]1234567ABCDEFG", "../data/svg/gs1_128_cc_fig12.svg" }, + /* 6*/ { BARCODE_CODABLOCKF, -1, -1, -1, -1, -1, -1, 3, -1, "AAAAAAAAA", "", "../data/svg/codablockf_3rows.svg" }, + /* 7*/ { BARCODE_CODABLOCKF, -1, -1, -1, 2, 2, -1, 3, -1, "AAAAAAAAA", "", "../data/svg/codablockf_hvwsp2.svg" }, + /* 8*/ { BARCODE_CODABLOCKF, -1, 2, BARCODE_BOX, 2, 2, -1, -1, -1, "AAAAAAAAA", "", "../data/svg/codablockf_hvwsp2_box2.svg" }, + /* 9*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, "9771384524017+12", "", "../data/svg/ean13_2addon_ggs_5.2.2.5.1-2.svg" }, + /* 10*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, "9780877799306+54321", "", "../data/svg/ean13_5addon_ggs_5.2.2.5.2-2.svg" }, + /* 11*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, 1, -1, "123456789012+12", "[91]123456789012345678901", "../data/svg/ean13_cc_2addon_cca_4x4.svg" }, + /* 12*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, 2, -1, "123456789012+54321", "[91]1234567890", "../data/svg/ean13_cc_5addon_ccb_3x4.svg" }, + /* 13*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, 0, 2, -1, "123456789012+54321", "[91]1234567890", "../data/svg/ean13_cc_5addon_ccb_3x4_notext.svg" }, + /* 14*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, -1, -1, -1, "012345678905+24", "", "../data/svg/upca_2addon_ggs_5.2.6.6-5.svg" }, + /* 15*/ { BARCODE_UPCA, -1, -1, -1, -1, -1, -1, -1, -1, "614141234417+12345", "", "../data/svg/upca_5addon.svg" }, + /* 16*/ { BARCODE_UPCA, -1, 3, BARCODE_BIND, -1, -1, -1, -1, -1, "614141234417+12345", "", "../data/svg/upca_5addon_bind3.svg" }, + /* 17*/ { BARCODE_UPCA, -1, -1, SMALL_TEXT | BOLD_TEXT, -1, -1, -1, -1, -1, "614141234417+12345", "", "../data/svg/upca_5addon_small_bold.svg" }, + /* 18*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, -1, 1, -1, "12345678901+12", "[91]123456789", "../data/svg/upca_cc_2addon_cca_3x4.svg" }, + /* 19*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, -1, 2, -1, "12345678901+12121", "[91]1234567890123", "../data/svg/upca_cc_5addon_ccb_4x4.svg" }, + /* 20*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, -1, 0, 2, -1, "12345678901+12121", "[91]1234567890123", "../data/svg/upca_cc_5addon_ccb_4x4_notext.svg" }, + /* 21*/ { BARCODE_UPCA_CC, -1, 3, BARCODE_BIND, -1, -1, -1, 2, -1, "12345678901+12121", "[91]1234567890123", "../data/svg/upca_cc_5addon_ccb_4x4_bind3.svg" }, + /* 22*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, -1, -1, -1, "1234567+12", "", "../data/svg/upce_2addon.svg" }, + /* 23*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, -1, -1, -1, "1234567+12345", "", "../data/svg/upce_5addon.svg" }, + /* 24*/ { BARCODE_UPCE, -1, -1, SMALL_TEXT, -1, -1, -1, -1, -1, "1234567+12345", "", "../data/svg/upce_5addon_small.svg" }, + /* 25*/ { BARCODE_UPCE, -1, -1, -1, -1, -1, 0, -1, -1, "1234567+12345", "", "../data/svg/upce_5addon_notext.svg" }, + /* 26*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, -1, 1, -1, "0654321+89", "[91]1", "../data/svg/upce_cc_2addon_cca_5x2.svg" }, + /* 27*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, -1, 2, -1, "1876543+56789", "[91]12345", "../data/svg/upce_cc_5addon_ccb_8x2.svg" }, + /* 28*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, -1, 0, 2, -1, "1876543+56789", "[91]12345", "../data/svg/upce_cc_5addon_ccb_8x2_notext.svg" }, + /* 29*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, "1234567+12", "", "../data/svg/ean8_2addon.svg" }, + /* 30*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, "1234567+12345", "", "../data/svg/ean8_5addon.svg" }, + /* 31*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, 1, -1, "9876543+65", "[91]1234567", "../data/svg/ean8_cc_2addon_cca_4x3.svg" }, + /* 32*/ { BARCODE_EANX_CC, -1, -1, -1, -1, -1, -1, 2, -1, "9876543+74083", "[91]123456789012345678", "../data/svg/ean8_cc_5addon_ccb_8x3.svg" }, + /* 33*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, "12345", "", "../data/svg/ean5.svg" }, + /* 34*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, "12", "", "../data/svg/ean2.svg" }, + /* 35*/ { BARCODE_CODE39, -1, -1, SMALL_TEXT, -1, -1, -1, -1, -1, "123", "", "../data/svg/code39_small.svg" }, + /* 36*/ { BARCODE_POSTNET, -1, -1, -1, -1, -1, -1, -1, -1, "12345", "", "../data/svg/postnet_zip.svg" }, + /* 37*/ { BARCODE_MAXICODE, -1, 2, BARCODE_BOX, -1, -1, -1, -1, -1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "../data/svg/maxicode_box2.svg" }, + /* 38*/ { BARCODE_MAXICODE, -1, 1, BARCODE_BIND, -1, 1, -1, -1, -1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "../data/svg/maxicode_vwsp1_bind1.svg" }, + /* 39*/ { BARCODE_DATAMATRIX, -1, 1, BARCODE_BIND | BARCODE_DOTTY_MODE, -1, 1, -1, -1, -1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "../data/svg/datamatrix_vwsp1_bind1_dotty.svg" }, + /* 40*/ { BARCODE_DATAMATRIX, -1, 1, BARCODE_BIND | BARCODE_DOTTY_MODE, 1, 1, -1, -1, -1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "../data/svg/datamatrix_hvwsp1_bind1_dotty.svg" }, }; int data_size = ARRAY_SIZE(data); @@ -121,6 +130,12 @@ static void test_print(int index, int generate, int debug) { if (data[i].border_width != -1) { symbol->border_width = data[i].border_width; } + if (data[i].whitespace_width != -1) { + symbol->whitespace_width = data[i].whitespace_width; + } + if (data[i].whitespace_height != -1) { + symbol->whitespace_height = data[i].whitespace_height; + } if (strlen(data[i].composite)) { text = data[i].composite; strcpy(symbol->primary, data[i].data); @@ -137,9 +152,10 @@ static void test_print(int index, int generate, int debug) { assert_zero(ret, "i:%d %s ZBarcode_Print %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, ret); if (generate) { - printf(" /*%3d*/ { %s, %s, %d, %s, %d, %d, %d, \"%s\", \"%s\", \"%s\" },\n", + printf(" /*%3d*/ { %s, %s, %d, %s, %d, %d, %d, %d, %d, \"%s\", \"%s\", \"%s\" },\n", i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), data[i].border_width, testUtilOutputOptionsName(data[i].output_options), - data[i].show_hrt, data[i].option_1, data[i].option_2, testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].composite, data[i].expected_file); + data[i].whitespace_width, data[i].whitespace_height, data[i].show_hrt, data[i].option_1, data[i].option_2, + testUtilEscape(data[i].data, length, escaped, escaped_size), data[i].composite, data[i].expected_file); ret = rename(symbol->outfile, data[i].expected_file); assert_zero(ret, "i:%d rename(%s, %s) ret %d != 0\n", i, symbol->outfile, data[i].expected_file, ret); if (have_libreoffice) { diff --git a/backend/tests/test_vector.c b/backend/tests/test_vector.c index 5c1c1243..cec91485 100644 --- a/backend/tests/test_vector.c +++ b/backend/tests/test_vector.c @@ -592,6 +592,7 @@ static void test_output_options(int index, int debug) { struct item { int symbology; int whitespace_width; + int whitespace_height; int border_width; int output_options; char *data; @@ -608,45 +609,49 @@ static void test_output_options(int index, int debug) { }; // s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<")) struct item data[] = { - /* 0*/ { BARCODE_CODE128, -1, -1, -1, "A123", 0, 50, 1, 79, 158, 118.9, 0, 0, 4 }, - /* 1*/ { BARCODE_CODE128, -1, 2, -1, "A123", 0, 50, 1, 79, 158, 118.9, 0, 0, 4 }, - /* 2*/ { BARCODE_CODE128, -1, 2, BARCODE_BIND, "A123", 0, 50, 1, 79, 158, 126.9, 1, 0, 4 }, - /* 3*/ { BARCODE_CODE128, -1, 2, BARCODE_BIND, "A123", 0, 50, 1, 79, 158, 126.9, 0, 4, 4 }, - /* 4*/ { BARCODE_CODE128, -1, 2, BARCODE_BOX, "A123", 0, 50, 1, 79, 166, 126.9, 1, 4, 4 }, - /* 5*/ { BARCODE_CODE128, -1, 0, BARCODE_BIND, "A123", 0, 50, 1, 79, 158, 118.9, 0, 0, 4 }, - /* 6*/ { BARCODE_CODE128, -1, 0, BARCODE_BOX, "A123", 0, 50, 1, 79, 158, 118.9, 0, 4, 4 }, - /* 7*/ { BARCODE_CODE128, -1, -1, -1, "A123", 0, 50, 1, 79, 158, 118.9, 0, 6, 8 }, - /* 8*/ { BARCODE_CODE128, 3, 4, BARCODE_BIND, "A123", 0, 50, 1, 79, 170, 134.89999, 1, 6, 8 }, - /* 9*/ { BARCODE_CODE128, 3, 4, BARCODE_BIND, "A123", 0, 50, 1, 79, 170, 134.89999, 0, 14, 8 }, - /* 10*/ { BARCODE_CODE128, 3, 4, BARCODE_BOX, "A123", 0, 50, 1, 79, 186, 134.89999, 1, 14, 8 }, - /* 11*/ { BARCODE_CODE128, -1, -1, BARCODE_DOTTY_MODE, "A123", ZINT_ERROR_INVALID_OPTION, -1, -1, -1, -1, -1, -1, -1, -1 }, - /* 12*/ { BARCODE_QRCODE, -1, -1, -1, "A123", 0, 21, 21, 21, 42, 42, 0, 0, 6 }, - /* 13*/ { BARCODE_QRCODE, -1, 3, -1, "A123", 0, 21, 21, 21, 42, 42, 0, 0, 6 }, - /* 14*/ { BARCODE_QRCODE, -1, 3, BARCODE_BIND, "A123", 0, 21, 21, 21, 42, 54, 1, 0, 6 }, - /* 15*/ { BARCODE_QRCODE, -1, 3, BARCODE_BIND, "A123", 0, 21, 21, 21, 42, 54, 0, 22, 8 }, - /* 16*/ { BARCODE_QRCODE, -1, 3, BARCODE_BOX, "A123", 0, 21, 21, 21, 54, 54, 1, 22, 8 }, - /* 17*/ { BARCODE_QRCODE, -1, -1, -1, "A123", 0, 21, 21, 21, 42, 42, 0, 10, 12 }, - /* 18*/ { BARCODE_QRCODE, 5, 6, BARCODE_BIND, "A123", 0, 21, 21, 21, 62, 66, 1, 10, 12 }, - /* 19*/ { BARCODE_QRCODE, 5, 6, BARCODE_BIND, "A123", 0, 21, 21, 21, 62, 66, 0, 22, 12 }, - /* 20*/ { BARCODE_QRCODE, 5, 6, BARCODE_BOX, "A123", 0, 21, 21, 21, 86, 66, 1, 22, 12 }, - /* 21*/ { BARCODE_QRCODE, -1, -1, BARCODE_DOTTY_MODE, "A123", 0, 21, 21, 21, 42, 42, 0, 0, 50 }, - /* 22*/ { BARCODE_QRCODE, -1, 4, BARCODE_DOTTY_MODE, "A123", 0, 21, 21, 21, 42, 42, 0, 0, 50 }, - /* 23*/ { BARCODE_QRCODE, -1, 4, BARCODE_BIND | BARCODE_DOTTY_MODE, "A123", 0, 21, 21, 21, 42, 58, 1, 0, 50 }, - /* 24*/ { BARCODE_QRCODE, -1, 4, BARCODE_BIND | BARCODE_DOTTY_MODE, "A123", 0, 21, 21, 21, 42, 58, 0, 54, 0 }, - /* 25*/ { BARCODE_QRCODE, 1, 4, BARCODE_BOX | BARCODE_DOTTY_MODE, "A123", 0, 21, 21, 21, 62, 58, 1, 54, 0 }, - /* 26*/ { BARCODE_MAXICODE, -1, -1, -1, "A123", 0, 165, 33, 30, 60, 57.733398, 0, 0, 67.7334 }, - /* 27*/ { BARCODE_MAXICODE, -1, 5, -1, "A123", 0, 165, 33, 30, 60, 57.733398, 0, 0, 67.7334 }, - /* 28*/ { BARCODE_MAXICODE, -1, 5, BARCODE_BIND, "A123", 0, 165, 33, 30, 60, 77.733398, 1, 0, 67.7334 }, - /* 29*/ { BARCODE_MAXICODE, -1, 5, BARCODE_BIND, "A123", 0, 165, 33, 30, 60, 77.733398, 0, 70, 0 }, - /* 30*/ { BARCODE_MAXICODE, -1, 5, BARCODE_BOX, "A123", 0, 165, 33, 30, 80, 77.733398, 1, 70, 0 }, - /* 31*/ { BARCODE_MAXICODE, -1, -1, -1, "A123", 0, 165, 33, 30, 60, 57.733398, 0, 0, 67.7334 }, - /* 32*/ { BARCODE_MAXICODE, 6, 5, BARCODE_BIND, "A123", 0, 165, 33, 30, 84, 77.733398, 1, 0, 67.7334 }, - /* 33*/ { BARCODE_MAXICODE, 6, 5, BARCODE_BIND, "A123", 0, 165, 33, 30, 84, 77.733398, 0, 94, 0 }, - /* 34*/ { BARCODE_MAXICODE, 6, 5, BARCODE_BOX, "A123", 0, 165, 33, 30, 104, 77.733398, 1, 94, 0 }, - /* 35*/ { BARCODE_MAXICODE, -1, -1, BARCODE_DOTTY_MODE, "A123", ZINT_ERROR_INVALID_OPTION, -1, -1, -1, -1, -1, -1, -1, -1 }, - /* 36*/ { BARCODE_ITF14, -1, -1, -1, "123", 0, 50, 1, 135, 330, 138.89999, 1, 320, 0 }, - /* 37*/ { BARCODE_ITF14, -1, 0, -1, "123", 0, 50, 1, 135, 330, 138.89999, 1, 320, 0 }, - /* 38*/ { BARCODE_ITF14, -1, 0, BARCODE_BOX, "123", 0, 50, 1, 135, 310, 118.9, 0, 300, 0 }, // No zero-width/height rectangles + /* 0*/ { BARCODE_CODE128, -1, -1, -1, -1, "A123", 0, 50, 1, 79, 158, 118.9, 0, 0, 4 }, + /* 1*/ { BARCODE_CODE128, -1, -1, 2, -1, "A123", 0, 50, 1, 79, 158, 118.9, 0, 0, 4 }, + /* 2*/ { BARCODE_CODE128, -1, -1, 2, BARCODE_BIND, "A123", 0, 50, 1, 79, 158, 126.9, 1, 0, 4 }, + /* 3*/ { BARCODE_CODE128, -1, -1, 2, BARCODE_BIND, "A123", 0, 50, 1, 79, 158, 126.9, 0, 4, 4 }, + /* 4*/ { BARCODE_CODE128, -1, -1, 2, BARCODE_BOX, "A123", 0, 50, 1, 79, 166, 126.9, 1, 4, 4 }, + /* 5*/ { BARCODE_CODE128, -1, -1, 0, BARCODE_BIND, "A123", 0, 50, 1, 79, 158, 118.9, 0, 0, 4 }, + /* 6*/ { BARCODE_CODE128, -1, -1, 0, BARCODE_BOX, "A123", 0, 50, 1, 79, 158, 118.9, 0, 4, 4 }, + /* 7*/ { BARCODE_CODE128, -1, -1, -1, -1, "A123", 0, 50, 1, 79, 158, 118.9, 0, 2, 0 }, + /* 8*/ { BARCODE_CODE128, 1, -1, -1, -1, "A123", 0, 50, 1, 79, 162, 118.9, 1, 2, 0 }, + /* 9*/ { BARCODE_CODE128, 1, 2, -1, -1, "A123", 0, 50, 1, 79, 162, 126.9, 0, 2, 0 }, + /* 10*/ { BARCODE_CODE128, 1, 2, -1, -1, "A123", 0, 50, 1, 79, 162, 126.9, 1, 2, 4 }, + /* 11*/ { BARCODE_CODE128, -1, -1, -1, -1, "A123", 0, 50, 1, 79, 158, 118.9, 0, 6, 8 }, + /* 12*/ { BARCODE_CODE128, 3, -1, 4, BARCODE_BIND, "A123", 0, 50, 1, 79, 170, 134.89999, 1, 6, 8 }, + /* 13*/ { BARCODE_CODE128, 3, -1, 4, BARCODE_BIND, "A123", 0, 50, 1, 79, 170, 134.89999, 0, 14, 8 }, + /* 14*/ { BARCODE_CODE128, 3, -1, 4, BARCODE_BOX, "A123", 0, 50, 1, 79, 186, 134.89999, 1, 14, 8 }, + /* 15*/ { BARCODE_CODE128, -1, -1, -1, BARCODE_DOTTY_MODE, "A123", ZINT_ERROR_INVALID_OPTION, -1, -1, -1, -1, -1, -1, -1, -1 }, + /* 16*/ { BARCODE_QRCODE, -1, -1, -1, -1, "A123", 0, 21, 21, 21, 42, 42, 0, 0, 6 }, + /* 17*/ { BARCODE_QRCODE, -1, -1, 3, -1, "A123", 0, 21, 21, 21, 42, 42, 0, 0, 6 }, + /* 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 }; int data_size = ARRAY_SIZE(data); @@ -663,6 +668,9 @@ static void test_output_options(int index, int debug) { if (data[i].whitespace_width != -1) { symbol->whitespace_width = data[i].whitespace_width; } + if (data[i].whitespace_height != -1) { + symbol->whitespace_height = data[i].whitespace_height; + } if (data[i].border_width != -1) { symbol->border_width = data[i].border_width; } diff --git a/backend/tests/testcommon.h b/backend/tests/testcommon.h index 733fc561..cb218edb 100644 --- a/backend/tests/testcommon.h +++ b/backend/tests/testcommon.h @@ -36,6 +36,12 @@ #ifndef TESTCOMMON_H #define TESTCOMMON_H +#define ZINT_DEBUG_TEST_PRINT 16 +#define ZINT_DEBUG_TEST_LESS_NOISY 32 +#define ZINT_DEBUG_TEST_KEEP_OUTFILE 64 +#define ZINT_DEBUG_TEST_BWIPP 128 +#define ZINT_DEBUG_TEST_PERFORMANCE 256 + #include #include "../common.h" @@ -73,12 +79,6 @@ void testRun(int argc, char *argv[], testFunction funcs[], int funcs_size); #define assert_fail(...) assert_exp(0, __VA_ARGS__) #define assert_nothing(__exp__, ...) {printf(__VA_ARGS__); __exp__;} -#define ZINT_DEBUG_TEST_PRINT 16 -#define ZINT_DEBUG_TEST_LESS_NOISY 32 -#define ZINT_DEBUG_TEST_KEEP_OUTFILE 64 -#define ZINT_DEBUG_TEST_BWIPP 128 -#define ZINT_DEBUG_TEST_PERFORMANCE 256 - INTERNAL void vector_free(struct zint_symbol *symbol); /* Free vector structures */ int testUtilSetSymbol(struct zint_symbol *symbol, int symbology, int input_mode, int eci, int option_1, int option_2, int option_3, int output_options, char *data, int length, int debug); diff --git a/backend/vector.c b/backend/vector.c index 06d7de38..208bb27c 100644 --- a/backend/vector.c +++ b/backend/vector.c @@ -487,10 +487,11 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_ vector->width = symbol->width + dot_overspill + (xoffset + roffset); vector->height = symbol->height + textoffset + dot_overspill + (yoffset + boffset); - if (symbol->border_width > 0 && ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND))) { - default_text_posn = symbol->height + text_height + text_gap + symbol->border_width + symbol->border_width; + if (symbol->border_width > 0 && (symbol->output_options & (BARCODE_BOX | BARCODE_BIND))) { + default_text_posn = symbol->height + text_height + text_gap + symbol->whitespace_height + + symbol->border_width * 2; } else { - default_text_posn = symbol->height + text_height + text_gap; + default_text_posn = symbol->height + text_height + text_gap + symbol->whitespace_height; } // Plot Maxicode symbols @@ -807,7 +808,7 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_ } // Binding and boxes - if ((symbol->output_options & BARCODE_BIND) != 0) { + if (symbol->output_options & BARCODE_BIND) { if ((symbol->rows > 1) && (is_stackable(symbol->symbology) == 1)) { float sep_height = 1.0f; if (symbol->option_3 > 0 && symbol->option_3 <= 4) { @@ -831,28 +832,35 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_ } } if (symbol->border_width > 0) { - if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) { + if (symbol->output_options & (BARCODE_BOX | BARCODE_BIND)) { + float ybind_bottom = vector->height - symbol->border_width - textoffset - symbol->whitespace_height; // Top - rectangle = vector_plot_create_rect(0.0f, 0.0f, vector->width, symbol->border_width); - if (!(symbol->output_options & BARCODE_BOX) && (symbol->symbology == BARCODE_CODABLOCKF || symbol->symbology == BARCODE_HIBC_BLOCKF)) { + rectangle = vector_plot_create_rect(0.0f, symbol->whitespace_height, vector->width, symbol->border_width); + if (!(symbol->output_options & BARCODE_BOX) + && (symbol->symbology == BARCODE_CODABLOCKF || symbol->symbology == BARCODE_HIBC_BLOCKF)) { + /* CodaBlockF bind - does not extend over horizontal whitespace */ rectangle->x = xoffset; rectangle->width -= (2.0f * xoffset); } vector_plot_add_rect(symbol, rectangle, &last_rectangle); // Bottom - rectangle = vector_plot_create_rect(0.0f, vector->height - symbol->border_width - textoffset, vector->width, symbol->border_width); - if (!(symbol->output_options & BARCODE_BOX) && (symbol->symbology == BARCODE_CODABLOCKF || symbol->symbology == BARCODE_HIBC_BLOCKF)) { + rectangle = vector_plot_create_rect(0.0f, ybind_bottom, vector->width, symbol->border_width); + if (!(symbol->output_options & BARCODE_BOX) + && (symbol->symbology == BARCODE_CODABLOCKF || symbol->symbology == BARCODE_HIBC_BLOCKF)) { + /* CodaBlockF bind - does not extend over horizontal whitespace */ rectangle->x = xoffset; rectangle->width -= (2.0f * xoffset); } vector_plot_add_rect(symbol, rectangle, &last_rectangle); } if (symbol->output_options & BARCODE_BOX) { + float xbox_right = vector->width - symbol->border_width; + float box_height = vector->height - textoffset - (symbol->whitespace_height + symbol->border_width) * 2; // Left - rectangle = vector_plot_create_rect(0.0f, 0.0f, symbol->border_width, vector->height - textoffset); + rectangle = vector_plot_create_rect(0.0f, yoffset, symbol->border_width, box_height); vector_plot_add_rect(symbol, rectangle, &last_rectangle); // Right - rectangle = vector_plot_create_rect(vector->width - symbol->border_width, 0.0f, symbol->border_width, vector->height - textoffset); + rectangle = vector_plot_create_rect(xbox_right, yoffset, symbol->border_width, box_height); vector_plot_add_rect(symbol, rectangle, &last_rectangle); } } diff --git a/backend/zint.h b/backend/zint.h index 502743b7..d2ad7d67 100644 --- a/backend/zint.h +++ b/backend/zint.h @@ -77,6 +77,7 @@ extern "C" { int symbology; int height; /* Height in X-dims (ignored for fixed-width barcodes) */ int whitespace_width; /* Width in X-dims of whitespace to left/right of barcode */ + int whitespace_height; /* Height in X-dims of whitespace above and below the barcode */ int border_width; /* Size of border in X-dims */ int output_options; char fgcolour[10]; /* Foreground as RGB/RGBA hexadecimal string */ diff --git a/backend_tcl/zint.c b/backend_tcl/zint.c index 198ef74e..47c4e594 100644 --- a/backend_tcl/zint.c +++ b/backend_tcl/zint.c @@ -113,6 +113,8 @@ - -cols maximum changed from 67 to 108 (DotCode) 2021-05-10 GL - Added -gs1parens option +2021-05-22 GL +- Added -vwhitesp option */ #if defined(__WIN32__) || defined(_WIN32) || defined(WIN32) @@ -473,6 +475,7 @@ static char help_message[] = "zint tcl(stub,obj) dll\n" " -square bool: force Data Matrix symbols to be square\n" /* cli option --types not supported */ " -vers integer: Symbology option\n" + " -vwhitesp integer: vertical quiet zone in modules\n" " -whitesp integer: horizontal quiet zone in modules\n" " -werror bool: Convert all warnings into errors\n" " -wzpl bool: ZPL compatibility mode (allows non-standard symbols)\n" @@ -685,6 +688,7 @@ static int Encode(Tcl_Interp *interp, int objc, /*------------------------------------------------------------------------*/ /* >>> Prepare zint object */ my_symbol = ZBarcode_Create(); + my_symbol->debug = ZINT_DEBUG_PRINT; my_symbol->input_mode = UNICODE_MODE; my_symbol->option_3 = 0; /*------------------------------------------------------------------------*/ @@ -698,7 +702,7 @@ static int Encode(Tcl_Interp *interp, int objc, "-fullmultibyte", "-gs1parens", "-gssep", "-height", "-init", "-mask", "-mode", "-nobackground", "-notext", "-primary", "-reverse", "-rotate", "-rows", "-scale", "-scmvv", "-secure", "-separator", "-smalltext", - "-square", "-to", "-vers", "-werror", "-whitesp", "-wzpl", + "-square", "-to", "-vers", "-vwhitesp", "-werror", "-whitesp", "-wzpl", NULL}; enum iOption { iAddonGap, iBarcode, iBG, iBind, iBold, iBorder, iBox, @@ -706,7 +710,7 @@ static int Encode(Tcl_Interp *interp, int objc, iFullMultiByte, iGS1Parens, iGSSep, iHeight, iInit, iMask, iMode, iNoBackground, iNoText, iPrimary, iReverse, iRotate, iRows, iScale, iSCMvv, iSecure, iSeparator, iSmallText, - iSquare, iTo, iVers, iWError, iWhiteSp, iWZPL + iSquare, iTo, iVers, iVWhiteSp, iWError, iWhiteSp, iWZPL }; int optionIndex; int intValue; @@ -769,15 +773,16 @@ static int Encode(Tcl_Interp *interp, int objc, case iBorder: case iCols: case iHeight: + case iMask: case iMode: case iRotate: case iRows: case iSecure: - case iVers: - case iWhiteSp: case iSeparator: - case iMask: case iSCMvv: + case iVers: + case iVWhiteSp: + case iWhiteSp: /* >> Int */ if (TCL_OK != Tcl_GetIntFromObj(interp, objv[optionPos+1], &intValue)) @@ -1052,6 +1057,9 @@ static int Encode(Tcl_Interp *interp, int objc, my_symbol->symbology = s_code_number[intValue]; } break; + case iVWhiteSp: + my_symbol->whitespace_height = intValue; + break; case iWhiteSp: my_symbol->whitespace_width = intValue; break; diff --git a/docs/manual.txt b/docs/manual.txt index 09381fa4..a8ffd5e2 100644 --- a/docs/manual.txt +++ b/docs/manual.txt @@ -384,12 +384,24 @@ This specifies a symbol height of 100 times the X-dimension of the symbol. 4.5 Adjusting whitespace ------------------------ -The amount of whitespace to the left and right of the generated barcode can be -altered using the –w switch. For example: +The amount of horizontal whitespace to the left and right of the generated +barcode can be altered using the –w or --whitesp switch. For example: zint -w 10 -d "This Text" -This specifies a whitespace width of 10 times the X-dimension of the symbol. +This specifies a whitespace width of 10 times the X-dimension of the symbol +both to the left and to the right of the barcode. + +The amount of vertical whitespace above and below the barcode can be altered +using the --vwhitesp switch. For example for 3 times the X-dimension: + +zint --vwhitesp 3 -d "This Text" + +Note that the whitespace at the bottom appears below the text, if any. + +Horizontal and vertical whitespace can of course be used together: + +zint -b DATAMATRIX --whitesp 1 --vwhitesp 1 -d "This Text" 4.6 Adding boundary bars and boxes ---------------------------------- @@ -397,17 +409,20 @@ Zint allows the symbol to be bound with 'boundary bars' (also known as 'bearer bars') using the option --bind. These bars help to prevent misreading of the 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 -whitespace with the --box option. +horizontal whitespace with the --box option. The width of the boundary or box can be specified using the --border switch. For example: -zint --box --border=10 -d "This" +zint --box --border=10 -w 10 -d "This" -gives a box with a width 10 times the X-dimension of the symbol. +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. -These options are ignored for Code 16k, Code 49 and Codablock-F. Special -considerations apply to ITF-14 - see the specific section for that symbology. +Code 16k, Code 49 and Codablock-F 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. 4.7 Using colour ---------------- @@ -465,14 +480,14 @@ multiple of the default X-dimension. The scale is multiplied by 2 before being applied. The default scale is 1. For raster output, the default X-dimension is 2 pixels (except for MaxiCode, see -4.9.2 below, and dotty mode, see 4.14). For example for PNG images a scale of 5 -will increase the X-dimension to 10 pixels. Scales should be given in increments -of 0.5, i.e. 0.5, 1, 1.5, 2, 2.5, 3, 3.5, etc., to avoid the X-dimension -varying across the symbol due to interpolation. 0.5 increments are also faster -to render. +4.9.2 below). For example for PNG images a scale of 5 will increase the +X-dimension to 10 pixels. Scales should be given in increments of 0.5, i.e. 0.5, +1, 1.5, 2, 2.5, 3, 3.5, etc., to avoid the X-dimension varying across the symbol +due to interpolation. 0.5 increments are also faster to render. The minimum scale for non-dotty raster output is 0.5, giving a minimum X-dimension of 1 pixel, and text will not be printed for scales less than 1. +The minimum scale for raster output in dotty mode is 1 (see 4.14). The minimum scale for vector output is 0.1, giving a minimum X-dimension of 0.2. @@ -762,7 +777,7 @@ matrix symbologies, and is automatically selected for DotCode. The size of the dots can be adjusted using the --dotsize= option followed by the radius of the dot, where that radius is given as a multiple of the X-dimension. The minimum dot size is 0.01, the maximum is 20. The default and minimum scale for -raster output in dotty mode is 2. +raster output in dotty mode is 1. 4.15 Help options ----------------- @@ -966,7 +981,8 @@ Variable Name | Type | Meaning | Default Value symbology | integer | Symbol to use (see section | BARCODE_CODE128 | | 5.7). | height | integer | Symbol height. [1] | 50 -whitespace_width | integer | Whitespace width. | 0 +whitespace_width | integer | Horizontal whitespace width.| 0 +whitespace_height | integer | Vertical whitespace height. | 0 border_width | integer | Border width. | 0 output_options | integer | Set various output file | 0 (none) | | parameters (see section | diff --git a/frontend/main.c b/frontend/main.c index e2507b3f..fa8d2076 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -117,13 +117,13 @@ static void usage(void) { " -b, --barcode=TYPE Number or name of barcode type. Default is 20 (CODE128)\n" " --addongap=NUMBER Set add-on gap in multiples of X-dimension for UPC/EAN\n" " --batch Treat each line of input file as a separate data set\n" - " --bg=COLOUR Specify a background colour (in hex)\n" + " --bg=COLOUR Specify a background colour (in hex RGB/RGBA)\n" " --binary Treat input as raw binary data\n" " --bind Add boundary bars\n" " --bold Use bold text\n" " --border=NUMBER Set width of border in multiples of X-dimension\n" " --box Add a box around the symbol\n" - " --cmyk Use CMYK colour space in EPS symbols\n" + " --cmyk Use CMYK colour space in EPS/TIF symbols\n" " --cols=NUMBER Set the number of data columns in symbol\n" " -d, --data=DATA Set the symbol content\n" " --direct Send output to stdout\n" @@ -134,7 +134,7 @@ static void usage(void) { " -e, --ecinos Display table of ECI character encodings\n" " --eci=NUMBER Set the ECI (Extended Channel Interpretation) code\n" " --esc Process escape characters in input data\n" - " --fg=COLOUR Specify a foreground colour (in hex)\n" + " --fg=COLOUR Specify a foreground colour (in hex RGB/RGBA)\n" " --filetype=TYPE Set output file type BMP/EMF/EPS/GIF/PCX/PNG/SVG/TIF/TXT\n" " --fullmultibyte Use multibyte for binary/Latin (QR/Han Xin/Grid Matrix)\n" " --gs1 Treat input as GS1 compatible data\n" @@ -147,7 +147,7 @@ static void usage(void) { " --mask=NUMBER Set masking pattern to use (QR/Han Xin/DotCode)\n" " --mirror Use batch data to determine filename\n" " --mode=NUMBER Set encoding mode (MaxiCode/Composite)\n" - " --nobackground Remove background (PNG/SVG/EPS only)\n" + " --nobackground Remove background (EMF/EPS/GIF/PNG/SVG/TIF only)\n" " --notext Remove human readable text\n" " -o, --output=FILE Send output to FILE. Default is out.png\n" " --primary=STRING Set structured primary message (MaxiCode/Composite)\n" @@ -162,7 +162,8 @@ static void usage(void) { " --square Force Data Matrix symbols to be square\n" " -t, --types Display table of barcode types\n" " --vers=NUMBER Set symbol version (size, check digits, other options)\n" - " -w, --whitesp=NUMBER Set width of whitespace in multiples of X-dimension\n" + " --vwhitesp=NUMBER Set height of vertical whitespace in multiples of X-dim\n" + " -w, --whitesp=NUMBER Set width of horizontal whitespace in multiples of X-dim\n" " --werror Convert all warnings into errors\n" " --wzpl ZPL compatibility mode (allows non-standard symbols)\n" ); @@ -798,7 +799,7 @@ int main(int argc, char **argv) { OPT_GS1, OPT_GS1PARENS, OPT_GSSEP, OPT_HEIGHT, OPT_INIT, OPT_MIRROR, OPT_MASK, OPT_MODE, OPT_NOBACKGROUND, OPT_NOTEXT, OPT_PRIMARY, OPT_ROTATE, OPT_ROWS, OPT_SCALE, OPT_SCMVV, OPT_SECURE, OPT_SEPARATOR, OPT_SMALL, OPT_SQUARE, OPT_VERBOSE, OPT_VERS, - OPT_WERROR, OPT_WZPL, + OPT_VWHITESP, OPT_WERROR, OPT_WZPL, }; int option_index = 0; static struct option long_options[] = { @@ -852,6 +853,7 @@ int main(int argc, char **argv) { {"types", 0, NULL, 't'}, {"verbose", 0, NULL, OPT_VERBOSE}, // Currently undocumented, output some debug info {"vers", 1, NULL, OPT_VERS}, + {"vwhitesp", 1, NULL, OPT_VWHITESP}, {"werror", 0, NULL, OPT_WERROR}, {"whitesp", 1, NULL, 'w'}, {"wzpl", 0, NULL, OPT_WZPL}, @@ -1163,6 +1165,18 @@ int main(int argc, char **argv) { fflush(stderr); } break; + case OPT_VWHITESP: + if (!validate_int(optarg, &val)) { + fprintf(stderr, "Error 153: Invalid vertical whitespace value '%s'\n", optarg); + return do_exit(1); + } + if (val <= 1000) { /* `val` >= 0 always */ + my_symbol->whitespace_height = val; + } else { + fprintf(stderr, "Warning 154: Vertical whitespace value out of range\n"); + fflush(stderr); + } + break; case OPT_WERROR: my_symbol->warn_level = WARN_FAIL_ALL; break; @@ -1195,13 +1209,13 @@ int main(int argc, char **argv) { case 'w': if (!validate_int(optarg, &val)) { - fprintf(stderr, "Error 120: Invalid whitespace value '%s'\n", optarg); + fprintf(stderr, "Error 120: Invalid horizontal whitespace value '%s'\n", optarg); return do_exit(1); } if (val <= 1000) { /* `val` >= 0 always */ my_symbol->whitespace_width = val; } else { - fprintf(stderr, "Warning 121: Whitespace value out of range\n"); + fprintf(stderr, "Warning 121: Horizontal whitespace value out of range\n"); fflush(stderr); } break; diff --git a/frontend/tests/test_args.c b/frontend/tests/test_args.c index 65c5b1eb..64e0ded3 100644 --- a/frontend/tests/test_args.c +++ b/frontend/tests/test_args.c @@ -545,44 +545,47 @@ static void test_checks(int index, int debug) { int secure; int separator; int vers; + int vwhitesp; int w; char *expected; }; // s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<")) struct item data[] = { - /* 0*/ { -2, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 139: Invalid add-on gap value" }, - /* 1*/ { 6, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 140: Invalid add-on gap value" }, - /* 2*/ { 13, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 140: Invalid add-on gap value" }, - /* 3*/ { -1, -2, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 107: Invalid border width value" }, - /* 4*/ { -1, 1001, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 108: Border width out of range" }, - /* 5*/ { -1, -1, -1, 0.009, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 106: Invalid dot radius value" }, - /* 6*/ { -1, -1, -2, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 131: Invalid columns value" }, - /* 7*/ { -1, -1, 109, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 111: Number of columns out of range" }, - /* 8*/ { -1, -1, -1, -1, -2, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 138: Invalid ECI value" }, - /* 9*/ { -1, -1, -1, -1, 1000000, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 118: Invalid ECI code" }, - /* 10*/ { -1, -1, -1, -1, -1, "jpg", -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 142: File type 'jpg' not supported, ignoring" }, - /* 11*/ { -1, -1, -1, -1, -1, NULL, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 109: Invalid symbol height value" }, - /* 12*/ { -1, -1, -1, -1, -1, NULL, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 110: Symbol height out of range" }, - /* 13*/ { -1, -1, -1, -1, -1, NULL, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 148: Invalid mask value" }, - /* 14*/ { -1, -1, -1, -1, -1, NULL, -1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 147: Invalid mask value" }, - /* 15*/ { -1, -1, -1, -1, -1, NULL, -1, -1, 7, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 116: Invalid mode" }, - /* 16*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, "Error 117: Invalid rotation value" }, - /* 17*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, 45, -1, -1, -1, -1, -1, -1, -1, "Warning 137: Invalid rotation parameter" }, - /* 18*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, "Error 132: Invalid rows value" }, - /* 19*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, 45, -1, -1, -1, -1, -1, -1, "Warning 112: Number of rows out of range" }, - /* 20*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -2, -1, -1, -1, -1, -1, "Warning 105: Invalid scale value" }, - /* 21*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, 0.49, -1, -1, -1, -1, -1, "Warning 146: Scaling less than 0.5 will be set to 0.5 for 'png' output" }, - /* 22*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -2, -1, -1, -1, -1, "Error 149: Invalid Structured Carrier Message version value" }, - /* 22*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, 100, -1, -1, -1, -1, "Warning 150: Invalid version (vv) for Structured Carrier Message, ignoring" }, - /* 22*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -2, -1, -1, -1, "Error 134: Invalid ECC value" }, - /* 23*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, 9, -1, -1, -1, "Warning 114: ECC level out of range" }, - /* 24*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, -1, "Error 128: Invalid separator value" }, - /* 25*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, 5, -1, -1, "Warning 127: Invalid separator value" }, - /* 26*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, "Error 133: Invalid version value" }, - /* 27*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, 85, -1, "Warning 113: Invalid version" }, - /* 28*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, "Error 120: Invalid whitespace value '-2'" }, - /* 29*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1001, "Warning 121: Whitespace value out of range" }, + /* 0*/ { -2, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 139: Invalid add-on gap value" }, + /* 1*/ { 6, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 140: Invalid add-on gap value" }, + /* 2*/ { 13, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 140: Invalid add-on gap value" }, + /* 3*/ { -1, -2, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 107: Invalid border width value" }, + /* 4*/ { -1, 1001, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 108: Border width out of range" }, + /* 5*/ { -1, -1, -1, 0.009, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 106: Invalid dot radius value" }, + /* 6*/ { -1, -1, -2, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 131: Invalid columns value" }, + /* 7*/ { -1, -1, 109, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 111: Number of columns out of range" }, + /* 8*/ { -1, -1, -1, -1, -2, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 138: Invalid ECI value" }, + /* 9*/ { -1, -1, -1, -1, 1000000, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 118: Invalid ECI code" }, + /* 10*/ { -1, -1, -1, -1, -1, "jpg", -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 142: File type 'jpg' not supported, ignoring" }, + /* 11*/ { -1, -1, -1, -1, -1, NULL, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 109: Invalid symbol height value" }, + /* 12*/ { -1, -1, -1, -1, -1, NULL, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 110: Symbol height out of range" }, + /* 13*/ { -1, -1, -1, -1, -1, NULL, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Error 148: Invalid mask value" }, + /* 14*/ { -1, -1, -1, -1, -1, NULL, -1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 147: Invalid mask value" }, + /* 15*/ { -1, -1, -1, -1, -1, NULL, -1, -1, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 116: Invalid mode" }, + /* 16*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, "Error 117: Invalid rotation value" }, + /* 17*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, 45, -1, -1, -1, -1, -1, -1, -1, -1, "Warning 137: Invalid rotation parameter" }, + /* 18*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, "Error 132: Invalid rows value" }, + /* 19*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, 45, -1, -1, -1, -1, -1, -1, -1, "Warning 112: Number of rows out of range" }, + /* 20*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, "Warning 105: Invalid scale value" }, + /* 21*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, 0.49, -1, -1, -1, -1, -1, -1, "Warning 146: Scaling less than 0.5 will be set to 0.5 for 'png' output" }, + /* 22*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -2, -1, -1, -1, -1, -1, "Error 149: Invalid Structured Carrier Message version value" }, + /* 23*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, 100, -1, -1, -1, -1, -1, "Warning 150: Invalid version (vv) for Structured Carrier Message, ignoring" }, + /* 24*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -2, -1, -1, -1, -1, "Error 134: Invalid ECC value" }, + /* 25*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, 9, -1, -1, -1, -1, "Warning 114: ECC level out of range" }, + /* 26*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, -1, -1, "Error 128: Invalid separator value" }, + /* 27*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, 5, -1, -1, -1, "Warning 127: Invalid separator value" }, + /* 28*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, -1, "Error 133: Invalid version value" }, + /* 29*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, 85, -1, -1, "Warning 113: Invalid version" }, + /* 30*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, "Error 153: Invalid vertical whitespace value '-2'" }, + /* 31*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1001, -1, "Warning 154: Vertical whitespace value out of range" }, + /* 32*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, "Error 120: Invalid horizontal whitespace value '-2'" }, + /* 33*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1001, "Warning 121: Horizontal whitespace value out of range" }, }; int data_size = ARRAY_SIZE(data); @@ -615,6 +618,7 @@ static void test_checks(int index, int debug) { arg_int(cmd, "--secure=", data[i].secure); arg_int(cmd, "--separator=", data[i].separator); arg_int(cmd, "--vers=", data[i].vers); + arg_int(cmd, "--vwhitesp=", data[i].vwhitesp); arg_int(cmd, "-w ", data[i].w); strcat(cmd, " 2>&1"); diff --git a/frontend_qt/mainWindow.ui b/frontend_qt/mainWindow.ui index 9eb2b282..e42a95cc 100644 --- a/frontend_qt/mainWindow.ui +++ b/frontend_qt/mainWindow.ui @@ -21,7 +21,7 @@ - 420 + 400 460 @@ -248,7 +248,7 @@ or import from file false - Component &Type: + &Type: cmbCompType @@ -260,6 +260,12 @@ or import from file + + + 60 + 16777215 + + false @@ -379,7 +385,7 @@ p, li { white-space: pre-wrap; } - 66 + 64 16777215 @@ -660,7 +666,8 @@ to delimit GS1 application identifiers heightb - Overall symbol height + Overall symbol height +(ignored if disabled) @@ -670,7 +677,8 @@ to delimit GS1 application identifiers false - Overall symbol height + Overall symbol height +(ignored if disabled) X @@ -768,7 +776,7 @@ to delimit GS1 application identifiers - Hori&zontal Whitespace: + &Whitespace: Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter @@ -777,19 +785,33 @@ to delimit GS1 application identifiers spnWhitespace - Width of whitespace on either side of barcode + Horizontal whitespace, Vertical whitespace - - - Width of whitespace on either side of barcode - - - X - - + + + + + Width of horizontal whitespace on either side of barcode + + + X + + + + + + + Height of vertical whitespace above and below the barcode + + + X + + + + @@ -844,14 +866,16 @@ to delimit GS1 application identifiers cmbFontSetting - Set font characteristics + Set font characteristics +(ignored if disabled) - Set font characteristics + Set font characteristics +(ignored if disabled) @@ -1033,14 +1057,16 @@ to delimit GS1 application identifiers spnDotSize - Size of dots + Size of dots +(ignored if disabled) - Size of dots + Size of dots +(ignored if disabled) false diff --git a/frontend_qt/mainwindow.cpp b/frontend_qt/mainwindow.cpp index d006cc13..6fd66cb9 100644 --- a/frontend_qt/mainwindow.cpp +++ b/frontend_qt/mainwindow.cpp @@ -168,6 +168,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags fl) heightb->setValue(settings.value("studio/appearance/height", 50).toInt()); bwidth->setValue(settings.value("studio/appearance/border", 0).toInt()); spnWhitespace->setValue(settings.value("studio/appearance/whitespace", 0).toInt()); + spnVWhitespace->setValue(settings.value("studio/appearance/vwhitespace", 0).toInt()); spnScale->setValue(settings.value("studio/appearance/scale", 1.0).toFloat()); btype->setCurrentIndex(settings.value("studio/appearance/border_type", 0).toInt()); cmbFontSetting->setCurrentIndex(settings.value("studio/appearance/font_setting", 0).toInt()); @@ -201,6 +202,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags fl) connect(chkRInit, SIGNAL(stateChanged( int )), SLOT(update_preview())); connect(chkGS1Parens, SIGNAL(stateChanged( int )), SLOT(update_preview())); connect(spnWhitespace, SIGNAL(valueChanged( int )), SLOT(update_preview())); + connect(spnVWhitespace, SIGNAL(valueChanged( int )), SLOT(update_preview())); connect(btnAbout, SIGNAL(clicked( bool )), SLOT(about())); connect(btnSave, SIGNAL(clicked( bool )), SLOT(save())); connect(spnScale, SIGNAL(valueChanged( double )), SLOT(change_print_scale())); @@ -257,6 +259,7 @@ MainWindow::~MainWindow() settings.setValue("studio/appearance/height", heightb->value()); settings.setValue("studio/appearance/border", bwidth->value()); settings.setValue("studio/appearance/whitespace", spnWhitespace->value()); + settings.setValue("studio/appearance/vwhitespace", spnVWhitespace->value()); settings.setValue("studio/appearance/scale", spnScale->value()); settings.setValue("studio/appearance/border_type", btype->currentIndex()); settings.setValue("studio/appearance/font_setting", cmbFontSetting->currentIndex()); @@ -705,6 +708,7 @@ void MainWindow::change_options() m_optionWidget = uiload.load(&file); file.close(); static const char *names[] = { "Standard (Matrix)", "Interleaved", "IATA", "", "Data Logic", "Industrial" }; + /*: %1 is name of variant (Standard, Interleaved, IATA, Data Logic, Industrial) */ tabMain->insertTab(1, m_optionWidget, tr("Cod&e 2 of 5 %1").arg(names[symbology - BARCODE_C25STANDARD])); connect(m_optionWidget->findChild("radC25Stand"), SIGNAL(clicked( bool )), SLOT(update_preview())); connect(m_optionWidget->findChild("radC25Check"), SIGNAL(clicked( bool )), SLOT(update_preview())); @@ -898,6 +902,7 @@ void MainWindow::change_options() m_optionWidget = uiload.load(&file); file.close(); tabMain->insertTab(1, m_optionWidget, tr("Cod&e 49")); + btype->setItemText(0, tr("Default (bind)")); connect(m_optionWidget->findChild("cmbC49RowSepHeight"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview())); connect(m_optionWidget->findChild("radC49GS1"), SIGNAL(toggled( bool )), SLOT(update_preview())); } else if (symbology == BARCODE_DBAR_EXPSTK) { @@ -1578,11 +1583,11 @@ void MainWindow::update_preview() m_bc.bc.setECI(cmbECI->isEnabled() ? cmbECI->currentIndex() : 0); m_bc.bc.setGS1Parens(chkGS1Parens->isEnabled() && chkGS1Parens->isChecked()); m_bc.bc.setReaderInit(chkRInit->isEnabled() && chkRInit->isChecked()); - m_bc.bc.setReaderInit(chkRInit->isEnabled() && chkRInit->isChecked()); m_bc.bc.setShowText(chkHRTShow->isEnabled() && chkHRTShow->isChecked()); m_bc.bc.setBorderType(btype->currentIndex()); m_bc.bc.setBorderWidth(bwidth->value()); m_bc.bc.setWhitespace(spnWhitespace->value()); + m_bc.bc.setVWhitespace(spnVWhitespace->value()); m_bc.bc.setFontSetting(cmbFontSetting->currentIndex()); m_bc.bc.setRotateAngle(cmbRotate->currentIndex()); m_bc.bc.setDotty(chkDotty->isEnabled() && chkDotty->isChecked()); @@ -1878,6 +1883,7 @@ void MainWindow::save_sub_settings(QSettings &settings, int symbology) { } settings.setValue(QString("studio/bc/%1/appearance/border").arg(name), bwidth->value()); settings.setValue(QString("studio/bc/%1/appearance/whitespace").arg(name), spnWhitespace->value()); + settings.setValue(QString("studio/bc/%1/appearance/vwhitespace").arg(name), spnVWhitespace->value()); settings.setValue(QString("studio/bc/%1/appearance/scale").arg(name), spnScale->value()); settings.setValue(QString("studio/bc/%1/appearance/border_type").arg(name), btype->currentIndex()); if (chkHRTShow->isEnabled()) { @@ -2124,6 +2130,7 @@ void MainWindow::load_sub_settings(QSettings &settings, int symbology) { } bwidth->setValue(settings.value(QString("studio/bc/%1/appearance/border").arg(name), 0).toInt()); spnWhitespace->setValue(settings.value(QString("studio/bc/%1/appearance/whitespace").arg(name), 0).toInt()); + spnVWhitespace->setValue(settings.value(QString("studio/bc/%1/appearance/vwhitespace").arg(name), 0).toInt()); spnScale->setValue(settings.value(QString("studio/bc/%1/appearance/scale").arg(name), 1.0).toFloat()); btype->setCurrentIndex(settings.value(QString("studio/bc/%1/appearance/border_type").arg(name), 0).toInt()); if (chkHRTShow->isEnabled()) { diff --git a/frontend_qt/qzint.cpp b/frontend_qt/qzint.cpp index 7e905670..31eaf4da 100644 --- a/frontend_qt/qzint.cpp +++ b/frontend_qt/qzint.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * Copyright (C) 2008 by BogDan Vatra * * bogdan@licentia.eu * - * Copyright (C) 2010-2020 Robin Stuart * + * Copyright (C) 2010-2021 Robin Stuart * * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -53,6 +53,7 @@ namespace Zint { target_size_vert = 0; m_option_2 = 0; m_whitespace = 0; + m_vwhitespace = 0; m_gs1parens = false; m_gssep = false; m_reader_init = false; @@ -75,6 +76,7 @@ namespace Zint { m_zintSymbol->symbology = m_symbol; m_zintSymbol->height = m_height; m_zintSymbol->whitespace_width = m_whitespace; + m_zintSymbol->whitespace_height = m_vwhitespace; m_zintSymbol->border_width = m_borderWidth; m_zintSymbol->option_1 = m_option_1; m_zintSymbol->input_mode = m_input_mode; @@ -125,6 +127,7 @@ namespace Zint { m_height = m_zintSymbol->height; m_borderWidth = m_zintSymbol->border_width; m_whitespace = m_zintSymbol->whitespace_width; + m_vwhitespace = m_zintSymbol->whitespace_height; emit encoded(); } } @@ -253,6 +256,10 @@ namespace Zint { m_whitespace = whitespace; } + void QZint::setVWhitespace(int vwhitespace) { + m_vwhitespace = vwhitespace; + } + int QZint::option1() const { return m_option_1; } diff --git a/frontend_qt/qzint.h b/frontend_qt/qzint.h index 60fe0523..c6e7b31b 100644 --- a/frontend_qt/qzint.h +++ b/frontend_qt/qzint.h @@ -1,6 +1,7 @@ /*************************************************************************** * Copyright (C) 2008 by BogDan Vatra * * bogdan@licentia.eu * + * Copyright (C) 2010-2021 Robin Stuart * * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -83,6 +84,8 @@ public: void setWhitespace(int whitespace); + void setVWhitespace(int vwhitespace); + void setFontSetting(int fontSettingIndex); void setShowText(bool show); @@ -148,6 +151,7 @@ private: QString m_lastError; int m_error; int m_whitespace; + int m_vwhitespace; zint_symbol * m_zintSymbol; float m_scale; int m_option_3;