diff --git a/backend/2of5.c b/backend/2of5.c index c3c795d7..26ef5e4e 100644 --- a/backend/2of5.c +++ b/backend/2of5.c @@ -279,6 +279,13 @@ INTERNAL int itf14(struct zint_symbol *symbol, unsigned char source[], int lengt localstr[14] = '\0'; error_number = interleaved_two_of_five(symbol, (unsigned char *) localstr, strlen(localstr)); ustrcpy(symbol->text, localstr); + + symbol->output_options |= BARCODE_BOX; + if (symbol->border_width == 0) { /* Allow override if non-zero */ + /* GS1 General Specifications 20.0 Sections 5.3.2.4 & 5.3.6 (4.83 / 1.016 ~ 4.75) */ + symbol->border_width = 5; /* Note change from previous value 8 */ + } + return error_number; } diff --git a/backend/code128.c b/backend/code128.c index 814d96b8..65dae265 100644 --- a/backend/code128.c +++ b/backend/code128.c @@ -45,19 +45,18 @@ static const char *C128Table[107] = { /* Code 128 character encodation - Table 1 */ - "212222", "222122", "222221", "121223", "121322", "131222", "122213", - "122312", "132212", "221213", "221312", "231212", "112232", "122132", "122231", "113222", - "123122", "123221", "223211", "221132", "221231", "213212", "223112", "312131", "311222", - "321122", "321221", "312212", "322112", "322211", "212123", "212321", "232121", "111323", - "131123", "131321", "112313", "132113", "132311", "211313", "231113", "231311", "112133", - "112331", "132131", "113123", "113321", "133121", "313121", "211331", "231131", "213113", - "213311", "213131", "311123", "311321", "331121", "312113", "312311", "332111", "314111", - "221411", "431111", "111224", "111422", "121124", "121421", "141122", "141221", "112214", - "112412", "122114", "122411", "142112", "142211", "241211", "221114", "413111", "241112", - "134111", "111242", "121142", "121241", "114212", "124112", "124211", "411212", "421112", - "421211", "212141", "214121", "412121", "111143", "111341", "131141", "114113", "114311", - "411113", "411311", "113141", "114131", "311141", "411131", "211412", "211214", "211232", - "2331112" + /* 0 1 2 3 4 5 6 7 8 9 */ + "212222", "222122", "222221", "121223", "121322", "131222", "122213", "122312", "132212", "221213", /* 0 */ + "221312", "231212", "112232", "122132", "122231", "113222", "123122", "123221", "223211", "221132", /* 10 */ + "221231", "213212", "223112", "312131", "311222", "321122", "321221", "312212", "322112", "322211", /* 20 */ + "212123", "212321", "232121", "111323", "131123", "131321", "112313", "132113", "132311", "211313", /* 30 */ + "231113", "231311", "112133", "112331", "132131", "113123", "113321", "133121", "313121", "211331", /* 40 */ + "231131", "213113", "213311", "213131", "311123", "311321", "331121", "312113", "312311", "332111", /* 50 */ + "314111", "221411", "431111", "111224", "111422", "121124", "121421", "141122", "141221", "112214", /* 60 */ + "112412", "122114", "122411", "142112", "142211", "241211", "221114", "413111", "241112", "134111", /* 70 */ + "111242", "121142", "121241", "114212", "124112", "124211", "411212", "421112", "421211", "212141", /* 80 */ + "214121", "412121", "111143", "111341", "131141", "114113", "114311", "411113", "411311", "113141", /* 90 */ + "114131", "311141", "411131", "211412", "211214", "211232", "2331112" /*100 */ }; /* Determine appropriate mode for a given character */ diff --git a/backend/common.c b/backend/common.c index 8050bcfa..87ca6649 100644 --- a/backend/common.c +++ b/backend/common.c @@ -218,28 +218,22 @@ INTERNAL int is_stackable(const int symbology) { return 0; } -/* Indicates which symbols can have addon (EAN-2 and EAN-5) */ +/* Indicates which symbols can have addon (EAN-2 and EAN-5) + * Note: if change this must also change version in frontend/main.c */ INTERNAL int is_extendable(const int symbology) { - if (symbology == BARCODE_EANX || symbology == BARCODE_EANX_CHK) { - return 1; - } - if (symbology == BARCODE_UPCA || symbology == BARCODE_UPCA_CHK) { - return 1; - } - if (symbology == BARCODE_UPCE || symbology == BARCODE_UPCE_CHK) { - return 1; - } - if (symbology == BARCODE_ISBNX) { - return 1; - } - if (symbology == BARCODE_UPCA_CC) { - return 1; - } - if (symbology == BARCODE_UPCE_CC) { - return 1; - } - if (symbology == BARCODE_EANX_CC) { - return 1; + + switch (symbology) { + case BARCODE_EANX: + case BARCODE_EANX_CHK: + case BARCODE_UPCA: + case BARCODE_UPCA_CHK: + case BARCODE_UPCE: + case BARCODE_UPCE_CHK: + case BARCODE_ISBNX: + case BARCODE_EANX_CC: + case BARCODE_UPCA_CC: + case BARCODE_UPCE_CC: + return 1; } return 0; diff --git a/backend/composite.c b/backend/composite.c index 49f9f780..a7ecabc6 100644 --- a/backend/composite.c +++ b/backend/composite.c @@ -328,6 +328,7 @@ static int cc_b(struct zint_symbol *symbol, char source[], int cc_width) { char pattern[580]; int variant, LeftRAPStart, CentreRAPStart, RightRAPStart, StartCluster; int LeftRAP, CentreRAP, RightRAP, Cluster, loop; + int columns; length = strlen(source) / 8; @@ -445,10 +446,10 @@ static int cc_b(struct zint_symbol *symbol, char source[], int cc_width) { /* Now we have the variant we can load the data - from here on the same as MicroPDF417 code */ variant--; assert(variant >= 0); - symbol->option_2 = MicroVariants[variant]; /* columns */ + columns = MicroVariants[variant]; /* columns */ symbol->rows = MicroVariants[variant + 34]; /* rows */ k = MicroVariants[variant + 68]; /* number of EC CWs */ - longueur = (symbol->option_2 * symbol->rows) - k; /* number of non-EC CWs */ + longueur = (columns * symbol->rows) - k; /* number of non-EC CWs */ i = longueur - mclength; /* amount of padding required */ offset = MicroVariants[variant + 102]; /* coefficient offset */ @@ -506,8 +507,8 @@ static int cc_b(struct zint_symbol *symbol, char source[], int cc_width) { for (j = 0; j < 5; j++) { dummy[j] = 0; } - for (j = 0; j < symbol->option_2; j++) { - dummy[j + 1] = chainemc[i * symbol->option_2 + j]; + for (j = 0; j < columns; j++) { + dummy[j + 1] = chainemc[i * columns + j]; } /* Copy the data into codebarre */ bin_append(rap_side[LeftRAP - 1], 10, pattern); diff --git a/backend/large.c b/backend/large.c index 6f7d7af5..45b53f8b 100644 --- a/backend/large.c +++ b/backend/large.c @@ -244,7 +244,7 @@ INTERNAL void large_unset_bit(large_int *t, int bit) { } } -/* Ouput large_int into an unsigned int array of size `size`, each element containing `bits` bits */ +/* Output large_int into an unsigned int array of size `size`, each element containing `bits` bits */ INTERNAL void large_uint_array(const large_int *t, unsigned int *uint_array, int size, int bits) { int i, j; uint64_t mask; diff --git a/backend/library.c b/backend/library.c index a9714af0..3576b6ee 100644 --- a/backend/library.c +++ b/backend/library.c @@ -672,14 +672,6 @@ static int reduced_charset(struct zint_symbol *symbol, const unsigned char *sour unsigned char* preprocessed = (unsigned char*) _alloca(in_length + 1); #endif - if (symbol->symbology == BARCODE_ITF14) { - symbol->whitespace_width = 20; - symbol->border_width = 8; - if (!(symbol->output_options & BARCODE_BOX)) { - symbol->output_options += BARCODE_BOX; - } - } - switch (symbol->input_mode & 0x07) { case DATA_MODE: case GS1_MODE: diff --git a/backend/output.c b/backend/output.c index 07c98858..b7bd48e8 100644 --- a/backend/output.c +++ b/backend/output.c @@ -30,14 +30,13 @@ */ /* vim: set ts=4 sw=4 et : */ -#include #include "common.h" #include "output.h" #define SSET "0123456789ABCDEF" /* Check colour options are good. Note: using raster.c error nos 651-654 */ -INTERNAL int check_colour_options(struct zint_symbol *symbol) { +INTERNAL int output_check_colour_options(struct zint_symbol *symbol) { int error_number; if (strlen(symbol->fgcolour) != 6) { @@ -68,32 +67,346 @@ INTERNAL int check_colour_options(struct zint_symbol *symbol) { } /* Return minimum quiet zones for each symbology */ -static void quiet_zones(struct zint_symbol *symbol, int *left, int *right, int *top, int *bottom) { +static int quiet_zones(struct zint_symbol *symbol, int *left, int *right, int *top, int *bottom) { + int done = 0; + *left = *right = *top = *bottom = 0; + /* These always have quiet zones set (previously used whitespace_width) */ switch (symbol->symbology) { case BARCODE_CODE16K: - /* BS EN 12323:2005 Section 4.5 c) */ + /* BS EN 12323:2005 Section 4.5 (c) */ *left = 10; *right = 1; + done = 1; break; case BARCODE_CODE49: /* ANSI/AIM BC6-2000 Section 2.4 */ *left = 10; *right = 1; + done = 1; break; case BARCODE_CODABLOCKF: case BARCODE_HIBC_BLOCKF: /* AIM ISS-X-24 Section 4.6.1 */ *left = 10; *right = 10; + done = 1; + break; + case BARCODE_ITF14: + /* GS1 General Specifications 20.0 Section 5.3.2.2 */ + *left = 10; + *right = 10; + done = 1; + break; + case BARCODE_EANX: + case BARCODE_EANX_CHK: + case BARCODE_EANX_CC: + case BARCODE_ISBNX: + /* GS1 General Specifications 20.0 Section 5.2.3.4 */ + switch (ustrlen(symbol->text)) { + case 13: /* EAN-13 */ + *left = 11; + *right = 7; + break; + case 16: /* EAN-13/ISBN + 2 digit addon */ + case 19: /* EAN-13/ISBN + 5 digit addon */ + *left = 11; + *right = 5; + break; + case 5: /* EAN-5 addon */ + case 2: /* EAN-2 addon */ + *left = 7; + *right = 5; + break; + default: /* EAN-8 (+/- 2/5 digit addon) */ + *left = 7; + *right = 7; + break; + } + done = 1; + break; + case BARCODE_UPCA: + case BARCODE_UPCA_CHK: + case BARCODE_UPCA_CC: + /* GS1 General Specifications 20.0 Section 5.2.3.4 */ + *left = 9; + if (ustrlen(symbol->text) > 12) { /* UPC-A + addon */ + *right = 5; + } else { + *right = 9; + } + done = 1; + break; + case BARCODE_UPCE: + case BARCODE_UPCE_CHK: + case BARCODE_UPCE_CC: + /* GS1 General Specifications 20.0 Section 5.2.3.4 */ + *left = 9; + if (ustrlen(symbol->text) > 8) { /* UPC-E + addon */ + *right = 5; + } else { + *right = 7; + } + done = 1; break; - /* TODO: others */ } + + if (done) { + return done; + } + + /* Only do others if flag set TODO: finish */ +#if 0 + if (!(symbol->output_options & BARCODE_QUIET_ZONES)) { + return done; + } +#else + return done; +#endif + + switch (symbol->symbology) { + case BARCODE_CODE11: + /* TODO */ + break; + + case BARCODE_C25MATRIX: + case BARCODE_C25INTER: + case BARCODE_C25IATA: + case BARCODE_C25LOGIC: + case BARCODE_C25IND: + *left = *right = 10; // Probably this TODO: check + done = 1; + break; + + case BARCODE_CODE39: + case BARCODE_EXCODE39: + case BARCODE_LOGMARS: + case BARCODE_PZN: + case BARCODE_VIN: + case BARCODE_HIBC_39: + case BARCODE_CODE32: + /* ISO/IEC 16388:2007 Section 4.4 (d) */ + *left = *right = 10; + done = 1; + break; + case BARCODE_EAN128: /* GS1-128 */ + case BARCODE_EAN128_CC: + case BARCODE_EAN14: + /* GS1 General Specifications 20.0 Section 5.4.4.2 */ + *left = *right = 10; + done = 1; + break; + case BARCODE_CODABAR: + /* BS EN 798:1995 Section 4.4.1 (d) */ + *left = *right = 10; + done = 1; + break; + case BARCODE_CODE128: + case BARCODE_CODE128B: + case BARCODE_HIBC_128: + case BARCODE_NVE18: + /* ISO/IEC 15417:2007 4.4.2 */ + *left = *right = 10; + done = 1; + break; + + case BARCODE_DPLEIT: + case BARCODE_DPIDENT: + /* TODO */ + break; + + case BARCODE_CODE93: + /* TODO */ + break; + + case BARCODE_FLAT: + /* TODO */ + break; + + case BARCODE_RSS14: /* GS1 Databar Omnidirectional */ + case BARCODE_RSS_LTD: /* GS1 Databar Limited */ + case BARCODE_RSS_EXP: /* GS1 Databar Expanded */ + case BARCODE_RSS14STACK: /* GS1 DataBar Stacked */ + case BARCODE_RSS14STACK_OMNI: /* GS1 DataBar Stacked Omnidirectional */ + case BARCODE_RSS_EXPSTACK: /* GS1 Databar Expanded Stacked */ + /* GS1 General Specifications 20.0 Section 5.5.1.1 - Quiet Zones: None required */ + *left = *right = 0; + done = 1; + break; + case BARCODE_RSS14_CC: + case BARCODE_RSS_LTD_CC: + case BARCODE_RSS_EXP_CC: + case BARCODE_RSS14STACK_CC: + case BARCODE_RSS14_OMNI_CC: + case BARCODE_RSS_EXPSTACK_CC: + /* GS1 General Specifications 20.0 Sections 5.9.2.1 (CC-A) & 5.9.2.2 (CC-B) */ + *left = *right = 1; + done = 1; + break; + + case BARCODE_TELEPEN: + case BARCODE_TELEPEN_NUM: + /* TODO */ + break; + + case BARCODE_POSTNET: + case BARCODE_PLANET: + /* Archived DMM C840 (Dec 09, 2004) left/right 0.125" ~ 6X, top/bottom 0.04" ~ 2X */ + *left = *right = 6; // TODO: Proper inch to X calc + *top = *bottom = 2; // TODO: Proper inch to X calc + done = 1; + break; + + case BARCODE_MSI_PLESSEY: + /* TODO */ + break; + + case BARCODE_FIM: + /* TODO */ + break; + + case BARCODE_PHARMA: + case BARCODE_PHARMA_TWO: + /* TODO */ + break; + + case BARCODE_PDF417: + case BARCODE_PDF417TRUNC: + case BARCODE_HIBC_PDF: + /* ISO/IEC 15438:2015 Section 5.8.3 */ + *left = *right = *top = *bottom = 2; + done = 1; + break; + case BARCODE_MICROPDF417: + case BARCODE_HIBC_MICPDF: + /* ISO/IEC 24728:2006 Section 5.8.3 */ + *left = *right = *top = *bottom = 1; + done = 1; + break; + case BARCODE_MAXICODE: + /* ISO/IEC 16023:2000 Section 4.11.5 */ + *left = *right = *top = *bottom = 1; + done = 1; + break; + case BARCODE_QRCODE: + case BARCODE_UPNQR: + case BARCODE_HIBC_QR: + /* ISO/IEC 18004:2015 Section 9.1 */ + *left = *right = *top = *bottom = 4; + done = 1; + break; + case BARCODE_MICROQR: + /* ISO/IEC 18004:2015 Section 9.1 */ + *left = *right = *top = *bottom = 2; + done = 1; + break; + case BARCODE_RMQR: + /* ISO/IEC JTC1/SC31N000 Section 6.3.10 */ + *left = *right = *top = *bottom = 2; + done = 1; + break; + case BARCODE_AUSPOST: + case BARCODE_AUSREPLY: + case BARCODE_AUSROUTE: + case BARCODE_AUSREDIRECT: + /* Customer Barcode Technical Specifications (2012) left/right 6mm ~ 6X, top/bottom 2mm ~ 2X */ + *left = *right = 6; // TODO: Proper mm to X calc + *top = *bottom = 2; // TODO: Proper mm to X calc + done = 1; + break; + + case BARCODE_RM4SCC: + /* TODO */ + break; + + case BARCODE_DATAMATRIX: + case BARCODE_HIBC_DM: + /* ISO/IEC 16022:2006 Section 7.1 */ + *left = *right = *top = *bottom = 1; + done = 1; + break; + + case BARCODE_JAPANPOST: + /* TODO */ + break; + + case BARCODE_KOREAPOST: + /* TODO */ + break; + + case BARCODE_ONECODE: + /* USPS-B-3200 (2015) Section 2.3.2 left/right 0.125" ~ 6X, top/bottom 0.026" ~ 1X */ + *left = *right = 6; // TODO: Proper inch to X calc + *top = *bottom = 1; // TODO: Proper inch to X calc + done = 1; + break; + + case BARCODE_PLESSEY: + /* TODO */ + break; + + case BARCODE_KIX: + /* Handleiding KIX code brochure left/right/top/bottom 2mm ~ 2X */ + *left = *right = *top = *bottom = 2; // TODO: Proper mm to X calc + done = 1; + break; + case BARCODE_AZTEC: + case BARCODE_HIBC_AZTEC: + case BARCODE_AZRUNE: + /* ISO/IEC 24778:2008 Section 4.1 (c) & Annex A.1 (Rune) - no quiet zone required */ + done = 1; + break; + + case BARCODE_DAFT: + /* TODO */ + break; + + case BARCODE_DOTCODE: + /* ISS DotCode Rev. 4.0 Section 4.1 (3) (c) */ + *left = *right = *top = *bottom = 3; + done = 1; + break; + case BARCODE_HANXIN: + /* ISO/IEC DIS 20830:2019 Section 4.2.8 (also Section 6.2) */ + *left = *right = *top = *bottom = 3; + done = 1; + break; + + case BARCODE_MAILMARK: + /* User Guide left/right/top/bottom 2mm ~ 2X */ + *left = *right = *top = *bottom = 2; // TODO: Proper mm to X calc + done = 1; + break; + + case BARCODE_CHANNEL: + /* ANSI/AIM BC12-1998 Section 4.4 (c) */ + *left = 1; + *right = 2; + done = 1; + break; + + case BARCODE_CODEONE: + /* TODO */ + break; + + case BARCODE_GRIDMATRIX: + /* AIMD014 (v 1.63) Section 7.1 */ + *left = *right = *top = *bottom = 6; + done = 1; + break; + case BARCODE_ULTRA: + /* AIMD/TSC15032-43 (v 0.99c) Section 9.2 */ + *left = *right = *top = *bottom = 1; + done = 1; + break; + } + + return done; /* For self-checking */ } /* Set left (x), top (y), right and bottom offsets for whitespace */ -INTERNAL void set_whitespace_offsets(struct zint_symbol *symbol, int *xoffset, int *yoffset, int *roffset, int *boffset) { +INTERNAL void output_set_whitespace_offsets(struct zint_symbol *symbol, int *xoffset, int *yoffset, int *roffset, int *boffset) { int qz_left, qz_right, qz_top, qz_bottom; quiet_zones(symbol, &qz_left, &qz_right, &qz_top, &qz_bottom); @@ -112,3 +425,163 @@ INTERNAL void set_whitespace_offsets(struct zint_symbol *symbol, int *xoffset, i *boffset += symbol->border_width; } } + +/* Set composite offset and main width excluding addon (for start of addon calc) and addon text, returning UPC/EAN type */ +INTERNAL int output_process_upcean(struct zint_symbol *symbol, int *p_main_width, int *p_comp_offset, unsigned char addon[6], int *p_addon_gap) { + int main_width; /* Width of main linear symbol, excluding addon */ + int comp_offset; /* Whitespace offset (if any) of main linear symbol due to having composite */ + int upceanflag; /* UPC/EAN type flag */ + int i, j, latch; + int text_length = ustrlen(symbol->text); + + latch = 0; + j = 0; + /* Isolate add-on text */ + for (i = 6; i < text_length && j < 5; i++) { + if (latch == 1) { + addon[j] = symbol->show_hrt ? symbol->text[i] : ' '; /* Use dummy space-filled addon if no hrt */ + j++; + } else if (symbol->text[i] == '+') { + latch = 1; + } + } + addon[j] = '\0'; + if (latch) { + if (symbol->symbology == BARCODE_UPCA || symbol->symbology == BARCODE_UPCA_CHK || symbol->symbology == BARCODE_UPCA_CC) { + *p_addon_gap = symbol->option_2 >= 9 && symbol->option_2 <= 12 ? symbol->option_2 : 9; + } else { + *p_addon_gap = symbol->option_2 >= 7 && symbol->option_2 <= 12 ? symbol->option_2 : 7; + } + } + + /* Calculate composite offset */ + comp_offset = 0; + if (is_composite(symbol->symbology)) { + while (!(module_is_set(symbol, symbol->rows - 1, comp_offset))) { + comp_offset++; + } + } + + upceanflag = 0; + main_width = symbol->width; + if ((symbol->symbology == BARCODE_EANX) || (symbol->symbology == BARCODE_EANX_CHK) + || (symbol->symbology == BARCODE_EANX_CC) || (symbol->symbology == BARCODE_ISBNX)) { + switch (text_length) { + case 13: /* EAN-13 */ + case 16: /* EAN-13 + EAN-2 */ + case 19: /* EAN-13 + EAN-5 */ + main_width = 95 + comp_offset; /* EAN-13 main symbol 95 modules wide */ + upceanflag = 13; + break; + case 2: + /* EAN-2 can't have addon or be composite */ + upceanflag = 2; + break; + case 5: + /* EAN-5 can't have addon or be composite */ + upceanflag = 5; + break; + default: + main_width = 68 + comp_offset; /* EAN-8 main symbol 68 modules wide */ + upceanflag = 8; + break; + } + } else if ((symbol->symbology == BARCODE_UPCA) || (symbol->symbology == BARCODE_UPCA_CHK) + || (symbol->symbology == BARCODE_UPCA_CC)) { + main_width = 95 + comp_offset; /* UPC-A main symbol 95 modules wide */ + upceanflag = 12; + } else if ((symbol->symbology == BARCODE_UPCE) || (symbol->symbology == BARCODE_UPCE_CHK) + || (symbol->symbology == BARCODE_UPCE_CC)) { + main_width = 51 + comp_offset; /* UPC-E main symbol 51 modules wide */ + upceanflag = 6; + } + + *p_comp_offset = comp_offset; + *p_main_width = main_width; + + return upceanflag; +} + +/* Calculate large bar height i.e. linear bars */ +INTERNAL double output_large_bar_height(struct zint_symbol *symbol) { + int i, large_bar_count, preset_height; + double large_bar_height; + + large_bar_count = 0; + preset_height = 0; + for (i = 0; i < symbol->rows; i++) { + preset_height += symbol->row_height[i]; + if (symbol->row_height[i] == 0) { + large_bar_count++; + } + } + + if (large_bar_count) { + large_bar_height = (double) (symbol->height - preset_height) / large_bar_count; + } else { + large_bar_height = 0.0; /* Not used if large_bar_count zero */ + } + + return large_bar_height; +} + +/* Split UPC/EAN add-on text into various constituents */ +INTERNAL void output_upcean_split_text(int upceanflag, unsigned char text[], + unsigned char textpart1[5], unsigned char textpart2[7], unsigned char textpart3[7], unsigned char textpart4[2]) { + int i; + + if (upceanflag == 6) { /* UPC-E */ + textpart1[0] = text[0]; + textpart1[1] = '\0'; + + for (i = 0; i < 6; i++) { + textpart2[i] = text[i + 1]; + } + textpart2[6] = '\0'; + + textpart3[0] = text[7]; + textpart3[1] = '\0'; + + } else if (upceanflag == 8) { /* EAN-8 */ + for (i = 0; i < 4; i++) { + textpart1[i] = text[i]; + } + textpart1[4] = '\0'; + + for (i = 0; i < 4; i++) { + textpart2[i] = text[i + 4]; + } + textpart2[4] = '\0'; + + } else if (upceanflag == 12) { /* UPC-A */ + textpart1[0] = text[0]; + textpart1[1] = '\0'; + + for (i = 0; i < 5; i++) { + textpart2[i] = text[i + 1]; + } + textpart2[5] = '\0'; + + for (i = 0; i < 5; i++) { + textpart3[i] = text[i + 6]; + } + textpart3[5] = '\0'; + + textpart4[0] = text[11]; + textpart4[1] = '\0'; + + } else if (upceanflag == 13) { /* EAN-13 */ + textpart1[0] = text[0]; + textpart1[1] = '\0'; + + for (i = 0; i < 6; i++) { + textpart2[i] = text[i + 1]; + } + textpart2[6] = '\0'; + + for (i = 0; i < 6; i++) { + textpart3[i] = text[i + 7]; + } + textpart3[6] = '\0'; + } +} diff --git a/backend/output.h b/backend/output.h index 7e5ecd6c..0bb05988 100644 --- a/backend/output.h +++ b/backend/output.h @@ -37,8 +37,12 @@ extern "C" { #endif /* __cplusplus */ -INTERNAL int check_colour_options(struct zint_symbol *symbol); -INTERNAL void set_whitespace_offsets(struct zint_symbol *symbol, int *xoffset, int *yoffset, int *roffset, int *boffset); +INTERNAL int output_check_colour_options(struct zint_symbol *symbol); +INTERNAL void output_set_whitespace_offsets(struct zint_symbol *symbol, int *xoffset, int *yoffset, int *roffset, int *boffset); +INTERNAL int output_process_upcean(struct zint_symbol *symbol, int *p_main_width, int *p_comp_offset, unsigned char addon[6], int *p_addon_gap); +INTERNAL double output_large_bar_height(struct zint_symbol *symbol); +INTERNAL void output_upcean_split_text(int upceanflag, unsigned char text[], + unsigned char textpart1[], unsigned char textpart2[], unsigned char textpart3[], unsigned char textpart4[]); #ifdef __cplusplus } diff --git a/backend/raster.c b/backend/raster.c index 434ab8f5..3af6ba2d 100644 --- a/backend/raster.c +++ b/backend/raster.c @@ -36,7 +36,7 @@ #include #include #endif -#include +#include #include "common.h" #include "output.h" @@ -46,7 +46,7 @@ #include "font.h" /* Font for human readable text */ -#define SSET "0123456789ABCDEF" +#define SSET "0123456789ABCDEF" #define DEFAULT_INK '1' #define DEFAULT_PAPER '0' @@ -66,6 +66,7 @@ static int buffer_plot(struct zint_symbol *symbol, char *pixelbuf) { int fgred, fggrn, fgblu, bgred, bggrn, bgblu; int row, column, i; + /* Free any previous bitmap */ if (symbol->bitmap != NULL) { free(symbol->bitmap); symbol->bitmap = NULL; @@ -137,7 +138,6 @@ static int buffer_plot(struct zint_symbol *symbol, char *pixelbuf) { symbol->bitmap[i + 1] = bggrn; symbol->bitmap[i + 2] = bgblu; break; - } } } @@ -251,7 +251,7 @@ static void draw_bar(char *pixelbuf, int xpos, int xlen, int ypos, int ylen, int } } -static void draw_circle(char *pixelbuf, int image_width, int image_height, int x0, int y0, float radius, char fill) { +static void draw_circle(char *pixelbuf, int image_width, int image_height, int x0, int y0, double radius, char fill) { int x, y; int radius_i = (int) radius; @@ -269,8 +269,8 @@ static void draw_circle(char *pixelbuf, int image_width, int image_height, int x static void draw_bullseye(char *pixelbuf, int image_width, int image_height, int xoffset, int yoffset, int scaler) { /* Central bullseye in Maxicode symbols */ - float x = 14.5 * scaler; - float y = 15.0 * scaler; + double x = 14.5 * scaler; + double y = 15.0 * scaler; if(scaler < 10) { x = 16.0 * scaler; y = 16.5 * scaler; @@ -415,7 +415,7 @@ static void draw_letter(char *pixelbuf, unsigned char letter, int xposn, int ypo } /* Plot a string into the pixel buffer */ -static void draw_string(char *pixbuf, char input_string[], int xposn, int yposn, int textflags, int image_width, int image_height) { +static void draw_string(char *pixbuf, unsigned char input_string[], int xposn, int yposn, int textflags, int image_width, int image_height) { int i, string_length, string_left_hand, letter_width = 7; switch (textflags) { @@ -432,27 +432,25 @@ static void draw_string(char *pixbuf, char input_string[], int xposn, int yposn, break; } - string_length = strlen(input_string); + string_length = ustrlen(input_string); string_left_hand = xposn - ((letter_width * string_length) / 2); for (i = 0; i < string_length; i++) { - // NOLINTNEXTLINE(clang-analyzer-core.CallAndMessage) suppress false positive about 2nd arg input_string[i] being uninitialized draw_letter(pixbuf, input_string[i], string_left_hand + (i * letter_width), yposn, textflags, image_width, image_height); } - } -static void plot_hexline(char *scaled_hexagon, int hexagon_size, float start_x, float start_y, float end_x, float end_y) { +static void plot_hexline(char *scaled_hexagon, int hexagon_size, double start_x, double start_y, double end_x, double end_y) { /* Draw a straight line from start to end */ int i; - float inc_x, inc_y; + double inc_x, inc_y; inc_x = (end_x - start_x) / hexagon_size; inc_y = (end_y - start_y) / hexagon_size; for (i = 0; i < hexagon_size; i++) { - float this_x = start_x + ((float)i * inc_x); - float this_y = start_y + ((float)i * inc_y); + double this_x = start_x + (i * inc_x); + double this_y = start_y + (i * inc_y); if (((this_x >= 0) && (this_x < hexagon_size)) && ((this_y >= 0) && (this_y < hexagon_size))) { scaled_hexagon[(hexagon_size * (int)this_y) + (int)this_x] = DEFAULT_INK; } @@ -463,10 +461,10 @@ static void plot_hexagon(char *scaled_hexagon, int hexagon_size) { /* Create a hexagon shape and fill it */ int line, i; - float x_offset[6]; - float y_offset[6]; - float start_x, start_y; - float end_x, end_y; + double x_offset[6]; + double y_offset[6]; + double start_x, start_y; + double end_x, end_y; x_offset[0] = 0.0; x_offset[1] = 0.86; @@ -484,16 +482,16 @@ static void plot_hexagon(char *scaled_hexagon, int hexagon_size) { /* Plot hexagon outline */ for (line = 0; line < 5; line++) { - start_x = ((float)hexagon_size / 2.0) + (((float)hexagon_size / 2.0) * x_offset[line]); - start_y = ((float)hexagon_size / 2.0) + (((float)hexagon_size / 2.0) * y_offset[line]); - end_x = ((float)hexagon_size / 2.0) + (((float)hexagon_size / 2.0) * x_offset[line + 1]); - end_y = ((float)hexagon_size / 2.0) + (((float)hexagon_size / 2.0) * y_offset[line + 1]); + start_x = (hexagon_size / 2.0) + ((hexagon_size / 2.0) * x_offset[line]); + start_y = (hexagon_size / 2.0) + ((hexagon_size / 2.0) * y_offset[line]); + end_x = (hexagon_size / 2.0) + ((hexagon_size / 2.0) * x_offset[line + 1]); + end_y = (hexagon_size / 2.0) + ((hexagon_size / 2.0) * y_offset[line + 1]); plot_hexline(scaled_hexagon, hexagon_size, start_x, start_y, end_x, end_y); } - start_x = ((float)hexagon_size / 2.0) + (((float)hexagon_size / 2.0) * x_offset[line]); - start_y = ((float)hexagon_size / 2.0) + (((float)hexagon_size / 2.0) * y_offset[line]); - end_x = ((float)hexagon_size / 2.0) + (((float)hexagon_size / 2.0) * x_offset[0]); - end_y = ((float)hexagon_size / 2.0) + (((float)hexagon_size / 2.0) * y_offset[0]); + start_x = (hexagon_size / 2.0) + ((hexagon_size / 2.0) * x_offset[line]); + start_y = (hexagon_size / 2.0) + ((hexagon_size / 2.0) * y_offset[line]); + end_x = (hexagon_size / 2.0) + ((hexagon_size / 2.0) * x_offset[0]); + end_y = (hexagon_size / 2.0) + ((hexagon_size / 2.0) * y_offset[0]); plot_hexline(scaled_hexagon, hexagon_size, start_x, start_y, end_x, end_y); /* Fill hexagon */ @@ -523,7 +521,7 @@ static int plot_raster_maxicode(struct zint_symbol *symbol, int rotate_angle, in int error_number; int xoffset, yoffset; int roffset, boffset; - float scaler = symbol->scale; + double scaler = symbol->scale; char *scaled_hexagon; int hexagon_size; @@ -531,10 +529,10 @@ static int plot_raster_maxicode(struct zint_symbol *symbol, int rotate_angle, in scaler = 0.5; } - set_whitespace_offsets(symbol, &xoffset, &yoffset, &roffset, &boffset); + output_set_whitespace_offsets(symbol, &xoffset, &yoffset, &roffset, &boffset); - image_width = (300 + 2 * (xoffset + roffset)) * scaler; - image_height = (300 + 2 * (yoffset + boffset)) * scaler; + image_width = ceil((300 + 2 * (xoffset + roffset)) * scaler); + image_height = ceil((300 + 2 * (yoffset + boffset)) * scaler); if (!(pixelbuf = (char *) malloc(image_width * image_height))) { strcpy(symbol->errtxt, "655: Insufficient memory for pixel buffer"); @@ -542,7 +540,7 @@ static int plot_raster_maxicode(struct zint_symbol *symbol, int rotate_angle, in } memset(pixelbuf, DEFAULT_PAPER, image_width * image_height); - hexagon_size = (int)(scaler * 10); + hexagon_size = ceil(scaler * 10); if (!(scaled_hexagon = (char *) malloc(hexagon_size * hexagon_size))) { strcpy(symbol->errtxt, "656: Insufficient memory for pixel buffer"); @@ -593,47 +591,9 @@ static int plot_raster_maxicode(struct zint_symbol *symbol, int rotate_angle, in return error_number; } -/* Convert UTF-8 to Latin1 Codepage for the interpretation line */ -static void to_latin1(unsigned char source[], unsigned char preprocessed[]) { - int j, i, input_length; - - input_length = ustrlen(source); - - j = 0; - i = 0; - while (i < input_length) { - switch (source[i]) { - case 0xC2: - /* UTF-8 C2xxh */ - /* Character range: C280h (latin: 80h) to C2BFh (latin: BFh) */ - i++; - preprocessed[j] = source[i]; - j++; - break; - case 0xC3: - /* UTF-8 C3xx */ - /* Character range: C380h (latin: C0h) to C3BFh (latin: FFh) */ - i++; - preprocessed[j] = source[i] + 64; - j++; - break; - default: - /* Process ASCII (< 80h), all other unicode points are ignored */ - if (source[i] < 128) { - preprocessed[j] = source[i]; - j++; - } - break; - } - i++; - } - preprocessed[j] = '\0'; - - return; -} - static int plot_raster_dotty(struct zint_symbol *symbol, int rotate_angle, int data_type) { - float scaler = 2 * symbol->scale; + double scaler = 2 * symbol->scale; + double half_scaler, dot_size_scaled; char *scaled_pixelbuf; int r, i; int scale_width, scale_height; @@ -643,7 +603,7 @@ static int plot_raster_dotty(struct zint_symbol *symbol, int rotate_angle, int d symbol->height = symbol->rows; // This is true because only 2d matrix symbols are processed here - set_whitespace_offsets(symbol, &xoffset, &yoffset, &roffset, &boffset); + output_set_whitespace_offsets(symbol, &xoffset, &yoffset, &roffset, &boffset); image_width = symbol->width + xoffset + roffset; image_height = symbol->height + yoffset + boffset; @@ -662,13 +622,16 @@ static int plot_raster_dotty(struct zint_symbol *symbol, int rotate_angle, int d memset(scaled_pixelbuf, DEFAULT_PAPER, scale_width * scale_height); /* Plot the body of the symbol to the pixel buffer */ + half_scaler = scaler / 2.0; + dot_size_scaled = (symbol->dot_size * scaler) / 2.0; for (r = 0; r < symbol->rows; r++) { + double row_scaled = (r + yoffset) * scaler + half_scaler; for (i = 0; i < symbol->width; i++) { if (module_is_set(symbol, r, i)) { draw_circle(scaled_pixelbuf, scale_width, scale_height, - (int) ((i + xoffset) * scaler) + (scaler / 2.0), - (int) ((r + yoffset) * scaler) + (scaler / 2.0), - (symbol->dot_size / 2.0) * scaler, + (i + xoffset) * scaler + half_scaler, + row_scaled, + dot_size_scaled, DEFAULT_INK); } } @@ -681,139 +644,61 @@ static int plot_raster_dotty(struct zint_symbol *symbol, int rotate_angle, int d } static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int data_type) { - int textdone, main_width, comp_offset, large_bar_count; - char textpart[10], addon[6]; - float addon_text_posn, preset_height, large_bar_height; - int i, r, textoffset, yoffset, xoffset, latch, image_width, image_height; - int roffset, boffset; - char *pixelbuf; - int addon_latch = 0, textflags = 0; - int block_width, textpos; - float row_height, row_posn; int error_number; + double large_bar_height; + int textdone; + int main_width, comp_offset, addon_gap; + unsigned char addon[6]; + int xoffset, yoffset, roffset, boffset; + double addon_text_posn; + int textoffset; int default_text_posn; + double row_height, row_posn; + int upceanflag = 0; + int addon_latch = 0; + unsigned char textpart1[5], textpart2[7], textpart3[7], textpart4[2]; + int textpos; + int hide_text = 0; + int i, r; + + int textflags = 0; + int image_width, image_height; + char *pixelbuf; int next_yposn; - float scaler = symbol->scale; + int latch; + int block_width; + double scaler = symbol->scale; + int scale_width, scale_height; char *scaled_pixelbuf; int horiz, vert; - int scale_width, scale_height; -#ifndef _MSC_VER - unsigned char local_text[ustrlen(symbol->text) + 1]; -#else - unsigned char* local_text = (unsigned char*) _alloca(ustrlen(symbol->text) + 1); -#endif - - if (symbol->show_hrt != 0) { - /* Copy text from symbol */ - to_latin1(symbol->text, local_text); - } else { - /* No text needed */ - if (is_extendable(symbol->symbology)) { - /* For these symbols use dummy text to ensure formatting is done - * properly even if no text is required */ - for (i = 0; i < (int) ustrlen(symbol->text); i++) { - if (symbol->text[i] == '+') { - local_text[i] = '+'; - } else { - local_text[i] = ' '; - } - } - local_text[ustrlen(symbol->text)] = '\0'; - } else { - /* For everything else, just remove the text */ - memset(local_text, 0, ustrlen(symbol->text) + 1); /* Note using memset() here to suppress clang-tidy false positives */ - } - } + large_bar_height = output_large_bar_height(symbol); textdone = 0; + main_width = symbol->width; comp_offset = 0; + + if (is_extendable(symbol->symbology)) { + upceanflag = output_process_upcean(symbol, &main_width, &comp_offset, addon, &addon_gap); + } + + output_set_whitespace_offsets(symbol, &xoffset, &yoffset, &roffset, &boffset); + addon_text_posn = 0.0; + hide_text = ((!symbol->show_hrt) || (ustrlen(symbol->text) == 0)); + if (symbol->output_options & SMALL_TEXT) { textflags = 1; } else if (symbol->output_options & BOLD_TEXT) { textflags = 2; } - if (symbol->height == 0) { - symbol->height = 50; - } - - large_bar_count = 0; - preset_height = 0.0; - for (i = 0; i < symbol->rows; i++) { - preset_height += symbol->row_height[i]; - if (symbol->row_height[i] == 0) { - large_bar_count++; - } - } - - if (large_bar_count == 0) { - symbol->height = preset_height; - large_bar_height = 10; - } else { - large_bar_height = (symbol->height - preset_height) / large_bar_count; - } - - if (is_composite(symbol->symbology)) { - while (!(module_is_set(symbol, symbol->rows - 1, comp_offset))) { - comp_offset++; - } - } - - /* Certain symbols need whitespace otherwise characters get chopped off the sides */ - if ((symbol->symbology == BARCODE_EANX) || (symbol->symbology == BARCODE_EANX_CHK) - || (symbol->symbology == BARCODE_EANX_CC) || (symbol->symbology == BARCODE_ISBNX)) { - switch (ustrlen(local_text)) { - case 13: /* EAN 13 */ - case 16: - case 19: - if (symbol->whitespace_width == 0) { - symbol->whitespace_width = 10; - } - main_width = 96 + comp_offset; - break; - default: - main_width = 68 + comp_offset; - } - } else if ((symbol->symbology == BARCODE_UPCA) || (symbol->symbology == BARCODE_UPCA_CHK) - || (symbol->symbology == BARCODE_UPCA_CC)) { - if (symbol->whitespace_width == 0) { - symbol->whitespace_width = 10; - } - main_width = 96 + comp_offset; - } else if ((symbol->symbology == BARCODE_UPCE) || (symbol->symbology == BARCODE_UPCE_CHK) - || (symbol->symbology == BARCODE_UPCE_CC)) { - if (symbol->whitespace_width == 0) { - symbol->whitespace_width = 10; - } - main_width = 51 + comp_offset; - } - - latch = 0; - r = 0; - /* Isolate add-on text */ - if (is_extendable(symbol->symbology)) { - for (i = 0; i < (int) ustrlen(local_text); i++) { - if (latch == 1) { - addon[r] = local_text[i]; - r++; - } - if (symbol->text[i] == '+') { - latch = 1; - } - } - } - addon[r] = '\0'; - - if (ustrlen(local_text) != 0) { + if (ustrlen(symbol->text) != 0) { textoffset = 9; } else { textoffset = 0; } - set_whitespace_offsets(symbol, &xoffset, &yoffset, &roffset, &boffset); - image_width = 2 * (symbol->width + xoffset + roffset); image_height = 2 * (symbol->height + textoffset + yoffset + boffset); @@ -825,9 +710,9 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int default_text_posn = image_height - 17; + row_height = 0.0; row_posn = textoffset + yoffset; next_yposn = textoffset + yoffset; - row_height = 0; /* Plot the body of the symbol to the pixel buffer */ for (r = 0; r < symbol->rows; r++) { @@ -855,9 +740,13 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int } while ((i + block_width < symbol->width) && module_is_set(symbol, this_row, i + block_width) == module_is_set(symbol, this_row, i)); if ((addon_latch == 0) && (r == 0) && (i > main_width)) { - plot_height = (int) (row_height - 5.0); - plot_yposn = (int) (row_posn - 5.0); - addon_text_posn = row_posn + row_height - 8.0; + if (upceanflag == 12 || upceanflag == 6) { /* UPC-A/E add-ons don't descend */ + plot_height = row_height > 8.0 ? row_height - 8.0 : 1; + plot_yposn = row_posn; + } else { + plot_height = row_height > 3.0 ? row_height - 3.0 : 1; + plot_yposn = row_posn - 5; + } addon_latch = 1; } if (module_fill) { @@ -875,193 +764,161 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int xoffset += comp_offset; - if ((symbol->symbology == BARCODE_EANX) || (symbol->symbology == BARCODE_EANX_CHK) - || (symbol->symbology == BARCODE_EANX_CC) || (symbol->symbology == BARCODE_ISBNX)) { - /* guard bar extensions and text formatting for EAN8 and EAN13 */ - switch (ustrlen(local_text)) { - case 8: /* EAN-8 */ - case 11: - case 14: - draw_bar(pixelbuf, (0 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, (2 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, (32 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, (34 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, (64 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, (66 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - for (i = 0; i < 4; i++) { - textpart[i] = local_text[i]; - } - textpart[4] = '\0'; - textpos = 2 * (17 + xoffset); + if (upceanflag) { + /* Guard bar extension */ - draw_string(pixelbuf, textpart, textpos, default_text_posn, textflags, image_width, image_height); - for (i = 0; i < 4; i++) { - textpart[i] = local_text[i + 4]; - } - textpart[4] = '\0'; - textpos = 2 * (50 + xoffset); - draw_string(pixelbuf, textpart, textpos, default_text_posn, textflags, image_width, image_height); - textdone = 1; - switch (strlen(addon)) { - case 2: - textpos = 2 * (xoffset + 86); - draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, textflags, image_width, image_height); - break; - case 5: - textpos = 2 * (xoffset + 100); - draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, textflags, image_width, image_height); - break; - } + if (upceanflag == 6) { /* UPC-E */ + draw_bar(pixelbuf, (0 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (2 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (46 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (48 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (50 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - break; - case 13: /* EAN 13 */ - case 16: - case 19: - draw_bar(pixelbuf, (0 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, (2 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, (46 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, (48 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, (92 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, (94 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); + } else if (upceanflag == 8) { /* EAN-8 */ + draw_bar(pixelbuf, (0 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (2 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (32 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (34 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (64 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (66 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - textpart[0] = local_text[0]; - textpart[1] = '\0'; - textpos = 2 * (-7 + xoffset); - draw_string(pixelbuf, textpart, textpos, default_text_posn, textflags, image_width, image_height); - for (i = 0; i < 6; i++) { - textpart[i] = local_text[i + 1]; + } else if (upceanflag == 12) { /* UPC-A */ + latch = 1; + + i = 0 + comp_offset; + do { + block_width = 0; + do { + block_width++; + } while ((i + block_width < symbol->width) && module_is_set(symbol, symbol->rows - 1, i + block_width) == module_is_set(symbol, symbol->rows - 1, i)); + if (latch == 1) { + /* a bar */ + draw_bar(pixelbuf, (i + xoffset - comp_offset) * 2, block_width * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); + latch = 0; + } else { + /* a space */ + latch = 1; } - textpart[6] = '\0'; + i += block_width; + } while (i < 11 + comp_offset); + draw_bar(pixelbuf, (46 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (48 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); + latch = 1; + i = 85 + comp_offset; + do { + block_width = 0; + do { + block_width++; + } while ((i + block_width < symbol->width) && module_is_set(symbol, symbol->rows - 1, i + block_width) == module_is_set(symbol, symbol->rows - 1, i)); + if (latch == 1) { + /* a bar */ + draw_bar(pixelbuf, (i + xoffset - comp_offset) * 2, block_width * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); + latch = 0; + } else { + /* a space */ + latch = 1; + } + i += block_width; + } while (i < 96 + comp_offset); + + } else if (upceanflag == 13) { /* EAN-13 */ + draw_bar(pixelbuf, (0 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (2 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (46 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (48 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (92 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); + draw_bar(pixelbuf, (94 + xoffset) * 2, 1 * 2, (4 + yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); + } + } + + if (!hide_text) { + + if (upceanflag) { + output_upcean_split_text(upceanflag, symbol->text, textpart1, textpart2, textpart3, textpart4); + + if (upceanflag == 6) { /* UPC-E */ + textpos = 2 * (-5 + xoffset); + draw_string(pixelbuf, textpart1, textpos, default_text_posn, textflags, image_width, image_height); textpos = 2 * (24 + xoffset); - draw_string(pixelbuf, textpart, textpos, default_text_posn, textflags, image_width, image_height); - for (i = 0; i < 6; i++) { - textpart[i] = local_text[i + 7]; - } - textpart[6] = '\0'; - textpos = 2 * (71 + xoffset); - draw_string(pixelbuf, textpart, textpos, default_text_posn, textflags, image_width, image_height); + draw_string(pixelbuf, textpart2, textpos, default_text_posn, textflags, image_width, image_height); + textpos = 2 * (55 + xoffset); + draw_string(pixelbuf, textpart3, textpos, default_text_posn, textflags, image_width, image_height); textdone = 1; - switch (strlen(addon)) { + switch (ustrlen(addon)) { case 2: - textpos = 2 * (xoffset + 114); - draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, textflags, image_width, image_height); + textpos = 2 * (61 + xoffset + addon_gap); + draw_string(pixelbuf, addon, textpos, addon_text_posn, textflags, image_width, image_height); break; case 5: - textpos = 2 * (xoffset + 128); - draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, textflags, image_width, image_height); + textpos = 2 * (75 + xoffset + addon_gap); + draw_string(pixelbuf, addon, textpos, addon_text_posn, textflags, image_width, image_height); break; } - break; - } + } else if (upceanflag == 8) { /* EAN-8 */ + textpos = 2 * (17 + xoffset); + draw_string(pixelbuf, textpart1, textpos, default_text_posn, textflags, image_width, image_height); + textpos = 2 * (50 + xoffset); + draw_string(pixelbuf, textpart2, textpos, default_text_posn, textflags, image_width, image_height); + textdone = 1; + switch (ustrlen(addon)) { + case 2: + textpos = 2 * (77 + xoffset + addon_gap); + draw_string(pixelbuf, addon, textpos, addon_text_posn, textflags, image_width, image_height); + break; + case 5: + textpos = 2 * (91 + xoffset + addon_gap); + draw_string(pixelbuf, addon, textpos, addon_text_posn, textflags, image_width, image_height); + break; + } - } else if ((symbol->symbology == BARCODE_UPCA) || (symbol->symbology == BARCODE_UPCA_CHK) - || (symbol->symbology == BARCODE_UPCA_CC)) { - /* guard bar extensions and text formatting for UPCA */ - latch = 1; + } else if (upceanflag == 12) { /* UPC-A */ + textpos = 2 * (-5 + xoffset); + draw_string(pixelbuf, textpart1, textpos, default_text_posn, textflags, image_width, image_height); + textpos = 2 * (27 + xoffset); + draw_string(pixelbuf, textpart2, textpos, default_text_posn, textflags, image_width, image_height); + textpos = 2 * (68 + xoffset); + draw_string(pixelbuf, textpart3, textpos, default_text_posn, textflags, image_width, image_height); + textpos = 2 * (100 + xoffset); + draw_string(pixelbuf, textpart4, textpos, default_text_posn, textflags, image_width, image_height); + textdone = 1; + switch (ustrlen(addon)) { + case 2: + textpos = 2 * (107 + xoffset + addon_gap); + draw_string(pixelbuf, addon, textpos, addon_text_posn, textflags, image_width, image_height); + break; + case 5: + textpos = 2 * (121 + xoffset + addon_gap); + draw_string(pixelbuf, addon, textpos, addon_text_posn, textflags, image_width, image_height); + break; + } - i = 0 + comp_offset; - do { - block_width = 0; - do { - block_width++; - } while ((i + block_width < symbol->width) && module_is_set(symbol, symbol->rows - 1, i + block_width) == module_is_set(symbol, symbol->rows - 1, i)); - if (latch == 1) { - /* a bar */ - draw_bar(pixelbuf, (i + xoffset - comp_offset) * 2, block_width * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - latch = 0; - } else { - /* a space */ - latch = 1; + } else if (upceanflag == 13) { /* EAN-13 */ + textpos = 2 * (-7 + xoffset); + draw_string(pixelbuf, textpart1, textpos, default_text_posn, textflags, image_width, image_height); + textpos = 2 * (24 + xoffset); + draw_string(pixelbuf, textpart2, textpos, default_text_posn, textflags, image_width, image_height); + textpos = 2 * (71 + xoffset); + draw_string(pixelbuf, textpart3, textpos, default_text_posn, textflags, image_width, image_height); + textdone = 1; + switch (ustrlen(addon)) { + case 2: + textpos = 2 * (105 + xoffset + addon_gap); + draw_string(pixelbuf, addon, textpos, addon_text_posn, textflags, image_width, image_height); + break; + case 5: + textpos = 2 * (119 + xoffset + addon_gap); + draw_string(pixelbuf, addon, textpos, addon_text_posn, textflags, image_width, image_height); + break; + } } - i += block_width; - } while (i < 11 + comp_offset); - draw_bar(pixelbuf, (46 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, (48 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - latch = 1; - i = 85 + comp_offset; - do { - block_width = 0; - do { - block_width++; - } while ((i + block_width < symbol->width) && module_is_set(symbol, symbol->rows - 1, i + block_width) == module_is_set(symbol, symbol->rows - 1, i)); - if (latch == 1) { - /* a bar */ - draw_bar(pixelbuf, (i + xoffset - comp_offset) * 2, block_width * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - latch = 0; - } else { - /* a space */ - latch = 1; - } - i += block_width; - } while (i < 96 + comp_offset); - textpart[0] = local_text[0]; - textpart[1] = '\0'; - textpos = 2 * (-5 + xoffset); - draw_string(pixelbuf, textpart, textpos, default_text_posn, textflags, image_width, image_height); - for (i = 0; i < 5; i++) { - textpart[i] = local_text[i + 1]; - } - textpart[5] = '\0'; - textpos = 2 * (27 + xoffset); - draw_string(pixelbuf, textpart, textpos, default_text_posn, textflags, image_width, image_height); - for (i = 0; i < 5; i++) { - textpart[i] = local_text[i + 6]; - } - textpart[6] = '\0'; - textpos = 2 * (68 + xoffset); - draw_string(pixelbuf, textpart, textpos, default_text_posn, textflags, image_width, image_height); - textpart[0] = local_text[11]; - textpart[1] = '\0'; - textpos = 2 * (100 + xoffset); - draw_string(pixelbuf, textpart, textpos, default_text_posn, textflags, image_width, image_height); - textdone = 1; - switch (strlen(addon)) { - case 2: - textpos = 2 * (xoffset + 116); - draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, textflags, image_width, image_height); - break; - case 5: - textpos = 2 * (xoffset + 130); - draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, textflags, image_width, image_height); - break; } - } else if ((symbol->symbology == BARCODE_UPCE) || (symbol->symbology == BARCODE_UPCE_CHK) - || (symbol->symbology == BARCODE_UPCE_CC)) { - /* guard bar extensions and text formatting for UPCE */ - draw_bar(pixelbuf, (0 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, (2 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, (46 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, (48 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - draw_bar(pixelbuf, (50 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height, DEFAULT_INK); - - textpart[0] = local_text[0]; - textpart[1] = '\0'; - textpos = 2 * (-5 + xoffset); - draw_string(pixelbuf, textpart, textpos, default_text_posn, textflags, image_width, image_height); - for (i = 0; i < 6; i++) { - textpart[i] = local_text[i + 1]; + if (!textdone) { + /* Put the human readable text at the bottom */ + textpos = 2 * (main_width / 2 + xoffset); + draw_string(pixelbuf, symbol->text, textpos, default_text_posn, textflags, image_width, image_height); } - textpart[6] = '\0'; - textpos = 2 * (24 + xoffset); - draw_string(pixelbuf, textpart, textpos, default_text_posn, textflags, image_width, image_height); - textpart[0] = local_text[7]; - textpart[1] = '\0'; - textpos = 2 * (55 + xoffset); - draw_string(pixelbuf, textpart, textpos, default_text_posn, textflags, image_width, image_height); - textdone = 1; - switch (strlen(addon)) { - case 2: - textpos = 2 * (xoffset + 70); - draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, textflags, image_width, image_height); - break; - case 5: - textpos = 2 * (xoffset + 84); - draw_string(pixelbuf, addon, textpos, image_height - (addon_text_posn * 2) - 13, textflags, image_width, image_height); - break; - } - } xoffset -= comp_offset; @@ -1103,13 +960,6 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int draw_bar(pixelbuf, (symbol->width + xoffset + roffset - symbol->border_width) * 2, symbol->border_width * 2, textoffset * 2, (symbol->height + (2 * symbol->border_width)) * 2, image_width, image_height, DEFAULT_INK); } - /* Put the human readable text at the bottom */ - if ((textdone == 0) && (ustrlen(local_text) != 0)) { - textpos = (image_width / 2); - draw_string(pixelbuf, (char*) local_text, textpos, default_text_posn, textflags, image_width, image_height); - } - - if (scaler <= 0) { scaler = 0.5; } @@ -1127,8 +977,9 @@ static int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int memset(scaled_pixelbuf, DEFAULT_PAPER, scale_width * scale_height); for (vert = 0; vert < scale_height; vert++) { + double vert_scaled = (vert * image_width) / scaler; for (horiz = 0; horiz < scale_width; horiz++) { - *(scaled_pixelbuf + (vert * scale_width) + horiz) = *(pixelbuf + ((int) (vert / scaler) * image_width) + (int) (horiz / scaler)); + *(scaled_pixelbuf + (vert * scale_width) + horiz) = *(pixelbuf + (int) (vert_scaled + (horiz / scaler))); } } @@ -1151,7 +1002,7 @@ INTERNAL int plot_raster(struct zint_symbol *symbol, int rotate_angle, int file_ } #endif /* NO_PNG */ - error = check_colour_options(symbol); + error = output_check_colour_options(symbol); if (error != 0) { return error; } diff --git a/backend/tests/README b/backend/tests/README index eed43866..b348bbe1 100644 --- a/backend/tests/README +++ b/backend/tests/README @@ -44,10 +44,18 @@ To show debug info (if any), use '-d ': ./test_dotcode -f input -i 2 -d 1 +(for other flags see /backend/tests/testcommon.h) + To generate test data, use '-g': ./test_dotcode -f encode -g +To run a test against BWIPP (if any), use '-d 128': + + ./test_composite -d 128 + +(see also /backend/tests/tools/run_bwipp_tests.sh) + ------------------------------------------------------------------------------ To make with gcc sanitize, first set for libzint and make: diff --git a/backend/tests/data/png/ean13_2addon_ggs_5.2.2.5.1-2.png b/backend/tests/data/png/ean13_2addon_ggs_5.2.2.5.1-2.png new file mode 100644 index 00000000..bb63e837 Binary files /dev/null and b/backend/tests/data/png/ean13_2addon_ggs_5.2.2.5.1-2.png differ diff --git a/backend/tests/data/png/ean13_5addon_ggs_5.2.2.5.2-2.png b/backend/tests/data/png/ean13_5addon_ggs_5.2.2.5.2-2.png new file mode 100644 index 00000000..c9f5b36a Binary files /dev/null and b/backend/tests/data/png/ean13_5addon_ggs_5.2.2.5.2-2.png differ diff --git a/backend/tests/data/png/ean2.png b/backend/tests/data/png/ean2.png new file mode 100644 index 00000000..b631d74c Binary files /dev/null and b/backend/tests/data/png/ean2.png differ diff --git a/backend/tests/data/png/ean5.png b/backend/tests/data/png/ean5.png new file mode 100644 index 00000000..8ecf3461 Binary files /dev/null and b/backend/tests/data/png/ean5.png differ diff --git a/backend/tests/data/png/ean8_2addon.png b/backend/tests/data/png/ean8_2addon.png new file mode 100644 index 00000000..c6173982 Binary files /dev/null and b/backend/tests/data/png/ean8_2addon.png differ diff --git a/backend/tests/data/png/ean8_5addon.png b/backend/tests/data/png/ean8_5addon.png new file mode 100644 index 00000000..650f46b8 Binary files /dev/null and b/backend/tests/data/png/ean8_5addon.png differ diff --git a/backend/tests/data/png/upca_2addon_ggs_5.2.6.6-5.png b/backend/tests/data/png/upca_2addon_ggs_5.2.6.6-5.png new file mode 100644 index 00000000..2bf091d8 Binary files /dev/null and b/backend/tests/data/png/upca_2addon_ggs_5.2.6.6-5.png differ diff --git a/backend/tests/data/png/upca_5addon.png b/backend/tests/data/png/upca_5addon.png new file mode 100644 index 00000000..d135b8b4 Binary files /dev/null and b/backend/tests/data/png/upca_5addon.png differ diff --git a/backend/tests/data/png/upce_2addon.png b/backend/tests/data/png/upce_2addon.png new file mode 100644 index 00000000..1886da8f Binary files /dev/null and b/backend/tests/data/png/upce_2addon.png differ diff --git a/backend/tests/data/png/upce_5addon.png b/backend/tests/data/png/upce_5addon.png new file mode 100644 index 00000000..2dc34601 Binary files /dev/null and b/backend/tests/data/png/upce_5addon.png differ diff --git a/backend/tests/data/svg/ean13_2addon_ggs_5.2.2.5.1-2.svg b/backend/tests/data/svg/ean13_2addon_ggs_5.2.2.5.1-2.svg new file mode 100644 index 00000000..9a2bcc61 --- /dev/null +++ b/backend/tests/data/svg/ean13_2addon_ggs_5.2.2.5.1-2.svg @@ -0,0 +1,65 @@ + + + + Zint Generated Symbol + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 9 + + + 771384 + + + 524017 + + + 12 + + + diff --git a/backend/tests/data/svg/ean13_5addon_ggs_5.2.2.5.2-2.svg b/backend/tests/data/svg/ean13_5addon_ggs_5.2.2.5.2-2.svg new file mode 100644 index 00000000..70e75e89 --- /dev/null +++ b/backend/tests/data/svg/ean13_5addon_ggs_5.2.2.5.2-2.svg @@ -0,0 +1,74 @@ + + + + Zint Generated Symbol + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 9 + + + 780877 + + + 799306 + + + 54321 + + + diff --git a/backend/tests/data/svg/ean2.svg b/backend/tests/data/svg/ean2.svg new file mode 100644 index 00000000..de4f02d4 --- /dev/null +++ b/backend/tests/data/svg/ean2.svg @@ -0,0 +1,23 @@ + + + + Zint Generated Symbol + + + + + + + + + + + + + 12 + + + diff --git a/backend/tests/data/svg/ean5.svg b/backend/tests/data/svg/ean5.svg new file mode 100644 index 00000000..156038d0 --- /dev/null +++ b/backend/tests/data/svg/ean5.svg @@ -0,0 +1,32 @@ + + + + Zint Generated Symbol + + + + + + + + + + + + + + + + + + + + + + 12345 + + + diff --git a/backend/tests/data/svg/ean8_2addon.svg b/backend/tests/data/svg/ean8_2addon.svg new file mode 100644 index 00000000..9693a44e --- /dev/null +++ b/backend/tests/data/svg/ean8_2addon.svg @@ -0,0 +1,53 @@ + + + + Zint Generated Symbol + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1234 + + + 5670 + + + 12 + + + diff --git a/backend/tests/data/svg/ean8_5addon.svg b/backend/tests/data/svg/ean8_5addon.svg new file mode 100644 index 00000000..5d1a2833 --- /dev/null +++ b/backend/tests/data/svg/ean8_5addon.svg @@ -0,0 +1,62 @@ + + + + Zint Generated Symbol + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1234 + + + 5670 + + + 12345 + + + diff --git a/backend/tests/data/svg/upca_2addon_ggs_5.2.6.6-5.svg b/backend/tests/data/svg/upca_2addon_ggs_5.2.6.6-5.svg new file mode 100644 index 00000000..6f1dc0b6 --- /dev/null +++ b/backend/tests/data/svg/upca_2addon_ggs_5.2.6.6-5.svg @@ -0,0 +1,69 @@ + + + + Zint Generated Symbol + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + 12345 + + + 67890 + + + 5 + + + 24 + + + diff --git a/backend/tests/data/svg/upca_5addon.svg b/backend/tests/data/svg/upca_5addon.svg new file mode 100644 index 00000000..218af826 --- /dev/null +++ b/backend/tests/data/svg/upca_5addon.svg @@ -0,0 +1,78 @@ + + + + Zint Generated Symbol + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 6 + + + 14141 + + + 23441 + + + 7 + + + 12345 + + + diff --git a/backend/tests/data/svg/upce_2addon.svg b/backend/tests/data/svg/upce_2addon.svg new file mode 100644 index 00000000..05f298ec --- /dev/null +++ b/backend/tests/data/svg/upce_2addon.svg @@ -0,0 +1,52 @@ + + + + Zint Generated Symbol + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + 234567 + + + 0 + + + 12 + + + diff --git a/backend/tests/data/svg/upce_5addon.svg b/backend/tests/data/svg/upce_5addon.svg new file mode 100644 index 00000000..4aac7c00 --- /dev/null +++ b/backend/tests/data/svg/upce_5addon.svg @@ -0,0 +1,61 @@ + + + + Zint Generated Symbol + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + 234567 + + + 0 + + + 12345 + + + diff --git a/backend/tests/test_2of5.c b/backend/tests/test_2of5.c index 85afc5dc..bfb752c1 100644 --- a/backend/tests/test_2of5.c +++ b/backend/tests/test_2of5.c @@ -193,6 +193,8 @@ static void test_encode(int index, int generate, int debug) { testStart(""); + int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); // Only do BWIPP test if asked, too slow otherwise + int ret; struct item { int symbology; @@ -206,37 +208,37 @@ static void test_encode(int index, int generate, int debug) { }; // BARCODE_ITF14 examples verified manually against GS1 General Specifications 20.0 struct item data[] = { - /* 0*/ { BARCODE_C25MATRIX, "87654321", 0, 1, 97, "Standard Code 2 of 5; verified manually against bwipp and tec-it", + /* 0*/ { BARCODE_C25MATRIX, "87654321", 0, 1, 97, "Standard Code 2 of 5; note zint uses 4X start/end wides while BWIPP uses 3X", "1111010101110100010101000111010001110101110111010101110111011100010101000101110111010111011110101" }, - /* 1*/ { BARCODE_C25INTER, "87654321", 0, 1, 81, "Interleaved Code 2 of 5; verified manually against bwipp and tec-it", + /* 1*/ { BARCODE_C25INTER, "87654321", 0, 1, 81, "Interleaved Code 2 of 5; verified manually against tec-it", "101011101010111000100010001110111000101010001000111010111010001110101011100011101" }, /* 2*/ { BARCODE_C25INTER, "602003", 0, 1, 63, "DX cartridge barcode https://en.wikipedia.org/wiki/Interleaved_2_of_5 example", "101010111011100010001010111010001000111010001000111011101011101" }, - /* 3*/ { BARCODE_C25IATA, "87654321", 0, 1, 121, "IATA Code 2 of 5; verified manually against bwipp and tec-it", + /* 3*/ { BARCODE_C25IATA, "87654321", 0, 1, 121, "IATA Code 2 of 5; verified manually against tec-it", "1010111010101110101010101110111010111011101010111010111010101010111010111011101110101010101110101011101110101010111011101" }, - /* 4*/ { BARCODE_C25LOGIC, "87654321", 0, 1, 89, "Code 2 of 5 Data Logic; verified manually against bwipp and tec-it", + /* 4*/ { BARCODE_C25LOGIC, "87654321", 0, 1, 89, "Code 2 of 5 Data Logic; verified manually against tec-it", "10101110100010101000111010001110101110111010101110111011100010101000101110111010111011101" }, - /* 5*/ { BARCODE_C25IND, "87654321", 0, 1, 131, "Industrial Code 2 of 5; verified manually against bwipp and tec-it", + /* 5*/ { BARCODE_C25IND, "87654321", 0, 1, 131, "Industrial Code 2 of 5; verified manually against tec-it", "11101110101110101011101010101011101110101110111010101110101110101010101110101110111011101010101011101010111011101010101110111010111" }, - /* 6*/ { BARCODE_DPLEIT, "87654321", 0, 1, 135, "Deutsche Post Leitcode; verified manually against bwipp and tec-it (0000087654321)", + /* 6*/ { BARCODE_DPLEIT, "0000087654321", 0, 1, 135, "Deutsche Post Leitcode; verified manually against tec-it", "101010101110001110001010101110001110001010001011101110001010100010001110111011101011100010100011101110001010100011101000100010111011101" }, /* 7*/ { BARCODE_DPLEIT, "5082300702800", 0, 1, 135, "Deutsche Post Leitcode https://de.wikipedia.org/wiki/Leitcode example", "101011101011100010001011101000101110100011101110100010001010101110111000100010100011101110100011101010001110001010001011100011101011101" }, - /* 8*/ { BARCODE_DPIDENT, "87654321", 0, 1, 117, "Deutsche Post Identcode; verified manually against bwipp and tec-it (00087654321)", + /* 8*/ { BARCODE_DPIDENT, "00087654321", 0, 1, 117, "Deutsche Post Identcode; verified manually against tec-it", "101010101110001110001010001011101110001010100010001110111011101011100010100011101110001010100011101000100010111011101" }, /* 9*/ { BARCODE_DPIDENT, "39601313414", 0, 1, 117, "Deutsche Post Identcode https://de.wikipedia.org/wiki/Leitcode example", "101011101110001010001010111011100010001011100010001010111011100010001010111010001011101011100010101110001000111011101" }, - /* 10*/ { BARCODE_ITF14, "87654321", 0, 1, 135, "ITF-14; verified manually against bwipp and tec-it (0000087654321)", + /* 10*/ { BARCODE_ITF14, "0000087654321", 0, 1, 135, "ITF-14; verified manually against tec-it", "101010101110001110001010101110001110001010001011101110001010100010001110111011101011100010100011101110001010100011101000101011100011101" }, /* 11*/ { BARCODE_ITF14, "0950110153000", 0, 1, 135, "GS1 General Specifications Figure 5.1-2", @@ -252,6 +254,8 @@ static void test_encode(int index, int generate, int debug) { int data_size = ARRAY_SIZE(data); char escaped[1024]; + char bwipp_buf[4096]; + char bwipp_msg[1024]; for (int i = 0; i < data_size; i++) { @@ -281,6 +285,15 @@ static void test_encode(int index, int generate, int debug) { ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row); assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data); } + + if (do_bwipp && testUtilCanBwipp(symbol->symbology, -1, -1, -1, debug)) { + ret = testUtilBwipp(symbol, -1, -1, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf)); + assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), ret); + + ret = testUtilBwippCmp(symbol, bwipp_msg, bwipp_buf, data[i].expected); + assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n", + i, testUtilBarcodeName(data[i].symbology), ret, bwipp_msg, bwipp_buf, data[i].expected); + } } } diff --git a/backend/tests/test_codablock.c b/backend/tests/test_codablock.c index 83ddbf89..b9b8cb80 100644 --- a/backend/tests/test_codablock.c +++ b/backend/tests/test_codablock.c @@ -432,7 +432,7 @@ static void test_encode(int index, int generate, int debug) { if (generate) { printf(" /*%3d*/ { %s, %d, %d, \"%s\", %s, %d, %d, %d, \"%s\",\n", i, testUtilBarcodeName(data[i].symbology), data[i].option_1, data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), - testUtilErrorName(data[i].ret), symbol->rows, data[i].bwipp_cmp, symbol->width, data[i].comment); + testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment); testUtilModulesDump(symbol, " ", "\n"); printf(" },\n"); } else { @@ -448,7 +448,7 @@ static void test_encode(int index, int generate, int debug) { if (do_bwipp && testUtilCanBwipp(symbol->symbology, data[i].option_1, data[i].option_2, -1, debug)) { if (!data[i].bwipp_cmp) { - if (debug & ZINT_DEBUG_TEST_PRINT) printf("%d: %s skipped, not BWIPP compatible\n", i, testUtilBarcodeName(symbol->symbology)); + if (debug & ZINT_DEBUG_TEST_PRINT) printf("%d: %s not BWIPP compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment); } else { ret = testUtilBwipp(symbol, data[i].option_1, data[i].option_2, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf)); assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), ret); diff --git a/backend/tests/test_code128.c b/backend/tests/test_code128.c index a3e41743..acbb2a31 100644 --- a/backend/tests/test_code128.c +++ b/backend/tests/test_code128.c @@ -443,99 +443,127 @@ static void test_encode(int index, int generate, int debug) { int expected_rows; int expected_width; + int bwipp_cmp; char *comment; char *expected; }; - // BARCODE_EAN128 examples verified manually against GS1 General Specifications 20.0 + // BARCODE_EAN128 examples verified manually against GS1 General Specifications 20.0 (GGS) struct item data[] = { - /* 0*/ { BARCODE_CODE128, UNICODE_MODE, "AIM", 0, 1, 68, "ISO/IEC 15417:2007 Figure 1", + /* 0*/ { BARCODE_CODE128, UNICODE_MODE, "AIM", 0, 1, 68, 1, "ISO/IEC 15417:2007 Figure 1", "11010010000101000110001100010001010111011000101110110001100011101011" }, - /* 1*/ { BARCODE_CODE128B, UNICODE_MODE, "AIM", 0, 1, 68, "128B same", + /* 1*/ { BARCODE_CODE128B, UNICODE_MODE, "AIM", 0, 1, 68, 1, "128B same", "11010010000101000110001100010001010111011000101110110001100011101011" }, - /* 2*/ { BARCODE_CODE128, UNICODE_MODE, "1234567890", 0, 1, 90, "", + /* 2*/ { BARCODE_CODE128, UNICODE_MODE, "1234567890", 0, 1, 90, 1, "", "110100111001011001110010001011000111000101101100001010011011110110100111100101100011101011" }, - /* 3*/ { BARCODE_CODE128B, UNICODE_MODE, "1234567890", 0, 1, 145, "", + /* 3*/ { BARCODE_CODE128B, UNICODE_MODE, "1234567890", 0, 1, 145, 1, "", "1101001000010011100110110011100101100101110011001001110110111001001100111010011101101110111010011001110010110010011101100101000110001100011101011" }, - /* 4*/ { BARCODE_EAN128, GS1_MODE, "[8018]950110153123456781", 0, 1, 167, "GS1 General Specifications Figure 2.5.2-1", + /* 4*/ { BARCODE_EAN128, GS1_MODE, "[8018]950110153123456781", 0, 1, 167, 1, "GGS Figure 2.5.2-1", "11010011100111101011101010011110011001110010101111010001100110110011001000100101110011001101100011011101101110101110110001000010110010010111100101111001001100011101011" }, - /* 5*/ { BARCODE_EAN128, GS1_MODE, "[415]5412345678908[3911]710125", 0, 1, 189, "GS1 General Specifications Figure 2.6.6-1 top", + /* 5*/ { BARCODE_EAN128, GS1_MODE, "[415]5412345678908[3911]710125", 0, 1, 189, 1, "GGS Figure 2.6.6-1 top", "110100111001111010111011000100010111010001101100010001011101101110101110110001000010110011011011110100011001001101000100011000100100100110100001100110110011100101100100001001101100011101011" }, - /* 6*/ { BARCODE_EAN128, GS1_MODE, "[12]010425[8020]ABC123", 0, 1, 189, "GS1 General Specifications Figure 2.6.6-1 bottom", + /* 6*/ { BARCODE_EAN128, GS1_MODE, "[12]010425[8020]ABC123", 0, 1, 189, 1, "GGS Figure 2.6.6-1 bottom", "110100111001111010111010110011100110011011001001000110011100101100101001111001100100111010111101110101000110001000101100010001000110100111001101100111001011001011100110010111001100011101011" }, - /* 7*/ { BARCODE_EAN128, GS1_MODE, "[253]950110153005812345678901", 0, 1, 211, "GS1 General Specifications Figure 2.6.9-1", + /* 7*/ { BARCODE_EAN128, GS1_MODE, "[253]950110153005812345678901", 0, 1, 211, 1, "GGS Figure 2.6.9-1", "1101001110011110101110111001011001101000100011000101110110001001001100110110011011101110110110011001110110001010110011100100010110001110001011011000010100110111101101011110111010011100110101110110001100011101011" }, - /* 8*/ { BARCODE_EAN128, GS1_MODE, "[253]950110153006567890543210987", 0, 1, 211, "GS1 General Specifications Figure 2.6.9-2", + /* 8*/ { BARCODE_EAN128, GS1_MODE, "[253]950110153006567890543210987", 0, 1, 211, 1, "GGS Figure 2.6.9-2", "1101001110011110101110111001011001101000100011000101110110001001001100110110011011101110110110011001001011000010000101100110110111101000100110010110001110110111001001100100100011110010100101110011001100011101011" }, - /* 9*/ { BARCODE_EAN128, GS1_MODE, "[253]95011015300657654321", 0, 1, 189, "GS1 General Specifications Figure 2.6.9-3", + /* 9*/ { BARCODE_EAN128, GS1_MODE, "[253]95011015300657654321", 0, 1, 189, 1, "GGS Figure 2.6.9-3", "110100111001111010111011100101100110100010001100010111011000100100110011011001101110111011011001100100101100001100101000011101011000110001101101011110111010011100110111001001101100011101011" }, - /* 10*/ { BARCODE_EAN128, GS1_MODE, "[253]9501101530065123456", 0, 1, 167, "GS1 General Specifications Figure 2.6.9-4", + /* 10*/ { BARCODE_EAN128, GS1_MODE, "[253]9501101530065123456", 0, 1, 167, 1, "GGS Figure 2.6.9-4", "11010011100111101011101110010110011010001000110001011101100010010011001101100110111011101101100110010010110000101100111001000101100011100010110100011110101100011101011" }, - /* 11*/ { BARCODE_EAN128, GS1_MODE, "[01]10857674002017[10]1152KMB", 0, 1, 211, "GS1 General Specifications Figure 4.15.1-1", + /* 11*/ { BARCODE_EAN128, GS1_MODE, "[01]10857674002017[10]1152KMB", 0, 1, 211, 1, "GGS Figure 4.15.1-1", "1101001110011110101110110011011001100100010010011110010110010100001000011001011011001100110010011101001110011011001000100110001001001101110001010111101110101100011101011101100010001011000100111001101100011101011" }, - /* 12*/ { BARCODE_EAN128, GS1_MODE, "[01]09501101530003", 0, 1, 134, "GS1 General Specifications Figure 5.1-3", + /* 12*/ { BARCODE_EAN128, GS1_MODE, "[01]09501101530003", 0, 1, 134, 1, "GGS Figure 5.1-3", "11010011100111101011101100110110011001001000110001011101100010010011001101100110111011101101100110010010011000100110100001100011101011" }, - /* 13*/ { BARCODE_EAN128, GS1_MODE, "[00]395123451234567895", 0, 1, 156, "GS1 General Specifications Figure 5.4.2-1", + /* 13*/ { BARCODE_EAN128, GS1_MODE, "[00]395123451234567895", 0, 1, 156, 1, "GGS Figure 5.4.2-1", "110100111001111010111011011001100110100010001101110100011101101110101110110001011001110010001011000111000101101100001010010111101000101111000101100011101011" }, - /* 14*/ { BARCODE_EAN128, GS1_MODE, "[00]395011010013000129", 0, 1, 156, "GS1 General Specifications Figure 6.6.5-6", + /* 14*/ { BARCODE_EAN128, GS1_MODE, "[00]006141411234567890", 0, 1, 156, 1, "GGS Figure 6.6.5-1. (and Figures 6.6.5-3 bottom, 6.6.5-4 bottom)", + "110100111001111010111011011001100110110011001100100001011000100010110001000101011001110010001011000111000101101100001010011011110110110110110001100011101011" + }, + /* 15*/ { BARCODE_EAN128, GS1_MODE, "[403]402621[401]950110153B01001", 0, 1, 266, 0, "GGS Figure 6.6.5-2 top **NOT SAME**, different encodation for zint, BWIPP & standard, same codeword count", + "11010011100111101011101100010100010001011000110011001101111000101010111101110100111001101011101111011110101110110001010001100101110011000101110110001001001100110110011011101110101111011101000101100010011101100101110111101100100010011001101100101001111001100011101011" + }, + /* 16*/ { BARCODE_EAN128, GS1_MODE, "[00]395011015300000011", 0, 1, 156, 1, "GGS Figure 6.6.5-2 bottom", + "110100111001111010111011011001100110100010001100010111011000100100110011011001101110111011011001100110110011001101100110011000100100100011101101100011101011" + }, + /* 17*/ { BARCODE_EAN128, GS1_MODE, "[420]45458", 0, 1, 90, 1, "GGS Figure 6.6.5-3 top", + "110100111001111010111010110111000100100011001110101100011101100010111100100101100011101011" + }, + /* 18*/ { BARCODE_EAN128, GS1_MODE, "[02]00614141000418[15]210228[10]451214[37]20", 0, 1, 255, 1, "GGS Figure 6.6.5-4 top", + "110100111001111010111011001100110110110011001100100001011000100010110001000101101100110010010001100110011100101011100110011011100100110011001101110011010011001000100101110110001011001110010011001110111101011101000110100011001001110100011110101100011101011" + }, + /* 19*/ { BARCODE_EAN128, GS1_MODE, "[420]87109", 0, 1, 90, 1, "GGS Figure 6.6.5-5 top", + "110100111001111010111010110111000100011001001001101000011001001000111001001101100011101011" + }, + /* 20*/ { BARCODE_EAN128, GS1_MODE, "[90]1528", 0, 1, 79, 1, "GGS Figure 6.6.5-5 middle", + "1101001110011110101110110111101101011100110011100110100111001100101100011101011" + }, + /* 21*/ { BARCODE_EAN128, GS1_MODE, "[00]000521775138957172", 0, 1, 156, 1, "GGS Figure 6.6.5-5 bottom", + "110100111001111010111011011001100110110011001000100110011011100100111101110101101110100010001100010101111010001001101000010011000010110011011001100011101011" + }, + /* 22*/ { BARCODE_EAN128, GS1_MODE, "[00]395011010013000129", 0, 1, 156, 1, "GGS Figure 6.6.5-6", "110100111001111010111011011001100110100010001100010111011000100100110011011001101100110010011011100110110011001100110110011100110010111101101101100011101011" }, - /* 15*/ { BARCODE_EAN128, GS1_MODE, "[401]931234518430GR", 0, 1, 167, "GS1 General Specifications Figure 6.6.5-7 top", + /* 23*/ { BARCODE_EAN128, GS1_MODE, "[00]395011010013000129", 0, 1, 156, 1, "GGS Figure 6.6.5-6", + "110100111001111010111011011001100110100010001100010111011000100100110011011001101100110010011011100110110011001100110110011100110010111101101101100011101011" + }, + /* 24*/ { BARCODE_EAN128, GS1_MODE, "[401]931234518430GR", 0, 1, 167, 1, "GGS Figure 6.6.5-7 top", "11010011100111101011101100010100011001011100110110001101110110111010111011000110011100101011000111010111101110100111011001101000100011000101110100110111001100011101011" }, - /* 16*/ { BARCODE_EAN128, GS1_MODE, "[00]093123450000000012", 0, 1, 156, "GS1 General Specifications Figure 6.6.5-7 bottom", + /* 25*/ { BARCODE_EAN128, GS1_MODE, "[00]093123450000000012", 0, 1, 156, 1, "GGS Figure 6.6.5-7 bottom", "110100111001111010111011011001100110010010001101100011011101101110101110110001101100110011011001100110110011001101100110010110011100110111010001100011101011" }, - /* 17*/ { BARCODE_EAN128, GS1_MODE, "[01]95012345678903", 0, 1, 134, "GS1 General Specifications Figure 7.8.5.1-1 1st", + /* 26*/ { BARCODE_EAN128, GS1_MODE, "[01]95012345678903", 0, 1, 134, 1, "GGS Figure 7.8.5.1-1 1st", "11010011100111101011101100110110010111101000110011011001110110111010111011000100001011001101101111010010011000110110001101100011101011" }, - /* 18*/ { BARCODE_EAN128, GS1_MODE, "[3102]000400", 0, 1, 101, "GS1 General Specifications Figure 7.8.5.1-1 2nd", + /* 27*/ { BARCODE_EAN128, GS1_MODE, "[3102]000400", 0, 1, 101, 1, "GGS Figure 7.8.5.1-1 2nd", "11010011100111101011101101100011011001100110110110011001001000110011011001100110110111101100011101011" }, - /* 19*/ { BARCODE_EAN128, GS1_MODE, "[01]95012345678903[3102]000400", 0, 1, 189, "GS1 General Specifications Figure 7.8.5.1-2", + /* 28*/ { BARCODE_EAN128, GS1_MODE, "[01]95012345678903[3102]000400", 0, 1, 189, 1, "GGS Figure 7.8.5.1-2", "110100111001111010111011001101100101111010001100110110011101101110101110110001000010110011011011110100100110001101100011011001100110110110011001001000110011011001100100100110001100011101011" }, - /* 20*/ { BARCODE_EAN128, GS1_MODE, "[8005]000365", 0, 1, 101, "GS1 General Specifications Figure 7.8.5.2-1 1st", + /* 29*/ { BARCODE_EAN128, GS1_MODE, "[8005]000365", 0, 1, 101, 1, "GGS Figure 7.8.5.2-1 1st", "11010011100111101011101010011110010001001100110110011001001001100010010110000100100001101100011101011" }, - /* 21*/ { BARCODE_EAN128, GS1_MODE, "[10]123456", 0, 1, 90, "GS1 General Specifications Figure 7.8.5.2-1 2nd", + /* 30*/ { BARCODE_EAN128, GS1_MODE, "[10]123456", 0, 1, 90, 1, "GGS Figure 7.8.5.2-1 2nd", "110100111001111010111011001000100101100111001000101100011100010110110010000101100011101011" }, - /* 22*/ { BARCODE_EAN128, GS1_MODE, "[8005]000365[10]123456", 0, 1, 156, "GS1 General Specifications Figure 7.8.5.2-2", + /* 31*/ { BARCODE_EAN128, GS1_MODE, "[8005]000365[10]123456", 0, 1, 156, 1, "GGS Figure 7.8.5.2-2", "110100111001111010111010100111100100010011001101100110010010011000100101100001111010111011001000100101100111001000101100011100010110101100001001100011101011" }, - /* 23*/ { BARCODE_EAN128, GS1_MODE, "[403]27653113+99000900090010", 0, 1, 222, "DHL Leitcode https://www.dhl.de/de/geschaeftskunden/paket/information/geschaeftskunden/abrechnung/leitcodierung.html", + /* 32*/ { BARCODE_EAN128, GS1_MODE, "[403]27653113+99000900090010", 0, 1, 222, 1, "DHL Leitcode https://www.dhl.de/de/geschaeftskunden/paket/information/geschaeftskunden/abrechnung/leitcodierung.html", "110100111001111010111011000101000110001101101100101000011011101110110001001001011110111011001011100110001001001011101111010111011110110110011001100100100011011001100110010010001101100110011001000100110001000101100011101011" }, - /* 24*/ { BARCODE_EAN128, GS1_MODE, "[00]340433935039756615", 0, 1, 156, "DHL Identcode https://www.dhl.de/de/geschaeftskunden/paket/information/geschaeftskunden/abrechnung/leitcodierung.html", + /* 33*/ { BARCODE_EAN128, GS1_MODE, "[00]340433935039756615", 0, 1, 156, 1, "DHL Identcode https://www.dhl.de/de/geschaeftskunden/paket/information/geschaeftskunden/abrechnung/leitcodierung.html", "110100111001111010111011011001100100010110001001000110010100011000101000111101100010111011010001000110000100101001000011010111001100100111001101100011101011" }, - /* 25*/ { BARCODE_EAN14, GS1_MODE, "4070071967072", 0, 1, 134, "Verified manually against tec-it", + /* 34*/ { BARCODE_EAN14, GS1_MODE, "4070071967072", 0, 1, 134, 1, "Verified manually against tec-it", "11010011100111101011101100110110011000101000101100001001001100010011001011100100001011001001100010011001001110110111001001100011101011" }, - /* 26*/ { BARCODE_NVE18, GS1_MODE, "40700000071967072", 0, 1, 156, "Verified manually against tec-it", + /* 35*/ { BARCODE_NVE18, GS1_MODE, "40700000071967072", 0, 1, 156, 1, "Verified manually against tec-it", "110100111001111010111011011001100110001010001011000010011011001100110110011001001100010011001011100100001011001001100010011001001110110111011101100011101011" }, - /* 27*/ { BARCODE_HIBC_128, UNICODE_MODE, "83278F8G9H0J2G", 0, 1, 211, "ANSI/HIBC 2.6 - 2016 Section 4.1, not same, uses different encoding (eg begins StartA instead of StartB)", + /* 36*/ { BARCODE_HIBC_128, UNICODE_MODE, "83278F8G9H0J2G", 0, 1, 211, 1, "ANSI/HIBC 2.6 - 2016 Section 4.1, not same, uses different encoding (eg begins StartA instead of StartB)", "1101001000011000100100111010011001011101111011000110110110000101001011110111010001100010111010011001101000100011100101100110001010001001110110010110111000110011100101101000100010001001100111101010001100011101011" }, - /* 28*/ { BARCODE_HIBC_128, UNICODE_MODE, "A123BJC5D6E71", 0, 1, 200, "ANSI/HIBC 2.6 - 2016 Figure 1, same", + /* 37*/ { BARCODE_HIBC_128, UNICODE_MODE, "A123BJC5D6E71", 0, 1, 200, 1, "ANSI/HIBC 2.6 - 2016 Figure 1, same", "11010010000110001001001010001100010011100110110011100101100101110010001011000101101110001000100011011011100100101100010001100111010010001101000111011011101001110011011010001000110001101101100011101011" }, - /* 29*/ { BARCODE_HIBC_128, UNICODE_MODE, "$$52001510X3G", 0, 1, 178, "ANSI/HIBC 2.6 - 2016 Figure 5, same", + /* 38*/ { BARCODE_HIBC_128, UNICODE_MODE, "$$52001510X3G", 0, 1, 178, 1, "ANSI/HIBC 2.6 - 2016 Figure 5, same", "1101001000011000100100100100011001001000110010111011110110111000101101100110010111001100110010001001011110111011100010110110010111001101000100010110001000100011110101100011101011" }, }; @@ -558,9 +586,9 @@ static void test_encode(int index, int generate, int debug) { assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); if (generate) { - printf(" /*%3d*/ { %s, %s, \"%s\", %s, %d, %d, \"%s\",\n", + printf(" /*%3d*/ { %s, %s, \"%s\", %s, %d, %d, %d, \"%s\",\n", i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), - testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment); + testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment); testUtilModulesDump(symbol, " ", "\n"); printf(" },\n"); } else { @@ -575,12 +603,16 @@ static void test_encode(int index, int generate, int debug) { } if (do_bwipp && testUtilCanBwipp(symbol->symbology, -1, -1, -1, debug)) { - ret = testUtilBwipp(symbol, -1, -1, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf)); - assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), ret); + if (!data[i].bwipp_cmp) { + if (debug & ZINT_DEBUG_TEST_PRINT) printf("%d: %s not BWIPP compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment); + } else { + ret = testUtilBwipp(symbol, -1, -1, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf)); + assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), ret); - ret = testUtilBwippCmp(symbol, bwipp_msg, bwipp_buf, data[i].expected); - assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n", - i, testUtilBarcodeName(data[i].symbology), ret, bwipp_msg, bwipp_buf, data[i].expected); + ret = testUtilBwippCmp(symbol, bwipp_msg, bwipp_buf, data[i].expected); + assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n", + i, testUtilBarcodeName(data[i].symbology), ret, bwipp_msg, bwipp_buf, data[i].expected); + } } } } diff --git a/backend/tests/test_composite.c b/backend/tests/test_composite.c index c98eec27..1a9d7813 100644 --- a/backend/tests/test_composite.c +++ b/backend/tests/test_composite.c @@ -55,22 +55,22 @@ static void test_eanx_leading_zeroes(int index, int debug) { /* 5*/ { BARCODE_EANX_CC, "123456", "[21]A12345678", 0, 8, 72 }, /* 6*/ { BARCODE_EANX_CC, "1234567", "[21]A12345678", 0, 8, 72 }, /* 7*/ { BARCODE_EANX_CC, "12345678", "[21]A12345678", 0, 7, 99 }, // EAN-13 - /* 8*/ { BARCODE_EANX_CC, "1+12", "[21]A12345678", 0, 8, 101 }, // EAN-8 + EAN-2 - /* 9*/ { BARCODE_EANX_CC, "12+12", "[21]A12345678", 0, 8, 101 }, - /*10*/ { BARCODE_EANX_CC, "123+12", "[21]A12345678", 0, 8, 101 }, - /*11*/ { BARCODE_EANX_CC, "1234+12", "[21]A12345678", 0, 8, 101 }, - /*12*/ { BARCODE_EANX_CC, "12345+12", "[21]A12345678", 0, 8, 101 }, - /*13*/ { BARCODE_EANX_CC, "123456+12", "[21]A12345678", 0, 8, 101 }, - /*14*/ { BARCODE_EANX_CC, "1234567+12", "[21]A12345678", 0, 8, 101 }, - /*15*/ { BARCODE_EANX_CC, "12345678+12", "[21]A12345678", 0, 7, 128 }, // EAN-13 + EAN-2 - /*16*/ { BARCODE_EANX_CC, "1+123", "[21]A12345678", 0, 8, 128 }, // EAN-8 + EAN-5 - /*17*/ { BARCODE_EANX_CC, "12+123", "[21]A12345678", 0, 8, 128 }, - /*18*/ { BARCODE_EANX_CC, "123+123", "[21]A12345678", 0, 8, 128 }, - /*19*/ { BARCODE_EANX_CC, "1234+123", "[21]A12345678", 0, 8, 128 }, - /*20*/ { BARCODE_EANX_CC, "12345+123", "[21]A12345678", 0, 8, 128 }, - /*21*/ { BARCODE_EANX_CC, "123456+123", "[21]A12345678", 0, 8, 128 }, - /*22*/ { BARCODE_EANX_CC, "1234567+123", "[21]A12345678", 0, 8, 128 }, - /*23*/ { BARCODE_EANX_CC, "12345678+123", "[21]A12345678", 0, 7, 155 }, // EAN-13 + EAN-5 + /* 8*/ { BARCODE_EANX_CC, "1+12", "[21]A12345678", 0, 8, 99 }, // EAN-8 + EAN-2 + /* 9*/ { BARCODE_EANX_CC, "12+12", "[21]A12345678", 0, 8, 99 }, + /*10*/ { BARCODE_EANX_CC, "123+12", "[21]A12345678", 0, 8, 99 }, + /*11*/ { BARCODE_EANX_CC, "1234+12", "[21]A12345678", 0, 8, 99 }, + /*12*/ { BARCODE_EANX_CC, "12345+12", "[21]A12345678", 0, 8, 99 }, + /*13*/ { BARCODE_EANX_CC, "123456+12", "[21]A12345678", 0, 8, 99 }, + /*14*/ { BARCODE_EANX_CC, "1234567+12", "[21]A12345678", 0, 8, 99 }, + /*15*/ { BARCODE_EANX_CC, "12345678+12", "[21]A12345678", 0, 7, 126 }, // EAN-13 + EAN-2 + /*16*/ { BARCODE_EANX_CC, "1+123", "[21]A12345678", 0, 8, 126 }, // EAN-8 + EAN-5 + /*17*/ { BARCODE_EANX_CC, "12+123", "[21]A12345678", 0, 8, 126 }, + /*18*/ { BARCODE_EANX_CC, "123+123", "[21]A12345678", 0, 8, 126 }, + /*19*/ { BARCODE_EANX_CC, "1234+123", "[21]A12345678", 0, 8, 126 }, + /*20*/ { BARCODE_EANX_CC, "12345+123", "[21]A12345678", 0, 8, 126 }, + /*21*/ { BARCODE_EANX_CC, "123456+123", "[21]A12345678", 0, 8, 126 }, + /*22*/ { BARCODE_EANX_CC, "1234567+123", "[21]A12345678", 0, 8, 126 }, + /*23*/ { BARCODE_EANX_CC, "12345678+123", "[21]A12345678", 0, 7, 153 }, // EAN-13 + EAN-5 }; int data_size = sizeof(data) / sizeof(struct item); @@ -1129,6 +1129,93 @@ static void test_examples(int index, int generate, int debug) { "000000000101100011000010100010011001001101001100011011101001110001110100100111101011001000010010100110001100100111001010000100010111001000100111000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" "000000011010011100111101011101100110110010110011100100010110001110001011011000010100110111101101011001110011011000110101111011101000110111011000111010110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" }, + /*56*/ { BARCODE_EANX_CC, 1, "123456789012+12", "[91]123456789012345678901", 0, 8, 126, "Example of EAN-13 with 2-digit addon, CC-A 4 cols, 4 rows", + "110100100011110011010011100101110111000100001001000110101110111001000001100000100110111011101100101000000000000000000000000000" + "110101100011101011001000000110011110101111101001000010110010111101100001100100111000001011001100101000000000000000000000000000" + "110101110011101011111010000111111001101110101011000010111110101111001101001101001110000011011100101000000000000000000000000000" + "110101111010001100110000100100001011100011101011100010100011100111000101101000100011000011011110101000000000000000000000000000" + "000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000" + "001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000" + "000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000" + "000101001001101111010011101011000100001010010001010101001000111010011100101100110110110010010001010000000101100110010100100110" + }, + /*57*/ { BARCODE_EANX_CC, 1, "123456789012+54321", "[91]1234567890", 0, 7, 153, "Example of EAN-13 with 5-digit addon, CC-B 4 cols, 3 rows", + "110110111011110011010011100101110111000100001001110100101110111001000001100000100110111011011000101000000000000000000000000000000000000000000000000000000" + "110110110011111101010011100111110001001001101001100100110100011100010001001011111100111011001000101000000000000000000000000000000000000000000000000000000" + "110110100010100000101111000111001111001011101001100110110011111010010001001111101101000011101000101000000000000000000000000000000000000000000000000000000" + "000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000" + "001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000" + "000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000" + "000101001001101111010011101011000100001010010001010101001000111010011100101100110110110010010001010000000101101110010101000110101000010100100110100110010" + }, + /*58*/ { BARCODE_UPCA_CC, 1, "12345678901+12", "[91]123456789", 0, 7, 128, "Example of UPC-A with 2-digit addon, CC-A 4 cols, 3 rows", + "11011011101111001101001110010111011100010000100111010010111011100100000110000010011011101101100010100000000000000000000000000000" + "11011011001110011100111101011000010001110010100110010011101011001000000100101111110011101100100010100000000000000000000000000000" + "11011010001000011110010001010111101000000100100110011010001110000101100110111000100011101110100010100000000000000000000000000000" + "00010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000" + "00100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000" + "00010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000" + "00010100110010010011011110101000110110001010111101010100010010010001110100111001011001101101100101000000000101100110010100100110" + }, + /*59*/ { BARCODE_UPCA_CC, 2, "12345678901+12121", "[91]1234567890123", 0, 8, 155, "Example of UPC-A with 5-digit addon, CC-B 4 cols, 4 rows", + "11010011101000111110100111011011111101011100100111011011010000111101100110010111000010001101001000100000000000000000000000000000000000000000000000000000000" + "11010011001011001001110000010111110110000010100111010011011111100110100111010011111001001101011000100000000000000000000000000000000000000000000000000000000" + "11010001001110011010000110011001000001011000100110010010011110111101000111000111010001001101011100100000000000000000000000000000000000000000000000000000000" + "11010001101100010111000001011101101110010000100110011011111000101011000111100010010100001101011110100000000000000000000000000000000000000000000000000000000" + "00010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000" + "00100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000" + "00010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000" + "00010100110010010011011110101000110110001010111101010100010010010001110100111001011001101101100101000000000101100110010100100110101100110100110110100110010" + }, + /*60*/ { BARCODE_UPCE_CC, 1, "0654321+89", "[91]1", 0, 9, 82, "Example of UPC-E with 2-digit addon, CC-A 2 cols, 5 rows", + "1101100110111101110101111101010001000111100011110101001000000000000000000000000000" + "1101101110111011000010001101110010101110000011100101001000000000000000000000000000" + "1101101100110001011111011101111010000100100011101101001000000000000000000000000000" + "1101101000100111011100111101110011110101110011101001001000000000000000000000000000" + "1101001000110011001000000101110100011011110011101001101000000000000000000000000000" + "0001000000000000000000000000000000000000000000000000010000000000000000000000000000" + "0010000000000000000000000000000000000000000000000000001000000000000000000000000000" + "0001000000000000000000000000000000000000000000000000010000000000000000000000000000" + "0001010000101011000100111010111101001101100110010101010000000101101101110100101110" + }, + /*61*/ { BARCODE_UPCE_CC, 2, "1876543+56789", "[91]12345", 0, 12, 109, "Example of UPC-E with 5-digit addon, CC-B 2 cols, 8 rows", + "1100100010111011111011101001000001000010001011001000101000000000000000000000000000000000000000000000000000000" + "1110100010110100001111011001100101110000100011101000101000000000000000000000000000000000000000000000000000000" + "1110110010111011001001111101000111100100001011101100101000000000000000000000000000000000000000000000000000000" + "1100110010110011101100010001010111110111110011001100101000000000000000000000000000000000000000000000000000000" + "1101110010111110010011011101001111110100110011011100101000000000000000000000000000000000000000000000000000000" + "1101111010110011100001011101001101000011100011011110101000000000000000000000000000000000000000000000000000000" + "1100111010101000100000100001011110111110110011001110101000000000000000000000000000000000000000000000000000000" + "1110111010101111001011110001011110001001111011101110101000000000000000000000000000000000000000000000000000000" + "0001000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000" + "0010000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000" + "0001000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000" + "0001010110111001000100001010110001010001101000010101010000000101101100010101011110100100010101101110100101110" + }, + /*62*/ { BARCODE_EANX_CC, 1, "9876543+65", "[91]1234567", 0, 8, 99, "Example of EAN-8 with 2-digit addon, CC-A 3 cols, 4 rows", + "100100011111001101010011000111000101110011001100010111010000011101001101000000000000000000000000000" + "110111111001101001010111000110111100101100001111000100111101011101011101000000000000000000000000000" + "100001011000001101010110000101011111011111001110100100001110011101011001000000000000000000000000000" + "111100100011001101010010000110010011111011101010011111000110011101010001000000000000000000000000000" + "000010000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000" + "000100000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000" + "000010000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000" + "000010100010110110111011101101011110101010011101011100100001011100101010000000101101011110101110010" + }, + /*63*/ { BARCODE_EANX_CC, 2, "9876543+74083", "[91]123456789012345678", 0, 12, 136, "Example of EAN-8 with 5-digit addon, CC-B 3 cols, 8 rows", + "1100111010111011111011101001000010110100000100001000101111101101001111011001110101000000000000000000000000000000000000000000000000000000" + "1110111010110010111000010001000010010111001011001000001110001101110100011101110101000000000000000000000000000000000000000000000000000000" + "1110011010110111111001101001000011010101000101111000001100100110111111011100110101000000000000000000000000000000000000000000000000000000" + "1111011010111011010000110001000111010110000110110011001110011010011000011110110101000000000000000000000000000000000000000000000000000000" + "1111001010111011011100100001000110010111011101111001001010011110000100011110010101000000000000000000000000000000000000000000000000000000" + "1110001010111111010110001001000100010111001011111101101001111000011011011100010101000000000000000000000000000000000000000000000000000000" + "1100001010111100100010111101001100010111001111001100101001110001110010011000010101000000000000000000000000000000000000000000000000000000" + "1100011010110011001111010001001110010111110111101110101011100111111001011000110101000000000000000000000000000000000000000000000000000000" + "0000000000000010000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000" + "0000000000000100000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000" + "0000000000000010000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000" + "0000000000000010100010110110111011101101011110101010011101011100100001011100101010000000101101110110100111010100011010101101110101000010" + }, }; int data_size = sizeof(data) / sizeof(struct item); @@ -1469,7 +1556,7 @@ static void test_ean128_cc_shift(int index, int generate, int debug) { if (do_bwipp && testUtilCanBwipp(symbol->symbology, data[i].option_1, -1, -1, debug)) { if (!data[i].bwipp_cmp) { - if (debug & ZINT_DEBUG_TEST_PRINT) printf("%d: %s skipped, not BWIPP compatible\n", i, testUtilBarcodeName(symbol->symbology)); + if (debug & ZINT_DEBUG_TEST_PRINT) printf("%d: %s not BWIPP compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment); } else { ret = testUtilBwipp(symbol, data[i].option_1, -1, -1, data[i].composite, composite_length, symbol->primary, bwipp_buf, sizeof(bwipp_buf)); assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), ret); diff --git a/backend/tests/test_png.c b/backend/tests/test_png.c index d54fcf8a..8c66b4bd 100644 --- a/backend/tests/test_png.c +++ b/backend/tests/test_png.c @@ -125,6 +125,16 @@ static void test_print(int index, int generate, int debug) { }; struct item data[] = { /* 0*/ { BARCODE_CODABLOCKF, 3, -1, "AAAAAAAAA", "../data/png/codablockf_3rows.png" }, + /* 1*/ { BARCODE_EANX, -1, -1, "9771384524017+12", "../data/png/ean13_2addon_ggs_5.2.2.5.1-2.png" }, + /* 2*/ { BARCODE_EANX, -1, -1, "9780877799306+54321", "../data/png/ean13_5addon_ggs_5.2.2.5.2-2.png" }, + /* 3*/ { BARCODE_UPCA, -1, -1, "012345678905+24", "../data/png/upca_2addon_ggs_5.2.6.6-5.png" }, + /* 4*/ { BARCODE_UPCA, -1, -1, "614141234417+12345", "../data/png/upca_5addon.png" }, + /* 5*/ { BARCODE_UPCE, -1, -1, "1234567+12", "../data/png/upce_2addon.png" }, + /* 6*/ { BARCODE_UPCE, -1, -1, "1234567+12345", "../data/png/upce_5addon.png" }, + /* 7*/ { BARCODE_EANX, -1, -1, "1234567+12", "../data/png/ean8_2addon.png" }, + /* 8*/ { BARCODE_EANX, -1, -1, "1234567+12345", "../data/png/ean8_5addon.png" }, + /* 9*/ { BARCODE_EANX, -1, -1, "12345", "../data/png/ean5.png" }, + /* 10*/ { BARCODE_EANX, -1, -1, "12", "../data/png/ean2.png" }, }; int data_size = ARRAY_SIZE(data); diff --git a/backend/tests/test_raster.c b/backend/tests/test_raster.c index 1d8b9a91..113b10db 100644 --- a/backend/tests/test_raster.c +++ b/backend/tests/test_raster.c @@ -124,111 +124,122 @@ static void test_buffer(int index, int generate, int debug) { /* 5*/ { BARCODE_C25IND, "0000000000", "", 50, 1, 159, 318, 118 }, /* 6*/ { BARCODE_CODE39, "0000000000", "", 50, 1, 155, 310, 118 }, /* 7*/ { BARCODE_EXCODE39, "0000000000", "", 50, 1, 155, 310, 118 }, - /* 8*/ { BARCODE_EANX, "123456789012", "", 50, 1, 95, 230, 118 }, - /* 9*/ { BARCODE_EANX_CHK, "1234567890128", "", 50, 1, 95, 230, 118 }, - /* 10*/ { BARCODE_EANX, "123456789012+12", "", 50, 1, 124, 288, 118 }, - /* 11*/ { BARCODE_EANX, "123456789012+12345", "", 50, 1, 151, 342, 118 }, - /* 12*/ { BARCODE_EANX, "1234567", "", 50, 1, 67, 134, 118 }, - /* 13*/ { BARCODE_EANX, "1234567+12", "", 50, 1, 96, 192, 118 }, - /* 14*/ { BARCODE_EANX, "1234567+12345", "", 50, 1, 123, 246, 118 }, - /* 15*/ { BARCODE_EANX, "1234", "", 50, 1, 47, 94, 118 }, - /* 16*/ { BARCODE_EANX, "12", "", 50, 1, 20, 40, 118 }, - /* 17*/ { BARCODE_EAN128, "[01]12345678901234", "", 50, 1, 134, 268, 118 }, - /* 18*/ { BARCODE_CODABAR, "A00000000B", "", 50, 1, 102, 204, 118 }, - /* 19*/ { BARCODE_CODE128, "0000000000", "", 50, 1, 90, 180, 118 }, - /* 20*/ { BARCODE_DPLEIT, "1234567890123", "", 50, 1, 135, 270, 118 }, - /* 21*/ { BARCODE_DPIDENT, "12345678901", "", 50, 1, 117, 234, 118 }, - /* 22*/ { BARCODE_CODE16K, "0000000000", "", 20, 2, 70, 162, 44 }, - /* 23*/ { BARCODE_CODE49, "0000000000", "", 20, 2, 70, 162, 44 }, - /* 24*/ { BARCODE_CODE93, "0000000000", "", 50, 1, 127, 254, 118 }, - /* 25*/ { BARCODE_FLAT, "1234567890", "", 50, 1, 90, 180, 100 }, - /* 26*/ { BARCODE_RSS14, "1234567890123", "", 50, 1, 96, 192, 118 }, - /* 27*/ { BARCODE_RSS_LTD, "1234567890123", "", 50, 1, 74, 148, 118 }, - /* 28*/ { BARCODE_RSS_EXP, "[01]12345678901234", "", 34, 1, 134, 268, 86 }, - /* 29*/ { BARCODE_TELEPEN, "0000000000", "", 50, 1, 208, 416, 118 }, - /* 30*/ { BARCODE_UPCA, "12345678904", "", 50, 1, 95, 230, 118 }, - /* 31*/ { BARCODE_UPCA_CHK, "12345678905", "", 50, 1, 95, 230, 118 }, - /* 32*/ { BARCODE_UPCA, "12345678904+12", "", 50, 1, 124, 288, 118 }, - /* 33*/ { BARCODE_UPCA, "12345678904+12345", "", 50, 1, 151, 342, 118 }, - /* 34*/ { BARCODE_UPCE, "1234567", "", 50, 1, 51, 142, 118 }, - /* 35*/ { BARCODE_UPCE_CHK, "12345670", "", 50, 1, 51, 142, 118 }, - /* 36*/ { BARCODE_UPCE, "1234567+12", "", 50, 1, 80, 200, 118 }, - /* 37*/ { BARCODE_UPCE, "1234567+12345", "", 50, 1, 107, 254, 118 }, - /* 38*/ { BARCODE_POSTNET, "00000000000", "", 12, 2, 185, 370, 24 }, - /* 39*/ { BARCODE_MSI_PLESSEY, "0000000000", "", 50, 1, 127, 254, 118 }, - /* 40*/ { BARCODE_FIM, "A", "", 50, 1, 17, 34, 100 }, - /* 41*/ { BARCODE_LOGMARS, "0000000000", "", 50, 1, 191, 382, 118 }, - /* 42*/ { BARCODE_PHARMA, "123456", "", 50, 1, 58, 116, 100 }, - /* 43*/ { BARCODE_PZN, "123456", "", 50, 1, 142, 284, 118 }, - /* 44*/ { BARCODE_PHARMA_TWO, "12345678", "", 10, 2, 29, 58, 20 }, - /* 45*/ { BARCODE_PDF417, "0000000000", "", 21, 7, 103, 206, 42 }, - /* 46*/ { BARCODE_PDF417TRUNC, "0000000000", "", 21, 7, 68, 136, 42 }, - /* 47*/ { BARCODE_MAXICODE, "0000000000", "", 165, 33, 30, 300, 300 }, - /* 48*/ { BARCODE_QRCODE, "1234567890AB", "", 21, 21, 21, 42, 42 }, - /* 49*/ { BARCODE_CODE128B, "0000000000", "", 50, 1, 145, 290, 118 }, - /* 50*/ { BARCODE_AUSPOST, "12345678901234567890123", "", 8, 3, 133, 266, 16 }, - /* 51*/ { BARCODE_AUSREPLY, "12345678", "", 8, 3, 73, 146, 16 }, - /* 52*/ { BARCODE_AUSROUTE, "12345678", "", 8, 3, 73, 146, 16 }, - /* 53*/ { BARCODE_AUSREDIRECT, "12345678", "", 8, 3, 73, 146, 16 }, - /* 54*/ { BARCODE_ISBNX, "123456789", "", 50, 1, 95, 230, 118 }, - /* 55*/ { BARCODE_ISBNX, "123456789+12", "", 50, 1, 124, 288, 118 }, - /* 56*/ { BARCODE_ISBNX, "123456789+12345", "", 50, 1, 151, 342, 118 }, - /* 57*/ { BARCODE_RM4SCC, "0000000000", "", 8, 3, 91, 182, 16 }, - /* 58*/ { BARCODE_DATAMATRIX, "ABC", "", 10, 10, 10, 20, 20 }, - /* 59*/ { BARCODE_EAN14, "1234567890123", "", 50, 1, 134, 268, 118 }, - /* 60*/ { BARCODE_VIN, "00000000000000000", "", 50, 1, 246, 492, 118 }, - /* 61*/ { BARCODE_CODABLOCKF, "0000000000", "", 20, 2, 101, 242, 44 }, - /* 62*/ { BARCODE_NVE18, "12345678901234567", "", 50, 1, 156, 312, 118 }, - /* 63*/ { BARCODE_JAPANPOST, "0000000000", "", 8, 3, 133, 266, 16 }, - /* 64*/ { BARCODE_KOREAPOST, "123456", "", 50, 1, 167, 334, 118 }, - /* 65*/ { BARCODE_RSS14STACK, "0000000000000", "", 13, 3, 50, 100, 26 }, - /* 66*/ { BARCODE_RSS14STACK_OMNI, "0000000000000", "", 69, 5, 50, 100, 138 }, - /* 67*/ { BARCODE_RSS_EXPSTACK, "[01]12345678901234", "", 71, 5, 102, 204, 142 }, - /* 68*/ { BARCODE_PLANET, "00000000000", "", 12, 2, 185, 370, 24 }, - /* 69*/ { BARCODE_MICROPDF417, "0000000000", "", 12, 6, 82, 164, 24 }, - /* 70*/ { BARCODE_ONECODE, "12345678901234567890", "", 8, 3, 129, 258, 16 }, - /* 71*/ { BARCODE_PLESSEY, "0000000000", "", 50, 1, 227, 454, 118 }, - /* 72*/ { BARCODE_TELEPEN_NUM, "0000000000", "", 50, 1, 128, 256, 118 }, - /* 73*/ { BARCODE_ITF14, "0000000000", "", 50, 1, 135, 382, 150 }, - /* 74*/ { BARCODE_KIX, "123456ABCDE", "", 8, 3, 87, 174, 16 }, - /* 75*/ { BARCODE_AZTEC, "1234567890AB", "", 15, 15, 15, 30, 30 }, - /* 76*/ { BARCODE_DAFT, "DAFTDAFTDAFTDAFT", "", 8, 3, 31, 62, 16 }, - /* 77*/ { BARCODE_MICROQR, "12345", "", 11, 11, 11, 22, 22 }, - /* 78*/ { BARCODE_HIBC_128, "0000000000", "", 50, 1, 134, 268, 118 }, - /* 79*/ { BARCODE_HIBC_39, "0000000000", "", 50, 1, 223, 446, 118 }, - /* 80*/ { BARCODE_HIBC_DM, "ABC", "", 12, 12, 12, 24, 24 }, - /* 81*/ { BARCODE_HIBC_QR, "1234567890AB", "", 21, 21, 21, 42, 42 }, - /* 82*/ { BARCODE_HIBC_PDF, "0000000000", "", 27, 9, 103, 206, 54 }, - /* 83*/ { BARCODE_HIBC_MICPDF, "0000000000", "", 34, 17, 38, 76, 68 }, - /* 84*/ { BARCODE_HIBC_BLOCKF, "0000000000", "", 30, 3, 101, 242, 64 }, - /* 85*/ { BARCODE_HIBC_AZTEC, "1234567890AB", "", 19, 19, 19, 38, 38 }, - /* 86*/ { BARCODE_DOTCODE, "ABC", "", 11, 11, 16, 33, 23 }, - /* 87*/ { BARCODE_HANXIN, "1234567890AB", "", 23, 23, 23, 46, 46 }, - /* 88*/ { BARCODE_MAILMARK, "01000000000000000AA00AA0A", "", 10, 3, 155, 310, 20 }, - /* 89*/ { BARCODE_AZRUNE, "255", "", 11, 11, 11, 22, 22 }, - /* 90*/ { BARCODE_CODE32, "12345678", "", 50, 1, 103, 206, 118 }, - /* 91*/ { BARCODE_EANX_CC, "123456789012", "[20]01", 50, 7, 99, 238, 118 }, - /* 92*/ { BARCODE_EANX_CC, "123456789012+12", "[20]01", 50, 7, 128, 296, 118 }, - /* 93*/ { BARCODE_EANX_CC, "123456789012+12345", "[20]01", 50, 7, 155, 350, 118 }, - /* 94*/ { BARCODE_EAN128_CC, "[01]12345678901234", "[20]01", 50, 5, 145, 290, 118 }, - /* 95*/ { BARCODE_RSS14_CC, "1234567890123", "[20]01", 21, 5, 100, 200, 60 }, - /* 96*/ { BARCODE_RSS_LTD_CC, "1234567890123", "[20]01", 19, 6, 74, 148, 56 }, - /* 97*/ { BARCODE_RSS_EXP_CC, "[01]12345678901234", "[20]01", 41, 5, 134, 268, 100 }, - /* 98*/ { BARCODE_UPCA_CC, "12345678901", "[20]01", 50, 7, 99, 238, 118 }, - /* 99*/ { BARCODE_UPCA_CC, "12345678901+12", "[20]01", 50, 7, 128, 296, 118 }, - /*100*/ { BARCODE_UPCA_CC, "12345678901+12345", "[20]01", 50, 7, 155, 350, 118 }, - /*101*/ { BARCODE_UPCE_CC, "1234567", "[20]01", 50, 9, 55, 150, 118 }, - /*102*/ { BARCODE_UPCE_CC, "1234567+12", "[20]01", 50, 9, 84, 208, 118 }, - /*103*/ { BARCODE_UPCE_CC, "1234567+12345", "[20]01", 50, 9, 111, 262, 118 }, - /*104*/ { BARCODE_RSS14STACK_CC, "0000000000000", "[20]01", 24, 9, 56, 112, 48 }, - /*105*/ { BARCODE_RSS14_OMNI_CC, "0000000000000", "[20]01", 80, 11, 56, 112, 160 }, - /*106*/ { BARCODE_RSS_EXPSTACK_CC, "[01]12345678901234", "[20]01", 78, 9, 102, 204, 156 }, - /*107*/ { BARCODE_CHANNEL, "00", "", 50, 1, 19, 38, 118 }, - /*108*/ { BARCODE_CODEONE, "12345678901234567890", "", 22, 22, 22, 44, 44 }, - /*109*/ { BARCODE_GRIDMATRIX, "ABC", "", 18, 18, 18, 36, 36 }, - /*110*/ { BARCODE_UPNQR, "1234567890AB", "", 77, 77, 77, 154, 154 }, - /*111*/ { BARCODE_ULTRA, "0000000000", "", 13, 13, 18, 36, 26 }, - /*112*/ { BARCODE_RMQR, "12345", "", 11, 11, 27, 54, 22 }, + /* 8*/ { BARCODE_EANX, "123456789012", "", 50, 1, 95, 226, 118 }, + /* 9*/ { BARCODE_EANX_CHK, "1234567890128", "", 50, 1, 95, 226, 118 }, + /* 10*/ { BARCODE_EANX, "123456789012+12", "", 50, 1, 122, 276, 118 }, + /* 11*/ { BARCODE_EANX_CHK, "1234567890128+12", "", 50, 1, 122, 276, 118 }, + /* 12*/ { BARCODE_EANX, "123456789012+12345", "", 50, 1, 149, 330, 118 }, + /* 13*/ { BARCODE_EANX_CHK, "1234567890128+12345", "", 50, 1, 149, 330, 118 }, + /* 14*/ { BARCODE_EANX, "1234567", "", 50, 1, 67, 162, 118 }, + /* 15*/ { BARCODE_EANX_CHK, "12345670", "", 50, 1, 67, 162, 118 }, + /* 16*/ { BARCODE_EANX, "1234567+12", "", 50, 1, 94, 216, 118 }, + /* 17*/ { BARCODE_EANX_CHK, "12345670+12", "", 50, 1, 94, 216, 118 }, + /* 18*/ { BARCODE_EANX, "1234567+12345", "", 50, 1, 121, 270, 118 }, + /* 19*/ { BARCODE_EANX_CHK, "12345670+12345", "", 50, 1, 121, 270, 118 }, + /* 20*/ { BARCODE_EANX, "1234", "", 50, 1, 47, 118, 118 }, + /* 21*/ { BARCODE_EANX_CHK, "1234", "", 50, 1, 47, 118, 118 }, + /* 22*/ { BARCODE_EANX, "12", "", 50, 1, 20, 64, 118 }, + /* 23*/ { BARCODE_EANX_CHK, "12", "", 50, 1, 20, 64, 118 }, + /* 24*/ { BARCODE_EAN128, "[01]12345678901234", "", 50, 1, 134, 268, 118 }, + /* 25*/ { BARCODE_CODABAR, "A00000000B", "", 50, 1, 102, 204, 118 }, + /* 26*/ { BARCODE_CODE128, "0000000000", "", 50, 1, 90, 180, 118 }, + /* 27*/ { BARCODE_DPLEIT, "1234567890123", "", 50, 1, 135, 270, 118 }, + /* 28*/ { BARCODE_DPIDENT, "12345678901", "", 50, 1, 117, 234, 118 }, + /* 29*/ { BARCODE_CODE16K, "0000000000", "", 20, 2, 70, 162, 44 }, + /* 30*/ { BARCODE_CODE49, "0000000000", "", 20, 2, 70, 162, 44 }, + /* 31*/ { BARCODE_CODE93, "0000000000", "", 50, 1, 127, 254, 118 }, + /* 32*/ { BARCODE_FLAT, "1234567890", "", 50, 1, 90, 180, 100 }, + /* 33*/ { BARCODE_RSS14, "1234567890123", "", 50, 1, 96, 192, 118 }, + /* 34*/ { BARCODE_RSS_LTD, "1234567890123", "", 50, 1, 74, 148, 118 }, + /* 35*/ { BARCODE_RSS_EXP, "[01]12345678901234", "", 34, 1, 134, 268, 86 }, + /* 36*/ { BARCODE_TELEPEN, "0000000000", "", 50, 1, 208, 416, 118 }, + /* 37*/ { BARCODE_UPCA, "12345678904", "", 50, 1, 95, 226, 118 }, + /* 38*/ { BARCODE_UPCA_CHK, "123456789043", "", 50, 1, 95, 226, 118 }, + /* 39*/ { BARCODE_UPCA, "12345678904+12", "", 50, 1, 124, 276, 118 }, + /* 40*/ { BARCODE_UPCA_CHK, "123456789043+12", "", 50, 1, 124, 276, 118 }, + /* 41*/ { BARCODE_UPCA, "12345678904+12345", "", 50, 1, 151, 330, 118 }, + /* 42*/ { BARCODE_UPCA_CHK, "123456789043+12345", "", 50, 1, 151, 330, 118 }, + /* 43*/ { BARCODE_UPCE, "1234567", "", 50, 1, 51, 134, 118 }, + /* 44*/ { BARCODE_UPCE_CHK, "12345670", "", 50, 1, 51, 134, 118 }, + /* 45*/ { BARCODE_UPCE, "1234567+12", "", 50, 1, 78, 184, 118 }, + /* 46*/ { BARCODE_UPCE_CHK, "12345670+12", "", 50, 1, 78, 184, 118 }, + /* 47*/ { BARCODE_UPCE, "1234567+12345", "", 50, 1, 105, 238, 118 }, + /* 48*/ { BARCODE_UPCE_CHK, "12345670+12345", "", 50, 1, 105, 238, 118 }, + /* 49*/ { BARCODE_POSTNET, "00000000000", "", 12, 2, 185, 370, 24 }, + /* 50*/ { BARCODE_MSI_PLESSEY, "0000000000", "", 50, 1, 127, 254, 118 }, + /* 51*/ { BARCODE_FIM, "A", "", 50, 1, 17, 34, 100 }, + /* 52*/ { BARCODE_LOGMARS, "0000000000", "", 50, 1, 191, 382, 118 }, + /* 53*/ { BARCODE_PHARMA, "123456", "", 50, 1, 58, 116, 100 }, + /* 54*/ { BARCODE_PZN, "123456", "", 50, 1, 142, 284, 118 }, + /* 55*/ { BARCODE_PHARMA_TWO, "12345678", "", 10, 2, 29, 58, 20 }, + /* 56*/ { BARCODE_PDF417, "0000000000", "", 21, 7, 103, 206, 42 }, + /* 57*/ { BARCODE_PDF417TRUNC, "0000000000", "", 21, 7, 68, 136, 42 }, + /* 58*/ { BARCODE_MAXICODE, "0000000000", "", 165, 33, 30, 300, 300 }, // Differs from vector + /* 59*/ { BARCODE_QRCODE, "1234567890AB", "", 21, 21, 21, 42, 42 }, + /* 60*/ { BARCODE_CODE128B, "0000000000", "", 50, 1, 145, 290, 118 }, + /* 61*/ { BARCODE_AUSPOST, "12345678901234567890123", "", 8, 3, 133, 266, 16 }, + /* 62*/ { BARCODE_AUSREPLY, "12345678", "", 8, 3, 73, 146, 16 }, + /* 63*/ { BARCODE_AUSROUTE, "12345678", "", 8, 3, 73, 146, 16 }, + /* 64*/ { BARCODE_AUSREDIRECT, "12345678", "", 8, 3, 73, 146, 16 }, + /* 65*/ { BARCODE_ISBNX, "123456789", "", 50, 1, 95, 226, 118 }, + /* 66*/ { BARCODE_ISBNX, "123456789+12", "", 50, 1, 122, 276, 118 }, + /* 67*/ { BARCODE_ISBNX, "123456789+12345", "", 50, 1, 149, 330, 118 }, + /* 68*/ { BARCODE_RM4SCC, "0000000000", "", 8, 3, 91, 182, 16 }, + /* 69*/ { BARCODE_DATAMATRIX, "ABC", "", 10, 10, 10, 20, 20 }, + /* 70*/ { BARCODE_EAN14, "1234567890123", "", 50, 1, 134, 268, 118 }, + /* 71*/ { BARCODE_VIN, "00000000000000000", "", 50, 1, 246, 492, 118 }, + /* 72*/ { BARCODE_CODABLOCKF, "0000000000", "", 20, 2, 101, 242, 44 }, + /* 73*/ { BARCODE_NVE18, "12345678901234567", "", 50, 1, 156, 312, 118 }, + /* 74*/ { BARCODE_JAPANPOST, "0000000000", "", 8, 3, 133, 266, 16 }, + /* 75*/ { BARCODE_KOREAPOST, "123456", "", 50, 1, 167, 334, 118 }, + /* 76*/ { BARCODE_RSS14STACK, "0000000000000", "", 13, 3, 50, 100, 26 }, + /* 77*/ { BARCODE_RSS14STACK_OMNI, "0000000000000", "", 69, 5, 50, 100, 138 }, + /* 78*/ { BARCODE_RSS_EXPSTACK, "[01]12345678901234", "", 71, 5, 102, 204, 142 }, + /* 79*/ { BARCODE_PLANET, "00000000000", "", 12, 2, 185, 370, 24 }, + /* 80*/ { BARCODE_MICROPDF417, "0000000000", "", 12, 6, 82, 164, 24 }, + /* 81*/ { BARCODE_ONECODE, "12345678901234567890", "", 8, 3, 129, 258, 16 }, + /* 82*/ { BARCODE_PLESSEY, "0000000000", "", 50, 1, 227, 454, 118 }, + /* 83*/ { BARCODE_TELEPEN_NUM, "0000000000", "", 50, 1, 128, 256, 118 }, + /* 84*/ { BARCODE_ITF14, "0000000000", "", 50, 1, 135, 330, 138 }, + /* 85*/ { BARCODE_KIX, "123456ABCDE", "", 8, 3, 87, 174, 16 }, + /* 86*/ { BARCODE_AZTEC, "1234567890AB", "", 15, 15, 15, 30, 30 }, + /* 87*/ { BARCODE_DAFT, "DAFTDAFTDAFTDAFT", "", 8, 3, 31, 62, 16 }, + /* 88*/ { BARCODE_MICROQR, "12345", "", 11, 11, 11, 22, 22 }, + /* 89*/ { BARCODE_HIBC_128, "0000000000", "", 50, 1, 134, 268, 118 }, + /* 90*/ { BARCODE_HIBC_39, "0000000000", "", 50, 1, 223, 446, 118 }, + /* 91*/ { BARCODE_HIBC_DM, "ABC", "", 12, 12, 12, 24, 24 }, + /* 92*/ { BARCODE_HIBC_QR, "1234567890AB", "", 21, 21, 21, 42, 42 }, + /* 93*/ { BARCODE_HIBC_PDF, "0000000000", "", 27, 9, 103, 206, 54 }, + /* 94*/ { BARCODE_HIBC_MICPDF, "0000000000", "", 34, 17, 38, 76, 68 }, + /* 95*/ { BARCODE_HIBC_BLOCKF, "0000000000", "", 30, 3, 101, 242, 64 }, + /* 96*/ { BARCODE_HIBC_AZTEC, "1234567890AB", "", 19, 19, 19, 38, 38 }, + /* 97*/ { BARCODE_DOTCODE, "ABC", "", 11, 11, 16, 33, 23 }, // Differs from vector + /* 98*/ { BARCODE_HANXIN, "1234567890AB", "", 23, 23, 23, 46, 46 }, + /* 99*/ { BARCODE_MAILMARK, "01000000000000000AA00AA0A", "", 10, 3, 155, 310, 20 }, + /*100*/ { BARCODE_AZRUNE, "255", "", 11, 11, 11, 22, 22 }, + /*101*/ { BARCODE_CODE32, "12345678", "", 50, 1, 103, 206, 118 }, + /*102*/ { BARCODE_EANX_CC, "123456789012", "[20]01", 50, 7, 99, 234, 118 }, + /*103*/ { BARCODE_EANX_CC, "123456789012+12", "[20]01", 50, 7, 126, 284, 118 }, + /*104*/ { BARCODE_EANX_CC, "123456789012+12345", "[20]01", 50, 7, 153, 338, 118 }, + /*105*/ { BARCODE_EAN128_CC, "[01]12345678901234", "[20]01", 50, 5, 145, 290, 118 }, + /*106*/ { BARCODE_RSS14_CC, "1234567890123", "[20]01", 21, 5, 100, 200, 60 }, + /*107*/ { BARCODE_RSS_LTD_CC, "1234567890123", "[20]01", 19, 6, 74, 148, 56 }, + /*108*/ { BARCODE_RSS_EXP_CC, "[01]12345678901234", "[20]01", 41, 5, 134, 268, 100 }, + /*109*/ { BARCODE_UPCA_CC, "12345678901", "[20]01", 50, 7, 99, 234, 118 }, + /*110*/ { BARCODE_UPCA_CC, "12345678901+12", "[20]01", 50, 7, 128, 284, 118 }, + /*111*/ { BARCODE_UPCA_CC, "12345678901+12345", "[20]01", 50, 7, 155, 338, 118 }, + /*112*/ { BARCODE_UPCE_CC, "1234567", "[20]01", 50, 9, 55, 142, 118 }, + /*113*/ { BARCODE_UPCE_CC, "1234567+12", "[20]01", 50, 9, 82, 192, 118 }, + /*114*/ { BARCODE_UPCE_CC, "1234567+12345", "[20]01", 50, 9, 109, 246, 118 }, + /*115*/ { BARCODE_RSS14STACK_CC, "0000000000000", "[20]01", 24, 9, 56, 112, 48 }, + /*116*/ { BARCODE_RSS14_OMNI_CC, "0000000000000", "[20]01", 80, 11, 56, 112, 160 }, + /*117*/ { BARCODE_RSS_EXPSTACK_CC, "[01]12345678901234", "[20]01", 78, 9, 102, 204, 156 }, + /*118*/ { BARCODE_CHANNEL, "00", "", 50, 1, 19, 38, 118 }, + /*119*/ { BARCODE_CODEONE, "12345678901234567890", "", 22, 22, 22, 44, 44 }, + /*120*/ { BARCODE_GRIDMATRIX, "ABC", "", 18, 18, 18, 36, 36 }, + /*121*/ { BARCODE_UPNQR, "1234567890AB", "", 77, 77, 77, 154, 154 }, + /*122*/ { BARCODE_ULTRA, "0000000000", "", 13, 13, 18, 36, 26 }, + /*123*/ { BARCODE_RMQR, "12345", "", 11, 11, 27, 54, 22 }, }; int data_size = ARRAY_SIZE(data); @@ -305,34 +316,38 @@ static void test_upcean_hrt(int index, int debug) { }; // s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<")) struct item data[] = { - /* 0*/ { BARCODE_EANX, -1, "123456789012", 0, 50, 1, 95, 230, 118, 103 /*text_row*/, 0, 20, -1, -1, -1 }, // EAN-13 - /* 1*/ { BARCODE_EANX, 0, "123456789012", 0, 50, 1, 95, 230, 118, 103 /*text_row*/, 0, 20, -1, -1, -1 }, // EAN-13 - /* 2*/ { BARCODE_EANX_CHK, -1, "1234567890128", 0, 50, 1, 95, 230, 118, 103 /*text_row*/, 0, 20, -1, -1, -1 }, // EAN-13 - /* 3*/ { BARCODE_EANX_CHK, 0, "1234567890128", 0, 50, 1, 95, 230, 118, 103 /*text_row*/, 0, 20, -1, -1, -1 }, // EAN-13 - /* 4*/ { BARCODE_EANX_CHK, -1, "1234567890128+12", 0, 50, 1, 124, 288, 118, 103 /*text_row*/, 0, 20, 5, 210, 78 }, // EAN-13 + EAN-2 - /* 5*/ { BARCODE_EANX_CHK, 0, "1234567890128+12", 0, 50, 1, 124, 288, 118, 103 /*text_row*/, 0, 20, 5, 210, 78 }, // EAN-13 + EAN-2 - /* 6*/ { BARCODE_EANX, -1, "1234567890128+12345", 0, 50, 1, 151, 342, 118, 103 /*text_row*/, 0, 20, 5, 210, 130 }, // EAN-13 + EAN-5 - /* 7*/ { BARCODE_EANX, 0, "1234567890128+12345", 0, 50, 1, 151, 342, 118, 103 /*text_row*/, 0, 20, 5, 210, 130 }, // EAN-13 + EAN-5 - /* 8*/ { BARCODE_ISBNX, -1, "9784567890120+12345", 0, 50, 1, 151, 342, 118, 103 /*text_row*/, 0, 20, 5, 210, 130 }, // ISBNX + EAN-5 - /* 9*/ { BARCODE_ISBNX, 0, "9784567890120+12345", 0, 50, 1, 151, 342, 118, 103 /*text_row*/, 0, 20, 5, 210, 130 }, // ISBNX + EAN-5 - /* 10*/ { BARCODE_EANX, -1, "123456", 0, 50, 1, 67, 134, 118, 103 /*text_row*/, 6, 58, -1, -1, -1 }, // EAN-8 - /* 11*/ { BARCODE_EANX, 0, "123456", 0, 50, 1, 67, 134, 118, 103 /*text_row*/, 6, 58, -1, -1, -1 }, // EAN-8 - /* 12*/ { BARCODE_EANX, -1, "123456+12", 0, 50, 1, 96, 192, 118, 103 /*text_row*/, 6, 58, 5, 134, 58 }, // EAN-8 + EAN-2 - /* 13*/ { BARCODE_EANX, 0, "123456+12", 0, 50, 1, 96, 192, 118, 103 /*text_row*/, 6, 58, 5, 134, 58 }, // EAN-8 + EAN-2 - /* 14*/ { BARCODE_EANX, -1, "123456+12345", 0, 50, 1, 123, 246, 118, 103 /*text_row*/, 6, 58, 5, 134, 112 }, // EAN-8 + EAN-5 - /* 15*/ { BARCODE_EANX, 0, "123456+12345", 0, 50, 1, 123, 246, 118, 103 /*text_row*/, 6, 58, 5, 134, 112 }, // EAN-8 + EAN-5 - /* 16*/ { BARCODE_UPCA, -1, "123456789012", 0, 50, 1, 95, 230, 118, 103 /*text_row*/, 0, 20, -1, -1, -1 }, - /* 17*/ { BARCODE_UPCA, 0, "123456789012", 0, 50, 1, 95, 230, 118, 103 /*text_row*/, 0, 20, -1, -1, -1 }, - /* 18*/ { BARCODE_UPCA, -1, "123456789012+12", 0, 50, 1, 124, 288, 118, 103 /*text_row*/, 0, 20, 5, 210, 78 }, - /* 19*/ { BARCODE_UPCA, 0, "123456789012+12", 0, 50, 1, 124, 288, 118, 103 /*text_row*/, 0, 20, 5, 210, 78 }, - /* 20*/ { BARCODE_UPCA_CHK, -1, "123456789012+12345", 0, 50, 1, 151, 342, 118, 103 /*text_row*/, 0, 20, 5, 210, 130 }, - /* 21*/ { BARCODE_UPCA_CHK, 0, "123456789012+12345", 0, 50, 1, 151, 342, 118, 103 /*text_row*/, 0, 20, 5, 210, 130 }, - /* 22*/ { BARCODE_UPCE, -1, "1234567", 0, 50, 1, 51, 142, 118, 103 /*text_row*/, 0, 20, -1, -1, -1 }, - /* 23*/ { BARCODE_UPCE, 0, "1234567", 0, 50, 1, 51, 142, 118, 103 /*text_row*/, 0, 20, -1, -1, -1 }, - /* 24*/ { BARCODE_UPCE_CHK, -1, "12345670+12", 0, 50, 1, 80, 200, 118, 103 /*text_row*/, 0, 20, 5, 122, 78 }, - /* 25*/ { BARCODE_UPCE_CHK, 0, "12345670+12", 0, 50, 1, 80, 200, 118, 103 /*text_row*/, 0, 20, 5, 122, 78 }, - /* 26*/ { BARCODE_UPCE, -1, "1234567+12345", 0, 50, 1, 107, 254, 118, 103 /*text_row*/, 0, 20, 5, 122, 130 }, - /* 27*/ { BARCODE_UPCE, 0, "1234567+12345", 0, 50, 1, 107, 254, 118, 103 /*text_row*/, 0, 20, 5, 122, 130 }, + /* 0*/ { BARCODE_EANX, -1, "123456789012", 0, 50, 1, 95, 226, 118, 103 /*text_row*/, 0, 20, -1, -1, -1 }, // EAN-13 + /* 1*/ { BARCODE_EANX, 0, "123456789012", 0, 50, 1, 95, 226, 118, 103 /*text_row*/, 0, 20, -1, -1, -1 }, // EAN-13 + /* 2*/ { BARCODE_EANX_CHK, -1, "1234567890128", 0, 50, 1, 95, 226, 118, 103 /*text_row*/, 0, 20, -1, -1, -1 }, // EAN-13 + /* 3*/ { BARCODE_EANX_CHK, 0, "1234567890128", 0, 50, 1, 95, 226, 118, 103 /*text_row*/, 0, 20, -1, -1, -1 }, // EAN-13 + /* 4*/ { BARCODE_EANX_CHK, -1, "1234567890128+12", 0, 50, 1, 122, 276, 118, 103 /*text_row*/, 0, 20, 5, 212, 64 }, // EAN-13 + EAN-2 + /* 5*/ { BARCODE_EANX_CHK, 0, "1234567890128+12", 0, 50, 1, 122, 276, 118, 103 /*text_row*/, 0, 20, 5, 212, 64 }, // EAN-13 + EAN-2 + /* 6*/ { BARCODE_EANX, -1, "1234567890128+12345", 0, 50, 1, 149, 330, 118, 103 /*text_row*/, 0, 20, 5, 212, 118 }, // EAN-13 + EAN-5 + /* 7*/ { BARCODE_EANX, 0, "1234567890128+12345", 0, 50, 1, 149, 330, 118, 103 /*text_row*/, 0, 20, 5, 212, 118 }, // EAN-13 + EAN-5 + /* 8*/ { BARCODE_ISBNX, -1, "9784567890120+12345", 0, 50, 1, 149, 330, 118, 103 /*text_row*/, 0, 20, 5, 212, 118 }, // ISBNX + EAN-5 + /* 9*/ { BARCODE_ISBNX, 0, "9784567890120+12345", 0, 50, 1, 149, 330, 118, 103 /*text_row*/, 0, 20, 5, 212, 118 }, // ISBNX + EAN-5 + /* 10*/ { BARCODE_EANX, -1, "123456", 0, 50, 1, 67, 162, 118, 103 /*text_row*/, 20, 58, -1, -1, -1 }, // EAN-8 + /* 11*/ { BARCODE_EANX, 0, "123456", 0, 50, 1, 67, 162, 118, 103 /*text_row*/, 20, 58, -1, -1, -1 }, // EAN-8 + /* 12*/ { BARCODE_EANX, -1, "123456+12", 0, 50, 1, 94, 216, 118, 103 /*text_row*/, 20, 58, 5, 148, 68 }, // EAN-8 + EAN-2 + /* 13*/ { BARCODE_EANX, 0, "123456+12", 0, 50, 1, 94, 216, 118, 103 /*text_row*/, 20, 58, 5, 148, 68 }, // EAN-8 + EAN-2 + /* 14*/ { BARCODE_EANX, -1, "123456+12345", 0, 50, 1, 121, 270, 118, 103 /*text_row*/, 20, 58, 5, 148, 122 }, // EAN-8 + EAN-5 + /* 15*/ { BARCODE_EANX, 0, "123456+12345", 0, 50, 1, 121, 270, 118, 103 /*text_row*/, 20, 58, 5, 148, 122 }, // EAN-8 + EAN-5 + /* 16*/ { BARCODE_EANX, -1, "1234", 0, 50, 1, 47, 118, 118, 103 /*text_row*/, 40, 36, -1, -1, -1 }, // EAN-5 + /* 17*/ { BARCODE_EANX, 0, "1234", 0, 50, 1, 47, 118, 118, 103 /*text_row*/, 40, 36, -1, -1, -1 }, // EAN-5 + /* 18*/ { BARCODE_EANX, -1, "12", 0, 50, 1, 20, 64, 118, 103 /*text_row*/, 20, 20, -1, -1, -1 }, // EAN-2 + /* 19*/ { BARCODE_EANX, 0, "12", 0, 50, 1, 20, 64, 118, 103 /*text_row*/, 20, 20, -1, -1, -1 }, // EAN-2 + /* 20*/ { BARCODE_UPCA, -1, "123456789012", 0, 50, 1, 95, 226, 118, 103 /*text_row*/, 0, 18, -1, -1, -1 }, + /* 21*/ { BARCODE_UPCA, 0, "123456789012", 0, 50, 1, 95, 226, 118, 103 /*text_row*/, 0, 18, -1, -1, -1 }, + /* 22*/ { BARCODE_UPCA, -1, "123456789012+12", 0, 50, 1, 124, 276, 118, 103 /*text_row*/, 0, 18, 5, 208, 68 }, + /* 23*/ { BARCODE_UPCA, 0, "123456789012+12", 0, 50, 1, 124, 276, 118, 103 /*text_row*/, 0, 18, 5, 208, 68 }, + /* 24*/ { BARCODE_UPCA_CHK, -1, "123456789012+12345", 0, 50, 1, 151, 330, 118, 103 /*text_row*/, 0, 18, 5, 208, 122 }, + /* 25*/ { BARCODE_UPCA_CHK, 0, "123456789012+12345", 0, 50, 1, 151, 330, 118, 103 /*text_row*/, 0, 18, 5, 208, 122 }, + /* 26*/ { BARCODE_UPCE, -1, "1234567", 0, 50, 1, 51, 134, 118, 103 /*text_row*/, 0, 18, -1, -1, -1 }, + /* 27*/ { BARCODE_UPCE, 0, "1234567", 0, 50, 1, 51, 134, 118, 103 /*text_row*/, 0, 18, -1, -1, -1 }, + /* 28*/ { BARCODE_UPCE_CHK, -1, "12345670+12", 0, 50, 1, 78, 184, 118, 103 /*text_row*/, 0, 18, 5, 120, 64 }, + /* 29*/ { BARCODE_UPCE_CHK, 0, "12345670+12", 0, 50, 1, 78, 184, 118, 103 /*text_row*/, 0, 18, 5, 120, 64 }, + /* 30*/ { BARCODE_UPCE, -1, "1234567+12345", 0, 50, 1, 105, 238, 118, 103 /*text_row*/, 0, 18, 5, 120, 118 }, + /* 31*/ { BARCODE_UPCE, 0, "1234567+12345", 0, 50, 1, 105, 238, 118, 103 /*text_row*/, 0, 18, 5, 120, 118 }, }; int data_size = ARRAY_SIZE(data); @@ -357,11 +372,13 @@ static void test_upcean_hrt(int index, int debug) { if (index != -1) testUtilBitmapPrint(symbol); - 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); - assert_equal(symbol->width, data[i].expected_width, "i:%d (%d) symbol->width %d != %d\n", i, data[i].symbology, symbol->width, data[i].expected_width); - 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); + 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); + assert_equal(symbol->width, data[i].expected_width, "i:%d (%s) symbol->width %d != %d\n", i, testUtilBarcodeName(data[i].symbology), symbol->width, data[i].expected_width); + assert_equal(symbol->bitmap_width, data[i].expected_bitmap_width, "i:%d (%s) symbol->bitmap_width %d != %d\n", + i, testUtilBarcodeName(data[i].symbology), symbol->bitmap_width, data[i].expected_bitmap_width); + assert_equal(symbol->bitmap_height, data[i].expected_bitmap_height, "i:%d (%s) symbol->bitmap_height %d != %d\n", + i, testUtilBarcodeName(data[i].symbology), symbol->bitmap_height, data[i].expected_bitmap_height); if (data[i].expected_text_row != -1) { int text_bits_set = 0; diff --git a/backend/tests/test_svg.c b/backend/tests/test_svg.c index 59297df9..4a473365 100644 --- a/backend/tests/test_svg.c +++ b/backend/tests/test_svg.c @@ -49,6 +49,16 @@ static void test_print(int index, int generate, int debug) { struct item data[] = { /* 0*/ { BARCODE_CODE128, -1, -1, "<>\"&'", "../data/svg/code128_amperands.svg" }, /* 1*/ { BARCODE_CODABLOCKF, 3, -1, "AAAAAAAAA", "../data/svg/codablockf_3rows.svg"}, + /* 2*/ { BARCODE_EANX, -1, -1, "9771384524017+12", "../data/svg/ean13_2addon_ggs_5.2.2.5.1-2.svg" }, + /* 3*/ { BARCODE_EANX, -1, -1, "9780877799306+54321", "../data/svg/ean13_5addon_ggs_5.2.2.5.2-2.svg" }, + /* 4*/ { BARCODE_UPCA, -1, -1, "012345678905+24", "../data/svg/upca_2addon_ggs_5.2.6.6-5.svg" }, + /* 5*/ { BARCODE_UPCA, -1, -1, "614141234417+12345", "../data/svg/upca_5addon.svg" }, + /* 6*/ { BARCODE_UPCE, -1, -1, "1234567+12", "../data/svg/upce_2addon.svg" }, + /* 7*/ { BARCODE_UPCE, -1, -1, "1234567+12345", "../data/svg/upce_5addon.svg" }, + /* 8*/ { BARCODE_EANX, -1, -1, "1234567+12", "../data/svg/ean8_2addon.svg" }, + /* 9*/ { BARCODE_EANX, -1, -1, "1234567+12345", "../data/svg/ean8_5addon.svg" }, + /* 10*/ { BARCODE_EANX, -1, -1, "12345", "../data/svg/ean5.svg" }, + /* 11*/ { BARCODE_EANX, -1, -1, "12", "../data/svg/ean2.svg" }, }; int data_size = sizeof(data) / sizeof(struct item); diff --git a/backend/tests/test_upcean.c b/backend/tests/test_upcean.c index cbc886fe..73bde64d 100644 --- a/backend/tests/test_upcean.c +++ b/backend/tests/test_upcean.c @@ -74,7 +74,7 @@ static void test_upce_length(int index, int debug) { int length = strlen(data[i].data); ret = ZBarcode_Encode(symbol, data[i].data, length); - assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret); + assert_equal(ret, data[i].ret, "i:%d ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); ZBarcode_Delete(symbol); } @@ -112,11 +112,11 @@ static void test_upca_print(int index, int debug) { int length = strlen(data[i].data); ret = ZBarcode_Encode(symbol, data[i].data, length); - assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret); + assert_equal(ret, data[i].ret, "i:%d ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); strcpy(symbol->outfile, "out.gif"); ret = ZBarcode_Print(symbol, 0); - assert_zero(ret, "i:%d %s ZBarcode_Print %s ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, ret); + assert_zero(ret, "i:%d %s ZBarcode_Print %s ret %d != 0 (%s)\n", i, testUtilBarcodeName(data[i].symbology), symbol->outfile, ret, symbol->errtxt); assert_zero(remove(symbol->outfile), "i:%d remove(%s) != 0\n", i, symbol->outfile); @@ -136,48 +136,51 @@ static void test_isbn(int index, int debug) { int ret_encode; int ret_vector; }; - // s/\/\*[ 0-9]*\*\//\=printf("\/*%2d*\/", line(".") - line("'<")) + // s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<")) struct item data[] = { - /* 0*/ { "0", 0, 0 }, // Left zero-padded if < 10 chars - /* 1*/ { "12345678", ZINT_ERROR_INVALID_CHECK, -1 }, - /* 2*/ { "12345679", 0, 0 }, // 9 is correct check digit - /* 3*/ { "123456789", 0, 0 }, - /* 4*/ { "0123456789", 0, 0 }, - /* 5*/ { "1234567890", ZINT_ERROR_INVALID_CHECK, -1 }, - /* 6*/ { "123456789X", 0, 0 }, // X is correct check digit - /* 7*/ { "8175257660", 0, 0 }, // 0 is correct check digit - /* 8*/ { "0590764845", 0, 0 }, // 5 is correct check digit - /* 9*/ { "0906495741", 0, 0 }, // 1 is correct check digit - /*10*/ { "0140430016", 0, 0 }, // 6 is correct check digit - /*11*/ { "0571086187", 0, 0 }, // 7 is correct check digit - /*12*/ { "0486600882", 0, 0 }, // 2 is correct check digit - /*13*/ { "12345678901", ZINT_ERROR_TOO_LONG, -1 }, - /*14*/ { "123456789012", ZINT_ERROR_TOO_LONG, -1 }, - /*15*/ { "1234567890123", ZINT_ERROR_INVALID_DATA, -1 }, - /*16*/ { "9784567890120", 0, 0 }, // 0 is correct check digit - /*17*/ { "9783161484100", 0, 0 }, // 0 is correct check digit - /*18*/ { "9781846688225", 0, 0 }, // 5 is correct check digit - /*19*/ { "9781847657954", 0, 0 }, // 4 is correct check digit - /*20*/ { "9781846688188", 0, 0 }, // 8 is correct check digit - /*21*/ { "9781847659293", 0, 0 }, // 3 is correct check digit - /*22*/ { "97845678901201", ZINT_ERROR_TOO_LONG, -1 }, - /*23*/ { "3954994+12", 0, 0 }, - /*24*/ { "3954994+12345", 0, 0 }, - /*25*/ { "3954994+123456", ZINT_ERROR_TOO_LONG, -1 }, - /*26*/ { "3954994+", 0, 0 }, - /*27*/ { "61954993+1", 0, 0 }, - /*28*/ { "61954993+123", 0, 0 }, - /*29*/ { "361954999+12", 0, 0 }, - /*30*/ { "361954999+1234", 0, 0 }, - /*31*/ { "361954999+12", 0, 0 }, - /*32*/ { "199900003X+12", 0, 0 }, - /*33*/ { "199900003X+12345", 0, 0 }, - /*34*/ { "9791234567896+12", 0, 0 }, - /*35*/ { "9791234567896+12345", 0, 0 }, - /*36*/ { "9791234567896+", 0, 0 }, - /*37*/ { "97912345678961+", ZINT_ERROR_TOO_LONG, -1 }, - /*38*/ { "97912345678961+12345", ZINT_ERROR_TOO_LONG, -1 }, - /*39*/ { "9791234567896+123456", ZINT_ERROR_TOO_LONG, -1 }, + /* 0*/ { "0", 0, 0 }, // Left zero-padded if < 10 chars + /* 1*/ { "12345678", ZINT_ERROR_INVALID_CHECK, -1 }, + /* 2*/ { "12345679", 0, 0 }, // 9 is correct check digit + /* 3*/ { "123456789", 0, 0 }, + /* 4*/ { "0123456789", 0, 0 }, + /* 5*/ { "1234567890", ZINT_ERROR_INVALID_CHECK, -1 }, + /* 6*/ { "123456789X", 0, 0 }, // X is correct check digit + /* 7*/ { "123456789x", 0, 0 }, // x is correct check digit + /* 8*/ { "8175257660", 0, 0 }, // 0 is correct check digit + /* 9*/ { "0590764845", 0, 0 }, // 5 is correct check digit + /* 10*/ { "0906495741", 0, 0 }, // 1 is correct check digit + /* 11*/ { "0140430016", 0, 0 }, // 6 is correct check digit + /* 12*/ { "0571086187", 0, 0 }, // 7 is correct check digit + /* 13*/ { "0486600882", 0, 0 }, // 2 is correct check digit + /* 14*/ { "12345678901", ZINT_ERROR_TOO_LONG, -1 }, + /* 15*/ { "123456789012", ZINT_ERROR_TOO_LONG, -1 }, + /* 16*/ { "1234567890123", ZINT_ERROR_INVALID_DATA, -1 }, + /* 17*/ { "9784567890120", 0, 0 }, // 0 is correct check digit + /* 18*/ { "9783161484100", 0, 0 }, // 0 is correct check digit + /* 19*/ { "9781846688225", 0, 0 }, // 5 is correct check digit + /* 20*/ { "9781847657954", 0, 0 }, // 4 is correct check digit + /* 21*/ { "9781846688188", 0, 0 }, // 8 is correct check digit + /* 22*/ { "9781847659293", 0, 0 }, // 3 is correct check digit + /* 23*/ { "97845678901201", ZINT_ERROR_TOO_LONG, -1 }, + /* 24*/ { "3954994+12", 0, 0 }, + /* 25*/ { "3954994+12345", 0, 0 }, + /* 26*/ { "3954994+123456", ZINT_ERROR_TOO_LONG, -1 }, + /* 27*/ { "3954994+", 0, 0 }, + /* 28*/ { "61954993+1", 0, 0 }, + /* 29*/ { "61954993+123", 0, 0 }, + /* 30*/ { "361954999+12", 0, 0 }, + /* 31*/ { "361954999+1234", 0, 0 }, + /* 32*/ { "361954999+12", 0, 0 }, + /* 33*/ { "199900003X+12", 0, 0 }, + /* 34*/ { "199900003x+12", 0, 0 }, + /* 35*/ { "199900003X+12345", 0, 0 }, + /* 36*/ { "199900003x+12345", 0, 0 }, + /* 37*/ { "9791234567896+12", 0, 0 }, + /* 38*/ { "9791234567896+12345", 0, 0 }, + /* 39*/ { "9791234567896+", 0, 0 }, + /* 40*/ { "97912345678961+", ZINT_ERROR_TOO_LONG, -1 }, + /* 41*/ { "97912345678961+12345", ZINT_ERROR_TOO_LONG, -1 }, + /* 42*/ { "9791234567896+123456", ZINT_ERROR_TOO_LONG, -1 }, }; int data_size = sizeof(data) / sizeof(struct item); @@ -194,11 +197,11 @@ static void test_isbn(int index, int debug) { int length = strlen(data[i].data); ret = ZBarcode_Encode(symbol, data[i].data, length); - assert_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d, errtxt %s\n", i, ret, data[i].ret_encode, symbol->errtxt); + assert_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret_encode, symbol->errtxt); if (data[i].ret_vector != -1) { ret = ZBarcode_Buffer_Vector(symbol, 0); - assert_equal(ret, data[i].ret_vector, "i:%d ZBarcode_Buffer_Vector ret %d != %d\n", i, ret, data[i].ret_vector); + assert_equal(ret, data[i].ret_vector, "i:%d ZBarcode_Buffer_Vector ret %d != %d (%s)\n", i, ret, data[i].ret_vector, symbol->errtxt); } ZBarcode_Delete(symbol); @@ -242,10 +245,10 @@ static void test_vector_same(int index, int debug) { int length = strlen(data[i].data); ret = ZBarcode_Encode(symbol, data[i].data, length); - assert_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret_encode); + assert_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret_encode, symbol->errtxt); ret = ZBarcode_Buffer_Vector(symbol, 0); - assert_equal(ret, data[i].ret_vector, "i:%d ZBarcode_Buffer_Vector ret %d != %d\n", i, ret, data[i].ret_vector); + assert_equal(ret, data[i].ret_vector, "i:%d ZBarcode_Buffer_Vector ret %d != %d (%s)\n", i, ret, data[i].ret_vector, symbol->errtxt); assert_nonnull(symbol->vector, "i:%d symbol->vector NULL\n", i); vectors[j] = testUtilVectorCpy(symbol->vector); @@ -268,13 +271,18 @@ static void test_vector_same(int index, int debug) { testFinish(); } +// https://www.isbn-international.org/content/isbn-users-manual ISBN Users' Manual +// https://bisg.org/page/BarcodingGuidelines BISG Barcode Guidelines for the US Book Industry (BISG BGUSBI) static void test_encode(int index, int generate, int debug) { testStart(""); + int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); // Only do BWIPP test if asked, too slow otherwise + int ret; struct item { int symbology; + int option_2; unsigned char *data; int ret; @@ -284,15 +292,120 @@ static void test_encode(int index, int generate, int debug) { char *expected; }; struct item data[] = { - /* 0*/ { BARCODE_UPCA, "1234567890", 0, 1, 95, "GS1 General Specifications 20.0 Figure 5.1-1 left", + /* 0*/ { BARCODE_UPCA, -1, "01234567890", 0, 1, 95, "GGS Figure 5.1-1 UPC-A (also Figure 5.2.2.3-1., 5.2.6.6-2., 6.4.9-1. and BS EN 797:1996 Figure 3)", "10100011010011001001001101111010100011011000101010101000010001001001000111010011100101001110101" }, - /* 1*/ { BARCODE_EANX, "4512345678906", 0, 1, 95, "GS1 General Specifications 20.0 Figure 5.1-1 right", + /* 1*/ { BARCODE_EANX, -1, "4512345678906", 0, 1, 95, "GGS Figure 5.1-1 EAN-13", "10101100010110011001001101111010011101011100101010101000010001001001000111010011100101010000101" }, + /* 2*/ { BARCODE_EANX_CHK, -1, "9501101531000", 0, 1, 95, "GGS Figure 5.2.2.1-2. EAN-13 (also Figure 6.5.2.2-1., 6.5.3.2-1., 6.5.3.2-2., 6.5.6.4-1.)", + "10101100010100111011001100110010100111001100101010100111010000101100110111001011100101110010101" + }, + /* 3*/ { BARCODE_EANX, -1, "9501234", 0, 1, 67, "GGS Figure 5.2.2.2-1. EAN-8", + "1010001011011000100011010011001010101101100100001010111001010000101" + }, + /* 4*/ { BARCODE_UPCE, -1, "0012345", 0, 1, 51, "GGS Figure 5.2.2.4-1. UPC-E (also BS EN 797:1996 Figure 4)", + "101010011100110010011011011110100111010110001010101" + }, + /* 5*/ { BARCODE_EANX, -1, "9771384524017+12", 0, 1, 122, "GGS Figure 5.2.2.5.1-2. EAN-13 barcode with two-digit add-on", + "10101110110010001011001101111010001001010001101010100111011011001011100111001011001101000100101000000010110011001010010011" + }, + /* 6*/ { BARCODE_EANX, -1, "9780877799306+54321", 0, 1, 149, "GGS Figure 5.2.2.5.2-2. EAN-13 barcode with five-digit add-on", + "10101110110001001010011101101110010001011101101010100010011101001110100100001011100101010000101000000010110111001010100011010100001010010011010011001" + }, + /* 7*/ { BARCODE_EANX, -1, "501234567890", 0, 1, 95, "GGS Figure 5.2.6.6-1. EAN-13 (also BS EN 797:1996 Figure 1)", + "10100011010110011001101101111010100011011100101010101000010001001001000111010011100101110010101" + }, + /* 8*/ { BARCODE_EANX, -1, "2012345", 0, 1, 67, "GGS Figure 5.2.6.6-3. EAN-8", + "1010010011000110100110010010011010101000010101110010011101100110101" + }, + /* 9*/ { BARCODE_UPCE_CHK, -1, "00783491", 0, 1, 51, "GGS Figure 5.2.6.6-4. UPC-E", + "101010011100100010110111010000101000110001011010101" + }, + /* 10*/ { BARCODE_UPCA, -1, "01234567890+24", 0, 1, 124, "GGS Figure 5.2.6.6-5. UPC-A barcode with two-digit add-on", + "1010001101001100100100110111101010001101100010101010100001000100100100011101001110010100111010100000000010110010011010100011" + }, + /* 11*/ { BARCODE_EANX, -1, "1234567891019+45678", 0, 1, 149, "GGS Figure 5.2.6.6-6. EAN-13 barcode with five-digit add-on", + "10100100110111101001110101100010000101001000101010100100011101001100110111001011001101110100101000000010110011101010110001010101111010010001010110111" + }, + /* 12*/ { BARCODE_EANX, -1, "5024425377399", 0, 1, 95, "GGS Figure 5.10.5.12-1. EAN-13", + "10100011010011011001110101000110010011011100101010100001010001001000100100001011101001110100101" + }, + /* 13*/ { BARCODE_UPCA_CHK, -1, "614141000302", 0, 1, 95, "GGS Figure 5.10.6.3-1. UPC-A", + "10101011110011001010001100110010100011001100101010111001011100101110010100001011100101101100101" + }, + /* 14*/ { BARCODE_UPCA, -1, "61414123440", 0, 1, 95, "GGS Figure 6.4.17-2. UPC-A Daisy 5pc Set", + "10101011110011001010001100110010100011001100101010110110010000101011100101110011100101110010101" + }, + /* 15*/ { BARCODE_EANX, -1, "5410038302178", 0, 1, 95, "GGS Figure 6.5.5.3-1. EAN-13", + "10101000110110011010011100011010111101000100101010100001011100101101100110011010001001001000101" + }, + /* 16*/ { BARCODE_EANX, -1, "501234567890+12", 0, 1, 122, "BS EN 797:1996 Figure 5 EAN-13 with 2-digit add-on", + "10100011010110011001101101111010100011011100101010101000010001001001000111010011100101110010101000000010110011001010010011" + }, + /* 17*/ { BARCODE_EANX, -1, "501234567890+86104", 0, 1, 149, "BS EN 797:1996 Figure 6 EAN-13 with 5-digit add-on", + "10100011010110011001101101111010100011011100101010101000010001001001000111010011100101110010101000000010110001001010101111010011001010001101010011101" + }, + /* 18*/ { BARCODE_UPCA_CHK, -1, "614141234417+12345", 0, 1, 151, "Example of UPC-A with 5-digit add-on", + "1010101111001100101000110011001010001100110010101011011001000010101110010111001100110100010010100000000010110110011010010011010100001010100011010110001" + }, + /* 19*/ { BARCODE_UPCE, -1, "1234567+12", 0, 1, 78, "Example of UPC-E with 2-digit add-on", + "101001001101111010100011011100100001010010001010101000000010110011001010010011" + }, + /* 20*/ { BARCODE_UPCE_CHK, -1, "12345670+12345", 0, 1, 105, "Example of UPC-E with 5-digit add-on", + "101001001101111010100011011100100001010010001010101000000010110110011010010011010100001010100011010110001" + }, + /* 21*/ { BARCODE_EANX, -1, "1234567+12", 0, 1, 94, "Example of EAN-8 with 2-digit add-on", + "1010011001001001101111010100011010101001110101000010001001110010101000000010110011001010010011" + }, + /* 22*/ { BARCODE_EANX_CHK, -1, "12345670+12345", 0, 1, 121, "Example of EAN-8 with 5-digit add-on", + "1010011001001001101111010100011010101001110101000010001001110010101000000010110110011010010011010100001010100011010110001" + }, + /* 23*/ { BARCODE_EANX, -1, "54321", 0, 1, 47, "Example of EAN-5", + "10110111001010100011010100001010010011010011001" + }, + /* 24*/ { BARCODE_EANX, -1, "21", 0, 1, 20, "Example of EAN-2", + "10110010011010110011" + }, + /* 25*/ { BARCODE_EANX_CHK, 9, "76543210+21", 0, 1, 96, "Example of EAN-8 barcode with two-digit add-on, addon_gap 9", + "101011101101011110110001010001101010100001011011001100110111001010100000000010110010011010110011" + }, + /* 26*/ { BARCODE_EANX, 12, "7654321+54321", 0, 1, 126, "Example of EAN-8 barcode with five-digit add-on, addon_gap 12", + "101011101101011110110001010001101010100001011011001100110111001010100000000000010110111001010100011010100001010010011010011001" + }, + /* 27*/ { BARCODE_UPCA_CHK, 10, "210987654329+21", 0, 1, 125, "Example of UPC-A with 2-digit add-on, addon_gap 10", + "10100100110011001000110100010110110111011101101010101000010011101011100100001011011001110100101000000000010110010011010110011" + }, + /* 28*/ { BARCODE_UPCA, 12, "21098765432+12121", 0, 1, 154, "Example of UPC-A with 5-digit add-on, addon_gap 12", + "1010010011001100100011010001011011011101110110101010100001001110101110010000101101100111010010100000000000010110011001010010011010110011010011011010011001" + }, + /* 29*/ { BARCODE_UPCE_CHK, 8, "06543217+21", 0, 1, 79, "Example of UPC-A with 2-digit add-on, addon_gap 8", + "1010000101011000100111010111101001101100110010101010000000010110010011010110011" + }, + /* 30*/ { BARCODE_UPCE, 11, "1654321+12121", 0, 1, 109, "Example of UPC-A with 5-digit add-on, addon_gap 11", + "1010101111011100101000110111101001101101100110101010000000000010110011001010010011010110011010011011010011001" + }, + /* 31*/ { BARCODE_ISBNX, -1, "9789295055124", 0, 1, 95, "ISBN Users' Manual 7th Ed. 13.2", + "10101110110001001001011100100110010111011000101010111001010011101001110110011011011001011100101" + }, + /* 32*/ { BARCODE_ISBNX, -1, "9780123456786+50995", 0, 1, 149, "BISG BGUSBI Figure 1: Bookland EAN (with Price Add-On) (and Figures 4, 5, 6)", + "10101110110001001010011100110010011011011110101010101110010011101010000100010010010001010000101000000010110110001010100111010001011010001011010111001" + }, + /* 33*/ { BARCODE_ISBNX, -1, "9781402894626+50495", 0, 1, 149, "BISG BGUSBI Figure 2", + "10101110110001001011001101000110100111001001101010100100011101001011100101000011011001010000101000000010110111001010001101010100011010001011010111001" + }, + /* 34*/ { BARCODE_ISBNX, 10, "9780940016644+50750", 0, 1, 152, "BISG BGUSBI Figure 3, addon_gap 10", + "10101110110001001010011100010110011101000110101010111001011001101010000101000010111001011100101000000000010110111001010001101010010001010110001010001101" + }, + /* 35*/ { BARCODE_ISBNX, -1, "9791234567896+12", 0, 1, 122, "Example of ISBN with 2-digit add-on", + "10101110110010111011001100100110100001010001101010100111010100001000100100100011101001010000101000000010110011001010010011" + }, }; int data_size = ARRAY_SIZE(data); + char bwipp_buf[4096]; + char bwipp_msg[1024]; + for (int i = 0; i < data_size; i++) { if (index != -1 && i != index) continue; @@ -300,14 +413,14 @@ static void test_encode(int index, int generate, int debug) { struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); + int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug); ret = ZBarcode_Encode(symbol, data[i].data, length); - assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret); + assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); if (generate) { - printf(" /*%3d*/ { %s, \"%s\", %s, %d, %d, \"%s\",\n", - i, testUtilBarcodeName(data[i].symbology), data[i].data, testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment); + printf(" /*%3d*/ { %s, %d, \"%s\", %s, %d, %d, \"%s\",\n", + i, testUtilBarcodeName(data[i].symbology), data[i].option_2, data[i].data, testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment); testUtilModulesDump(symbol, " ", "\n"); printf(" },\n"); } else { @@ -320,6 +433,15 @@ static void test_encode(int index, int generate, int debug) { ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row); assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data); } + + if (do_bwipp && testUtilCanBwipp(symbol->symbology, -1, data[i].option_2, -1, debug)) { + ret = testUtilBwipp(symbol, -1, data[i].option_2, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf)); + assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(data[i].symbology), ret); + + ret = testUtilBwippCmp(symbol, bwipp_msg, bwipp_buf, data[i].expected); + assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n", + i, testUtilBarcodeName(data[i].symbology), ret, bwipp_msg, bwipp_buf, data[i].expected); + } } } diff --git a/backend/tests/test_vector.c b/backend/tests/test_vector.c index c8a5bb4c..bddf4b89 100644 --- a/backend/tests/test_vector.c +++ b/backend/tests/test_vector.c @@ -138,119 +138,130 @@ static void test_buffer_vector(int index, int generate, int debug) { float expected_vector_height; }; struct item data[] = { - /* 0*/ { BARCODE_CODE11, "0000000000", "", 50, 1, 99, 198.0, 118.0 }, - /* 1*/ { BARCODE_C25MATRIX, "0000000000", "", 50, 1, 117, 234.0, 118.0 }, - /* 2*/ { BARCODE_C25INTER, "0000000000", "", 50, 1, 99, 198.0, 118.0 }, - /* 3*/ { BARCODE_C25IATA, "0000000000", "", 50, 1, 149, 298.0, 118.0 }, - /* 4*/ { BARCODE_C25LOGIC, "0000000000", "", 50, 1, 109, 218.0, 118.0 }, - /* 5*/ { BARCODE_C25IND, "0000000000", "", 50, 1, 159, 318.0, 118.0 }, - /* 6*/ { BARCODE_CODE39, "0000000000", "", 50, 1, 155, 310.0, 118.0 }, - /* 7*/ { BARCODE_EXCODE39, "0000000000", "", 50, 1, 155, 310.0, 118.0 }, - /* 8*/ { BARCODE_EANX, "123456789012", "", 50, 1, 95, 230.0, 118.0 }, - /* 9*/ { BARCODE_EANX_CHK, "1234567890128", "", 50, 1, 95, 230.0, 118.0 }, - /* 10*/ { BARCODE_EANX, "123456789012+12", "", 50, 1, 124, 288.0, 118.0 }, - /* 11*/ { BARCODE_EANX, "123456789012+12345", "", 50, 1, 151, 342.0, 118.0 }, - /* 12*/ { BARCODE_EANX, "1234567", "", 50, 1, 67, 134.0, 118.0 }, - /* 13*/ { BARCODE_EANX, "1234567+12", "", 50, 1, 96, 192.0, 118.0 }, - /* 14*/ { BARCODE_EANX, "1234567+12345", "", 50, 1, 123, 246.0, 118.0 }, - /* 15*/ { BARCODE_EANX, "1234", "", 50, 1, 47, 94.0, 118.0 }, - /* 16*/ { BARCODE_EANX, "12", "", 50, 1, 20, 40.0, 118.0 }, - /* 17*/ { BARCODE_EAN128, "[01]12345678901234", "", 50, 1, 134, 268.0, 118.0 }, - /* 18*/ { BARCODE_CODABAR, "A00000000B", "", 50, 1, 102, 204.0, 118.0 }, - /* 19*/ { BARCODE_CODE128, "0000000000", "", 50, 1, 90, 180.0, 118.0 }, - /* 20*/ { BARCODE_DPLEIT, "1234567890123", "", 50, 1, 135, 270.0, 118.0 }, - /* 21*/ { BARCODE_DPIDENT, "12345678901", "", 50, 1, 117, 234.0, 118.0 }, - /* 22*/ { BARCODE_CODE16K, "0000000000", "", 20, 2, 70, 162.0, 44.0 }, - /* 23*/ { BARCODE_CODE49, "0000000000", "", 20, 2, 70, 162.0, 44.0 }, - /* 24*/ { BARCODE_CODE93, "0000000000", "", 50, 1, 127, 254.0, 118.0 }, - /* 25*/ { BARCODE_FLAT, "1234567890", "", 50, 1, 90, 180.0, 100.0 }, - /* 26*/ { BARCODE_RSS14, "1234567890123", "", 50, 1, 96, 192.0, 118.0 }, - /* 27*/ { BARCODE_RSS_LTD, "1234567890123", "", 50, 1, 74, 148.0, 118.0 }, - /* 28*/ { BARCODE_RSS_EXP, "[01]12345678901234", "", 34, 1, 134, 268.0, 86.0 }, - /* 29*/ { BARCODE_TELEPEN, "0000000000", "", 50, 1, 208, 416.0, 118.0 }, - /* 30*/ { BARCODE_UPCA, "12345678904", "", 50, 1, 95, 230.0, 118.0 }, - /* 31*/ { BARCODE_UPCA_CHK, "12345678905", "", 50, 1, 95, 230.0, 118.0 }, - /* 32*/ { BARCODE_UPCA, "12345678904+12", "", 50, 1, 124, 288.0, 118.0 }, - /* 33*/ { BARCODE_UPCA, "12345678904+12345", "", 50, 1, 151, 342.0, 118.0 }, - /* 34*/ { BARCODE_UPCE, "1234567", "", 50, 1, 51, 142.0, 118.0 }, - /* 35*/ { BARCODE_UPCE_CHK, "12345670", "", 50, 1, 51, 142.0, 118.0 }, - /* 36*/ { BARCODE_UPCE, "1234567+12", "", 50, 1, 80, 200.0, 118.0 }, - /* 37*/ { BARCODE_UPCE, "1234567+12345", "", 50, 1, 107, 254.0, 118.0 }, - /* 38*/ { BARCODE_POSTNET, "00000000000", "", 12, 2, 185, 370.0, 24.0 }, - /* 39*/ { BARCODE_MSI_PLESSEY, "0000000000", "", 50, 1, 127, 254.0, 118.0 }, - /* 40*/ { BARCODE_FIM, "A", "", 50, 1, 17, 34.0, 100.0 }, - /* 41*/ { BARCODE_LOGMARS, "0000000000", "", 50, 1, 191, 382.0, 118.0 }, - /* 42*/ { BARCODE_PHARMA, "123456", "", 50, 1, 58, 116.0, 100.0 }, - /* 43*/ { BARCODE_PZN, "123456", "", 50, 1, 142, 284.0, 118.0 }, - /* 44*/ { BARCODE_PHARMA_TWO, "12345678", "", 10, 2, 29, 58.0, 20.0 }, - /* 45*/ { BARCODE_PDF417, "0000000000", "", 21, 7, 103, 206.0, 42.0 }, - /* 46*/ { BARCODE_PDF417TRUNC, "0000000000", "", 21, 7, 68, 136.0, 42.0 }, - /* 47*/ { BARCODE_MAXICODE, "0000000000", "", 165, 33, 30, 74.0, 72.0 }, - /* 48*/ { BARCODE_QRCODE, "1234567890AB", "", 21, 21, 21, 42.0, 42.0 }, - /* 49*/ { BARCODE_CODE128B, "0000000000", "", 50, 1, 145, 290.0, 118.0 }, - /* 50*/ { BARCODE_AUSPOST, "12345678901234567890123", "", 8, 3, 133, 266.0, 16.0 }, - /* 51*/ { BARCODE_AUSREPLY, "12345678", "", 8, 3, 73, 146.0, 16.0 }, - /* 52*/ { BARCODE_AUSROUTE, "12345678", "", 8, 3, 73, 146.0, 16.0 }, - /* 53*/ { BARCODE_AUSREDIRECT, "12345678", "", 8, 3, 73, 146.0, 16.0 }, - /* 54*/ { BARCODE_ISBNX, "123456789", "", 50, 1, 95, 230.0, 118.0 }, - /* 55*/ { BARCODE_ISBNX, "123456789+12", "", 50, 1, 124, 288.0, 118.0 }, - /* 56*/ { BARCODE_ISBNX, "123456789+12345", "", 50, 1, 151, 342.0, 118.0 }, - /* 57*/ { BARCODE_RM4SCC, "0000000000", "", 8, 3, 91, 182.0, 16.0 }, - /* 58*/ { BARCODE_DATAMATRIX, "ABC", "", 10, 10, 10, 20.0, 20.0 }, - /* 59*/ { BARCODE_EAN14, "1234567890123", "", 50, 1, 134, 268.0, 118.0 }, - /* 60*/ { BARCODE_VIN, "00000000000000000", "", 50, 1, 246, 492.0, 118.0 }, - /* 61*/ { BARCODE_CODABLOCKF, "0000000000", "", 20, 2, 101, 242.0, 44.0 }, - /* 62*/ { BARCODE_NVE18, "12345678901234567", "", 50, 1, 156, 312.0, 118.0 }, - /* 63*/ { BARCODE_JAPANPOST, "0000000000", "", 8, 3, 133, 266.0, 16.0 }, - /* 64*/ { BARCODE_KOREAPOST, "123456", "", 50, 1, 167, 334.0, 118.0 }, - /* 65*/ { BARCODE_RSS14STACK, "0000000000000", "", 13, 3, 50, 100.0, 26.0 }, - /* 66*/ { BARCODE_RSS14STACK_OMNI, "0000000000000", "", 69, 5, 50, 100.0, 138.0 }, - /* 67*/ { BARCODE_RSS_EXPSTACK, "[01]12345678901234", "", 71, 5, 102, 204.0, 142.0 }, - /* 68*/ { BARCODE_PLANET, "00000000000", "", 12, 2, 185, 370.0, 24.0 }, - /* 69*/ { BARCODE_MICROPDF417, "0000000000", "", 12, 6, 82, 164.0, 24.0 }, - /* 70*/ { BARCODE_ONECODE, "12345678901234567890", "", 8, 3, 129, 258.0, 16.0 }, - /* 71*/ { BARCODE_PLESSEY, "0000000000", "", 50, 1, 227, 454.0, 118.0 }, - /* 72*/ { BARCODE_TELEPEN_NUM, "0000000000", "", 50, 1, 128, 256.0, 118.0 }, - /* 73*/ { BARCODE_ITF14, "0000000000", "", 50, 1, 135, 382.0, 150.0 }, - /* 74*/ { BARCODE_KIX, "123456ABCDE", "", 8, 3, 87, 174.0, 16.0 }, - /* 75*/ { BARCODE_AZTEC, "1234567890AB", "", 15, 15, 15, 30.0, 30.0 }, - /* 76*/ { BARCODE_DAFT, "DAFTDAFTDAFTDAFT", "", 8, 3, 31, 62.0, 16.0 }, - /* 77*/ { BARCODE_MICROQR, "12345", "", 11, 11, 11, 22.0, 22.0 }, - /* 78*/ { BARCODE_HIBC_128, "0000000000", "", 50, 1, 134, 268.0, 118.0 }, - /* 79*/ { BARCODE_HIBC_39, "0000000000", "", 50, 1, 223, 446.0, 118.0 }, - /* 80*/ { BARCODE_HIBC_DM, "ABC", "", 12, 12, 12, 24.0, 24.0 }, - /* 81*/ { BARCODE_HIBC_QR, "1234567890AB", "", 21, 21, 21, 42.0, 42.0 }, - /* 82*/ { BARCODE_HIBC_PDF, "0000000000", "", 27, 9, 103, 206.0, 54.0 }, - /* 83*/ { BARCODE_HIBC_MICPDF, "0000000000", "", 34, 17, 38, 76.0, 68.0 }, - /* 84*/ { BARCODE_HIBC_BLOCKF, "0000000000", "", 30, 3, 101, 242.0, 64.0 }, - /* 85*/ { BARCODE_HIBC_AZTEC, "1234567890AB", "", 19, 19, 19, 38.0, 38.0 }, - /* 86*/ { BARCODE_DOTCODE, "ABC", "", 11, 11, 16, 32.0, 22.0 }, - /* 87*/ { BARCODE_HANXIN, "1234567890AB", "", 23, 23, 23, 46.0, 46.0 }, - /* 88*/ { BARCODE_MAILMARK, "01000000000000000AA00AA0A", "", 10, 3, 155, 310.0, 20.0 }, - /* 89*/ { BARCODE_AZRUNE, "255", "", 11, 11, 11, 22.0, 22.0 }, - /* 90*/ { BARCODE_CODE32, "12345678", "", 50, 1, 103, 206.0, 118.0 }, - /* 91*/ { BARCODE_EANX_CC, "123456789012", "[20]01", 50, 7, 99, 238.0, 118.0 }, - /* 92*/ { BARCODE_EANX_CC, "123456789012+12", "[20]01", 50, 7, 128, 296.0, 118.0 }, - /* 93*/ { BARCODE_EANX_CC, "123456789012+12345", "[20]01", 50, 7, 155, 350.0, 118.0 }, - /* 94*/ { BARCODE_EAN128_CC, "[01]12345678901234", "[20]01", 50, 5, 145, 290.0, 118.0 }, - /* 95*/ { BARCODE_RSS14_CC, "1234567890123", "[20]01", 21, 5, 100, 200.0, 60.0 }, - /* 96*/ { BARCODE_RSS_LTD_CC, "1234567890123", "[20]01", 19, 6, 74, 148.0, 56.0 }, - /* 97*/ { BARCODE_RSS_EXP_CC, "[01]12345678901234", "[20]01", 41, 5, 134, 268.0, 100.0 }, - /* 98*/ { BARCODE_UPCA_CC, "12345678901", "[20]01", 50, 7, 99, 238.0, 118.0 }, - /* 99*/ { BARCODE_UPCA_CC, "12345678901+12", "[20]01", 50, 7, 128, 296.0, 118.0 }, - /*100*/ { BARCODE_UPCA_CC, "12345678901+12345", "[20]01", 50, 7, 155, 350.0, 118.0 }, - /*101*/ { BARCODE_UPCE_CC, "1234567", "[20]01", 50, 9, 55, 150.0, 118.0 }, - /*102*/ { BARCODE_UPCE_CC, "1234567+12", "[20]01", 50, 9, 84, 208.0, 118.0 }, - /*103*/ { BARCODE_UPCE_CC, "1234567+12345", "[20]01", 50, 9, 111, 262.0, 118.0 }, - /*104*/ { BARCODE_RSS14STACK_CC, "0000000000000", "[20]01", 24, 9, 56, 112.0, 48.0 }, - /*105*/ { BARCODE_RSS14_OMNI_CC, "0000000000000", "[20]01", 80, 11, 56, 112.0, 160.0 }, - /*106*/ { BARCODE_RSS_EXPSTACK_CC, "[01]12345678901234", "[20]01", 78, 9, 102, 204.0, 156.0 }, - /*107*/ { BARCODE_CHANNEL, "00", "", 50, 1, 19, 38.0, 118.0 }, - /*108*/ { BARCODE_CODEONE, "12345678901234567890", "", 22, 22, 22, 44.0, 44.0 }, - /*109*/ { BARCODE_GRIDMATRIX, "ABC", "", 18, 18, 18, 36.0, 36.0 }, - /*110*/ { BARCODE_UPNQR, "1234567890AB", "", 77, 77, 77, 154.0, 154.0 }, - /*111*/ { BARCODE_ULTRA, "0000000000", "", 13, 13, 18, 36.0, 26.0 }, - /*112*/ { BARCODE_RMQR, "12345", "", 11, 11, 27, 54.0, 22.0 }, + /* 0*/ { BARCODE_CODE11, "0000000000", "", 50, 1, 99, 198, 118 }, + /* 1*/ { BARCODE_C25MATRIX, "0000000000", "", 50, 1, 117, 234, 118 }, + /* 2*/ { BARCODE_C25INTER, "0000000000", "", 50, 1, 99, 198, 118 }, + /* 3*/ { BARCODE_C25IATA, "0000000000", "", 50, 1, 149, 298, 118 }, + /* 4*/ { BARCODE_C25LOGIC, "0000000000", "", 50, 1, 109, 218, 118 }, + /* 5*/ { BARCODE_C25IND, "0000000000", "", 50, 1, 159, 318, 118 }, + /* 6*/ { BARCODE_CODE39, "0000000000", "", 50, 1, 155, 310, 118 }, + /* 7*/ { BARCODE_EXCODE39, "0000000000", "", 50, 1, 155, 310, 118 }, + /* 8*/ { BARCODE_EANX, "123456789012", "", 50, 1, 95, 226, 118 }, + /* 9*/ { BARCODE_EANX_CHK, "1234567890128", "", 50, 1, 95, 226, 118 }, + /* 10*/ { BARCODE_EANX, "123456789012+12", "", 50, 1, 122, 276, 118 }, + /* 11*/ { BARCODE_EANX_CHK, "1234567890128+12", "", 50, 1, 122, 276, 118 }, + /* 12*/ { BARCODE_EANX, "123456789012+12345", "", 50, 1, 149, 330, 118 }, + /* 13*/ { BARCODE_EANX_CHK, "1234567890128+12345", "", 50, 1, 149, 330, 118 }, + /* 14*/ { BARCODE_EANX, "1234567", "", 50, 1, 67, 162, 118 }, + /* 15*/ { BARCODE_EANX_CHK, "12345670", "", 50, 1, 67, 162, 118 }, + /* 16*/ { BARCODE_EANX, "1234567+12", "", 50, 1, 94, 216, 118 }, + /* 17*/ { BARCODE_EANX_CHK, "12345670+12", "", 50, 1, 94, 216, 118 }, + /* 18*/ { BARCODE_EANX, "1234567+12345", "", 50, 1, 121, 270, 118 }, + /* 19*/ { BARCODE_EANX_CHK, "12345670+12345", "", 50, 1, 121, 270, 118 }, + /* 20*/ { BARCODE_EANX, "1234", "", 50, 1, 47, 118, 118 }, + /* 21*/ { BARCODE_EANX_CHK, "1234", "", 50, 1, 47, 118, 118 }, + /* 22*/ { BARCODE_EANX, "12", "", 50, 1, 20, 64, 118 }, + /* 23*/ { BARCODE_EANX_CHK, "12", "", 50, 1, 20, 64, 118 }, + /* 24*/ { BARCODE_EAN128, "[01]12345678901234", "", 50, 1, 134, 268, 118 }, + /* 25*/ { BARCODE_CODABAR, "A00000000B", "", 50, 1, 102, 204, 118 }, + /* 26*/ { BARCODE_CODE128, "0000000000", "", 50, 1, 90, 180, 118 }, + /* 27*/ { BARCODE_DPLEIT, "1234567890123", "", 50, 1, 135, 270, 118 }, + /* 28*/ { BARCODE_DPIDENT, "12345678901", "", 50, 1, 117, 234, 118 }, + /* 29*/ { BARCODE_CODE16K, "0000000000", "", 20, 2, 70, 162, 44 }, + /* 30*/ { BARCODE_CODE49, "0000000000", "", 20, 2, 70, 162, 44 }, + /* 31*/ { BARCODE_CODE93, "0000000000", "", 50, 1, 127, 254, 118 }, + /* 32*/ { BARCODE_FLAT, "1234567890", "", 50, 1, 90, 180, 100 }, + /* 33*/ { BARCODE_RSS14, "1234567890123", "", 50, 1, 96, 192, 118 }, + /* 34*/ { BARCODE_RSS_LTD, "1234567890123", "", 50, 1, 74, 148, 118 }, + /* 35*/ { BARCODE_RSS_EXP, "[01]12345678901234", "", 34, 1, 134, 268, 86 }, + /* 36*/ { BARCODE_TELEPEN, "0000000000", "", 50, 1, 208, 416, 118 }, + /* 37*/ { BARCODE_UPCA, "12345678904", "", 50, 1, 95, 226, 118 }, + /* 38*/ { BARCODE_UPCA_CHK, "123456789043", "", 50, 1, 95, 226, 118 }, + /* 39*/ { BARCODE_UPCA, "12345678904+12", "", 50, 1, 124, 276, 118 }, + /* 40*/ { BARCODE_UPCA_CHK, "123456789043+12", "", 50, 1, 124, 276, 118 }, + /* 41*/ { BARCODE_UPCA, "12345678904+12345", "", 50, 1, 151, 330, 118 }, + /* 42*/ { BARCODE_UPCA_CHK, "123456789043+12345", "", 50, 1, 151, 330, 118 }, + /* 43*/ { BARCODE_UPCE, "1234567", "", 50, 1, 51, 134, 118 }, + /* 44*/ { BARCODE_UPCE_CHK, "12345670", "", 50, 1, 51, 134, 118 }, + /* 45*/ { BARCODE_UPCE, "1234567+12", "", 50, 1, 78, 184, 118 }, + /* 46*/ { BARCODE_UPCE_CHK, "12345670+12", "", 50, 1, 78, 184, 118 }, + /* 47*/ { BARCODE_UPCE, "1234567+12345", "", 50, 1, 105, 238, 118 }, + /* 48*/ { BARCODE_UPCE_CHK, "12345670+12345", "", 50, 1, 105, 238, 118 }, + /* 49*/ { BARCODE_POSTNET, "00000000000", "", 12, 2, 185, 370, 24 }, + /* 50*/ { BARCODE_MSI_PLESSEY, "0000000000", "", 50, 1, 127, 254, 118 }, + /* 51*/ { BARCODE_FIM, "A", "", 50, 1, 17, 34, 100 }, + /* 52*/ { BARCODE_LOGMARS, "0000000000", "", 50, 1, 191, 382, 118 }, + /* 53*/ { BARCODE_PHARMA, "123456", "", 50, 1, 58, 116, 100 }, + /* 54*/ { BARCODE_PZN, "123456", "", 50, 1, 142, 284, 118 }, + /* 55*/ { BARCODE_PHARMA_TWO, "12345678", "", 10, 2, 29, 58, 20 }, + /* 56*/ { BARCODE_PDF417, "0000000000", "", 21, 7, 103, 206, 42 }, + /* 57*/ { BARCODE_PDF417TRUNC, "0000000000", "", 21, 7, 68, 136, 42 }, + /* 58*/ { BARCODE_MAXICODE, "0000000000", "", 165, 33, 30, 74, 72 }, // Differs from raster + /* 59*/ { BARCODE_QRCODE, "1234567890AB", "", 21, 21, 21, 42, 42 }, + /* 60*/ { BARCODE_CODE128B, "0000000000", "", 50, 1, 145, 290, 118 }, + /* 61*/ { BARCODE_AUSPOST, "12345678901234567890123", "", 8, 3, 133, 266, 16 }, + /* 62*/ { BARCODE_AUSREPLY, "12345678", "", 8, 3, 73, 146, 16 }, + /* 63*/ { BARCODE_AUSROUTE, "12345678", "", 8, 3, 73, 146, 16 }, + /* 64*/ { BARCODE_AUSREDIRECT, "12345678", "", 8, 3, 73, 146, 16 }, + /* 65*/ { BARCODE_ISBNX, "123456789", "", 50, 1, 95, 226, 118 }, + /* 66*/ { BARCODE_ISBNX, "123456789+12", "", 50, 1, 122, 276, 118 }, + /* 67*/ { BARCODE_ISBNX, "123456789+12345", "", 50, 1, 149, 330, 118 }, + /* 68*/ { BARCODE_RM4SCC, "0000000000", "", 8, 3, 91, 182, 16 }, + /* 69*/ { BARCODE_DATAMATRIX, "ABC", "", 10, 10, 10, 20, 20 }, + /* 70*/ { BARCODE_EAN14, "1234567890123", "", 50, 1, 134, 268, 118 }, + /* 71*/ { BARCODE_VIN, "00000000000000000", "", 50, 1, 246, 492, 118 }, + /* 72*/ { BARCODE_CODABLOCKF, "0000000000", "", 20, 2, 101, 242, 44 }, + /* 73*/ { BARCODE_NVE18, "12345678901234567", "", 50, 1, 156, 312, 118 }, + /* 74*/ { BARCODE_JAPANPOST, "0000000000", "", 8, 3, 133, 266, 16 }, + /* 75*/ { BARCODE_KOREAPOST, "123456", "", 50, 1, 167, 334, 118 }, + /* 76*/ { BARCODE_RSS14STACK, "0000000000000", "", 13, 3, 50, 100, 26 }, + /* 77*/ { BARCODE_RSS14STACK_OMNI, "0000000000000", "", 69, 5, 50, 100, 138 }, + /* 78*/ { BARCODE_RSS_EXPSTACK, "[01]12345678901234", "", 71, 5, 102, 204, 142 }, + /* 79*/ { BARCODE_PLANET, "00000000000", "", 12, 2, 185, 370, 24 }, + /* 80*/ { BARCODE_MICROPDF417, "0000000000", "", 12, 6, 82, 164, 24 }, + /* 81*/ { BARCODE_ONECODE, "12345678901234567890", "", 8, 3, 129, 258, 16 }, + /* 82*/ { BARCODE_PLESSEY, "0000000000", "", 50, 1, 227, 454, 118 }, + /* 83*/ { BARCODE_TELEPEN_NUM, "0000000000", "", 50, 1, 128, 256, 118 }, + /* 84*/ { BARCODE_ITF14, "0000000000", "", 50, 1, 135, 330, 138 }, + /* 85*/ { BARCODE_KIX, "123456ABCDE", "", 8, 3, 87, 174, 16 }, + /* 86*/ { BARCODE_AZTEC, "1234567890AB", "", 15, 15, 15, 30, 30 }, + /* 87*/ { BARCODE_DAFT, "DAFTDAFTDAFTDAFT", "", 8, 3, 31, 62, 16 }, + /* 88*/ { BARCODE_MICROQR, "12345", "", 11, 11, 11, 22, 22 }, + /* 89*/ { BARCODE_HIBC_128, "0000000000", "", 50, 1, 134, 268, 118 }, + /* 90*/ { BARCODE_HIBC_39, "0000000000", "", 50, 1, 223, 446, 118 }, + /* 91*/ { BARCODE_HIBC_DM, "ABC", "", 12, 12, 12, 24, 24 }, + /* 92*/ { BARCODE_HIBC_QR, "1234567890AB", "", 21, 21, 21, 42, 42 }, + /* 93*/ { BARCODE_HIBC_PDF, "0000000000", "", 27, 9, 103, 206, 54 }, + /* 94*/ { BARCODE_HIBC_MICPDF, "0000000000", "", 34, 17, 38, 76, 68 }, + /* 95*/ { BARCODE_HIBC_BLOCKF, "0000000000", "", 30, 3, 101, 242, 64 }, + /* 96*/ { BARCODE_HIBC_AZTEC, "1234567890AB", "", 19, 19, 19, 38, 38 }, + /* 97*/ { BARCODE_DOTCODE, "ABC", "", 11, 11, 16, 32, 22 }, // Differs from raster + /* 98*/ { BARCODE_HANXIN, "1234567890AB", "", 23, 23, 23, 46, 46 }, + /* 99*/ { BARCODE_MAILMARK, "01000000000000000AA00AA0A", "", 10, 3, 155, 310, 20 }, + /*100*/ { BARCODE_AZRUNE, "255", "", 11, 11, 11, 22, 22 }, + /*101*/ { BARCODE_CODE32, "12345678", "", 50, 1, 103, 206, 118 }, + /*102*/ { BARCODE_EANX_CC, "123456789012", "[20]01", 50, 7, 99, 234, 118 }, + /*103*/ { BARCODE_EANX_CC, "123456789012+12", "[20]01", 50, 7, 126, 284, 118 }, + /*104*/ { BARCODE_EANX_CC, "123456789012+12345", "[20]01", 50, 7, 153, 338, 118 }, + /*105*/ { BARCODE_EAN128_CC, "[01]12345678901234", "[20]01", 50, 5, 145, 290, 118 }, + /*106*/ { BARCODE_RSS14_CC, "1234567890123", "[20]01", 21, 5, 100, 200, 60 }, + /*107*/ { BARCODE_RSS_LTD_CC, "1234567890123", "[20]01", 19, 6, 74, 148, 56 }, + /*108*/ { BARCODE_RSS_EXP_CC, "[01]12345678901234", "[20]01", 41, 5, 134, 268, 100 }, + /*109*/ { BARCODE_UPCA_CC, "12345678901", "[20]01", 50, 7, 99, 234, 118 }, + /*110*/ { BARCODE_UPCA_CC, "12345678901+12", "[20]01", 50, 7, 128, 284, 118 }, + /*111*/ { BARCODE_UPCA_CC, "12345678901+12345", "[20]01", 50, 7, 155, 338, 118 }, + /*112*/ { BARCODE_UPCE_CC, "1234567", "[20]01", 50, 9, 55, 142, 118 }, + /*113*/ { BARCODE_UPCE_CC, "1234567+12", "[20]01", 50, 9, 82, 192, 118 }, + /*114*/ { BARCODE_UPCE_CC, "1234567+12345", "[20]01", 50, 9, 109, 246, 118 }, + /*115*/ { BARCODE_RSS14STACK_CC, "0000000000000", "[20]01", 24, 9, 56, 112, 48 }, + /*116*/ { BARCODE_RSS14_OMNI_CC, "0000000000000", "[20]01", 80, 11, 56, 112, 160 }, + /*117*/ { BARCODE_RSS_EXPSTACK_CC, "[01]12345678901234", "[20]01", 78, 9, 102, 204, 156 }, + /*118*/ { BARCODE_CHANNEL, "00", "", 50, 1, 19, 38, 118 }, + /*119*/ { BARCODE_CODEONE, "12345678901234567890", "", 22, 22, 22, 44, 44 }, + /*120*/ { BARCODE_GRIDMATRIX, "ABC", "", 18, 18, 18, 36, 36 }, + /*121*/ { BARCODE_UPNQR, "1234567890AB", "", 77, 77, 77, 154, 154 }, + /*122*/ { BARCODE_ULTRA, "0000000000", "", 13, 13, 18, 36, 26 }, + /*123*/ { BARCODE_RMQR, "12345", "", 11, 11, 27, 54, 22 }, }; int data_size = sizeof(data) / sizeof(struct item); @@ -323,34 +334,46 @@ static void test_upcean_hrt(int index, int debug) { }; // s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<")) struct item data[] = { - /* 0*/ { BARCODE_EANX, -1, "123456789012", 0, 50, 1, 95, 230.0, 118.0, 10, -1 }, // EAN-13 + /* 0*/ { BARCODE_EANX, -1, "123456789012", 0, 50, 1, 95, 230.0, 118.0, 8, -1 }, // EAN-13 /* 1*/ { BARCODE_EANX, 0, "123456789012", 0, 50, 1, 95, 230.0, 118.0, -1, -1 }, // EAN-13 - /* 2*/ { BARCODE_EANX_CHK, -1, "1234567890128", 0, 50, 1, 95, 230.0, 118.0, 10, -1 }, // EAN-13 + /* 2*/ { BARCODE_EANX_CHK, -1, "1234567890128", 0, 50, 1, 95, 230.0, 118.0, 8, -1 }, // EAN-13 /* 3*/ { BARCODE_EANX_CHK, 0, "1234567890128", 0, 50, 1, 95, 230.0, 118.0, -1, -1 }, // EAN-13 - /* 4*/ { BARCODE_EANX, -1, "123456789012+12", 0, 50, 1, 124, 288.0, 118.0, 10, 70 }, // EAN-13 + EAN-2 - /* 5*/ { BARCODE_EANX, 0, "123456789012+12", 0, 50, 1, 124, 288.0, 118.0, -1, -1 }, // EAN-13 + EAN-2 - /* 6*/ { BARCODE_EANX, -1, "123456789012+12345", 0, 50, 1, 151, 342.0, 118.0, 10, 70 }, // EAN-13 + EAN-5 - /* 7*/ { BARCODE_EANX, 0, "123456789012+12345", 0, 50, 1, 151, 342.0, 118.0, -1, -1 }, // EAN-13 + EAN-5 - /* 8*/ { BARCODE_ISBNX, -1, "9784567890120+12345", 0, 50, 1, 151, 342.0, 118.0, 10, 70 }, // ISBNX + EAN-5 - /* 9*/ { BARCODE_ISBNX, 0, "9784567890120+12345", 0, 50, 1, 151, 342.0, 118.0, -1, -1 }, // ISBNX + EAN-5 - /* 10*/ { BARCODE_EANX, -1, "1234567", 0, 50, 1, 67, 134.0, 118.0, 34, -1 }, // EAN-8 - /* 11*/ { BARCODE_EANX, 0, "1234567", 0, 50, 1, 67, 134.0, 118.0, -1, -1 }, // EAN-8 - /* 12*/ { BARCODE_EANX, -1, "1234567+12", 0, 50, 1, 96, 192.0, 118.0, 34, 100 }, // EAN-8 + EAN-2 - /* 13*/ { BARCODE_EANX, 0, "1234567+12", 0, 50, 1, 96, 192.0, 118.0, -1, -1 }, // EAN-8 + EAN-2 - /* 14*/ { BARCODE_EANX, -1, "1234567+12345", 0, 50, 1, 123, 246.0, 118.0, 34, 100 }, // EAN-8 + EAN-5 - /* 15*/ { BARCODE_EANX, 0, "1234567+12345", 0, 50, 1, 123, 246.0, 118.0, -1, -1 }, // EAN-8 + EAN-5 - /* 16*/ { BARCODE_UPCA, -1, "12345678901", 0, 50, 1, 95, 230.0, 118.0, 10, -1 }, - /* 17*/ { BARCODE_UPCA, 0, "12345678901", 0, 50, 1, 95, 230.0, 118.0, -1, -1 }, - /* 18*/ { BARCODE_UPCA, -1, "12345678901+12", 0, 50, 1, 124, 288.0, 118.0, 10, 74 }, - /* 19*/ { BARCODE_UPCA, 0, "12345678901+12", 0, 50, 1, 124, 288.0, 118.0, -1, -1 }, - /* 20*/ { BARCODE_UPCA_CHK, -1, "123456789012+12345", 0, 50, 1, 151, 342.0, 118.0, 10, 74 }, - /* 21*/ { BARCODE_UPCA_CHK, 0, "123456789012+12345", 0, 50, 1, 151, 342.0, 118.0, -1, -1 }, - /* 22*/ { BARCODE_UPCE, -1, "1234567", 0, 50, 1, 51, 142.0, 118.0, 10, -1 }, - /* 23*/ { BARCODE_UPCE, 0, "1234567", 0, 50, 1, 51, 142.0, 118.0, -1, -1 }, - /* 24*/ { BARCODE_UPCE_CHK, -1, "12345670+12", 0, 50, 1, 80, 200.0, 118.0, 10, 68 }, - /* 25*/ { BARCODE_UPCE_CHK, 0, "12345670+12", 0, 50, 1, 80, 200.0, 118.0, -1, -1 }, - /* 26*/ { BARCODE_UPCE, -1, "1234567+12345", 0, 50, 1, 107, 254.0, 118.0, 10, 68 }, - /* 27*/ { BARCODE_UPCE, 0, "1234567+12345", 0, 50, 1, 107, 254.0, 118.0, -1, -1 }, + /* 4*/ { BARCODE_ISBNX, -1, "9784567890120", 0, 50, 1, 95, 230.0, 118.0, 8, -1 }, + /* 5*/ { BARCODE_ISBNX, 0, "9784567890120", 0, 50, 1, 95, 230.0, 118.0, -1, -1 }, + /* 6*/ { BARCODE_EANX, -1, "1234567", 0, 50, 1, 67, 134.0, 118.0, 48, -1 }, // EAN-8 + /* 7*/ { BARCODE_EANX, 0, "1234567", 0, 50, 1, 67, 134.0, 118.0, -1, -1 }, // EAN-8 + /* 8*/ { BARCODE_EANX, -1, "1234", 0, 50, 1, 47, 94.0, 118.0, 61, -1 }, // EAN-5 + /* 9*/ { BARCODE_EANX, 0, "1234", 0, 50, 1, 47, 94.0, 118.0, -1, -1 }, // EAN-5 + /* 10*/ { BARCODE_EANX, -1, "12", 0, 50, 1, 20, 40.0, 118.0, 34, -1 }, // EAN-2 + /* 11*/ { BARCODE_EANX, 0, "12", 0, 50, 1, 20, 40.0, 118.0, -1, -1 }, // EAN-2 + /* 12*/ { BARCODE_UPCA, -1, "12345678901", 0, 50, 1, 95, 230.0, 118.0, 8, -1 }, + /* 13*/ { BARCODE_UPCA, 0, "12345678901", 0, 50, 1, 95, 230.0, 118.0, -1, -1 }, + /* 14*/ { BARCODE_UPCA_CHK, -1, "123456789012", 0, 50, 1, 95, 230.0, 118.0, 8, -1 }, + /* 15*/ { BARCODE_UPCA_CHK, 0, "123456789012", 0, 50, 1, 95, 230.0, 118.0, -1, -1 }, + /* 16*/ { BARCODE_UPCE, -1, "1234567", 0, 50, 1, 51, 142.0, 118.0, 8, -1 }, + /* 17*/ { BARCODE_UPCE, 0, "1234567", 0, 50, 1, 51, 142.0, 118.0, -1, -1 }, + /* 18*/ { BARCODE_UPCE_CHK, -1, "12345670", 0, 50, 1, 51, 142.0, 118.0, 8, -1 }, + /* 19*/ { BARCODE_UPCE_CHK, 0, "12345670", 0, 50, 1, 51, 142.0, 118.0, -1, -1 }, + /* 20*/ { BARCODE_EANX, -1, "123456789012+12", 0, 50, 1, 122, 276.0, 118.0, 8, 70 }, // EAN-13 + EAN-2 + /* 21*/ { BARCODE_EANX, 0, "123456789012+12", 0, 50, 1, 122, 276.0, 118.0, -1, -1 }, // EAN-13 + EAN-2 + /* 22*/ { BARCODE_ISBNX, -1, "9784567890120+12", 0, 50, 1, 122, 276.0, 118.0, 8, 70 }, // ISBN + EAN-2 + /* 23*/ { BARCODE_ISBNX, 0, "9784567890120+12", 0, 50, 1, 122, 276.0, 118.0, -1, -1 }, // ISBN + EAN-2 + /* 24*/ { BARCODE_EANX, -1, "123456789012+12345", 0, 50, 1, 149, 330.0, 118.0, 8, 70 }, // EAN-13 + EAN-5 + /* 25*/ { BARCODE_EANX, 0, "123456789012+12345", 0, 50, 1, 149, 330.0, 118.0, -1, -1 }, // EAN-13 + EAN-5 + /* 26*/ { BARCODE_ISBNX, -1, "9784567890120+12345", 0, 50, 1, 149, 330.0, 118.0, 8, 70 }, // ISBN + EAN-5 + /* 27*/ { BARCODE_ISBNX, 0, "9784567890120+12345", 0, 50, 1, 149, 330.0, 118.0, -1, -1 }, // ISBN + EAN-5 + /* 28*/ { BARCODE_EANX, -1, "1234567+12", 0, 50, 1, 94, 216.0, 118.0, 48, 114 }, // EAN-8 + EAN-2 + /* 29*/ { BARCODE_EANX, 0, "1234567+12", 0, 50, 1, 94, 216.0, 118.0, -1, -1 }, // EAN-8 + EAN-2 + /* 30*/ { BARCODE_EANX, -1, "1234567+12345", 0, 50, 1, 121, 270.0, 118.0, 48, 114 }, // EAN-8 + EAN-5 + /* 31*/ { BARCODE_EANX, 0, "1234567+12345", 0, 50, 1, 121, 270.0, 118.0, -1, -1 }, // EAN-8 + EAN-5 + /* 32*/ { BARCODE_UPCA, -1, "12345678901+12", 0, 50, 1, 124, 288.0, 118.0, 8, 72 }, + /* 33*/ { BARCODE_UPCA, 0, "12345678901+12", 0, 50, 1, 124, 288.0, 118.0, -1, -1 }, + /* 34*/ { BARCODE_UPCA, -1, "12345678901+12345", 0, 50, 1, 151, 342.0, 118.0, 8, 72 }, + /* 35*/ { BARCODE_UPCA, 0, "12345678901+12345", 0, 50, 1, 151, 342.0, 118.0, -1, -1 }, + /* 36*/ { BARCODE_UPCE, -1, "1234567+12", 0, 50, 1, 78, 184.0, 118.0, 8, 66 }, + /* 37*/ { BARCODE_UPCE, 0, "1234567+12", 0, 50, 1, 78, 184.0, 118.0, -1, -1 }, + /* 38*/ { BARCODE_UPCE, -1, "1234567+12345", 0, 50, 1, 105, 238.0, 118.0, 8, 66 }, + /* 39*/ { BARCODE_UPCE, 0, "1234567+12345", 0, 50, 1, 105, 238.0, 118.0, -1, -1 }, }; int data_size = sizeof(data) / sizeof(struct item); @@ -647,10 +670,10 @@ static void test_upcean_whitespace_width(int index, int debug) { }; // s/\/\*[ 0-9]*\*\//\=printf("\/*%2d*\/", line(".") - line("'<")) struct item data[] = { - /* 0*/ { BARCODE_UPCA, "12345678904+12345", 0, 151, 342.0, 5, 16.0 }, - /* 1*/ { BARCODE_UPCA, "12345678904+12345", 11, 151, 342.0 + 4 * (11 - 10), 5, 16.0 }, - /* 2*/ { BARCODE_UPCE, "1234567+12", 0, 80, 200.0, 4, 16.0 }, - /* 3*/ { BARCODE_UPCE, "1234567+12", 8, 80, 200.0 + 4 * (8 - 10), 4, 16.0 }, // Note: change from previous behaviour where if whitespace < 10 then set to 10 + /* 0*/ { BARCODE_UPCA, "12345678904+12345", 0, 151, 330.0, 5, 16.0 }, + /* 1*/ { BARCODE_UPCA, "12345678904+12345", 11, 151, 330.0 + 4 * 11, 5, 16.0 }, + /* 2*/ { BARCODE_UPCE, "1234567+12", 0, 78, 184.0, 4, 16.0 }, + /* 3*/ { BARCODE_UPCE, "1234567+12", 8, 78, 184.0 + 4 * 8, 4, 16.0 }, // Note: change from previous behaviour where if whitespace < 10 then set to 10 }; int data_size = sizeof(data) / sizeof(struct item); diff --git a/backend/tests/testcommon.c b/backend/tests/testcommon.c index bbc13c83..62d456ea 100644 --- a/backend/tests/testcommon.c +++ b/backend/tests/testcommon.c @@ -383,7 +383,7 @@ char *testUtilBarcodeName(int symbology) { return ""; } if (data[symbology].val != symbology || (data[symbology].define != -1 && data[symbology].define != symbology)) { // Self-check - fprintf(stderr, "testUtilBarcodeName data table out of sync (%d)\n", symbology); + fprintf(stderr, "testUtilBarcodeName: data table out of sync (%d)\n", symbology); abort(); } return data[symbology].name; @@ -443,7 +443,7 @@ char *testUtilErrorName(int error_number) { return ""; } if (data[error_number].val != error_number || (data[error_number].define != -1 && data[error_number].define != error_number)) { // Self-check - fprintf(stderr, "testUtilErrorName data table out of sync (%d)\n", error_number); + fprintf(stderr, "testUtilErrorName: data table out of sync (%d)\n", error_number); abort(); } return data[error_number].name; @@ -474,7 +474,7 @@ char *testUtilInputModeName(int input_mode) { return input_mode == -1 ? "-1" : ""; } if (data[input_mode].val != input_mode || (data[input_mode].define != -1 && data[input_mode].define != input_mode)) { // Self-check - fprintf(stderr, "testUtilInputModeName data table out of sync (%d)\n", input_mode); + fprintf(stderr, "testUtilInputModeName: data table out of sync (%d)\n", input_mode); abort(); } return data[input_mode].name; @@ -487,7 +487,11 @@ char *testUtilOption3Name(int option_3) { case ZINT_FULL_MULTIBYTE: return "ZINT_FULL_MULTIBYTE"; case ULTRA_COMPRESSION: return "ULTRA_COMPRESSION"; } - return "-1"; + if (option_3 != -1 && option_3 != 0) { + fprintf(stderr, "testUtilOption3Name: unknown value (%d)\n", option_3); + abort(); + } + return option_3 ? "-1" : "0"; } char *testUtilOutputOptionsName(int output_options) { @@ -523,7 +527,7 @@ char *testUtilOutputOptionsName(int output_options) { buf[0] = '\0'; for (i = 0; i < data_size; i++) { if (data[i].define != data[i].val) { // Self-check - fprintf(stderr, "testUtilOutputOptionsName data table out of sync (%d)\n", i); + fprintf(stderr, "testUtilOutputOptionsName: data table out of sync (%d)\n", i); abort(); } if (output_options & data[i].define) { @@ -531,9 +535,13 @@ char *testUtilOutputOptionsName(int output_options) { strcat(buf, " | "); } strcat(buf, data[i].name); - set = 1; + set |= data[i].define; } } + if (set != output_options) { + fprintf(stderr, "testUtilOutputOptionsName: unknown output option(s) %d (%d)\n", output_options & set, output_options); + abort(); + } return buf; } @@ -1472,10 +1480,10 @@ static char *testUtilBwippName(int symbology, int option_1, int option_2, int op { "", -1, 10, 0, 0, 0, 0, 0, }, { "", -1, 11, 0, 0, 0, 0, 0, }, { "", -1, 12, 0, 0, 0, 0, 0, }, - { "ean13", BARCODE_EANX, 13, 0, 0, 0, 0, 0, }, - { "ean13", BARCODE_EANX_CHK, 14, 0, 0, 0, 0, 0, }, + { "ean13", BARCODE_EANX, 13, 0, 1, 0, 0, 1 /*gs1_cvt*/, }, + { "ean13", BARCODE_EANX_CHK, 14, 0, 1, 0, 0, 1, }, { "", -1, 15, 0, 0, 0, 0, 0, }, - { "gs1-128", BARCODE_EAN128, 16, 0, 0, 0, 0, 1 /*gs1_cnt*/, }, + { "gs1-128", BARCODE_EAN128, 16, 0, 0, 0, 0, 1 /*gs1_cvt*/, }, { "", -1, 17, 0, 0, 0, 0, 0, }, { "rationalizedCodabar", BARCODE_CODABAR, 18, 0, 0, 0, 0, 0, }, { "", -1, 19, 0, 0, 0, 0, 0, }, @@ -1493,11 +1501,11 @@ static char *testUtilBwippName(int symbology, int option_1, int option_2, int op { "databarexpanded", BARCODE_RSS_EXP, 31, 0, 1, 0, 1 /*linear_row_height*/, 1, }, { "telepen", BARCODE_TELEPEN, 32, 0, 0, 0, 0, 0, }, { "", -1, 33, 0, 0, 0, 0, 0, }, - { "upca", BARCODE_UPCA, 34, 0, 0, 0, 0, 0, }, - { "upca", BARCODE_UPCA_CHK, 35, 0, 0, 0, 0, 0, }, + { "upca", BARCODE_UPCA, 34, 0, 1, 0, 0, 1 /*gs1_cvt*/, }, + { "upca", BARCODE_UPCA_CHK, 35, 0, 1, 0, 0, 1, }, { "", -1, 36, 0, 0, 0, 0, 0, }, - { "upce", BARCODE_UPCE, 37, 0, 0, 0, 0, 0, }, - { "upce", BARCODE_UPCE_CHK, 38, 0, 0, 0, 0, 0, }, + { "upce", BARCODE_UPCE, 37, 0, 1, 0, 0, 1 /*gs1_cvt*/, }, + { "upce", BARCODE_UPCE_CHK, 38, 0, 1, 0, 0, 1, }, { "", -1, 39, 0, 0, 0, 0, 0, }, { "postnet", BARCODE_POSTNET, 40, 0, 0, 0, 0, 0, }, { "", -1, 41, 0, 0, 0, 0, 0, }, @@ -1528,7 +1536,7 @@ static char *testUtilBwippName(int symbology, int option_1, int option_2, int op { "", BARCODE_AUSREPLY, 66, 0, 0, 0, 0, 0, }, { "", BARCODE_AUSROUTE, 67, 0, 0, 0, 0, 0, }, { "", BARCODE_AUSREDIRECT, 68, 0, 0, 0, 0, 0, }, - { "isbn", BARCODE_ISBNX, 69, 0, 0, 0, 0, 0, }, + { "isbn", BARCODE_ISBNX, 69, 0, 1, 0, 0, 1 /*gs1_cvt*/, }, { "royalmail", BARCODE_RM4SCC, 70, 0, 0, 0, 0, 0, }, { "datamatrix", BARCODE_DATAMATRIX, 71, 0, 0, 0, 0, 0, }, { "ean14", BARCODE_EAN14, 72, 0, 0, 0, 0, 1 /*gs1_cvt*/, }, @@ -1612,7 +1620,7 @@ static char *testUtilBwippName(int symbology, int option_1, int option_2, int op return NULL; } if (data[symbology].val != symbology || (data[symbology].define != -1 && data[symbology].define != symbology)) { // Self-check - fprintf(stderr, "testUtilBarcodeName data table out of sync (%d)\n", symbology); + fprintf(stderr, "testUtilBwippName: data table out of sync (%d)\n", symbology); abort(); } if (data[symbology].name[0] == '\0') { @@ -1654,14 +1662,22 @@ int testUtilCanBwipp(int symbology, int option_1, int option_2, int option_3, in return 0; } -static void testUtilBwippCvtGS1Data(char *bwipp_data) { +static void testUtilBwippCvtGS1Data(char *bwipp_data, int upcean, int *addon_posn) { char *b; + int pipe = 0; + *addon_posn = 0; for (b = bwipp_data; *b; b++) { + if (upcean && *b == '|') { + pipe = 1; + } if (*b == '[') { *b = '('; } else if (*b == ']') { *b = ')'; + } else if (*b == '+' && upcean && !pipe) { + *b = ' '; + *addon_posn = b - bwipp_data; } } } @@ -1693,6 +1709,24 @@ static char *testUtilBwippEscape(char *bwipp_data, int bwipp_data_size, const ch return bwipp_data; } +static void testUtilISBNHyphenate(char *bwipp_data, int addon_posn) { + /* Hack in 4 hyphens in fixed format, wrong for many ISBNs */ + char temp[13 + 4 + 1 + 5 + 1]; + int len = strlen(bwipp_data); + int i, j; + + if (len < 13 || (addon_posn && addon_posn < 13 ) || len >= (int) sizeof(temp)) { + return; + } + for (i = 0, j = 0; i <= len; i++, j++) { + if (i == 3 || i == 5 || i == 10 || i == 12) { + temp[j++] = '-'; + } + temp[j] = bwipp_data[i]; + } + strcpy(bwipp_data, temp); +} + #define GS_INITIAL_LEN 35 /* Length of cmd up to -q */ int testUtilBwipp(const struct zint_symbol *symbol, int option_1, int option_2, int option_3, const char *data, int length, const char *primary, char *buffer, int buffer_size) { @@ -1704,7 +1738,7 @@ int testUtilBwipp(const struct zint_symbol *symbol, int option_1, int option_2, int symbology = symbol->symbology; int data_len = length == -1 ? (int) strlen(data) : length; int primary_len = primary ? (int) strlen(primary) : 0; - int max_data_len = 4 + primary_len + 1 + 1 + data_len * 4; /* 4 AI prefix + primary + '|' + leading zero + escaped data */ + int max_data_len = 4 + primary_len + 1 + 1 + data_len * 4 + 32; /* 4 AI prefix + primary + '|' + leading zero + escaped data + fudge */ char cmd[max_data_len + 1024]; char *bwipp_barcode = NULL; @@ -1723,6 +1757,10 @@ int testUtilBwipp(const struct zint_symbol *symbol, int option_1, int option_2, int r, h; int parse; + int upcean = is_extendable(symbology); + int upca = symbology == BARCODE_UPCA || symbology == BARCODE_UPCA_CHK || symbology == BARCODE_UPCA_CC; + int addon_posn; + bwipp_data[0] = bwipp_opts_buf[0] = '\0'; bwipp_barcode = testUtilBwippName(symbology, option_1, option_2, option_3, &linear_row_height, &gs1_cvt); @@ -1739,20 +1777,27 @@ int testUtilBwipp(const struct zint_symbol *symbol, int option_1, int option_2, } if (is_composite(symbology)) { - if (symbology == BARCODE_EANX_CC && primary_len <= 7) { - bwipp_barcode = "ean8composite"; - } if (!primary) { fprintf(stderr, "testUtilBwipp: no primary data given %s\n", testUtilBarcodeName(symbology)); return -1; } - if (*primary != '[' && symbology != BARCODE_EANX_CC && symbology != BARCODE_UPCE_CC && symbology != BARCODE_UPCA_CC) { + if (*primary != '[' && !upcean) { strcat(bwipp_data, "(01)"); } strcat(bwipp_data, primary); strcat(bwipp_data, "|"); strcat(bwipp_data, data); - testUtilBwippCvtGS1Data(bwipp_data); + testUtilBwippCvtGS1Data(bwipp_data, upcean, &addon_posn); + + if (upcean) { + if (symbology == BARCODE_EANX_CC && (primary_len <= 8 || (addon_posn && addon_posn <= 8))) { + bwipp_barcode = "ean8composite"; + } + if (addon_posn) { + sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%saddongap=%d", strlen(bwipp_opts_buf) ? " " : "", option_2 > 0 ? option_2 : upca ? 9 : 7); + bwipp_opts = bwipp_opts_buf; + } + } if (option_1 > 0) { sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%sccversion=%c", strlen(bwipp_opts_buf) ? " " : "", option_1 == 1 ? 'a' : option_1 == 2 ? 'b' : 'c'); @@ -1764,11 +1809,24 @@ int testUtilBwipp(const struct zint_symbol *symbol, int option_1, int option_2, } } else { if (gs1_cvt) { - if (*data != '[') { + if (*data != '[' && !upcean) { strcat(bwipp_data, symbology == BARCODE_NVE18 ? "(00)" : "(01)"); } strcat(bwipp_data, data); - testUtilBwippCvtGS1Data(bwipp_data); + testUtilBwippCvtGS1Data(bwipp_data, upcean, &addon_posn); + + if (upcean) { + if ((symbology == BARCODE_EANX || symbology == BARCODE_EANX_CHK) && (data_len <= 8 || (addon_posn && addon_posn <= 8))) { + bwipp_barcode = data_len <= 3 ? "ean2" : data_len <= 5 ? "ean5" : "ean8"; + } + if (symbology == BARCODE_ISBNX) { + testUtilISBNHyphenate(bwipp_data, addon_posn); + } + if (addon_posn) { + sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%saddongap=%d", strlen(bwipp_opts_buf) ? " " : "", option_2 > 0 ? option_2 : upca ? 9 : 7); + bwipp_opts = bwipp_opts_buf; + } + } if (option_2 > 0) { if (symbology == BARCODE_RSS_EXP || symbology == BARCODE_RSS_EXPSTACK) { @@ -1802,13 +1860,11 @@ int testUtilBwipp(const struct zint_symbol *symbol, int option_1, int option_2, if (option_1 > 0) { sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%srows=%d", strlen(bwipp_opts_buf) ? " " : "", option_1); } - //} else { /* BWIPP does not really support both row and column given */ - if (option_2 > 0) { - sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%scolumns=%d", strlen(bwipp_opts_buf) ? " " : "", option_2 - 5); - } else { - sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%scolumns=%d", strlen(bwipp_opts_buf) ? " " : "", (symbol->width - 57) / 11); - } - //} + if (option_2 > 0) { + sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%scolumns=%d", strlen(bwipp_opts_buf) ? " " : "", option_2 - 5); + } else { + sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%scolumns=%d", strlen(bwipp_opts_buf) ? " " : "", (symbol->width - 57) / 11); + } bwipp_opts = bwipp_opts_buf; } else if (symbology == BARCODE_CODE11 || symbology == BARCODE_CODE39 || symbology == BARCODE_EXCODE39 || symbology == BARCODE_LOGMARS) { if (option_2 > 0) { @@ -1843,19 +1899,35 @@ int testUtilBwipp(const struct zint_symbol *symbol, int option_1, int option_2, /* Hack in various adjustments */ if (symbology == BARCODE_RSS14 || symbology == BARCODE_RSS_LTD || symbology == BARCODE_RSS_EXP) { /* Begin with space */ - memmove(cmd + GS_INITIAL_LEN + 5, cmd + GS_INITIAL_LEN, strlen(cmd) + 1 - GS_INITIAL_LEN); - memcpy(cmd + GS_INITIAL_LEN, " -sbs", 5); + char adj[5] = " -sbs"; + memmove(cmd + GS_INITIAL_LEN + sizeof(adj), cmd + GS_INITIAL_LEN, strlen(cmd) + 1 - GS_INITIAL_LEN); + memcpy(cmd + GS_INITIAL_LEN, adj, sizeof(adj)); } if (symbology == BARCODE_CODE11 || symbology == BARCODE_CODE39 || symbology == BARCODE_EXCODE39 || symbology == BARCODE_PZN || symbology == BARCODE_VIN) { /* Ratio 3 width bar/space -> 2 width */ - memmove(cmd + GS_INITIAL_LEN + 8, cmd + GS_INITIAL_LEN, strlen(cmd) + 1 - GS_INITIAL_LEN); - memcpy(cmd + GS_INITIAL_LEN, " -sr=0.6", 8); + char adj[8] = " -sr=0.6"; + memmove(cmd + GS_INITIAL_LEN + sizeof(adj), cmd + GS_INITIAL_LEN, strlen(cmd) + 1 - GS_INITIAL_LEN); + memcpy(cmd + GS_INITIAL_LEN, adj, sizeof(adj)); + } + if (symbology == BARCODE_C25INTER || symbology == BARCODE_DPLEIT || symbology == BARCODE_DPIDENT || symbology == BARCODE_ITF14) { + /* Ratio 2 width bar/space -> 3 width */ + char adj[8] = " -sr=1.3"; + memmove(cmd + GS_INITIAL_LEN + sizeof(adj), cmd + GS_INITIAL_LEN, strlen(cmd) + 1 - GS_INITIAL_LEN); + memcpy(cmd + GS_INITIAL_LEN, adj, sizeof(adj)); } if (symbology == BARCODE_CODE11 || symbology == BARCODE_CODE39 || symbology == BARCODE_EXCODE39 || symbology == BARCODE_HIBC_39 - || symbology == BARCODE_LOGMARS || symbology == BARCODE_PZN || symbology == BARCODE_VIN) { + || symbology == BARCODE_LOGMARS || symbology == BARCODE_PZN || symbology == BARCODE_VIN + || symbology == BARCODE_C25INTER || symbology == BARCODE_DPLEIT || symbology == BARCODE_DPIDENT || symbology == BARCODE_ITF14) { /* End sbs loop on bar */ - memmove(cmd + GS_INITIAL_LEN + 6, cmd + GS_INITIAL_LEN, strlen(cmd) + 1 - GS_INITIAL_LEN); - memcpy(cmd + GS_INITIAL_LEN, " -selb", 6); + char adj[6] = " -selb"; + memmove(cmd + GS_INITIAL_LEN + sizeof(adj), cmd + GS_INITIAL_LEN, strlen(cmd) + 1 - GS_INITIAL_LEN); + memcpy(cmd + GS_INITIAL_LEN, adj, sizeof(adj)); + } + if (symbology == BARCODE_C25MATRIX) { + /* Zint uses 4X start/stop wides while BWIPP uses 3X - convert */ + char adj[91] = " -sp='i 0 eq i limit 4 sub eq or sbs i get 3 eq and { (1111) print true } { false } ifelse'"; + memmove(cmd + GS_INITIAL_LEN + sizeof(adj), cmd + GS_INITIAL_LEN, strlen(cmd) + 1 - GS_INITIAL_LEN); + memcpy(cmd + GS_INITIAL_LEN, adj, sizeof(adj)); } if (symbol->debug & ZINT_DEBUG_TEST_PRINT) { diff --git a/backend/tests/tools/bwipp_dump-barcode.ps.diff b/backend/tests/tools/bwipp_dump-barcode.ps.diff index fb044787..7baa0503 100644 --- a/backend/tests/tools/bwipp_dump-barcode.ps.diff +++ b/backend/tests/tools/bwipp_dump-barcode.ps.diff @@ -1,5 +1,5 @@ ---- ../../../../postscriptbarcode/build/monolithic/barcode.ps 2020-07-10 13:08:57.215118693 +0100 -+++ ../tools/bwipp_dump.ps 2020-07-10 13:44:00.892056648 +0100 +--- ../../../../postscriptbarcode/build/monolithic/barcode.ps 2020-07-14 14:52:24.208222925 +0100 ++++ ../tools/bwipp_dump.ps 2020-07-14 17:29:15.314238749 +0100 @@ -29,6 +29,8 @@ % CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS % IN THE SOFTWARE. @@ -9,7 +9,7 @@ % --BEGIN TEMPLATE-- % --BEGIN RESOURCE preamble-- -@@ -24484,34 +24486,72 @@ +@@ -24485,34 +24487,80 @@ pop } ifelse @@ -64,7 +64,7 @@ + } { + /linsym exch def + /linpixs [ -+ linsym /sbs get { 1 index 1 eq {{0}} {{1}} ifelse repeat } forall % Alternates x 1/0's ++ linsym /sbs get { cvi 1 index 1 eq {{0}} {{1}} ifelse repeat } forall % Alternates x 1/0's + ] def + /linheight linsym /bhs get 0 get 72 mul cvi def @@ -75,18 +75,26 @@ + + /linpad [ ccpixx 97 sub {0} repeat ] def + ++ /diff linpixs length linpad length add 2 add ccpixx sub def % An add-on can make linear wider than composite ++ diff 0 gt { % Left align composite ++ /ccrpad [ diff {0} repeat ] def ++ /pixx ccpixx diff add def ++ } { ++ /ccrpad 0 array def ++ /pixx ccpixx def ++ } ifelse ++ + /pixs [ + 0 ccpixx ccpixs length 1 sub { + /i exch def -+ 2 { ccpixs i ccpixx getinterval aload pop } repeat ++ 2 { ccpixs i ccpixx getinterval aload pop ccrpad aload pop } repeat + } for -+ 2 { linpad aload pop 0 1 93 {0} repeat 1 0 } repeat -+ 2 { linpad aload pop 1 0 93 {0} repeat 0 1 } repeat -+ 2 { linpad aload pop 0 1 93 {0} repeat 1 0 } repeat ++ 2 { linpad aload pop 0 1 93 {0} repeat 1 0 ccrpad aload pop } repeat ++ 2 { linpad aload pop 1 0 93 {0} repeat 0 1 ccrpad aload pop } repeat ++ 2 { linpad aload pop 0 1 93 {0} repeat 1 0 ccrpad aload pop } repeat + linheight { linpad aload pop 0 linpixs aload pop 0 } repeat + ] def + -+ /pixx ccpixx def + /pixy pixs length pixx idiv def + << + /ren //renmatrix @@ -101,7 +109,7 @@ end -@@ -24570,7 +24610,7 @@ +@@ -24571,7 +24619,7 @@ pop } ifelse @@ -110,7 +118,7 @@ % Get the result of encoding with ean8 and gs1-cc options (lintype) (ean8) put -@@ -24578,29 +24618,67 @@ +@@ -24579,29 +24627,75 @@ options (dontdraw) true put % Plot the linear part @@ -157,7 +165,7 @@ + } { + /linsym exch def + /linpixs [ -+ linsym /sbs get { 1 index 1 eq {{0}} {{1}} ifelse repeat } forall % Alternates x 1/0's ++ linsym /sbs get { cvi 1 index 1 eq {{0}} {{1}} ifelse repeat } forall % Alternates x 1/0's + ] def + /linheight linsym /bhs get 0 get 72 mul cvi def @@ -172,18 +180,26 @@ - grestore + /linpad [ ccpixx 69 sub {0} repeat ] def + ++ /diff linpixs length linpad length add 2 add ccpixx sub def % An add-on can make linear wider than composite ++ diff 0 gt { % Left align composite ++ /ccrpad [ diff {0} repeat ] def ++ /pixx ccpixx diff add def ++ } { ++ /ccrpad 0 array def ++ /pixx ccpixx def ++ } ifelse ++ + /pixs [ + 0 ccpixx ccpixs length 1 sub { + /i exch def -+ 2 { ccpixs i ccpixx getinterval aload pop } repeat ++ 2 { ccpixs i ccpixx getinterval aload pop ccrpad aload pop } repeat + } for -+ 2 { linpad aload pop 0 1 65 {0} repeat 1 0 } repeat -+ 2 { linpad aload pop 1 0 65 {0} repeat 0 1 } repeat -+ 2 { linpad aload pop 0 1 65 {0} repeat 1 0 } repeat ++ 2 { linpad aload pop 0 1 65 {0} repeat 1 0 ccrpad aload pop } repeat ++ 2 { linpad aload pop 1 0 65 {0} repeat 0 1 ccrpad aload pop } repeat ++ 2 { linpad aload pop 0 1 65 {0} repeat 1 0 ccrpad aload pop } repeat + linheight { linpad aload pop 0 linpixs aload pop 0 } repeat + ] def + -+ /pixx ccpixx def + /pixy pixs length pixx idiv def + << + /ren //renmatrix @@ -198,7 +214,7 @@ end -@@ -24659,34 +24737,72 @@ +@@ -24660,34 +24754,80 @@ pop } ifelse @@ -253,7 +269,7 @@ + } { + /linsym exch def + /linpixs [ -+ linsym /sbs get { 1 index 1 eq {{0}} {{1}} ifelse repeat } forall % Alternates x 1/0's ++ linsym /sbs get { cvi 1 index 1 eq {{0}} {{1}} ifelse repeat } forall % Alternates x 1/0's + ] def + /linheight linsym /bhs get 0 get 72 mul cvi def @@ -264,18 +280,26 @@ + + /linpad [ ccpixx 97 sub {0} repeat ] def + ++ /diff linpixs length linpad length add 2 add ccpixx sub def % An add-on can make linear wider than composite ++ diff 0 gt { % Left align composite ++ /ccrpad [ diff {0} repeat ] def ++ /pixx ccpixx diff add def ++ } { ++ /ccrpad 0 array def ++ /pixx ccpixx def ++ } ifelse ++ + /pixs [ + 0 ccpixx ccpixs length 1 sub { + /i exch def -+ 2 { ccpixs i ccpixx getinterval aload pop } repeat ++ 2 { ccpixs i ccpixx getinterval aload pop ccrpad aload pop } repeat + } for -+ 2 { linpad aload pop 0 1 93 {0} repeat 1 0 } repeat -+ 2 { linpad aload pop 1 0 93 {0} repeat 0 1 } repeat -+ 2 { linpad aload pop 0 1 93 {0} repeat 1 0 } repeat ++ 2 { linpad aload pop 0 1 93 {0} repeat 1 0 ccrpad aload pop } repeat ++ 2 { linpad aload pop 1 0 93 {0} repeat 0 1 ccrpad aload pop } repeat ++ 2 { linpad aload pop 0 1 93 {0} repeat 1 0 ccrpad aload pop } repeat + linheight { linpad aload pop 0 linpixs aload pop 0 } repeat + ] def + -+ /pixx ccpixx def + /pixy pixs length pixx idiv def + << + /ren //renmatrix @@ -290,7 +314,7 @@ end -@@ -24760,34 +24876,72 @@ +@@ -24761,34 +24901,80 @@ /opt options >> def @@ -345,7 +369,7 @@ + } { + /linsym exch def + /linpixs [ -+ linsym /sbs get { 1 index 1 eq {{0}} {{1}} ifelse repeat } forall % Alternates x 1/0's ++ linsym /sbs get { cvi 1 index 1 eq {{0}} {{1}} ifelse repeat } forall % Alternates x 1/0's + ] def + /linheight linsym /bhs get 0 get 72 mul cvi def @@ -356,18 +380,26 @@ + + /linpad [ ccpixx 53 sub {0} repeat ] def + ++ /diff linpixs length linpad length add 2 add ccpixx sub def % An add-on can make linear wider than composite ++ diff 0 gt { % Left align composite ++ /ccrpad [ diff {0} repeat ] def ++ /pixx ccpixx diff add def ++ } { ++ /ccrpad 0 array def ++ /pixx ccpixx def ++ } ifelse ++ + /pixs [ + 0 ccpixx ccpixs length 1 sub { + /i exch def -+ 2 { ccpixs i ccpixx getinterval aload pop } repeat ++ 2 { ccpixs i ccpixx getinterval aload pop ccrpad aload pop } repeat + } for -+ 2 { linpad aload pop 0 1 49 {0} repeat 1 0 } repeat -+ 2 { linpad aload pop 1 0 49 {0} repeat 0 1 } repeat -+ 2 { linpad aload pop 0 1 49 {0} repeat 1 0 } repeat ++ 2 { linpad aload pop 0 1 49 {0} repeat 1 0 ccrpad aload pop } repeat ++ 2 { linpad aload pop 1 0 49 {0} repeat 0 1 ccrpad aload pop } repeat ++ 2 { linpad aload pop 0 1 49 {0} repeat 1 0 ccrpad aload pop } repeat + linheight { linpad aload pop 0 linpixs aload pop 0 } repeat + ] def + -+ /pixx ccpixx def + /pixy pixs length pixx idiv def + << + /ren //renmatrix @@ -382,7 +414,7 @@ end -@@ -24846,7 +25000,7 @@ +@@ -24847,7 +25033,7 @@ pop } ifelse @@ -391,7 +423,7 @@ options (lintype) (databaromni) put options (linkage) true put -@@ -24857,7 +25011,7 @@ +@@ -24858,7 +25044,7 @@ linear options //databaromni exec dup (sbs) get /linsbs exch def dup (bhs) get 0 get 72 mul /linheight exch def @@ -400,7 +432,7 @@ % Plot the separator /sepfinder { -@@ -24888,20 +25042,66 @@ +@@ -24889,20 +25075,66 @@ sep 0 [0 0 0] putinterval sep sep length 4 sub [0 0 0 0] putinterval 18 sepfinder 64 sepfinder @@ -436,14 +468,14 @@ + /ccpixs compsym /pixs get def + /ccpixx compsym /pixx get def + -+ /linpixs [ 0 % Begin with left guard space -+ linsbs { 1 index 0 eq {{1}} {{0}} ifelse repeat } forall % Alternates x 1/0's ++ /linpixs [ 0 % Begin with left guard space ++ linsbs { cvi 1 index 0 eq {{1}} {{0}} ifelse repeat } forall % Alternates x 1/0's + ] def -+ /sep [ 0 sep aload pop ] def % Pad with left guard space ++ /sep [ 0 sep aload pop ] def % Pad with left guard space + + /linheight linheight cvi def + /diff linpixs length ccpixx sub def -+ diff 0 gt { % Centre align composite, doubling up rows ++ diff 0 gt { % Centre align composite, doubling up rows + /ccpad [ diff 2 idiv {0} repeat ] def + /pixs [ + 0 ccpixx ccpixs length 1 sub { @@ -453,10 +485,10 @@ + sep aload pop linheight { linpixs aload pop } repeat + ] def + /pixx linpixs length def -+ } { % Right pad composite, doubling up rows, and left pad (right align) separator/linear ++ } { % Right pad composite, doubling up rows, and left pad (right align) separator/linear + /linpad [ diff neg 1 add {0} repeat ] def + /pixs [ -+ 0 ccpixx ccpixs length 1 sub { % Right pad composite with 1 space ++ 0 ccpixx ccpixs length 1 sub { % Right pad composite with 1 space + /i exch def + 2 { ccpixs i ccpixx getinterval aload pop 0 } repeat + } for @@ -479,7 +511,7 @@ end -@@ -24959,7 +25159,7 @@ +@@ -24960,7 +25192,7 @@ pop } ifelse @@ -488,7 +520,7 @@ options (lintype) (databarstacked) put options (linkage) true put -@@ -24970,7 +25170,7 @@ +@@ -24971,7 +25203,7 @@ linear options //databarstacked exec dup (pixs) get 0 2 index (pixx) get getinterval /bot exch def dup (pixy) get /linheight exch def @@ -497,7 +529,7 @@ % Plot the separator /sepfinder { -@@ -24998,20 +25198,52 @@ +@@ -24999,20 +25231,52 @@ sep 0 [ 0 0 0 0 ] putinterval sep sep length 4 sub [ 0 0 0 0 ] putinterval 18 sepfinder @@ -537,12 +569,12 @@ + /pixx ccpixx 1 add def + /linpad [ pixx linwidth sub {0} repeat ] def + /pixs [ -+ 0 ccpixx ccpixs length 1 sub { % Left pad composite with 1 space, doubling up rows ++ 0 ccpixx ccpixs length 1 sub { % Left pad composite with 1 space, doubling up rows + /i exch def + 2 { 0 ccpixs i ccpixx getinterval aload pop } repeat + } for + sep aload pop linpad aload pop -+ 0 linwidth linpixs length 1 sub { % Right pad linear ++ 0 linwidth linpixs length 1 sub { % Right pad linear + /i exch def + linpixs i linwidth getinterval aload pop linpad aload pop + } for @@ -562,7 +594,7 @@ end -@@ -25069,7 +25301,7 @@ +@@ -25070,7 +25334,7 @@ pop } ifelse @@ -571,7 +603,7 @@ options (lintype) (databarstackedomni) put options (linkage) true put -@@ -25080,7 +25312,7 @@ +@@ -25081,7 +25345,7 @@ linear options //databarstackedomni exec dup (pixs) get 0 2 index (pixx) get getinterval /bot exch def dup (pixy) get /linheight exch def @@ -580,7 +612,7 @@ % Plot the separator /sepfinder { -@@ -25108,20 +25340,52 @@ +@@ -25109,20 +25373,52 @@ sep 0 [ 0 0 0 0 ] putinterval sep sep length 4 sub [ 0 0 0 0 ] putinterval 18 sepfinder @@ -620,12 +652,12 @@ + /pixx ccpixx 1 add def + /linpad [ pixx linwidth sub {0} repeat ] def + /pixs [ -+ 0 ccpixx ccpixs length 1 sub { % Left pad composite with 1 space, doubling up rows ++ 0 ccpixx ccpixs length 1 sub { % Left pad composite with 1 space, doubling up rows + /i exch def + 2 { 0 ccpixs i ccpixx getinterval aload pop } repeat + } for + sep aload pop linpad aload pop -+ 0 linwidth linpixs length 1 sub { % Right pad linear ++ 0 linwidth linpixs length 1 sub { % Right pad linear + /i exch def + linpixs i linwidth getinterval aload pop linpad aload pop + } for @@ -645,7 +677,7 @@ end -@@ -25294,7 +25558,7 @@ +@@ -25295,7 +25591,7 @@ pop } ifelse @@ -654,7 +686,7 @@ options (lintype) (databarlimited) put options (linkage) true put -@@ -25305,7 +25569,7 @@ +@@ -25306,7 +25602,7 @@ linear options //databarlimited exec dup (sbs) get /linsbs exch def dup (bhs) get 0 get 72 mul /linheight exch def @@ -663,7 +695,7 @@ % Plot the separator mark -@@ -25313,22 +25577,68 @@ +@@ -25314,22 +25610,68 @@ counttomark 1 sub array astore /sep exch def pop pop sep 0 [0 0 0] putinterval sep sep length 4 sub [0 0 0 0] putinterval @@ -703,14 +735,14 @@ + /ccpixx compsym /pixx get def - grestore -+ /linpixs [ 0 % Begin with left guard space -+ linsbs { 1 index 0 eq {{1}} {{0}} ifelse repeat } forall % Alternates x 1/0's ++ /linpixs [ 0 % Begin with left guard space ++ linsbs { cvi 1 index 0 eq {{1}} {{0}} ifelse repeat } forall % Alternates x 1/0's + ] def -+ /sep [ 0 sep aload pop ] def % Offset by 1 ++ /sep [ 0 sep aload pop ] def % Offset by 1 + + /linheight linheight cvi def + /diff linpixs length ccpixx sub def -+ diff 0 gt { % 2 column - centre align ++ diff 0 gt { % 2 column - centre align + /ccpad [ diff 2 idiv {0} repeat ] def + /pixs [ + 0 ccpixx ccpixs length 1 sub { @@ -720,10 +752,10 @@ + sep aload pop linheight { linpixs aload pop } repeat + ] def + /pixx linpixs length def -+ } { % 3/4 column - right pad 1 and right align separator/linear ++ } { % 3/4 column - right pad 1 and right align separator/linear + /linpad [ diff neg 1 add {0} repeat ] def + /pixs [ -+ 0 ccpixx ccpixs length 1 sub { % Right pad composite with 1 space ++ 0 ccpixx ccpixs length 1 sub { % Right pad composite with 1 space + /i exch def + 2 { ccpixs i ccpixx getinterval aload pop 0 } repeat + } for @@ -746,7 +778,7 @@ end -@@ -25387,7 +25697,7 @@ +@@ -25388,7 +25730,7 @@ pop } ifelse @@ -755,7 +787,7 @@ options (lintype) (databarexpanded) put options (linkage) true put -@@ -25398,7 +25708,7 @@ +@@ -25399,7 +25741,7 @@ linear options //databarexpanded exec dup (sbs) get /linsbs exch def dup (bhs) get 0 get 72 mul /linheight exch def @@ -764,7 +796,7 @@ % Plot the separator /sepfinder { -@@ -25427,20 +25737,60 @@ +@@ -25428,20 +25770,60 @@ 18 98 bot length 13 sub {} for 69 98 bot length 13 sub {} for ] {sepfinder} forall @@ -800,10 +832,10 @@ + /ccpixs compsym /pixs get def + /ccpixx compsym /pixx get def + -+ /linpixs [ 0 % Begin with left guard space -+ linsbs { 1 index 0 eq {{1}} {{0}} ifelse repeat } forall % Alternates x 1/0's ++ /linpixs [ 0 % Begin with left guard space ++ linsbs { cvi 1 index 0 eq {{1}} {{0}} ifelse repeat } forall % Alternates x 1/0's + ] def -+ /sep [ 0 sep aload pop ] def % Offset by 1 ++ /sep [ 0 sep aload pop ] def % Offset by 1 + + /linheight linheight cvi def + /diff linpixs length ccpixx sub def @@ -837,7 +869,7 @@ end -@@ -25498,7 +25848,7 @@ +@@ -25499,7 +25881,7 @@ pop } ifelse @@ -846,7 +878,7 @@ options (lintype) (databarexpandedstacked) put options (linkage) true put -@@ -25509,7 +25859,7 @@ +@@ -25510,7 +25892,7 @@ linear options //databarexpandedstacked exec dup (pixs) get 0 2 index (pixx) get getinterval /bot exch def dup (pixy) get /linheight exch def @@ -855,7 +887,7 @@ % Plot the separator /sepfinder { -@@ -25529,27 +25879,55 @@ +@@ -25530,27 +25912,55 @@ } for } bind def /sep [ bot {1 exch sub} forall ] def @@ -900,10 +932,10 @@ + /ccpixx compsym /pixx get def + + /pixx sep length def -+ /cclpad [ pixx ccpixx sub 1 add 2 idiv {0} repeat ] def % Add 1 to allow for odd difference ++ /cclpad [ pixx ccpixx sub 1 add 2 idiv {0} repeat ] def % Add 1 to allow for odd difference + /ccrpad [ pixx ccpixx sub 2 idiv {0} repeat ] def + /pixs [ -+ 0 ccpixx ccpixs length 1 sub { % Centre align composite ++ 0 ccpixx ccpixs length 1 sub { % Centre align composite + /i exch def + 2 { cclpad aload pop ccpixs i ccpixx getinterval aload pop ccrpad aload pop } repeat + } for @@ -925,7 +957,7 @@ end -@@ -25608,7 +25986,7 @@ +@@ -25609,7 +26019,7 @@ pop } ifelse @@ -934,7 +966,7 @@ options (inkspread) (0) put options (dontdraw) true put -@@ -25635,35 +26013,87 @@ +@@ -25636,35 +26046,87 @@ linear << options {} forall >> //gs1-128 exec dup (sbs) get /linsbs exch def dup (bhs) get 0 get 72 mul /linheight exch def @@ -989,23 +1021,23 @@ + /ccpixx compsym /pixx get def + + /linpixs [ -+ linsbs { 1 index 1 eq {{0}} {{1}} ifelse repeat } forall % Alternates x 1/0's ++ linsbs { cvi 1 index 1 eq {{0}} {{1}} ifelse repeat } forall % Alternates x 1/0's + ] def + -+ x 0 gt { % Left pad composite ++ x 0 gt { % Left pad composite + /cclpad [ x {0} repeat ] def + /linlpad 0 array def + /diff linwidth ccpixx x add sub def -+ } { % Left pad linear ++ } { % Left pad linear + /cclpad 0 array def + /linlpad [ x neg {0} repeat ] def + /diff linwidth x sub ccpixx sub def + } ifelse + -+ diff 0 gt { % Right pad composite ++ diff 0 gt { % Right pad composite + /ccrpad [ diff {0} repeat ] def + /linrpad 0 array def -+ } { % Right pad linear ++ } { % Right pad linear + /ccrpad 0 array def + /linrpad [ diff neg {0} repeat ] def + } ifelse @@ -1036,7 +1068,7 @@ end -@@ -26961,3 +27391,115 @@ +@@ -26962,3 +27424,124 @@ % --END ENCODER hibcazteccode-- % --END TEMPLATE-- @@ -1099,15 +1131,15 @@ +ret /pixs known { + /pixs ret /pixs get def + -+ n ret /pixx known and { % If newlines requested and have row width ++ n ret /pixx known and { % If newlines requested and have row width + /pixx ret /pixx get def -+ 0 pixx pixs length 1 sub { % For i = 0; i < pixs length; i += pixx -+ pixs exch pixx getinterval { % For j = i; j < i + pixx; j++ ++ 0 pixx pixs length 1 sub { % For i = 0; i < pixs length; i += pixx ++ pixs exch pixx getinterval { % For j = i; j < i + pixx; j++ + 1 string cvs print + } forall + (\n) print + } for -+ } { % Else dump the whole thing, no newlines ++ } { % Else dump the whole thing, no newlines + pixs { 1 string cvs print } forall + } ifelse +} { @@ -1115,10 +1147,17 @@ + ret /sbs known { + /sbs ret /sbs get def + -+ % Check if given ratio arg to adjust width of bars/spaces (eg "0.6" reduces 3 -> 2) ++ % Check if given preprocessor override ++ systemdict /p known { ++ /p systemdict /p get cvx def ++ } { ++ /p { false } def ++ } ifelse ++ ++ % Check if given ratio arg to adjust width of bars/spaces (e.g. "0.6" reduces 3 -> 2, "1.3" increases 2 -> 3) + systemdict /r known { + /r systemdict /r get cvr def -+ /f { r mul ceiling cvi } def ++ /f { r mul round cvi } def + } { + /f {} def + } ifelse @@ -1135,11 +1174,13 @@ + + 0 1 limit { + /i exch def -+ i 2 mod 0 eq { % i is even -+ sbs i get f { (1) print } repeat -+ } { -+ sbs i get f { (0) print } repeat -+ } ifelse ++ p not { % If not preprocessed ++ i 2 mod 0 eq { % i is even ++ sbs i get f cvi { (1) print } repeat ++ } { ++ sbs i get f cvi { (0) print } repeat ++ } ifelse ++ } if + } for + n { (\n) print } if + } if diff --git a/backend/tests/tools/bwipp_dump.ps.tar.xz b/backend/tests/tools/bwipp_dump.ps.tar.xz index 447a11c9..53f5f9fb 100644 Binary files a/backend/tests/tools/bwipp_dump.ps.tar.xz and b/backend/tests/tools/bwipp_dump.ps.tar.xz differ diff --git a/backend/tests/tools/run_bwipp_tests.sh b/backend/tests/tools/run_bwipp_tests.sh new file mode 100755 index 00000000..fb779d5a --- /dev/null +++ b/backend/tests/tools/run_bwipp_tests.sh @@ -0,0 +1,11 @@ +#!/bin/bash +./test_2of5 -f encode -d $(expr 128 + 16) +./test_channel -f encode -d $(expr 128 + 16) +./test_codablock -f encode -d $(expr 128 + 16) +./test_code -f encode -d $(expr 128 + 16) +./test_code128 -f encode -d $(expr 128 + 16) +./test_composite -d $(expr 128 + 16) +./test_gs1 -f gs1_reduce -d $(expr 128 + 16) +./test_rss -d $(expr 128 + 16) +./test_telepen -f encode -d $(expr 128 + 16) +./test_upcean -f encode -d $(expr 128 + 16) diff --git a/backend/tools/gen_pwr928_table.php b/backend/tools/gen_pwr928_table.php new file mode 100644 index 00000000..598e4ef1 --- /dev/null +++ b/backend/tools/gen_pwr928_table.php @@ -0,0 +1,46 @@ + +*/ +/* vim: set ts=4 sw=4 et : */ + +/* The functions "getBit", "init928" and "encode928" are copyright BSI and are + released with permission under the following terms: + + "Copyright subsists in all BSI publications. BSI also holds the copyright, in the + UK, of the international standardisation bodies. Except as + permitted under the Copyright, Designs and Patents Act 1988 no extract may be + reproduced, stored in a retrieval system or transmitted in any form or by any + means - electronic, photocopying, recording or otherwise - without prior written + permission from BSI. + + "This does not preclude the free use, in the course of implementing the standard, + of necessary details such as symbols, and size, type or grade designations. If these + details are to be used for any other purpose than implementation then the prior + written permission of BSI must be obtained." + + The date of publication for these functions is 31 May 2006 + */ + +$cw = array(0, 0, 0, 0, 0, 0, 1); +$pwr928 = array( $cw ); + +for ($j = 1; $j < 69; $j++) { + for ($v = 0, $i = 6; $i >= 1; $i--) { + $v = (2 * $cw[$i]) + (int)($v / 928); + $pwr928[$j][$i] = $cw[$i] = $v % 928; + } + $pwr928[$j][0] = $cw[0] = (2 * $cw[0]) + (int)($v / 928); +} + +printf("static UINT pwr928[69][7] = {\n"); +for ($i = 0; $i < 69; $i++) { + printf(" { "); + for ($j = 0; $j < 7; $j++) { + printf("%3d, ", $pwr928[$i][$j]); + } + printf("},\n"); +} +printf("};\n"); diff --git a/backend/upcean.c b/backend/upcean.c index 5355fc6e..b8b5c29f 100644 --- a/backend/upcean.c +++ b/backend/upcean.c @@ -305,13 +305,15 @@ static int upce(struct zint_symbol *symbol, unsigned char source[], char dest[]) } /* EAN-2 and EAN-5 add-on codes */ -static void add_on(unsigned char source[], char dest[], int mode) { +static void add_on(unsigned char source[], char dest[], int addon_gap) { char parity[6]; unsigned int i, code_type; /* If an add-on then append with space */ - if (mode != 0) { - strcat(dest, "9"); + if (addon_gap != 0) { + i = strlen(dest); + dest[i] = itoc(addon_gap); + dest[i + 1] = '\0'; } /* Start character */ @@ -704,6 +706,7 @@ INTERNAL int eanx(struct zint_symbol *symbol, unsigned char source[], int src_le unsigned char local_source[20] = {0}; unsigned int latch, reader, writer, with_addon; int error_number, i, plus_count; + int addon_gap = 0; with_addon = FALSE; latch = FALSE; @@ -714,7 +717,7 @@ INTERNAL int eanx(struct zint_symbol *symbol, unsigned char source[], int src_le return ZINT_ERROR_TOO_LONG; } if (symbol->symbology != BARCODE_ISBNX) { - /* ISBN has it's own checking routine */ + /* ISBN has its own checking routine */ error_number = is_sane("0123456789+", source, src_len); if (error_number == ZINT_ERROR_INVALID_DATA) { strcpy(symbol->errtxt, "284: Invalid characters in data"); @@ -741,11 +744,6 @@ INTERNAL int eanx(struct zint_symbol *symbol, unsigned char source[], int src_le } /* Add leading zeroes */ - ustrcpy(local_source, (unsigned char *) ""); - if (symbol->symbology == BARCODE_ISBNX) { - to_upper(local_source); - } - ean_leading_zeroes(symbol, source, local_source); for (reader = 0; reader < ustrlen(local_source); reader++) { @@ -774,6 +772,12 @@ INTERNAL int eanx(struct zint_symbol *symbol, unsigned char source[], int src_le writer++; } } while (reader <= ustrlen(local_source)); + + if (symbol->symbology == BARCODE_UPCA || symbol->symbology == BARCODE_UPCA_CHK || symbol->symbology == BARCODE_UPCA_CC) { + addon_gap = symbol->option_2 >= 9 && symbol->option_2 <= 12 ? symbol->option_2 : 9; + } else { + addon_gap = symbol->option_2 >= 7 && symbol->option_2 <= 12 ? symbol->option_2 : 7; + } } else { strcpy((char*) first_part, (char*) local_source); } @@ -894,12 +898,12 @@ INTERNAL int eanx(struct zint_symbol *symbol, unsigned char source[], int src_le switch (ustrlen(second_part)) { case 0: break; case 2: - add_on(second_part, (char*) dest, 1); + add_on(second_part, (char*) dest, addon_gap); strcat((char*) symbol->text, "+"); strcat((char*) symbol->text, (char*) second_part); break; case 5: - add_on(second_part, (char*) dest, 1); + add_on(second_part, (char*) dest, addon_gap); strcat((char*) symbol->text, "+"); strcat((char*) symbol->text, (char*) second_part); break; diff --git a/backend/vector.c b/backend/vector.c index 5313b60a..2c1a91bd 100644 --- a/backend/vector.c +++ b/backend/vector.c @@ -31,7 +31,6 @@ /* vim: set ts=4 sw=4 et : */ #include -#include #include #ifdef _MSC_VER @@ -45,7 +44,7 @@ INTERNAL int ps_plot(struct zint_symbol *symbol); INTERNAL int svg_plot(struct zint_symbol *symbol); INTERNAL int emf_plot(struct zint_symbol *symbol); -static struct zint_vector_rect *vector_plot_create_rect(float x, float y, float width, float height) { +static struct zint_vector_rect *vector_plot_create_rect(double x, double y, double width, double height) { struct zint_vector_rect *rect; rect = (struct zint_vector_rect*) malloc(sizeof (struct zint_vector_rect)); @@ -72,7 +71,7 @@ static int vector_plot_add_rect(struct zint_symbol *symbol, struct zint_vector_r return 1; } -static struct zint_vector_hexagon *vector_plot_create_hexagon(float x, float y, float diameter) { +static struct zint_vector_hexagon *vector_plot_create_hexagon(double x, double y, double diameter) { struct zint_vector_hexagon *hexagon; hexagon = (struct zint_vector_hexagon*) malloc(sizeof (struct zint_vector_hexagon)); @@ -80,7 +79,7 @@ static struct zint_vector_hexagon *vector_plot_create_hexagon(float x, float y, hexagon->next = NULL; hexagon->x = x; hexagon->y = y; - hexagon->diameter = (float)((diameter * 5.0) / 4.0); // Ugly kludge for legacy support + hexagon->diameter = (diameter * 5.0) / 4.0; // Ugly kludge for legacy support return hexagon; } @@ -96,7 +95,7 @@ static int vector_plot_add_hexagon(struct zint_symbol *symbol, struct zint_vecto return 1; } -static struct zint_vector_circle *vector_plot_create_circle(float x, float y, float diameter, int colour) { +static struct zint_vector_circle *vector_plot_create_circle(double x, double y, double diameter, int colour) { struct zint_vector_circle *circle; circle = (struct zint_vector_circle *) malloc(sizeof (struct zint_vector_circle)); @@ -122,7 +121,7 @@ static int vector_plot_add_circle(struct zint_symbol *symbol, struct zint_vector } static int vector_plot_add_string(struct zint_symbol *symbol, - unsigned char *text, float x, float y, float fsize, float width, + unsigned char *text, double x, double y, double fsize, double width, struct zint_vector_string **last_string) { struct zint_vector_string *string; @@ -196,7 +195,7 @@ static void vector_scale(struct zint_symbol *symbol, int file_type) { struct zint_vector_hexagon *hex; struct zint_vector_circle *circle; struct zint_vector_string *string; - float scale = symbol->scale * 2.0f; + double scale = symbol->scale * 2.0; if ((file_type == OUT_EMF_FILE) && (symbol->symbology == BARCODE_MAXICODE)) { // Increase size to overcome limitations in EMF file format @@ -270,39 +269,44 @@ static void vector_reduce_rectangles(struct zint_symbol *symbol) { INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_type) { int error_number; + double large_bar_height; + int textdone; + int main_width, comp_offset, addon_gap; + unsigned char addon[6]; + int xoffset, yoffset, roffset, boffset; + double addon_text_posn; + int textoffset; + int default_text_posn; + double row_height, row_posn; + int upceanflag = 0; + int addon_latch = 0; + unsigned char textpart1[5], textpart2[7], textpart3[7], textpart4[2]; + int textpos; + int hide_text = 0; + int i, r; + + double text_height; + int rect_count, last_row_start; + int this_row; + struct zint_vector *vector; struct zint_vector_rect *rectangle, *rect, *last_rectangle = NULL; struct zint_vector_hexagon *last_hexagon = NULL; struct zint_vector_string *last_string = NULL; struct zint_vector_circle *last_circle = NULL; - - int i, r, latch; - float textpos, large_bar_height, preset_height, row_height, row_posn = 0.0; - float text_offset, text_height; - int xoffset, yoffset, textdone, main_symbol_width_x; - int roffset, boffset; - char addon[6]; - int large_bar_count, symbol_lead_in; - float addon_text_posn; - float default_text_posn; - int hide_text = 0; - int upceanflag = 0; - int rect_count, last_row_start; - int this_row; - int addon_latch = 0; struct zint_vector_string *string; (void)rotate_angle; /* Not currently implemented */ + // Free any previous rendering structures + vector_free(symbol); + // Sanity check colours - error_number = check_colour_options(symbol); + error_number = output_check_colour_options(symbol); if (error_number != 0) { return error_number; } - // Free any previous rendering structures - vector_free(symbol); - // Allocate memory vector = symbol->vector = (struct zint_vector *) malloc(sizeof (struct zint_vector)); if (!vector) return ZINT_ERROR_MEMORY; @@ -311,121 +315,44 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_ vector->circles = NULL; vector->strings = NULL; - row_height = 0; + large_bar_height = output_large_bar_height(symbol); textdone = 0; - main_symbol_width_x = symbol->width; - strcpy(addon, ""); - symbol_lead_in = 0; - addon_text_posn = 0.0; - rect_count = 0; - last_row_start = 0; - /* - * Determine if there will be any addon texts and text height - */ - latch = 0; - r = 0; - /* Isolate add-on text */ + main_width = symbol->width; + comp_offset = 0; + if (is_extendable(symbol->symbology)) { - for (i = 0; i < (int) ustrlen(symbol->text); i++) { - if (latch == 1) { - addon[r] = symbol->text[i]; - r++; - } - if (symbol->text[i] == '+') { - latch = 1; - } - } - } - addon[r] = '\0'; - - - /* - * Calculate the width of the barcode, especially if there are any extra - * borders or white space to add. - */ - - if (is_composite(symbol->symbology)) { - while (!(module_is_set(symbol, symbol->rows - 1, symbol_lead_in))) { - symbol_lead_in++; - } + upceanflag = output_process_upcean(symbol, &main_width, &comp_offset, addon, &addon_gap); } - /* Certain symbols need whitespace otherwise characters get chopped off the sides */ - if ((symbol->symbology == BARCODE_EANX) || (symbol->symbology == BARCODE_EANX_CHK) - || (symbol->symbology == BARCODE_EANX_CC) || (symbol->symbology == BARCODE_ISBNX)) { - switch (ustrlen(symbol->text)) { - case 13: /* EAN 13 */ - case 16: - case 19: - if (symbol->whitespace_width == 0) { - symbol->whitespace_width = 10; - } - main_symbol_width_x = 96 + symbol_lead_in; - upceanflag = 13; - break; - case 2: - main_symbol_width_x = 22 + symbol_lead_in; - upceanflag = 2; - break; - case 5: - main_symbol_width_x = 49 + symbol_lead_in; - upceanflag = 5; - break; - default: - main_symbol_width_x = 68 + symbol_lead_in; - upceanflag = 8; - } - } else if ((symbol->symbology == BARCODE_UPCA) || (symbol->symbology == BARCODE_UPCA_CHK) - || (symbol->symbology == BARCODE_UPCA_CC)) { - upceanflag = 12; - if (symbol->whitespace_width == 0) { - symbol->whitespace_width = 10; - } - main_symbol_width_x = 96 + symbol_lead_in; - } else if ((symbol->symbology == BARCODE_UPCE) || (symbol->symbology == BARCODE_UPCE_CHK) - || (symbol->symbology == BARCODE_UPCE_CC)) { - upceanflag = 6; - if (symbol->whitespace_width == 0) { - symbol->whitespace_width = 10; - } - main_symbol_width_x = 51 + symbol_lead_in; - } + output_set_whitespace_offsets(symbol, &xoffset, &yoffset, &roffset, &boffset); - if ((!symbol->show_hrt) || (ustrlen(symbol->text) == 0)) { - hide_text = 1; + addon_text_posn = 0.0; + hide_text = ((!symbol->show_hrt) || (ustrlen(symbol->text) == 0)); + + if (hide_text) { text_height = 0.0; - text_offset = upceanflag ? 9.0f : 0.0f; + textoffset = upceanflag ? 9.0 : 0.0; } else { - text_height = upceanflag ? 11.0f : 9.0f; - text_offset = 9.0; + text_height = upceanflag ? 11.0 : 9.0; + textoffset = 9.0; } if (symbol->output_options & SMALL_TEXT) - text_height *= 0.8f; + text_height *= 0.8; - set_whitespace_offsets(symbol, &xoffset, &yoffset, &roffset, &boffset); - - // Determine if height should be overridden - large_bar_count = 0; - preset_height = 0.0; - for (i = 0; i < symbol->rows; i++) { - preset_height += symbol->row_height[i]; - if (symbol->row_height[i] == 0) { - large_bar_count++; - } - } - - vector->width = (float)ceil(symbol->width + (xoffset + roffset)); - vector->height = (float)ceil(symbol->height + text_offset + (yoffset + boffset)); - - large_bar_height = large_bar_count ? (symbol->height - preset_height) / large_bar_count : 0 /*Not used if large_bar_count zero*/; + vector->width = ceil(symbol->width + (xoffset + roffset)); + vector->height = ceil(symbol->height + textoffset + (yoffset + boffset)); if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) { - default_text_posn = symbol->height + text_offset + symbol->border_width + symbol->border_width; + default_text_posn = symbol->height + textoffset + symbol->border_width + symbol->border_width; } else { - default_text_posn = symbol->height + text_offset; + default_text_posn = symbol->height + textoffset; } + row_height = 0.0; + rect_count = 0; + last_row_start = 0; + // Plot rectangles - most symbols created here if ((symbol->symbology != BARCODE_MAXICODE) && ((symbol->output_options & BARCODE_DOTTY_MODE) == 0)) { for (r = 0; r < symbol->rows; r++) { @@ -434,7 +361,7 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_ if (symbol->row_height[this_row] == 0) { row_height = large_bar_height; } else { - row_height = (float)symbol->row_height[this_row]; + row_height = symbol->row_height[this_row]; } row_posn = 0; for (i = 0; i < r; i++) { @@ -453,19 +380,23 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_ do { block_width++; } while (i + block_width < symbol->width && module_is_set(symbol, this_row, i + block_width) == module_is_set(symbol, this_row, i)); - if ((addon_latch == 0) && (r == (symbol->rows - 1)) && (i > main_symbol_width_x)) { - addon_text_posn = row_posn + 8.0f; + if ((addon_latch == 0) && (r == (symbol->rows - 1)) && (i > main_width)) { + addon_text_posn = row_posn + 8.0; addon_latch = 1; } if (module_is_set(symbol, this_row, i)) { /* a bar or colour block */ if (addon_latch == 0) { - rectangle = vector_plot_create_rect((float)(i + xoffset), row_posn, (float)block_width, row_height); + rectangle = vector_plot_create_rect(i + xoffset, row_posn, block_width, row_height); if (symbol->symbology == BARCODE_ULTRA) { rectangle->colour = module_is_set(symbol, this_row, i); } } else { - rectangle = vector_plot_create_rect((float)(i + xoffset), row_posn + 10.0f, (float)block_width, row_height - 5.0f); + if (upceanflag == 12 || upceanflag == 6) { /* UPC-A/E don't descend */ + rectangle = vector_plot_create_rect(i + xoffset, row_posn + 10.0, block_width, row_height > 10.0 ? row_height - 10.0 : 1.0); + } else { + rectangle = vector_plot_create_rect(i + xoffset, row_posn + 10.0, block_width, row_height > 5.0 ? row_height - 5.0 : 1.0); + } } vector_plot_add_rect(symbol, rectangle, &last_rectangle); rect_count++; @@ -479,21 +410,21 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_ // Plot Maxicode symbols if (symbol->symbology == BARCODE_MAXICODE) { struct zint_vector_circle *circle; - vector->width = 37.0f + (xoffset + roffset); - vector->height = 36.0f + (yoffset + boffset); + vector->width = 37.0 + (xoffset + roffset); + vector->height = 36.0 + (yoffset + boffset); // Bullseye - circle = vector_plot_create_circle(17.88f + xoffset, 17.8f + yoffset, 10.85f, 0); + circle = vector_plot_create_circle(17.88 + xoffset, 17.8 + yoffset, 10.85, 0); vector_plot_add_circle(symbol, circle, &last_circle); - circle = vector_plot_create_circle(17.88f + xoffset, 17.8f + yoffset, 8.97f, 1); + circle = vector_plot_create_circle(17.88 + xoffset, 17.8 + yoffset, 8.97, 1); vector_plot_add_circle(symbol, circle, &last_circle); - circle = vector_plot_create_circle(17.88f + xoffset, 17.8f + yoffset, 7.10f, 0); + circle = vector_plot_create_circle(17.88 + xoffset, 17.8 + yoffset, 7.10, 0); vector_plot_add_circle(symbol, circle, &last_circle); - circle = vector_plot_create_circle(17.88f + xoffset, 17.8f + yoffset, 5.22f, 1); + circle = vector_plot_create_circle(17.88 + xoffset, 17.8 + yoffset, 5.22, 1); vector_plot_add_circle(symbol, circle, &last_circle); - circle = vector_plot_create_circle(17.88f + xoffset, 17.8f + yoffset, 3.31f, 0); + circle = vector_plot_create_circle(17.88 + xoffset, 17.8 + yoffset, 3.31, 0); vector_plot_add_circle(symbol, circle, &last_circle); - circle = vector_plot_create_circle(17.88f + xoffset, 17.8f + yoffset, 1.43f, 1); + circle = vector_plot_create_circle(17.88 + xoffset, 17.8 + yoffset, 1.43, 1); vector_plot_add_circle(symbol, circle, &last_circle); /* Hexagons */ @@ -501,8 +432,8 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_ for (i = 0; i < symbol->width; i++) { if (module_is_set(symbol, r, i)) { //struct zint_vector_hexagon *hexagon = vector_plot_create_hexagon(((i * 0.88) + ((r & 1) ? 1.76 : 1.32)), ((r * 0.76) + 0.76), symbol->dot_size); - struct zint_vector_hexagon *hexagon = vector_plot_create_hexagon(((i * 1.23f) + 0.615f + ((r & 1) ? 0.615f : 0.0f)) + xoffset, - ((r * 1.067f) + 0.715f) + yoffset, symbol->dot_size); + struct zint_vector_hexagon *hexagon = vector_plot_create_hexagon(((i * 1.23) + 0.615 + ((r & 1) ? 0.615 : 0.0)) + xoffset, + ((r * 1.067) + 0.715) + yoffset, symbol->dot_size); vector_plot_add_hexagon(symbol, hexagon, &last_hexagon); } } @@ -514,247 +445,204 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_ for (r = 0; r < symbol->rows; r++) { for (i = 0; i < symbol->width; i++) { if (module_is_set(symbol, r, i)) { - struct zint_vector_circle *circle = vector_plot_create_circle(i + 0.5f + xoffset, r + 0.5f + yoffset, 1.0f, 0); + struct zint_vector_circle *circle = vector_plot_create_circle(i + 0.5 + xoffset, r + 0.5 + yoffset, 1.0, 0); vector_plot_add_circle(symbol, circle, &last_circle); } } } } - /* Guard bar extension */ - if (upceanflag == 6) { - i = 0; - for (rect = symbol->vector->rectangles; rect != NULL; rect = rect->next) { - switch (i - last_row_start) { - case 0: - case 1: - case 14: - case 15: - case 16: - rect->height += 5.0; - break; + if (upceanflag) { + /* Guard bar extension */ + if (upceanflag == 6) { /* UPC-E */ + i = 0; + for (rect = symbol->vector->rectangles; rect != NULL; rect = rect->next) { + switch (i - last_row_start) { + case 0: + case 1: + case 14: + case 15: + case 16: + rect->height += 5.0; + break; + } + i++; } - i++; - } - } - - if (upceanflag == 8) { - i = 0; - for (rect = symbol->vector->rectangles; rect != NULL; rect = rect->next) { - switch (i - last_row_start) { - case 0: - case 1: - case 10: - case 11: - case 20: - case 21: - rect->height += 5.0; - break; + } else if (upceanflag == 8) { /* EAN-8 */ + i = 0; + for (rect = symbol->vector->rectangles; rect != NULL; rect = rect->next) { + switch (i - last_row_start) { + case 0: + case 1: + case 10: + case 11: + case 20: + case 21: + rect->height += 5.0; + break; + } + i++; } - i++; - } - } - - if (upceanflag == 12) { - i = 0; - for (rect = symbol->vector->rectangles; rect != NULL; rect = rect->next) { - switch (i - last_row_start) { - case 0: - case 1: - case 2: - case 3: - case 14: - case 15: - case 26: - case 27: - case 28: - case 29: - rect->height += 5.0; - break; + } else if (upceanflag == 12) { /* UPC-A */ + i = 0; + for (rect = symbol->vector->rectangles; rect != NULL; rect = rect->next) { + switch (i - last_row_start) { + case 0: + case 1: + case 2: + case 3: + case 14: + case 15: + case 26: + case 27: + case 28: + case 29: + rect->height += 5.0; + break; + } + i++; } - i++; - } - } - - if (upceanflag == 13) { - i = 0; - for (rect = symbol->vector->rectangles; rect != NULL; rect = rect->next) { - switch (i - last_row_start) { - case 0: - case 1: - case 14: - case 15: - case 28: - case 29: - rect->height += 5.0; - break; + } else if (upceanflag == 13) { /* EAN-13 */ + i = 0; + for (rect = symbol->vector->rectangles; rect != NULL; rect = rect->next) { + switch (i - last_row_start) { + case 0: + case 1: + case 14: + case 15: + case 28: + case 29: + rect->height += 5.0; + break; + } + i++; } - i++; } } /* Add the text */ if (!hide_text) { - char textpart[10]; - float textwidth; - xoffset += symbol_lead_in; + xoffset += comp_offset; - if (upceanflag == 8) { - for (i = 0; i < 4; i++) { - textpart[i] = symbol->text[i]; - } - textpart[4] = '\0'; - textpos = 17; - textwidth = 4.0 * 8.5; - vector_plot_add_string(symbol, (unsigned char *) textpart, textpos + xoffset, default_text_posn, text_height, textwidth, &last_string); - for (i = 0; i < 4; i++) { - textpart[i] = symbol->text[i + 4]; - } - textpart[4] = '\0'; - textpos = 50; - vector_plot_add_string(symbol, (unsigned char *) textpart, (textpos + xoffset), default_text_posn, text_height, textwidth, &last_string); - textdone = 1; - switch (strlen(addon)) { - case 2: - textpos = (float)(xoffset + 86); - textwidth = 2.0f * 8.5f; - vector_plot_add_string(symbol, (unsigned char *) addon, textpos, addon_text_posn, text_height, textwidth, &last_string); - break; - case 5: - textpos = (float)(xoffset + 100); - textwidth = 5.0f * 8.5f; - vector_plot_add_string(symbol, (unsigned char *) addon, textpos, addon_text_posn, text_height, textwidth, &last_string); - break; - } + if (upceanflag) { + double textwidth; + output_upcean_split_text(upceanflag, symbol->text, textpart1, textpart2, textpart3, textpart4); - } + if (upceanflag == 6) { /* UPC-E */ + textpos = -5 + xoffset; + textwidth = 6.2; + vector_plot_add_string(symbol, textpart1, textpos, default_text_posn - 2.0, text_height * (8.0 / 11.0), textwidth, &last_string); + textpos = 24 + xoffset; + textwidth = 6.0 * 8.5; + vector_plot_add_string(symbol, textpart2, textpos, default_text_posn, text_height, textwidth, &last_string); + textpos = 55 + xoffset; + textwidth = 6.2; + vector_plot_add_string(symbol, textpart3, textpos, default_text_posn - 2.0, text_height * (8.0 / 11.0), textwidth, &last_string); + textdone = 1; + switch (ustrlen(addon)) { + case 2: + textpos = 61 + xoffset + addon_gap; + textwidth = 2.0 * 8.5; + vector_plot_add_string(symbol, addon, textpos, addon_text_posn, text_height, textwidth, &last_string); + break; + case 5: + textpos = 75 + xoffset + addon_gap; + textwidth = 5.0 * 8.5; + vector_plot_add_string(symbol, addon, textpos, addon_text_posn, text_height, textwidth, &last_string); + break; + } - if (upceanflag == 13) { - textpart[0] = symbol->text[0]; - textpart[1] = '\0'; - textpos = -5; // 7 - textwidth = 8.5; - vector_plot_add_string(symbol, (unsigned char *) textpart, textpos + xoffset, default_text_posn, text_height, textwidth, &last_string); + } else if (upceanflag == 8) { /* EAN-8 */ + textpos = 17 + xoffset; + textwidth = 4.0 * 8.5; + vector_plot_add_string(symbol, textpart1, textpos, default_text_posn, text_height, textwidth, &last_string); + textpos = 50 + xoffset; + vector_plot_add_string(symbol, textpart2, textpos, default_text_posn, text_height, textwidth, &last_string); + textdone = 1; + switch (ustrlen(addon)) { + case 2: + textpos = 77 + xoffset + addon_gap; + textwidth = 2.0 * 8.5; + vector_plot_add_string(symbol, addon, textpos, addon_text_posn, text_height, textwidth, &last_string); + break; + case 5: + textpos = 91 + xoffset + addon_gap; + textwidth = 5.0 * 8.5; + vector_plot_add_string(symbol, addon, textpos, addon_text_posn, text_height, textwidth, &last_string); + break; + } - for (i = 0; i < 6; i++) { - textpart[i] = symbol->text[i + 1]; - } - textpart[6] = '\0'; - textpos = 25; - textwidth = 6.0 * 8.5; - vector_plot_add_string(symbol, (unsigned char *) textpart, textpos + xoffset, default_text_posn, text_height, textwidth, &last_string); - for (i = 0; i < 6; i++) { - textpart[i] = symbol->text[i + 7]; - } - textpart[6] = '\0'; - textpos = 72; - vector_plot_add_string(symbol, (unsigned char *) textpart, textpos + xoffset, default_text_posn, text_height, textwidth, &last_string); - textdone = 1; - switch (strlen(addon)) { - case 2: - textpos = (float)(xoffset + 114); - textwidth = 2.0f * 8.5f; - vector_plot_add_string(symbol, (unsigned char *) addon, textpos, addon_text_posn, text_height, textwidth, &last_string); - break; - case 5: - textpos = (float)(xoffset + 128); - textwidth = 5.0f * 8.5f; - vector_plot_add_string(symbol, (unsigned char *) addon, textpos, addon_text_posn, text_height, textwidth, &last_string); - break; + } else if (upceanflag == 12) { /* UPC-A */ + textpos = -5 + xoffset; + textwidth = 6.2; + vector_plot_add_string(symbol, textpart1, textpos, default_text_posn - 2.0, text_height * (8.0 / 11.0), textwidth, &last_string); + textpos = 27 + xoffset; + textwidth = 5.0 * 8.5; + vector_plot_add_string(symbol, textpart2, textpos, default_text_posn, text_height, textwidth, &last_string); + textpos = 68 + xoffset; + vector_plot_add_string(symbol, textpart3, textpos, default_text_posn, text_height, textwidth, &last_string); + textpos = 100 + xoffset; + textwidth = 6.2; + vector_plot_add_string(symbol, textpart4, textpos, default_text_posn - 2.0, text_height * (8.0 / 11.0), textwidth, &last_string); + textdone = 1; + switch (ustrlen(addon)) { + case 2: + textpos = 107 + xoffset + addon_gap; + textwidth = 2.0 * 8.5; + vector_plot_add_string(symbol, addon, textpos, addon_text_posn, text_height, textwidth, &last_string); + break; + case 5: + textpos = 121 + xoffset + addon_gap; + textwidth = 5.0 * 8.5; + vector_plot_add_string(symbol, addon, textpos, addon_text_posn, text_height, textwidth, &last_string); + break; + } + + } else if (upceanflag == 13) { /* EAN-13 */ + textpos = -7 + xoffset; + textwidth = 8.5; + vector_plot_add_string(symbol, textpart1, textpos, default_text_posn, text_height, textwidth, &last_string); + textpos = 24 + xoffset; + textwidth = 6.0 * 8.5; + vector_plot_add_string(symbol, textpart2, textpos, default_text_posn, text_height, textwidth, &last_string); + textpos = 71 + xoffset; + vector_plot_add_string(symbol, textpart3, textpos, default_text_posn, text_height, textwidth, &last_string); + textdone = 1; + switch (ustrlen(addon)) { + case 2: + textpos = 105 + xoffset + addon_gap; + textwidth = 2.0 * 8.5; + vector_plot_add_string(symbol, addon, textpos, addon_text_posn, text_height, textwidth, &last_string); + break; + case 5: + textpos = 119 + xoffset + addon_gap; + textwidth = 5.0 * 8.5; + vector_plot_add_string(symbol, addon, textpos, addon_text_posn, text_height, textwidth, &last_string); + break; + } } } - if (upceanflag == 12) { - textpart[0] = symbol->text[0]; - textpart[1] = '\0'; - textpos = -5; - textwidth = 6.2f; - vector_plot_add_string(symbol, (unsigned char *) textpart, textpos + xoffset, default_text_posn - 2.0f, text_height * (8.0f / 11.0f), textwidth, &last_string); - for (i = 0; i < 5; i++) { - textpart[i] = symbol->text[i + 1]; - } - textpart[5] = '\0'; - textpos = 27; - textwidth = 5.0f * 8.5f; - vector_plot_add_string(symbol, (unsigned char *) textpart, textpos + xoffset, default_text_posn, text_height, textwidth, &last_string); - for (i = 0; i < 5; i++) { - textpart[i] = symbol->text[i + 6]; - } - textpos = 68; - vector_plot_add_string(symbol, (unsigned char *) textpart, textpos + xoffset, default_text_posn, text_height, textwidth, &last_string); - textpart[0] = symbol->text[11]; - textpart[1] = '\0'; - textpos = 100; - textwidth = 6.2f; - vector_plot_add_string(symbol, (unsigned char *) textpart, textpos + xoffset, default_text_posn - 2.0f, text_height * (8.0f / 11.0f), textwidth, &last_string); - textdone = 1; - switch (strlen(addon)) { - case 2: - textpos = (float)(xoffset + 116); - textwidth = 2.0f * 8.5f; - vector_plot_add_string(symbol, (unsigned char *) addon, textpos, addon_text_posn, text_height, textwidth, &last_string); - break; - case 5: - textpos = (float)(xoffset + 130); - textwidth = 5.0f * 8.5f; - vector_plot_add_string(symbol, (unsigned char *) addon, textpos, addon_text_posn, text_height, textwidth, &last_string); - break; + if (!textdone) { + /* Put normal human readable text at the bottom (and centered) */ + // calculate start xoffset to center text + vector_plot_add_string(symbol, symbol->text, main_width / 2.0 + xoffset, default_text_posn, text_height, symbol->width, &last_string); + + // Remove control characters from readable text + // This only applies to Code 128 + string = symbol->vector->strings; + if (string) { + for (i = 0; i < string->length; i++) { + if (string->text[i] < ' ') { + string->text[i] = ' '; + } + } } } - if (upceanflag == 6) { - textpart[0] = symbol->text[0]; - textpart[1] = '\0'; - textpos = -5; - textwidth = 6.2f; - vector_plot_add_string(symbol, (unsigned char *) textpart, textpos + xoffset, default_text_posn - 2.0f, text_height * (8.0f / 11.0f), textwidth, &last_string); - for (i = 0; i < 6; i++) { - textpart[i] = symbol->text[i + 1]; - } - textpart[6] = '\0'; - textpos = 24; - textwidth = 6.0 * 8.5; - vector_plot_add_string(symbol, (unsigned char *) textpart, textpos + xoffset, default_text_posn, text_height, textwidth, &last_string); - textpart[0] = symbol->text[7]; - textpart[1] = '\0'; - textpos = 55; - textwidth = 6.2f; - vector_plot_add_string(symbol, (unsigned char *) textpart, textpos + xoffset, default_text_posn - 2.0f, text_height * (8.0f / 11.0f), textwidth, &last_string); - textdone = 1; - switch (strlen(addon)) { - case 2: - textpos = (float)(xoffset + 70); - textwidth = 2.0f * 8.5f; - vector_plot_add_string(symbol, (unsigned char *) addon, textpos, addon_text_posn, text_height, textwidth, &last_string); - break; - case 5: - textpos = (float)(xoffset + 84); - textwidth = 5.0f * 8.5f; - vector_plot_add_string(symbol, (unsigned char *) addon, textpos, addon_text_posn, text_height, textwidth, &last_string); - break; - } - } - - /* Put normal human readable text at the bottom (and centered) */ - if (textdone == 0) { - // caculate start xoffset to center text - vector_plot_add_string(symbol, symbol->text, (symbol->width / 2.0f) + xoffset, default_text_posn, text_height, (float)symbol->width, &last_string); - } - - xoffset -= symbol_lead_in; // Restore xoffset - } - - //Remove control characters from readable text - // This only applies to Code 128 - string = symbol->vector->strings; - if (string) { - for (i = 0; i < string->length; i++) { - if (string->text[i] < ' ') { - string->text[i] = ' '; - } - } + xoffset -= comp_offset; // Restore xoffset } // Binding and boxes @@ -767,7 +655,7 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_ /* row binding */ for (r = 1; r < symbol->rows; r++) { if (symbol->symbology != BARCODE_CODABLOCKF && symbol->symbology != BARCODE_HIBC_BLOCKF) { - rectangle = vector_plot_create_rect((float)xoffset, (r * row_height) + yoffset - sep_height / 2, (float)symbol->width, sep_height); + rectangle = vector_plot_create_rect(xoffset, (r * row_height) + yoffset - sep_height / 2, symbol->width, sep_height); vector_plot_add_rect(symbol, rectangle, &last_rectangle); } else { /* Avoid 11-module start and 13-module stop chars */ @@ -779,26 +667,26 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_ } if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) { // Top - rectangle = vector_plot_create_rect(0.0f, 0.0f, vector->width, (float)symbol->border_width); + rectangle = vector_plot_create_rect(0.0, 0.0, vector->width, symbol->border_width); if (!(symbol->output_options & BARCODE_BOX) && (symbol->symbology == BARCODE_CODABLOCKF || symbol->symbology == BARCODE_HIBC_BLOCKF)) { - rectangle->x = (float)xoffset; - rectangle->width -= (2.0f * xoffset); + rectangle->x = xoffset; + rectangle->width -= (2.0 * xoffset); } vector_plot_add_rect(symbol, rectangle, &last_rectangle); // Bottom - rectangle = vector_plot_create_rect(0.0f, vector->height - symbol->border_width - text_offset, vector->width, (float)symbol->border_width); + rectangle = vector_plot_create_rect(0.0, 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->x = (float)xoffset; - rectangle->width -= (2.0f * xoffset); + rectangle->x = xoffset; + rectangle->width -= (2.0 * xoffset); } vector_plot_add_rect(symbol, rectangle, &last_rectangle); } if (symbol->output_options & BARCODE_BOX) { // Left - rectangle = vector_plot_create_rect(0.0f, 0.0f, (float)symbol->border_width, vector->height - text_offset); + rectangle = vector_plot_create_rect(0.0, 0.0, symbol->border_width, vector->height - textoffset); vector_plot_add_rect(symbol, rectangle, &last_rectangle); // Right - rectangle = vector_plot_create_rect(vector->width - symbol->border_width, 0.0f, (float)symbol->border_width, vector->height - text_offset); + rectangle = vector_plot_create_rect(vector->width - symbol->border_width, 0.0, symbol->border_width, vector->height - textoffset); vector_plot_add_rect(symbol, rectangle, &last_rectangle); } diff --git a/docs/manual.txt b/docs/manual.txt index 5c4de702..daddb9b0 100644 --- a/docs/manual.txt +++ b/docs/manual.txt @@ -297,7 +297,7 @@ Numeric Value | Barcode Name 72 | EAN-14 73 | Vehicle Identification Number 74 | Codablock-F -75 | NVE-18 +75 | NVE-18 (SSCC-18) 76 | Japanese Postal Code 77 | Korea Post 79 | GS1 DataBar Stacked (stacked version of GS1 DataBar Truncated) @@ -352,7 +352,7 @@ example: zint --height=100 -d "This Text" -This specifies a symbol height of 100 times the x-resolution of the symbol. +This specifies a symbol height of 100 times the X-dimension of the symbol. 4.5 Adjusting whitespace ------------------------ @@ -361,7 +361,7 @@ altered using the –w switch. For example: zint -w 10 -d "This Text" -This specifies a whitespace width of 10 times the x-resolution of the symbol. +This specifies a whitespace width of 10 times the X-dimension of the symbol. 4.6 Adding boundary bars and boxes ---------------------------------- @@ -376,7 +376,7 @@ For example: zint --box --border=10 -d "This" -gives a box with a width 10 times the x-resolution of the symbol. +gives a box with a width 10 times the X-dimension of the symbol. 4.7 Using colour ---------------- @@ -1031,7 +1031,7 @@ Value | 72 | BARCODE_EAN14 | EAN-14 73 | BARCODE_VIN | Vehicle Identification Number 74 | BARCODE_CODABLOCKF | Codablock-F -75 | BARCODE_NVE18 | NVE-18 +75 | BARCODE_NVE18 | NVE-18 (SSCC-18) 76 | BARCODE_JAPANPOST | Japanese Postal Code 77 | BARCODE_KOREAPOST | Korea Post 79 | BARCODE_RSS14STACK | GS1 DataBar Stacked @@ -1245,8 +1245,13 @@ my_symbol->symbology = BARCODE_UPCA; error = ZBarcode_Encode_and_Print(my_symbol, "72527270270+12345"); -If your input data already includes the check digit symbology 35 can be used -which takes a 12 digit input and validates the check digit before encoding. +If your input data already includes the check digit symbology BARCODE_UPCA_CHK +(35) can be used which takes a 12 digit input and validates the check digit +before encoding. + +You can adjust the gap between the main symbol and an add-on in multiples of +the X-dimension by setting --addongap= (option_2) to a value between 9 (default) +and 12. 6.1.3.2 UPC Version E --------------------- @@ -1265,8 +1270,13 @@ my_symbol->symbology = BARCODE_UPCE; error = ZBarcode_Encode_and_Print(my_symbol, "1123456"); -If your input data already includes the check digit symbology 38 can be used -which takes a 7 or 8 digit input and validates the check digit before encoding. +If your input data already includes the check digit symbology BARCODE_UPCE_CHK +(38) can be used which takes a 7 or 8 digit input and validates the check digit +before encoding. + +You can adjust the gap between the main symbol and an add-on in multiples of +the X-dimension by setting --addongap= (option_2) to a value between 7 (default) +and 12. 6.1.4 European Article Number (EN 797) -------------------------------------- @@ -1296,8 +1306,12 @@ error = ZBarcode_Encode_and_Print(my_symbol, "7432365+54321"); All of the EAN symbols include check digits which are added by Zint. If you are encoding an EAN-8 or EAN-13 symbol and your data already includes -the check digit then you can use symbology 14 which takes an 8 or 13 digit input -and validates the check digit before encoding. +the check digit then you can use symbology BARCODE_EANX_CHK (14) which takes an +8 or 13 digit input and validates the check digit before encoding. + +You can adjust the gap between the main symbol and an add-on in multiples of +the X-dimension by setting --addongap= (option_2) to a value between 7 (default) +and 12. 6.1.4.2 SBN, ISBN and ISBN-13 ----------------------------- @@ -1305,7 +1319,8 @@ EAN-13 symbols (also known as Bookland EAN-13) can also be produced from 9-digit SBN, 10-digit ISBN or 13-digit ISBN-13 data. The relevant check digit needs to be present in the input data and will be verified before the symbol is generated. In addition EAN-2 and EAN-5 add-on symbols can be added using the + -symbol as with UPC symbols. +symbol as with UPC symbols, and the gap set with --addongap= (option_2) to +between 7 (default) and 12. 6.1.5 Plessey ------------- @@ -1454,11 +1469,12 @@ zint --barcode=16 -d "[01]98898765432106[3202]012345[15]991231" A shorter version of GS1-128 which encodes GTIN data only. A 13 digit number is required. The GTIN check digit and AI (01) are added by Zint. -6.1.11.5 NVE-18 ---------------- -A variation of Code 128 the "Nummer der Versandeinheit" standard includes both -modulo-10 and modulo-103 check digits. NVE-18 requires a 17 digit numerical -input and check digits are added by Zint. +6.1.11.5 NVE-18 (SSCC-18) +------------------------- +A variation of Code 128 the "Nummer der Versandeinheit" standard, also known as +SSCC-18 (Serial Shipping Container Code), includes both modulo-10 and modulo-103 +check digits. NVE-18 requires a 17 digit numerical input. Check digits and AI +(00) are added by Zint. 6.1.11.6 HIBC Code 128 ---------------------- diff --git a/frontend/main.c b/frontend/main.c index ef47fa92..eb6aacd1 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -78,6 +78,7 @@ static void usage(void) { printf( "Zint version %d.%d.%d\n" "Encode input data in a barcode and save as BMP/EMF/EPS/GIF/PCX/PNG/SVG/TIF/TXT\n\n" " -b, --barcode=NUMBER Number of barcode type. Default is 20 (Code 128)\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" " --binary Treat input as raw binary data\n" @@ -420,6 +421,27 @@ static int is_stackable(const int symbology) { return 0; } +/* Indicates which symbols can have addon (EAN-2 and EAN-5) + * Note: if change this must also change version in backend/common.c */ +static int is_extendable(const int symbology) { + + switch (symbology) { + case BARCODE_EANX: + case BARCODE_EANX_CHK: + case BARCODE_UPCA: + case BARCODE_UPCA_CHK: + case BARCODE_UPCE: + case BARCODE_UPCE_CHK: + case BARCODE_ISBNX: + case BARCODE_EANX_CC: + case BARCODE_UPCA_CC: + case BARCODE_UPCE_CC: + return 1; + } + + return 0; +} + int main(int argc, char **argv) { struct zint_symbol *my_symbol; int error_number; @@ -429,6 +451,7 @@ int main(int argc, char **argv) { int mirror_mode; int fullmultibyte; int separator; + int addon_gap; char filetype[4]; int i; @@ -441,6 +464,7 @@ int main(int argc, char **argv) { mirror_mode = 0; fullmultibyte = 0; separator = 0; + addon_gap = 0; for (i = 0; i < 4; i++) { filetype[i] = '\0'; @@ -491,6 +515,7 @@ int main(int argc, char **argv) { {"small", 0, 0, 0}, {"bold", 0, 0, 0}, {"cmyk", 0, 0, 0}, + {"addongap", 1, 0, 0}, {"batch", 0, 0, 0}, {"mirror", 0, 0, 0}, {"dotty", 0, 0, 0}, @@ -591,6 +616,19 @@ int main(int argc, char **argv) { separator = 0; } } + if (!strcmp(long_options[option_index].name, "addongap")) { + error_number = validator(NESET, optarg); + if (error_number == ZINT_ERROR_INVALID_DATA) { + fprintf(stderr, "Error 139: Invalid add-on gap value\n"); + exit(1); + } + addon_gap = atoi(optarg); + if (addon_gap < 7 || addon_gap > 12) { + fprintf(stderr, "Warning 140: Invalid add-on gap value\n"); + fflush(stderr); + addon_gap = 0; + } + } if (!strcmp(long_options[option_index].name, "dotsize")) { my_symbol->dot_size = (float) (atof(optarg)); if (my_symbol->dot_size < 0.01) { @@ -816,6 +854,9 @@ int main(int argc, char **argv) { } else if (separator && is_stackable(my_symbol->symbology)) { my_symbol->option_3 = separator; } + if (addon_gap && is_extendable(my_symbol->symbology)) { + my_symbol->option_2 = addon_gap; + } error_number = ZBarcode_Encode(my_symbol, (unsigned char*) optarg, strlen(optarg)); generated = 1; if (error_number != 0) { diff --git a/frontend_qt/CMakeLists.txt b/frontend_qt/CMakeLists.txt index 920a15f8..cf8090e6 100644 --- a/frontend_qt/CMakeLists.txt +++ b/frontend_qt/CMakeLists.txt @@ -8,9 +8,9 @@ set(zint-qt_SRCS barcodeitem.cpp main.cpp mainwindow.cpp datawindow.cpp sequen QT5_WRAP_CPP(zint-qt_SRCS mainwindow.h datawindow.h sequencewindow.h exportwindow.h) QT5_WRAP_UI(zint-qt_SRCS mainWindow.ui extData.ui extSequence.ui extExport.ui) -# grpAztec.ui grpC49.ui grpDBExtend.ui grpLOGMARS.ui grpPDF417.ui grpVIN.ui -# grpC11.ui grpChannel.ui grpDM.ui grpMaxicode.ui grpPZN.ui -# grpC128.ui grpCodabar.ui grpDotCode.ui grpMicroPDF.ui grpQR.ui +# grpAztec.ui grpC49.ui grpDBExtend.ui grpLOGMARS.ui grpPDF417.ui grpUPCA.ui +# grpC11.ui grpChannel.ui grpDM.ui grpMaxicode.ui grpPZN.ui grpUPCEAN.ui +# grpC128.ui grpCodabar.ui grpDotCode.ui grpMicroPDF.ui grpQR.ui grpVIN.ui # grpC16k.ui grpCodablockF.ui grpGrid.ui grpMQR.ui grpRMQR.ui # grpC39.ui grpCodeOne.ui grpHX.ui grpMSICheck.ui grpUltra.ui diff --git a/frontend_qt/frontend_qt.pro b/frontend_qt/frontend_qt.pro index 48ef0cef..ba5f88fa 100644 --- a/frontend_qt/frontend_qt.pro +++ b/frontend_qt/frontend_qt.pro @@ -39,6 +39,8 @@ FORMS += extData.ui \ grpPDF417.ui \ grpQR.ui \ grpRMQR.ui \ + grpUPCA.ui \ + grpUPCEAN.ui \ grpVIN.ui \ mainWindow.ui \ grpDotCode.ui diff --git a/frontend_qt/grpUPCA.ui b/frontend_qt/grpUPCA.ui new file mode 100644 index 00000000..3e9361f6 --- /dev/null +++ b/frontend_qt/grpUPCA.ui @@ -0,0 +1,81 @@ + + + grpUPCA + + + + 0 + 0 + 310 + 78 + + + + + 600 + 16777215 + + + + Form + + + + + + + + &Add-on Gap: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + cmbUPCAAddonGap + + + + + + + + 9 X (default) + + + + + 10 X + + + + + 11 X + + + + + 12 X + + + + + + + + + + Qt::Vertical + + + + 20 + 30 + + + + + + + + + diff --git a/frontend_qt/grpUPCEAN.ui b/frontend_qt/grpUPCEAN.ui new file mode 100644 index 00000000..d520fa9f --- /dev/null +++ b/frontend_qt/grpUPCEAN.ui @@ -0,0 +1,91 @@ + + + grpUPCEAN + + + + 0 + 0 + 310 + 78 + + + + + 600 + 16777215 + + + + Form + + + + + + + + &Add-on Gap: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + cmbUPCEANAddonGap + + + + + + + + 7 X (default) + + + + + 8 X + + + + + 9 X + + + + + 10 X + + + + + 11 X + + + + + 12 X + + + + + + + + + + Qt::Vertical + + + + 20 + 30 + + + + + + + + + diff --git a/frontend_qt/mainwindow.cpp b/frontend_qt/mainwindow.cpp index 8d9a24ac..61dcb1ea 100644 --- a/frontend_qt/mainwindow.cpp +++ b/frontend_qt/mainwindow.cpp @@ -96,7 +96,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags fl) "MicroPDF417 (ISO 24728)", "Micro QR Code", "MSI Plessey", - "NVE-18", + "NVE-18 (SSCC-18)", "PDF417 (ISO 15438)", "Pharmacode", "Pharmacode 2-track", @@ -722,7 +722,7 @@ void MainWindow::change_options() tabMain->insertTab(1,m_optionWidget,tr("GS1 DataBar Stacked")); connect(m_optionWidget->findChild("cmbCols"), SIGNAL(currentIndexChanged ( int )), SLOT(update_preview())); } - + if (symbology == BARCODE_ULTRA) { QFile file(":/grpUltra.ui"); @@ -738,6 +738,36 @@ void MainWindow::change_options() connect(m_optionWidget->findChild("radUltraGS1"), SIGNAL(clicked( bool )), SLOT(update_preview())); } + if (symbology == BARCODE_UPCA || symbology == BARCODE_UPCA_CHK || symbology == BARCODE_UPCA_CC) + { + QFile file(":/grpUPCA.ui"); + if (!file.open(QIODevice::ReadOnly)) + return; + m_optionWidget=uiload.load(&file); + file.close(); + tabMain->insertTab(1, m_optionWidget, tr("UPC-A")); + connect(m_optionWidget->findChild("cmbUPCAAddonGap"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview())); + } + + if (symbology == BARCODE_EANX || symbology == BARCODE_EANX_CHK || symbology == BARCODE_EANX_CC + || symbology == BARCODE_UPCE || symbology == BARCODE_UPCE_CHK || symbology == BARCODE_UPCE_CC + || symbology == BARCODE_ISBNX) + { + QFile file(":/grpUPCEAN.ui"); + if (!file.open(QIODevice::ReadOnly)) + return; + m_optionWidget=uiload.load(&file); + file.close(); + if (symbology == BARCODE_UPCE || symbology == BARCODE_UPCE_CHK || symbology == BARCODE_UPCE_CC) { + tabMain->insertTab(1, m_optionWidget, tr("UPC-E")); + } else if (symbology == BARCODE_ISBNX) { + tabMain->insertTab(1, m_optionWidget, tr("ISBN")); + } else { + tabMain->insertTab(1, m_optionWidget, tr("EAN")); + } + connect(m_optionWidget->findChild("cmbUPCEANAddonGap"), SIGNAL(currentIndexChanged( int )), SLOT(update_preview())); + } + if (symbology == BARCODE_VIN) { QFile file(":/grpVIN.ui"); @@ -812,8 +842,27 @@ void MainWindow::maxi_primary() } } +void MainWindow::upcean_addon_gap(QComboBox *comboBox, QLabel* label, int base) +{ + const QRegularExpression addonRE("^[0-9X]+[+][0-9]+$"); + int item_val; + + if (txtData->text().contains(addonRE)) { + comboBox->setEnabled(true); + label->setEnabled(true); + item_val = comboBox->currentIndex(); + if (item_val) { + m_bc.bc.setOption2(item_val + base); + } + } else { + comboBox->setEnabled(false); + label->setEnabled(false); + } +} + void MainWindow::update_preview() { + int symbology = metaObject()->enumerator(0).value(bstyle->currentIndex()); int width = view->geometry().width(); int height = view->geometry().height(); int item_val; @@ -838,8 +887,9 @@ void MainWindow::update_preview() m_bc.bc.setHideText(1); } m_bc.bc.setGSSep(false); - switch(metaObject()->enumerator(0).value(bstyle->currentIndex())) - { + + switch (symbology) { + case BARCODE_CODE128: if(m_optionWidget->findChild("radC128Stand")->isChecked()) m_bc.bc.setSymbol(BARCODE_CODE128); @@ -864,6 +914,12 @@ void MainWindow::update_preview() m_bc.bc.setSymbol(BARCODE_EANX_CC); else m_bc.bc.setSymbol(BARCODE_EANX); + upcean_addon_gap(m_optionWidget->findChild("cmbUPCEANAddonGap"), m_optionWidget->findChild("lblUPCEANAddonGap"), 7 /*base*/); + break; + + case BARCODE_ISBNX: + m_bc.bc.setSymbol(symbology); + upcean_addon_gap(m_optionWidget->findChild("cmbUPCEANAddonGap"), m_optionWidget->findChild("lblUPCEANAddonGap"), 7 /*base*/); break; case BARCODE_UPCA: @@ -871,6 +927,7 @@ void MainWindow::update_preview() m_bc.bc.setSymbol(BARCODE_UPCA_CC); else m_bc.bc.setSymbol(BARCODE_UPCA); + upcean_addon_gap(m_optionWidget->findChild("cmbUPCAAddonGap"), m_optionWidget->findChild("lblUPCAAddonGap"), 9 /*base*/); break; case BARCODE_UPCE: @@ -878,6 +935,7 @@ void MainWindow::update_preview() m_bc.bc.setSymbol(BARCODE_UPCE_CC); else m_bc.bc.setSymbol(BARCODE_UPCE); + upcean_addon_gap(m_optionWidget->findChild("cmbUPCEANAddonGap"), m_optionWidget->findChild("lblUPCEANAddonGap"), 7 /*base*/); break; case BARCODE_RSS14: @@ -1196,7 +1254,7 @@ void MainWindow::update_preview() m_bc.bc.setSecurityLevel(item_val); } break; - + case BARCODE_ULTRA: m_bc.bc.setSymbol(BARCODE_ULTRA); if(m_optionWidget->findChild("radUltraEcc")->isChecked()) @@ -1213,7 +1271,7 @@ void MainWindow::update_preview() break; default: - m_bc.bc.setSymbol(metaObject()->enumerator(0).value(bstyle->currentIndex())); + m_bc.bc.setSymbol(symbology); break; } diff --git a/frontend_qt/mainwindow.h b/frontend_qt/mainwindow.h index f8123fea..8c71eb9b 100644 --- a/frontend_qt/mainwindow.h +++ b/frontend_qt/mainwindow.h @@ -129,6 +129,7 @@ public slots: protected: void resizeEvent(QResizeEvent *event); + void upcean_addon_gap(QComboBox *comboBox, QLabel* label, int base); private slots: bool save(); diff --git a/frontend_qt/resources.qrc b/frontend_qt/resources.qrc index 926cffd6..0c4fe5ac 100644 --- a/frontend_qt/resources.qrc +++ b/frontend_qt/resources.qrc @@ -29,6 +29,8 @@ grpCodablockF.ui grpRMQR.ui grpUltra.ui + grpUPCA.ui + grpUPCEAN.ui grpVIN.ui