Add compliant height, using ZINT_COMPLIANT_HEIGHT flag for back-compatibility

Rename barcode funcs to same as BARCODE_XXX name
library: barcode funcs array for dispatch, used for ZBarcode_ValidID() also
general: change is_sane() comparison to nonzero from ZINT_ERROR_INVALID_OPTION
MAILMARK: fuller error messages
CODABAR: add option to show check character in HRT
zint.h: use 0xNNNN for OR-able defines
GUI: add guard descent height reset button, add Zint version to window title,
  static get_zint_version() method, use QStringLiteral (QSL shorthand),
  use SIGNAL(toggled()), add errtxt "popup" and status bar, add icons,
  add saveAs shortcut, add main menu, context menus and actions, add help,
  reset_view() -> reset_colours(), add copy to clipboard as EMF/GIF/PNG/TIF,
  lessen triggering of update_preview(), shorten names of getters/setters,
  simplify/shorten some update_preview() logic in switch,
  CODEONE disable structapp for Version S
qzint.cpp: add on_errored signal, add missing getters, add test
This commit is contained in:
gitlost 2021-10-09 00:13:39 +01:00
parent 206ae26d20
commit 72eac41c34
82 changed files with 5570 additions and 3774 deletions

View File

@ -27,6 +27,10 @@ Changes
- Add Structured Append support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, MAXICODE, MICROPDF417, PDF417, QRCODE, ULTRA
- ULTRA: add revision 2 support (based on BWIPP 2021-09-28 update)
- Add compliant height
- GUI: add Menu, copy to clipboard EMF/GIF/PNG/TIF, errtxt bar and status bar,
icons (feathericons)
- CODABAR: add show check digit option
Bugs
----
@ -41,7 +45,8 @@ Bugs
platform variation (#204 ARM-Cortex crash)
- raster/vector.c: use new stripf() func to workaround gcc 32-bit
float variations
- raster.c: Don't allow for text if scale < 1.0
- raster.c: Don't add height offset for text if scale < 1.0 (as won't print)
- ISBNX: fix not returning error number (warning) correctly
Version 2.10.0 2021-08-14

View File

@ -64,7 +64,7 @@ static char check_digit(const unsigned int count) {
static int c25_common(struct zint_symbol *symbol, const unsigned char source[], int length, const int max,
const char *table[10], const char *start_stop[2], const int error_base) {
int i, error_number;
int i;
char dest[512]; /* Largest destination 6 + (80 + 1) * 6 + 5 + 1 = 498 */
unsigned char temp[80 + 1 + 1]; /* Largest maximum 80 */
int have_checkdigit = symbol->option_2 == 1 || symbol->option_2 == 2;
@ -74,11 +74,10 @@ static int c25_common(struct zint_symbol *symbol, const unsigned char source[],
sprintf(symbol->errtxt, "%d: Input too long (%d character maximum)", error_base, max);
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
if (is_sane(NEON, source, length) != 0) {
/* errtxt 302: 304: 306: 308: */
sprintf(symbol->errtxt, "%d: Invalid character in data (digits only)", error_base + 1);
return error_number;
return ZINT_ERROR_INVALID_DATA;
}
ustrcpy(temp, source);
@ -107,46 +106,44 @@ static int c25_common(struct zint_symbol *symbol, const unsigned char source[],
symbol->text[length - 1] = '\0';
}
return error_number;
return 0;
}
/* Code 2 of 5 Standard (Code 2 of 5 Matrix) */
INTERNAL int matrix_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length) {
INTERNAL int c25standard(struct zint_symbol *symbol, unsigned char source[], int length) {
return c25_common(symbol, source, length, 80, C25MatrixTable, C25MatrixStartStop, 301);
}
/* Code 2 of 5 Industrial */
INTERNAL int industrial_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length) {
INTERNAL int c25ind(struct zint_symbol *symbol, unsigned char source[], int length) {
return c25_common(symbol, source, length, 45, C25IndustTable, C25IndustStartStop, 303);
}
/* Code 2 of 5 IATA */
INTERNAL int iata_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length) {
INTERNAL int c25iata(struct zint_symbol *symbol, unsigned char source[], int length) {
return c25_common(symbol, source, length, 45, C25IndustTable, C25IataLogicStartStop, 305);
}
/* Code 2 of 5 Data Logic */
INTERNAL int logic_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length) {
INTERNAL int c25logic(struct zint_symbol *symbol, unsigned char source[], int length) {
return c25_common(symbol, source, length, 80, C25MatrixTable, C25IataLogicStartStop, 307);
}
/* Common to Interleaved, ITF-14, DP Leitcode, DP Identcode */
static int c25inter_common(struct zint_symbol *symbol, unsigned char source[], int length,
const int dont_set_height) {
int i, j, error_number;
int i, j, error_number = 0;
char bars[7], spaces[7], mixed[14], dest[512]; /* 4 + (90 + 2) * 5 + 3 + 1 = 468 */
unsigned char temp[90 + 2 + 1];
int have_checkdigit = symbol->option_2 == 1 || symbol->option_2 == 2;
float height;
if (length > 90) {
strcpy(symbol->errtxt, "309: Input too long (90 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
if (is_sane(NEON, source, length) != 0) {
strcpy(symbol->errtxt, "310: Invalid character in data (digits only)");
return error_number;
return ZINT_ERROR_INVALID_DATA;
}
temp[0] = '\0';
@ -199,26 +196,29 @@ static int c25inter_common(struct zint_symbol *symbol, unsigned char source[], i
}
if (!dont_set_height) {
#ifdef COMPLIANT_HEIGHTS
if (symbol->output_options & COMPLIANT_HEIGHT) {
/* ISO/IEC 16390:2007 Section 4.4 min height 5mm or 15% of symbol width whichever greater where
(P = character pairs, N = wide/narrow ratio = 3) width = (P(4N + 6) + N + 6)X = (length / 2) * 18 + 9 */
height = (float) ((18.0 * (length / 2) + 9.0) * 0.15);
if (height < (float) (5.0 / 0.33)) { /* Taking X = 0.330mm from Annex D.3.1 (application specification) */
height = (float) (5.0 / 0.33);
(P = character pairs, N = wide/narrow ratio = 3)
width = (P(4N + 6) + N + 6)X = (length / 2) * 18 + 9 */
/* Taking X = 0.330mm from Annex D.3.1 (application specification) */
const float min_height_min = stripf(5.0f / 0.33f);
float min_height = stripf((18.0f * (length / 2) + 9.0f) * 0.15f);
if (min_height < min_height_min) {
min_height = min_height_min;
}
/* Using 50 as default as none recommended */
error_number = set_height(symbol, height, height > 50.0f ? height : 50.0f, 0.0f, 0 /*no_errtxt*/);
#else
height = 50.0f;
(void) set_height(symbol, 0.0f, height, 0.0f, 1 /*no_errtxt*/);
#endif
error_number = set_height(symbol, min_height, min_height > 50.0f ? min_height : 50.0f, 0.0f,
0 /*no_errtxt*/);
} else {
(void) set_height(symbol, 0.0f, 50.0f, 0.0f, 1 /*no_errtxt*/);
}
}
return error_number;
}
/* Code 2 of 5 Interleaved ISO/IEC 16390:2007 */
INTERNAL int interleaved_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length) {
INTERNAL int c25inter(struct zint_symbol *symbol, unsigned char source[], int length) {
return c25inter_common(symbol, source, length, 0 /*dont_set_height*/);
}
@ -232,10 +232,9 @@ INTERNAL int itf14(struct zint_symbol *symbol, unsigned char source[], int lengt
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
if (is_sane(NEON, source, length) != 0) {
strcpy(symbol->errtxt, "312: Invalid character in data (digits only)");
return error_number;
return ZINT_ERROR_INVALID_DATA;
}
/* Add leading zeros as required */
@ -261,14 +260,14 @@ INTERNAL int itf14(struct zint_symbol *symbol, unsigned char source[], int lengt
}
if (error_number < ZINT_ERROR) {
#ifdef COMPLIANT_HEIGHTS
/* GS1 General Specifications 21.0.1 5.12.3.2 table 2, including footnote (**): (note bind/box additional to
symbol->height), same as GS1-128: "in case of further space constraints"
if (symbol->output_options & COMPLIANT_HEIGHT) {
/* GS1 General Specifications 21.0.1 5.12.3.2 table 2, including footnote (**): (note bind/box additional
to symbol->height), same as GS1-128: "in case of further space constraints"
height 5.8mm / 1.016mm (X max) ~ 5.7; default 31.75mm / 0.495mm ~ 64.14 */
warn_number = set_height(symbol, (float) (5.8 / 1.016), (float) (31.75 / 0.495), 0.0f, 0 /*no_errtxt*/);
#else
warn_number = set_height(symbol, stripf(5.8f / 1.016f), stripf(31.75f / 0.495f), 0.0f, 0 /*no_errtxt*/);
} else {
(void) set_height(symbol, 0.0f, 50.0f, 0.0f, 1 /*no_errtxt*/);
#endif
}
}
return error_number ? error_number : warn_number;
@ -286,10 +285,9 @@ INTERNAL int dpleit(struct zint_symbol *symbol, unsigned char source[], int leng
strcpy(symbol->errtxt, "313: Input wrong length (13 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
if (is_sane(NEON, source, length) != 0) {
strcpy(symbol->errtxt, "314: Invalid character in data (digits only)");
return error_number;
return ZINT_ERROR_INVALID_DATA;
}
zeroes = 13 - length;
@ -325,10 +323,9 @@ INTERNAL int dpident(struct zint_symbol *symbol, unsigned char source[], int len
strcpy(symbol->errtxt, "315: Input wrong length (11 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
if (is_sane(NEON, source, length) != 0) {
strcpy(symbol->errtxt, "316: Invalid character in data (digits only)");
return error_number;
return ZINT_ERROR_INVALID_DATA;
}
zeroes = 11 - length;

View File

@ -88,7 +88,7 @@ static void rs_error(char data_pattern[]) {
INTERNAL int daft_set_height(struct zint_symbol *symbol, float min_height, float max_height);
/* Handles Australia Posts's 4 State Codes */
INTERNAL int australia_post(struct zint_symbol *symbol, unsigned char source[], int length) {
INTERNAL int auspost(struct zint_symbol *symbol, unsigned char source[], int length) {
/* Customer Standard Barcode, Barcode 2 or Barcode 3 system determined automatically
(i.e. the FCC doesn't need to be specified by the user) dependent
on the length of the input string */
@ -108,10 +108,9 @@ INTERNAL int australia_post(struct zint_symbol *symbol, unsigned char source[],
char localstr[30];
/* Check input immediately to catch nuls */
error_number = is_sane(GDSET, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
if (is_sane(GDSET, source, length) != 0) {
strcpy(symbol->errtxt, "404: Invalid character in data (alphanumerics, space and \"#\" only)");
return error_number;
return ZINT_ERROR_INVALID_DATA;
}
strcpy(localstr, "");
@ -127,23 +126,25 @@ INTERNAL int australia_post(struct zint_symbol *symbol, unsigned char source[],
break;
case 16:
strcpy(fcc, "59");
error_number = is_sane(NEON, source, length);
if (is_sane(NEON, source, length) != 0) {
strcpy(symbol->errtxt, "402: Invalid character in data (digits only for length 16)");
return ZINT_ERROR_INVALID_DATA;
}
break;
case 18:
strcpy(fcc, "62");
break;
case 23:
strcpy(fcc, "62");
error_number = is_sane(NEON, source, length);
if (is_sane(NEON, source, length) != 0) {
strcpy(symbol->errtxt, "406: Invalid character in data (digits only for length 23)");
return ZINT_ERROR_INVALID_DATA;
}
break;
default:
strcpy(symbol->errtxt, "401: Auspost input is wrong length (8, 13, 16, 18 or 23 characters only)");
return ZINT_ERROR_TOO_LONG;
}
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "402: Invalid character in data (digits only for lengths 16 and 23)");
return error_number;
}
} else {
int zeroes;
if (length > 8) {
@ -174,10 +175,9 @@ INTERNAL int australia_post(struct zint_symbol *symbol, unsigned char source[],
/* Verify that the first 8 characters are numbers */
memcpy(dpid, localstr, 8);
dpid[8] = '\0';
error_number = is_sane(NEON, (unsigned char *) dpid, 8);
if (error_number == ZINT_ERROR_INVALID_DATA) {
if (is_sane(NEON, (unsigned char *) dpid, 8) != 0) {
strcpy(symbol->errtxt, "405: Invalid character in DPID (first 8 characters) (digits only)");
return error_number;
return ZINT_ERROR_INVALID_DATA;
}
/* Start character */
@ -238,21 +238,23 @@ INTERNAL int australia_post(struct zint_symbol *symbol, unsigned char source[],
writer += 2;
}
#ifdef COMPLIANT_HEIGHTS
if (symbol->output_options & COMPLIANT_HEIGHT) {
/* Australia Post Customer Barcoding Technical Specifications (Revised Aug 2012) Dimensions, placement and
printing p.12
https://auspost.com.au/content/dam/auspost_corp/media/documents/customer-barcode-technical-specifications-aug2012.pdf
(https://auspost.com.au/content/dam/auspost_corp/media/documents/
customer-barcode-technical-specifications-aug2012.pdf)
X 0.5mm (average of 0.4mm - 0.6mm), min height 4.2mm / 0.6mm (X max) = 7, max 5.6mm / 0.4mm (X min) = 14
Tracker 1.3mm (average of 1mm - 1.6mm), Ascender/Descender 3.15mm (average of 2.6mm - 3.7mm) less T = 1.85mm
Tracker 1.3mm (average of 1mm - 1.6mm)
Ascender/Descender 3.15mm (average of 2.6mm - 3.7mm) less T = 1.85mm
*/
symbol->row_height[0] = 1.85f / 0.5f; /* 3.7 */
symbol->row_height[1] = 1.3f / 0.5f; /* 2.6 */
symbol->row_height[0] = 3.7f; /* 1.85f / 0.5f */
symbol->row_height[1] = 2.6f; /* 1.3f / 0.5f */
error_number = daft_set_height(symbol, 7.0f, 14.0f); /* Note using max X for minimum and min X for maximum */
#else
} else {
symbol->row_height[0] = 3.0f;
symbol->row_height[1] = 2.0f;
error_number = daft_set_height(symbol, 0.0f, 0.0f);
#endif
}
symbol->rows = 3;
symbol->width = writer - 1;

View File

@ -1445,7 +1445,7 @@ INTERNAL int aztec(struct zint_symbol *symbol, unsigned char source[], int lengt
}
/* Encodes Aztec runes as specified in ISO/IEC 24778:2008 Annex A */
INTERNAL int aztec_runes(struct zint_symbol *symbol, unsigned char source[], int length) {
INTERNAL int azrune(struct zint_symbol *symbol, unsigned char source[], int length) {
unsigned int input_value;
int error_number, i, y, x, r;
char binary_string[28];

View File

@ -39,7 +39,7 @@
#include <assert.h>
#include "common.h"
INTERNAL int code_128(struct zint_symbol *symbol, unsigned char source[], int length);
INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int length);
#define uchar unsigned char
@ -601,7 +601,7 @@ static void SumASCII(uchar **ppOutPos, int Sum, int CharacterSet)
/* Main function called by zint framework
*/
INTERNAL int codablock(struct zint_symbol *symbol, unsigned char source[], int length) {
INTERNAL int codablockf(struct zint_symbol *symbol, unsigned char source[], int length) {
int charCur, dataLength;
int error_number;
int rows, columns, useColumns;
@ -613,7 +613,6 @@ INTERNAL int codablock(struct zint_symbol *symbol, unsigned char source[], int l
int emptyColumns;
char dest[1000];
int r, c;
float min_row_height = 0.0f;
#ifdef _MSC_VER
CharacterSetTable *T;
unsigned char *data;
@ -627,20 +626,20 @@ INTERNAL int codablock(struct zint_symbol *symbol, unsigned char source[], int l
/* option1: rows <= 0: automatic, 1..44 */
rows = symbol->option_1;
if (rows == 1) {
error_number = code_128(symbol, source, length); /* Only returns errors, not warnings */
error_number = code128(symbol, source, length); /* Only returns errors, not warnings */
if (error_number < ZINT_ERROR) {
symbol->output_options |= BARCODE_BIND;
if (symbol->border_width == 0) { /* Allow override if non-zero */
symbol->border_width = 1; /* AIM ISS-X-24 Section 4.6.1 b) (note change from previous default 2) */
}
symbol->text[0] = '\0'; /* Disable HRT for compatibility with CODABLOCKF */
#ifdef COMPLIANT_HEIGHTS
if (symbol->output_options & COMPLIANT_HEIGHT) {
/* AIM ISS-X-24 Section 4.5.1 minimum row height 8 (for compatibility with CODABLOCKF, not specced for
CODE128) */
error_number = set_height(symbol, 8.0f, 10.0f, 0.0f, 0 /*no_errtxt*/);
#else
} else {
(void) set_height(symbol, 0.0f, 5.0f, 0.0f, 1 /*no_errtxt*/);
#endif
}
}
return error_number;
}
@ -961,17 +960,17 @@ INTERNAL int codablock(struct zint_symbol *symbol, unsigned char source[], int l
expand(symbol, dest);
}
#ifdef COMPLIANT_HEIGHTS
/* AIM ISS-X-24 Section 4.6.1 minimum row height; use 10 * rows as default for back-compatibility */
min_row_height = (float) (0.55 * useColumns + 3.0);
if (symbol->output_options & COMPLIANT_HEIGHT) {
/* AIM ISS-X-24 Section 4.6.1 minimum row height; use 10 * rows as default */
float min_row_height = stripf(0.55f * useColumns + 3.0f);
if (min_row_height < 8.0f) {
min_row_height = 8.0f;
}
error_number = set_height(symbol, min_row_height, (min_row_height > 10.0f ? min_row_height : 10.0f) * rows, 0.0f,
0 /*no_errtxt*/);
#else
(void) set_height(symbol, min_row_height, 10.0f * rows, 0.0f, 1 /*no_errtxt*/);
#endif
error_number = set_height(symbol, min_row_height, (min_row_height > 10.0f ? min_row_height : 10.0f) * rows,
0.0f, 0 /*no_errtxt*/);
} else {
(void) set_height(symbol, 0.0f, 10.0f * rows, 0.0f, 1 /*no_errtxt*/);
}
symbol->output_options |= BARCODE_BIND;

View File

@ -1,7 +1,8 @@
/* code.c - Handles Code 11, 39, 39+, 93, PZN, Channel and VIN */
/* LOGMARS MIL-STD-1189 Rev. B https://apps.dtic.mil/dtic/tr/fulltext/u2/a473534.pdf */
/* PZN https://www.ifaffm.de/mandanten/1/documents/04_ifa_coding_system/IFA_Info_Code_39_EN.pdf */
/* PZN https://www.ifaffm.de/mandanten/1/documents/04_ifa_coding_system/IFA-Info_Check_Digit_Calculations_PZN_PPN_UDI_EN.pdf */
/* PZN https://www.ifaffm.de/mandanten/1/documents/04_ifa_coding_system/
IFA-Info_Check_Digit_Calculations_PZN_PPN_UDI_EN.pdf */
/*
libzint - the open source barcode library
@ -98,11 +99,11 @@ static const char *C93Table[47] = {
};
/* *********************** CODE 11 ******************** */
INTERNAL int code_11(struct zint_symbol *symbol, unsigned char source[], int length) { /* Code 11 */
INTERNAL int code11(struct zint_symbol *symbol, unsigned char source[], int length) { /* Code 11 */
int i;
int h, c_digit, c_weight, c_count, k_digit, k_weight, k_count;
int weight[122], error_number;
int weight[122], error_number = 0;
char dest[750]; /* 6 + 121 * 6 + 2 * 6 + 5 + 1 == 750 */
char checkstr[3];
int num_check_digits;
@ -114,10 +115,9 @@ INTERNAL int code_11(struct zint_symbol *symbol, unsigned char source[], int len
strcpy(symbol->errtxt, "320: Input too long (121 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(SODIUM, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
if (is_sane(SODIUM, source, length) != 0) {
strcpy(symbol->errtxt, "321: Invalid character in data (digits and \"-\" only)");
return error_number;
return ZINT_ERROR_INVALID_DATA;
}
if (symbol->option_2 < 0 || symbol->option_2 > 2) {
@ -215,13 +215,12 @@ INTERNAL int code_11(struct zint_symbol *symbol, unsigned char source[], int len
}
/* Code 39 */
INTERNAL int c39(struct zint_symbol *symbol, unsigned char source[], int length) {
INTERNAL int code39(struct zint_symbol *symbol, unsigned char source[], int length) {
int i;
int counter;
int error_number;
int error_number = 0;
char dest[880]; /* 10 (Start) + 85 * 10 + 10 (Check) + 9 (Stop) + 1 = 880 */
char localstr[2] = {0};
float height;
counter = 0;
@ -242,10 +241,9 @@ INTERNAL int c39(struct zint_symbol *symbol, unsigned char source[], int length)
return ZINT_ERROR_TOO_LONG;
}
to_upper(source);
error_number = is_sane(SILVER, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
if (is_sane(SILVER, source, length) != 0) {
strcpy(symbol->errtxt, "324: Invalid character in data (alphanumerics, space and \"-.$/+%\" only)");
return error_number;
return ZINT_ERROR_INVALID_DATA;
}
/* Start character */
@ -291,26 +289,27 @@ INTERNAL int c39(struct zint_symbol *symbol, unsigned char source[], int length)
expand(symbol, dest);
#ifdef COMPLIANT_HEIGHTS
if (symbol->output_options & COMPLIANT_HEIGHT) {
if (symbol->symbology == BARCODE_LOGMARS) {
/* MIL-STD-1189 Rev. B Section 5.2
Min height 0.25" / 0.04" (X max) = 6.25
Default height 0.625" (average of 0.375" - 0.875") / 0.01375" (average of 0.0075" - 0.02") ~ 45.45 */
height = (float) (0.625 / 0.01375);
error_number = set_height(symbol, 6.25f, height, (float) (0.875 / 0.0075), 0 /*no_errtxt*/);
error_number = set_height(symbol, 6.25f, stripf(0.625f / 0.01375f), stripf(0.875f / 0.0075f),
0 /*no_errtxt*/);
} else if (symbol->symbology == BARCODE_CODE39 || symbol->symbology == BARCODE_EXCODE39
|| symbol->symbology == BARCODE_HIBC_39) {
/* ISO/IEC 16388:2007 4.4 (e) recommended min height 5.0mm or 15% of width excluding quiet zones;
as X left to application specification use
width = (C + 2) * (3 * N + 6) * X + (C + 1) * I = (C + 2) * 9 + C + 1) * X = (10 * C + 19) */
height = (float) ((10.0 * (symbol->option_2 == 1 ? length + 1 : length) + 19.0) * 0.15);
/* Using 50 as default as none recommended */
error_number = set_height(symbol, height, height > 50.0f ? height : 50.0f, 0.0f, 0 /*no_errtxt*/);
width = (C + 2) * (3 * N + 6) * X + (C + 1) * I = (C + 2) * 9 + C + 1) * X = (10 * C + 19);
use 50 as default as none recommended */
const float min_height = stripf((10.0f * (symbol->option_2 == 1 ? length + 1 : length) + 19.0f) * 0.15f);
error_number = set_height(symbol, min_height, min_height > 50.0f ? min_height : 50.0f, 0.0f,
0 /*no_errtxt*/);
}
// PZN and CODE32 set their own heights
} else {
(void) set_height(symbol, 0.0f, 50.f, 0.0f, 1 /*no_errtxt*/);
}
#else
height = 50.0f;
(void) set_height(symbol, 0.0f, height, 0.0f, 1 /*no_errtxt*/);
#endif
if (symbol->symbology == BARCODE_CODE39) {
ustrcpy(symbol->text, "*");
@ -325,7 +324,7 @@ INTERNAL int c39(struct zint_symbol *symbol, unsigned char source[], int length)
}
/* Pharmazentral Nummer (PZN) */
INTERNAL int pharmazentral(struct zint_symbol *symbol, unsigned char source[], int length) {
INTERNAL int pzn(struct zint_symbol *symbol, unsigned char source[], int length) {
int i, error_number, zeroes;
unsigned int count, check_digit;
@ -335,10 +334,9 @@ INTERNAL int pharmazentral(struct zint_symbol *symbol, unsigned char source[], i
strcpy(symbol->errtxt, "325: Input wrong length (7 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
if (is_sane(NEON, source, length) != 0) {
strcpy(symbol->errtxt, "326: Invalid character in data (digits only)");
return error_number;
return ZINT_ERROR_INVALID_DATA;
}
localstr[0] = '-';
@ -364,29 +362,29 @@ INTERNAL int pharmazentral(struct zint_symbol *symbol, unsigned char source[], i
}
localstr[8] = itoc(check_digit);
localstr[9] = '\0';
error_number = c39(symbol, (unsigned char *) localstr, 9);
error_number = code39(symbol, (unsigned char *) localstr, 9);
ustrcpy(symbol->text, "PZN ");
ustrcat(symbol->text, localstr);
#ifdef COMPLIANT_HEIGHTS
if (symbol->output_options & COMPLIANT_HEIGHT) {
/* Technical Information regarding PZN Coding V 2.1 (25 Feb 2019) Code size
https://www.ifaffm.de/mandanten/1/documents/04_ifa_coding_system/IFA_Info_Code_39_EN.pdf
"normal" X 0.25mm (0.187mm - 0.45mm), height 8mm - 20mm for 0.25mm X, 10mm mentioned so use that as default,
10mm / 0.25mm = 40 */
"normal" X 0.25mm (0.187mm - 0.45mm), height 8mm - 20mm for 0.25mm X, 10mm mentioned so use that
as default, 10mm / 0.25mm = 40 */
if (error_number < ZINT_ERROR) {
error_number = set_height(symbol, (float) (8.0 / 0.45), 40.0f, (float) (20.0 / 0.187), 0 /*no_errtxt*/);
error_number = set_height(symbol, stripf(8.0f / 0.45f), 40.0f, stripf(20.0f / 0.187f), 0 /*no_errtxt*/);
}
#else
} else {
if (error_number < ZINT_ERROR) {
(void) set_height(symbol, 0.0f, 50.0f, 0.0f, 1 /*no_errtxt*/);
}
#endif
}
return error_number;
}
/* Extended Code 39 - ISO/IEC 16388:2007 Annex A */
INTERNAL int ec39(struct zint_symbol *symbol, unsigned char source[], int length) {
INTERNAL int excode39(struct zint_symbol *symbol, unsigned char source[], int length) {
unsigned char buffer[85 * 2 + 1] = {0};
int i;
@ -408,21 +406,21 @@ INTERNAL int ec39(struct zint_symbol *symbol, unsigned char source[], int length
}
/* Then sends the buffer to the C39 function */
error_number = c39(symbol, buffer, (int) ustrlen(buffer));
error_number = code39(symbol, buffer, (int) ustrlen(buffer));
for (i = 0; i < length; i++)
symbol->text[i] = source[i] >= ' ' && source[i] != 0x7F ? source[i] : ' ';
symbol->text[length] = '\0';
symbol->text[length] = '\0'; /* Chops off check digit */
return error_number;
}
/* Code 93 is an advancement on Code 39 and the definition is a lot tighter */
INTERNAL int c93(struct zint_symbol *symbol, unsigned char source[], int length) {
INTERNAL int code93(struct zint_symbol *symbol, unsigned char source[], int length) {
/* SILVER includes the extra characters a, b, c and d to represent Code 93 specific
shift characters 1, 2, 3 and 4 respectively. These characters are never used by
c39() and ec39() */
`code39()` and `excode39()` */
int i;
int h, weight, c, k, error_number = 0;
@ -430,7 +428,6 @@ INTERNAL int c93(struct zint_symbol *symbol, unsigned char source[], int length)
char buffer[216]; /* 107*2 (107 full ASCII) + 1 = 215 */
char dest[668]; /* 6 (Start) + 107*6 + 2*6 (Checks) + 7 (Stop) + 1 (NUL) = 668 */
char set_copy[] = SILVER;
float height;
/* Suppresses clang-tidy clang-analyzer-core.CallAndMessage warning */
assert(length > 0);
@ -503,19 +500,15 @@ INTERNAL int c93(struct zint_symbol *symbol, unsigned char source[], int length)
strcat(dest, "1111411");
expand(symbol, dest);
#ifdef COMPLIANT_HEIGHTS
if (symbol->output_options & COMPLIANT_HEIGHT) {
/* ANSI/AIM BC5-1995 Section 2.6 minimum height 0.2" or 15% of symbol length, whichever is greater
0.2" / 0.0075" (min X) = ~26.66; symbol length = (9 * (C + 4) + 1) * X + 2 * Q = symbol->width + 20 */
height = (float) ((symbol->width + 20) * 0.15);
if (height < 0.2f / 0.0075f) {
height = 0.2f / 0.0075f;
no max X given so for min height use symbol length = (9 * (C + 4) + 1) * X + 2 * Q = symbol->width + 20;
use 40 as default height based on figures in spec */
float min_height = stripf((symbol->width + 20) * 0.15f);
error_number = set_height(symbol, min_height, min_height > 40.0f ? min_height : 40.0f, 0.0f, 0 /*no_errtxt*/);
} else {
(void) set_height(symbol, 0.0f, 50.0f, 0.0f, 1 /*no_errtxt*/);
}
/* Using 50 as default for back-compatibility */
error_number = set_height(symbol, height, height > 50.0f ? height : 50.0f, 0.0f, 0 /*no_errtxt*/);
#else
height = 50.0f;
(void) set_height(symbol, 0.0f, height, 0.0f, 1 /*no_errtxt*/);
#endif
if (symbol->option_2 == 1) {
symbol->text[length] = set_copy[c];
@ -578,12 +571,18 @@ static void CHNCHR(int channels, long target_value, int B[8], int S[8]) {
/* Use of initial pre-calculations taken from Barcode Writer in Pure PostScript (BWIPP)
* Copyright (c) 2004-2020 Terry Burton (MIT/X-Consortium license) */
static channel_precalc initial_precalcs[6] = {
{ 0, { 1, 1, 1, 1, 1, 2, 1, 2, }, { 1, 1, 1, 1, 1, 1, 1, 3, }, { 1, 1, 1, 1, 1, 3, 2, }, { 1, 1, 1, 1, 1, 3, 3, }, },
{ 0, { 1, 1, 1, 1, 2, 1, 1, 3, }, { 1, 1, 1, 1, 1, 1, 1, 4, }, { 1, 1, 1, 1, 4, 3, 3, }, { 1, 1, 1, 1, 4, 4, 4, }, },
{ 0, { 1, 1, 1, 2, 1, 1, 2, 3, }, { 1, 1, 1, 1, 1, 1, 1, 5, }, { 1, 1, 1, 5, 4, 4, 4, }, { 1, 1, 1, 5, 5, 5, 5, }, },
{ 0, { 1, 1, 2, 1, 1, 2, 1, 4, }, { 1, 1, 1, 1, 1, 1, 1, 6, }, { 1, 1, 6, 5, 5, 5, 4, }, { 1, 1, 6, 6, 6, 6, 6, }, },
{ 0, { 1, 2, 1, 1, 2, 1, 1, 5, }, { 1, 1, 1, 1, 1, 1, 1, 7, }, { 1, 7, 6, 6, 6, 5, 5, }, { 1, 7, 7, 7, 7, 7, 7, }, },
{ 0, { 2, 1, 1, 2, 1, 1, 2, 5, }, { 1, 1, 1, 1, 1, 1, 1, 8, }, { 8, 7, 7, 7, 6, 6, 6, }, { 8, 8, 8, 8, 8, 8, 8, }, },
{ 0, { 1, 1, 1, 1, 1, 2, 1, 2, }, { 1, 1, 1, 1, 1, 1, 1, 3, }, { 1, 1, 1, 1, 1, 3, 2, },
{ 1, 1, 1, 1, 1, 3, 3, }, },
{ 0, { 1, 1, 1, 1, 2, 1, 1, 3, }, { 1, 1, 1, 1, 1, 1, 1, 4, }, { 1, 1, 1, 1, 4, 3, 3, },
{ 1, 1, 1, 1, 4, 4, 4, }, },
{ 0, { 1, 1, 1, 2, 1, 1, 2, 3, }, { 1, 1, 1, 1, 1, 1, 1, 5, }, { 1, 1, 1, 5, 4, 4, 4, },
{ 1, 1, 1, 5, 5, 5, 5, }, },
{ 0, { 1, 1, 2, 1, 1, 2, 1, 4, }, { 1, 1, 1, 1, 1, 1, 1, 6, }, { 1, 1, 6, 5, 5, 5, 4, },
{ 1, 1, 6, 6, 6, 6, 6, }, },
{ 0, { 1, 2, 1, 1, 2, 1, 1, 5, }, { 1, 1, 1, 1, 1, 1, 1, 7, }, { 1, 7, 6, 6, 6, 5, 5, },
{ 1, 7, 7, 7, 7, 7, 7, }, },
{ 0, { 2, 1, 1, 2, 1, 1, 2, 5, }, { 1, 1, 1, 1, 1, 1, 1, 8, }, { 8, 7, 7, 7, 6, 6, 6, },
{ 8, 8, 8, 8, 8, 8, 8, }, },
};
int bmax[7], smax[7];
long value = 0;
@ -655,24 +654,22 @@ nb0: if (++B[0] <= bmax[0]) goto lb0;
}
/* Channel Code - According to ANSI/AIM BC12-1998 */
INTERNAL int channel_code(struct zint_symbol *symbol, unsigned char source[], int length) {
INTERNAL int channel(struct zint_symbol *symbol, unsigned char source[], int length) {
static int max_ranges[] = { -1, -1, -1, 26, 292, 3493, 44072, 576688, 7742862 };
int S[8] = {0}, B[8] = {0};
long target_value = 0;
char pattern[30];
int channels, i;
int error_number, zeroes;
int error_number = 0, zeroes;
char hrt[9];
float height;
if (length > 7) {
strcpy(symbol->errtxt, "333: Input too long (7 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
if (is_sane(NEON, source, length) != 0) {
strcpy(symbol->errtxt, "334: Invalid character in data (digits only)");
return error_number;
return ZINT_ERROR_INVALID_DATA;
}
if ((symbol->option_2 < 3) || (symbol->option_2 > 8)) {
@ -735,17 +732,15 @@ INTERNAL int channel_code(struct zint_symbol *symbol, unsigned char source[], in
expand(symbol, pattern);
#ifdef COMPLIANT_HEIGHTS
/* ANSI/AIM BC12-1998 gives min height as 5mm or 15% of length but X left as application specification so use
15% of length where
length = (3 (quiet zones) + 9 (finder) + 4 * channels - 2) * X */
height = (float) ((10 + 4 * channels) * 0.15);
/* Using 50 as default for back-compatibility */
error_number = set_height(symbol, height > 50.0f ? height : 50.0f, height, 0.0f, 0 /*no_errtxt*/);
#else
height = 50.0f;
(void) set_height(symbol, 0.0f, height, 0.0f, 1 /*no_errtxt*/);
#endif
if (symbol->output_options & COMPLIANT_HEIGHT) {
/* ANSI/AIM BC12-1998 gives min height as 5mm or 15% of length; X left as application specification so use
length = 1X (left qz) + (9 (finder) + 4 * 8 - 2) * X + 2X (right qz);
use 20 as default based on figures in spec */
const float min_height = stripf((1 + 9 + 4 * channels - 2 + 2) * 0.15f);
error_number = set_height(symbol, min_height, 20.0f, 0.0f, 0 /*no_errtxt*/);
} else {
(void) set_height(symbol, 0.0f, 50.0f, 0.0f, 1 /*no_errtxt*/);
}
return error_number;
}
@ -771,7 +766,7 @@ INTERNAL int vin(struct zint_symbol *symbol, unsigned char source[], int length)
}
// Check input characters, I, O and Q are not allowed
if (is_sane(ARSENIC, source, length) == ZINT_ERROR_INVALID_DATA) {
if (is_sane(ARSENIC, source, length) != 0) {
sprintf(symbol->errtxt, "337: Invalid character in data (\"%s\" only)", ARSENIC);
return ZINT_ERROR_INVALID_DATA;
}

View File

@ -957,7 +957,7 @@ static void block_copy(struct zint_symbol *symbol, char datagrid[136][120], cons
}
}
INTERNAL int code_one(struct zint_symbol *symbol, unsigned char source[], int length) {
INTERNAL int codeone(struct zint_symbol *symbol, unsigned char source[], int length) {
int size = 1, i, j;
char datagrid[136][120];
@ -972,6 +972,10 @@ INTERNAL int code_one(struct zint_symbol *symbol, unsigned char source[], int le
}
if (symbol->structapp.count) {
if (symbol->option_2 == 9) { /* Version S */
strcpy(symbol->errtxt, "714: Structured Append not available for Version S");
return ZINT_ERROR_INVALID_OPTION;
}
if ((symbol->input_mode & 0x07) == GS1_MODE) {
strcpy(symbol->errtxt, "710: Cannot have Structured Append and GS1 mode at the same time");
return ZINT_ERROR_INVALID_OPTION;
@ -997,15 +1001,11 @@ INTERNAL int code_one(struct zint_symbol *symbol, unsigned char source[], int le
unsigned int data[30], ecc[15];
int block_width;
if (symbol->structapp.count) { /* Version S */
strcpy(symbol->errtxt, "714: Structured Append not supported for Version S");
return ZINT_ERROR_INVALID_OPTION;
}
if (length > 18) {
strcpy(symbol->errtxt, "514: Input data too long for Version S");
return ZINT_ERROR_TOO_LONG;
}
if (is_sane(NEON, source, length) == ZINT_ERROR_INVALID_DATA) {
if (is_sane(NEON, source, length) != 0) {
strcpy(symbol->errtxt, "515: Invalid input data (Version S encodes numeric input only)");
return ZINT_ERROR_INVALID_DATA;
}

View File

@ -300,7 +300,7 @@ STATIC_UNLESS_ZINT_TEST int hrt_cpy_iso8859_1(struct zint_symbol *symbol, const
}
/* Handle Code 128, 128B and HIBC 128 */
INTERNAL int code_128(struct zint_symbol *symbol, unsigned char source[], int length) {
INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int length) {
int i, j, k, values[C128_MAX] = {0}, bar_characters, read, total_sum;
int error_number, indexchaine, indexliste, f_state;
int sourcelen;
@ -705,7 +705,7 @@ INTERNAL int code_128(struct zint_symbol *symbol, unsigned char source[], int le
}
/* Handle EAN-128 (Now known as GS1-128), and composite version if `cc_mode` set */
INTERNAL int ean_128_cc(struct zint_symbol *symbol, unsigned char source[], int length, const int cc_mode,
INTERNAL int gs1_128_cc(struct zint_symbol *symbol, unsigned char source[], int length, const int cc_mode,
const int cc_rows) {
int i, j, values[C128_MAX] = {0}, bar_characters, read, total_sum;
int error_number, warn_number = 0, indexchaine, indexliste;
@ -1014,23 +1014,26 @@ INTERNAL int ean_128_cc(struct zint_symbol *symbol, unsigned char source[], int
}
}
#ifdef COMPLIANT_HEIGHTS
if (symbol->output_options & COMPLIANT_HEIGHT) {
/* GS1 General Specifications 21.0.1 5.12.3.2 table 2, including footnote (**):
same as ITF-14: "in case of further space constraints" height 5.8mm / 1.016mm (X max) ~ 5.7;
default 31.75mm / 0.495mm ~ 64.14 */
const float min_height = stripf(5.8f / 1.016f);
const float default_height = stripf(31.75f / 0.495f);
if (symbol->symbology == BARCODE_GS1_128_CC) {
/* Pass back via temporary linear structure */
symbol->height = symbol->height ? (float) (5.8 / 1.016) : (float) (31.75 / 0.495);
symbol->height = symbol->height ? min_height : default_height;
} else {
warn_number = set_height(symbol, (float) (5.8 / 1.016), (float) (31.75 / 0.495), 0.0f, 0 /*no_errtxt*/);
warn_number = set_height(symbol, min_height, default_height, 0.0f, 0 /*no_errtxt*/);
}
#else
} else {
const float height = 50.0f;
if (symbol->symbology == BARCODE_GS1_128_CC) {
symbol->height = 50.0f - cc_rows * (cc_mode == 3 ? 3 : 2) - 1.0f;
symbol->height = height - cc_rows * (cc_mode == 3 ? 3 : 2) - 1.0f;
} else {
(void) set_height(symbol, 0.0f, 50.0f, 0.0f, 1 /*no_errtxt*/);
(void) set_height(symbol, 0.0f, height, 0.0f, 1 /*no_errtxt*/);
}
}
#endif
for (i = 0; i < length; i++) {
if (source[i] == '[') {
@ -1046,12 +1049,12 @@ INTERNAL int ean_128_cc(struct zint_symbol *symbol, unsigned char source[], int
}
/* Handle EAN-128 (Now known as GS1-128) */
INTERNAL int ean_128(struct zint_symbol *symbol, unsigned char source[], int length) {
return ean_128_cc(symbol, source, length, 0 /*cc_mode*/, 0 /*cc_rows*/);
INTERNAL int gs1_128(struct zint_symbol *symbol, unsigned char source[], int length) {
return gs1_128_cc(symbol, source, length, 0 /*cc_mode*/, 0 /*cc_rows*/);
}
/* Add check digit if encoding an NVE18 symbol */
INTERNAL int nve_18(struct zint_symbol *symbol, unsigned char source[], int length) {
INTERNAL int nve18(struct zint_symbol *symbol, unsigned char source[], int length) {
int i, count, check_digit;
int error_number, zeroes;
unsigned char ean128_equiv[23];
@ -1061,10 +1064,9 @@ INTERNAL int nve_18(struct zint_symbol *symbol, unsigned char source[], int leng
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
if (is_sane(NEON, source, length) != 0) {
strcpy(symbol->errtxt, "346: Invalid character in data (digits only)");
return error_number;
return ZINT_ERROR_INVALID_DATA;
}
zeroes = 17 - length;
@ -1083,13 +1085,13 @@ INTERNAL int nve_18(struct zint_symbol *symbol, unsigned char source[], int leng
ean128_equiv[21] = itoc(check_digit);
ean128_equiv[22] = '\0';
error_number = ean_128(symbol, ean128_equiv, 22);
error_number = gs1_128(symbol, ean128_equiv, 22);
return error_number;
}
/* EAN-14 - A version of EAN-128 */
INTERNAL int ean_14(struct zint_symbol *symbol, unsigned char source[], int length) {
INTERNAL int ean14(struct zint_symbol *symbol, unsigned char source[], int length) {
int i, count, check_digit;
int error_number, zeroes;
unsigned char ean128_equiv[19];
@ -1099,10 +1101,9 @@ INTERNAL int ean_14(struct zint_symbol *symbol, unsigned char source[], int leng
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
if (is_sane(NEON, source, length) != 0) {
strcpy(symbol->errtxt, "348: Invalid character in data (digits only)");
return error_number;
return ZINT_ERROR_INVALID_DATA;
}
zeroes = 13 - length;
@ -1121,7 +1122,7 @@ INTERNAL int ean_14(struct zint_symbol *symbol, unsigned char source[], int leng
ean128_equiv[17] = itoc(check_digit);
ean128_equiv[18] = '\0';
error_number = ean_128(symbol, ean128_equiv, 18);
error_number = gs1_128(symbol, ean128_equiv, 18);
return error_number;
}
@ -1129,7 +1130,7 @@ INTERNAL int ean_14(struct zint_symbol *symbol, unsigned char source[], int leng
/* DPD (Deutsher Paket Dienst) Code */
/* Specification at ftp://dpd.at/Datenspezifikationen/EN/gbs_V4.0.2_hauptdokument.pdf
* or https://docplayer.net/33728877-Dpd-parcel-label-specification.html */
INTERNAL int dpd_parcel(struct zint_symbol *symbol, unsigned char source[], int length) {
INTERNAL int dpd(struct zint_symbol *symbol, unsigned char source[], int length) {
int error_number = 0;
int i, p;
unsigned char identifier;
@ -1144,10 +1145,9 @@ INTERNAL int dpd_parcel(struct zint_symbol *symbol, unsigned char source[], int
identifier = source[0];
to_upper(source + 1);
error_number = is_sane(KRSET, source + 1, length - 1);
if (error_number == ZINT_ERROR_INVALID_DATA) {
if (is_sane(KRSET, source + 1, length - 1) != 0) {
strcpy(symbol->errtxt, "300: Invalid character in DPD data (alphanumerics only)");
return error_number;
return ZINT_ERROR_INVALID_DATA;
}
if ((identifier < 32) || (identifier > 127)) {
@ -1155,16 +1155,16 @@ INTERNAL int dpd_parcel(struct zint_symbol *symbol, unsigned char source[], int
return ZINT_ERROR_INVALID_DATA;
}
error_number = code_128(symbol, source, length); /* Only returns errors, not warnings */
error_number = code128(symbol, source, length); /* Only returns errors, not warnings */
if (error_number < ZINT_ERROR) {
#ifdef COMPLIANT_HEIGHTS
if (symbol->output_options & COMPLIANT_HEIGHT) {
/* Specification DPD and primetime Parcel Despatch 4.0.2 Section 5.5.1
25mm / 0.4mm (X max) = 62.5 min, 25mm / 0.375 (X) ~ 66.66 default */
error_number = set_height(symbol, 62.5f, (float) (25.0 / 0.375), 0.0f, 0 /*no_errtxt*/);
#else
error_number = set_height(symbol, 62.5f, stripf(25.0f / 0.375f), 0.0f, 0 /*no_errtxt*/);
} else {
(void) set_height(symbol, 0.0f, 50.0f, 0.0f, 1 /*no_errtxt*/);
#endif
}
cd = mod;

View File

@ -119,8 +119,6 @@ INTERNAL int code16k(struct zint_symbol *symbol, unsigned char source[], int len
int error_number = 0, first_sum, second_sum;
int input_length;
int gs1, c_count;
int separator;
float min_row_height = 0.0f;
/* Suppresses clang-analyzer-core.UndefinedBinaryOperatorResult warning on fset which is fully set */
assert(length > 0);
@ -490,16 +488,17 @@ INTERNAL int code16k(struct zint_symbol *symbol, unsigned char source[], int len
symbol->rows = rows;
symbol->width = 70;
#ifdef COMPLIANT_HEIGHTS
separator = symbol->option_3 >= 1 && symbol->option_3 <= 4 ? symbol->option_3 : 1;
/* BS EN 12323:2005 Section 4.5 (d) minimum 8X; use 10 * rows as default for back-compatibility */
min_row_height = 8.0f + separator;
error_number = set_height(symbol, min_row_height, (min_row_height > 10.0f ? min_row_height : 10.0f) * rows, 0.0f,
0 /*no_errtxt*/);
#else
(void)&separator;
(void) set_height(symbol, min_row_height, 10.0f * rows, 0.0f, 1 /*no_errtxt*/);
#endif
if (symbol->output_options & COMPLIANT_HEIGHT) {
/* BS EN 12323:2005 Section 4.5 (d) minimum 8X; use 10X as default
Section 4.5 (b) H = X[r(h + g) + g] = rows * row_height + (rows - 1) * separator as borders not included
in symbol->height (added on) */
const int separator = symbol->option_3 >= 1 && symbol->option_3 <= 4 ? symbol->option_3 : 1;
const float min_row_height = stripf((8.0f * rows + separator * (rows - 1)) / rows);
const float default_height = 10.0f * rows + separator * (rows - 1);
error_number = set_height(symbol, min_row_height, default_height, 0.0f, 0 /*no_errtxt*/);
} else {
(void) set_height(symbol, 0.0f, 10.0f * rows, 0.0f, 1 /*no_errtxt*/);
}
symbol->output_options |= BARCODE_BIND;

View File

@ -39,7 +39,7 @@
/* "!" represents Shift 1 and "&" represents Shift 2, "*" represents FNC1 */
INTERNAL int code_49(struct zint_symbol *symbol, unsigned char source[], int length) {
INTERNAL int code49(struct zint_symbol *symbol, unsigned char source[], int length) {
int i, j, rows, M, x_count, y_count, z_count, posn_val, local_value;
char intermediate[170] = "";
int codewords[170], codeword_count;
@ -49,8 +49,6 @@ INTERNAL int code_49(struct zint_symbol *symbol, unsigned char source[], int len
char pattern[80];
int gs1;
int h, len;
int separator;
float min_row_height = 0.0f;
int error_number = 0;
if (length > 81) {
@ -351,16 +349,17 @@ INTERNAL int code_49(struct zint_symbol *symbol, unsigned char source[], int len
symbol->rows = rows;
symbol->width = (int) strlen(pattern);
#ifdef COMPLIANT_HEIGHTS
separator = symbol->option_3 >= 1 && symbol->option_3 <= 4 ? symbol->option_3 : 1;
/* ANSI/AIM BC6-2000 Section 2.6 minimum 8X; use 10 * rows as default for back-compatibility */
min_row_height = 8.0f + separator;
error_number = set_height(symbol, min_row_height, (min_row_height > 10.0f ? min_row_height : 10.0f) * rows, 0.0f,
0 /*no_errtxt*/);
#else
(void)&separator;
(void) set_height(symbol, min_row_height, 10.0f * rows, 0.0f, 1 /*no_errtxt*/);
#endif
if (symbol->output_options & COMPLIANT_HEIGHT) {
/* ANSI/AIM BC6-2000 Section 2.6 minimum 8X; use 10X as default
Formula 2 H = ((h + g)r + g)X = rows * row_height + (rows - 1) * separator as borders not included
in symbol->height (added on) */
const int separator = symbol->option_3 >= 1 && symbol->option_3 <= 4 ? symbol->option_3 : 1;
const float min_row_height = stripf((8.0f * rows + separator * (rows - 1)) / rows);
const float default_height = 10.0f * rows + separator * (rows - 1);
error_number = set_height(symbol, min_row_height, default_height, 0.0f, 0 /*no_errtxt*/);
} else {
(void) set_height(symbol, 0.0f, 10.0f * rows, 0.0f, 1 /*no_errtxt*/);
}
symbol->output_options |= BARCODE_BIND;

View File

@ -406,11 +406,11 @@ INTERNAL int set_height(struct zint_symbol *symbol, const float min_row_height,
if (zero_count) {
if (symbol->height) {
row_height = (symbol->height - fixed_height) / zero_count;
row_height = stripf((symbol->height - fixed_height) / zero_count);
} else if (default_height) {
row_height = default_height / zero_count;
row_height = stripf(default_height / zero_count);
} else {
row_height = min_row_height;
row_height = stripf(min_row_height);
}
if (row_height < 0.5f) { /* Absolute minimum */
row_height = 0.5f;
@ -421,9 +421,9 @@ INTERNAL int set_height(struct zint_symbol *symbol, const float min_row_height,
strcpy(symbol->errtxt, "247: Height not compliant with standards");
}
}
symbol->height = row_height * zero_count + fixed_height;
symbol->height = stripf(row_height * zero_count + fixed_height);
} else {
symbol->height = fixed_height; /* Ignore any given height */
symbol->height = stripf(fixed_height); /* Ignore any given height */
}
if (max_height && symbol->height > max_height) {
error_number = ZINT_WARN_NONCOMPLIANT;

View File

@ -63,18 +63,18 @@
#define UINT unsigned short
#include "composite.h"
INTERNAL int ean_128_cc(struct zint_symbol *symbol, unsigned char source[], int length, const int cc_mode,
INTERNAL int gs1_128_cc(struct zint_symbol *symbol, unsigned char source[], int length, const int cc_mode,
const int cc_rows);
INTERNAL int eanx_cc(struct zint_symbol *symbol, unsigned char source[], int length, const int cc_rows);
INTERNAL int ean_leading_zeroes(struct zint_symbol *symbol, const unsigned char source[],
unsigned char local_source[], int *p_with_addon);
INTERNAL int rss14_stk_set_height(struct zint_symbol *symbol, const int first_row);
INTERNAL int rss14_cc(struct zint_symbol *symbol, unsigned char source[], int length, const int cc_rows);
INTERNAL int rsslimited_cc(struct zint_symbol *symbol, unsigned char source[], int length, const int cc_rows);
INTERNAL int rssexpanded_cc(struct zint_symbol *symbol, unsigned char source[], int length, const int cc_rows);
INTERNAL int rss_date(const unsigned char source[], const int src_posn);
INTERNAL int dbar_omnstk_set_height(struct zint_symbol *symbol, const int first_row);
INTERNAL int dbar_omn_cc(struct zint_symbol *symbol, unsigned char source[], int length, const int cc_rows);
INTERNAL int dbar_ltd_cc(struct zint_symbol *symbol, unsigned char source[], int length, const int cc_rows);
INTERNAL int dbar_exp_cc(struct zint_symbol *symbol, unsigned char source[], int length, const int cc_rows);
INTERNAL int dbar_date(const unsigned char source[], const int src_posn);
static int _min(const int first, const int second) {
@ -889,7 +889,7 @@ static int cc_binary_string(struct zint_symbol *symbol, const unsigned char sour
if ((source[0] == '1') && ((source[1] == '0') || (source[1] == '1') || (source[1] == '7'))) {
/* Source starts (10), (11) or (17) */
if (source[1] == '0' || rss_date(source, 2) >= 0) { /* Check date valid if (11) or (17) */
if (source[1] == '0' || dbar_date(source, 2) >= 0) { /* Check date valid if (11) or (17) */
encoding_method = 2;
}
} else if ((source[0] == '9') && (source[1] == '0')) {
@ -913,7 +913,7 @@ static int cc_binary_string(struct zint_symbol *symbol, const unsigned char sour
} else {
/* Production Date (11) or Expiration Date (17) */
bp = bin_append_posn(rss_date(source, 2), 16, binary_string, bp);
bp = bin_append_posn(dbar_date(source, 2), 16, binary_string, bp);
if (source[1] == '1') {
/* Production Date AI 11 */
@ -1257,7 +1257,7 @@ static int linear_dummy_run(int input_mode, unsigned char *source, const int len
dummy = ZBarcode_Create();
dummy->symbology = BARCODE_GS1_128_CC;
dummy->input_mode = input_mode;
error_number = ean_128_cc(dummy, source, length, 3 /*cc_mode*/, 0 /*cc_rows*/);
error_number = gs1_128_cc(dummy, source, length, 3 /*cc_mode*/, 0 /*cc_rows*/);
linear_width = dummy->width;
if (error_number >= ZINT_ERROR) {
strcpy(errtxt, dummy->errtxt);
@ -1434,6 +1434,7 @@ INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int l
linear->symbology = symbol->symbology;
linear->input_mode = symbol->input_mode;
linear->output_options = symbol->output_options;
linear->option_2 = symbol->option_2;
/* If symbol->height given minimum row height will be returned, else default height */
linear->height = symbol->height;
@ -1450,16 +1451,16 @@ INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int l
break;
case BARCODE_GS1_128_CC:
/* GS1-128 needs to know which type of 2D component is used */
error_number = ean_128_cc(linear, (unsigned char *) symbol->primary, pri_len, cc_mode, symbol->rows);
error_number = gs1_128_cc(linear, (unsigned char *) symbol->primary, pri_len, cc_mode, symbol->rows);
break;
case BARCODE_DBAR_OMN_CC:
error_number = rss14_cc(linear, (unsigned char *) symbol->primary, pri_len, symbol->rows);
error_number = dbar_omn_cc(linear, (unsigned char *) symbol->primary, pri_len, symbol->rows);
break;
case BARCODE_DBAR_LTD_CC:
error_number = rsslimited_cc(linear, (unsigned char *) symbol->primary, pri_len, symbol->rows);
error_number = dbar_ltd_cc(linear, (unsigned char *) symbol->primary, pri_len, symbol->rows);
break;
case BARCODE_DBAR_EXP_CC:
error_number = rssexpanded_cc(linear, (unsigned char *) symbol->primary, pri_len, symbol->rows);
error_number = dbar_exp_cc(linear, (unsigned char *) symbol->primary, pri_len, symbol->rows);
break;
case BARCODE_UPCA_CC:
error_number = eanx_cc(linear, (unsigned char *) symbol->primary, pri_len, symbol->rows);
@ -1468,13 +1469,13 @@ INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int l
error_number = eanx_cc(linear, (unsigned char *) symbol->primary, pri_len, symbol->rows);
break;
case BARCODE_DBAR_STK_CC:
error_number = rss14_cc(linear, (unsigned char *) symbol->primary, pri_len, symbol->rows);
error_number = dbar_omn_cc(linear, (unsigned char *) symbol->primary, pri_len, symbol->rows);
break;
case BARCODE_DBAR_OMNSTK_CC:
error_number = rss14_cc(linear, (unsigned char *) symbol->primary, pri_len, symbol->rows);
error_number = dbar_omn_cc(linear, (unsigned char *) symbol->primary, pri_len, symbol->rows);
break;
case BARCODE_DBAR_EXPSTK_CC:
error_number = rssexpanded_cc(linear, (unsigned char *) symbol->primary, pri_len, symbol->rows);
error_number = dbar_exp_cc(linear, (unsigned char *) symbol->primary, pri_len, symbol->rows);
break;
}
@ -1605,23 +1606,23 @@ INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int l
symbol->width += top_shift;
}
symbol->rows += linear->rows;
#ifdef COMPLIANT_HEIGHTS
if (symbol->output_options & COMPLIANT_HEIGHT) {
if (symbol->symbology == BARCODE_DBAR_STK_CC) {
/* Databar Stacked needs special treatment due to asymmetric rows */
warn_number = rss14_stk_set_height(symbol, symbol->rows - linear->rows + 1 /*first_row*/);
warn_number = dbar_omnstk_set_height(symbol, symbol->rows - linear->rows + 1 /*first_row*/);
} else {
/* If symbol->height given then min row height was returned, else default height */
warn_number = set_height(symbol, symbol->height ? linear->height : 0.0f,
symbol->height ? 0.0f : linear->height, 0.0f, 0 /*no_errtxt*/);
}
#else
} else {
if (symbol->symbology == BARCODE_DBAR_STK_CC) {
(void) rss14_stk_set_height(symbol, symbol->rows - linear->rows + 1 /*first_row*/);
(void) dbar_omnstk_set_height(symbol, symbol->rows - linear->rows + 1 /*first_row*/);
} else {
(void) set_height(symbol, symbol->height ? linear->height : 0.0f, symbol->height ? 0.0f : linear->height,
0.0f, 1 /*no_errtxt*/);
}
#endif
}
ustrcpy(symbol->text, linear->text);

View File

@ -1144,7 +1144,7 @@ static void add_tail(unsigned char target[], int tp, const int tail_length) {
}
}
static int data_matrix_200(struct zint_symbol *symbol, const unsigned char source[], int inputlen) {
static int datamatrix_200(struct zint_symbol *symbol, const unsigned char source[], int inputlen) {
int i, skew = 0;
unsigned char binary[2200];
int binlen;
@ -1266,12 +1266,12 @@ static int data_matrix_200(struct zint_symbol *symbol, const unsigned char sourc
return error_number;
}
INTERNAL int dmatrix(struct zint_symbol *symbol, unsigned char source[], int length) {
INTERNAL int datamatrix(struct zint_symbol *symbol, unsigned char source[], int length) {
int error_number;
if (symbol->option_1 <= 1) {
/* ECC 200 */
error_number = data_matrix_200(symbol, source, length);
error_number = datamatrix_200(symbol, source, length);
} else {
/* ECC 000 - 140 */
strcpy(symbol->errtxt, "524: Older Data Matrix standards are no longer supported");

View File

@ -1006,7 +1006,7 @@ static void place_layer_id(char *grid, int size, int layers, int modules, int ec
}
}
INTERNAL int grid_matrix(struct zint_symbol *symbol, unsigned char source[], int length) {
INTERNAL int gridmatrix(struct zint_symbol *symbol, unsigned char source[], int length) {
int size, modules, error_number;
int auto_layers, min_layers, layers, auto_ecc_level, min_ecc_level, ecc_level;
int x, y, i;

View File

@ -1448,7 +1448,7 @@ static void hx_apply_bitmask(unsigned char *grid, const int size, const int vers
}
/* Han Xin Code - main */
INTERNAL int han_xin(struct zint_symbol *symbol, unsigned char source[], int length) {
INTERNAL int hanxin(struct zint_symbol *symbol, unsigned char source[], int length) {
int est_binlen;
int ecc_level = symbol->option_1;
int i, j, j_max, version;

View File

@ -244,7 +244,7 @@ static unsigned short USPS_MSB_Math_CRC11GenerateFrameCheckSequence(unsigned cha
INTERNAL int daft_set_height(struct zint_symbol *symbol, float min_height, float max_height);
INTERNAL int imail(struct zint_symbol *symbol, unsigned char source[], int length) {
INTERNAL int usps_imail(struct zint_symbol *symbol, unsigned char source[], int length) {
char data_pattern[200];
int error_number;
int i, j, read;
@ -434,22 +434,22 @@ INTERNAL int imail(struct zint_symbol *symbol, unsigned char source[], int lengt
read += 2;
}
#ifdef COMPLIANT_HEIGHTS
if (symbol->output_options & COMPLIANT_HEIGHT) {
/* USPS-B-3200 Section 2.3.1
Using bar pitch as X (1" / 43) ~ 0.023" based on 22 bars + 21 spaces per inch (bar width 0.015" - 0.025"),
height 0.125" - 0.165"
Tracker 0.048" (average of 0.039" - 0.057")
Ascender/descender 0.0965" (average of 0.082" - 0.111") less T = 0.0485"
*/
symbol->row_height[0] = 0.0485f * 43; /* 2.0855 */
symbol->row_height[1] = 0.048f * 43; /* 2.064 */
symbol->row_height[0] = stripf(0.0485f * 43); /* 2.0855 */
symbol->row_height[1] = stripf(0.048f * 43); /* 2.064 */
/* Note using max X for minimum and min X for maximum */
error_number = daft_set_height(symbol, 0.125f * 39 /*4.875*/, 0.165f * 47 /*7.755*/);
#else
error_number = daft_set_height(symbol, stripf(0.125f * 39) /*4.875*/, stripf(0.165f * 47) /*7.755*/);
} else {
symbol->row_height[0] = 3.0f;
symbol->row_height[1] = 2.0f;
daft_set_height(symbol, 0.0f, 0.0f);
#endif
(void) daft_set_height(symbol, 0.0f, 0.0f);
}
symbol->rows = 3;
symbol->width = read - 1;
return error_number;

View File

@ -132,80 +132,75 @@ void ZBarcode_Delete(struct zint_symbol *symbol) {
}
INTERNAL int eanx(struct zint_symbol *symbol, unsigned char source[], int length); /* EAN system barcodes */
INTERNAL int c39(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 3 from 9 (or Code 39) */
/* Pharmazentral Nummer (PZN) */
INTERNAL int pharmazentral(struct zint_symbol *symbol, unsigned char source[], int length);
INTERNAL int code39(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 3 from 9 (or Code 39) */
INTERNAL int pzn(struct zint_symbol *symbol, unsigned char source[], int length); /* Pharmazentral Nummer (PZN) */
/* Extended Code 3 from 9 (or Code 39+) */
INTERNAL int ec39(struct zint_symbol *symbol, unsigned char source[], int length);
INTERNAL int excode39(struct zint_symbol *symbol, unsigned char source[], int length);
/* Codabar - a simple substitution cipher */
INTERNAL int codabar(struct zint_symbol *symbol, unsigned char source[], int length);
/* Code 2 of 5 Standard (& Matrix) */
INTERNAL int matrix_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length);
/* Code 2 of 5 Industrial */
INTERNAL int industrial_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length);
INTERNAL int iata_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 2 of 5 IATA */
/* Code 2 of 5 Interleaved */
INTERNAL int interleaved_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length);
/* Code 2 of 5 Data Logic */
INTERNAL int logic_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length);
INTERNAL int c25standard(struct zint_symbol *symbol, unsigned char source[], int length);
INTERNAL int c25ind(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 2 of 5 Industrial */
INTERNAL int c25iata(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 2 of 5 IATA */
INTERNAL int c25inter(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 2 of 5 Interleaved */
INTERNAL int c25logic(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 2 of 5 Data Logic */
INTERNAL int itf14(struct zint_symbol *symbol, unsigned char source[], int length); /* ITF-14 */
INTERNAL int dpleit(struct zint_symbol *symbol, unsigned char source[], int length); /* Deutsche Post Leitcode */
INTERNAL int dpident(struct zint_symbol *symbol, unsigned char source[], int length); /* Deutsche Post Identcode */
/* Code 93 - a re-working of Code 39+, generates 2 check digits */
INTERNAL int c93(struct zint_symbol *symbol, unsigned char source[], int length);
INTERNAL int code_128(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 128 and NVE-18 */
INTERNAL int ean_128(struct zint_symbol *symbol, unsigned char source[], int length); /* EAN-128 (GS1-128) */
INTERNAL int code_11(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 11 */
INTERNAL int msi_handle(struct zint_symbol *symbol, unsigned char source[], int length); /* MSI Plessey */
INTERNAL int code93(struct zint_symbol *symbol, unsigned char source[], int length);
INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 128 and NVE-18 */
INTERNAL int gs1_128(struct zint_symbol *symbol, unsigned char source[], int length); /* EAN-128 (GS1-128) */
INTERNAL int code11(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 11 */
INTERNAL int msi_plessey(struct zint_symbol *symbol, unsigned char source[], int length); /* MSI Plessey */
INTERNAL int telepen(struct zint_symbol *symbol, unsigned char source[], int length); /* Telepen ASCII */
INTERNAL int telepen_num(struct zint_symbol *symbol, unsigned char source[], int length); /* Telepen Numeric */
INTERNAL int plessey(struct zint_symbol *symbol, unsigned char source[], int length); /* Plessey Code */
INTERNAL int pharma_one(struct zint_symbol *symbol, unsigned char source[], int length); /* Pharmacode One Track */
INTERNAL int flattermarken(struct zint_symbol *symbol, unsigned char source[], int length); /* Flattermarken */
INTERNAL int pharma(struct zint_symbol *symbol, unsigned char source[], int length); /* Pharmacode One Track */
INTERNAL int flat(struct zint_symbol *symbol, unsigned char source[], int length); /* Flattermarken */
INTERNAL int fim(struct zint_symbol *symbol, unsigned char source[], int length); /* Facing Identification Mark */
INTERNAL int pharma_two(struct zint_symbol *symbol, unsigned char source[], int length); /* Pharmacode Two Track */
INTERNAL int post_plot(struct zint_symbol *symbol, unsigned char source[], int length); /* Postnet */
INTERNAL int planet_plot(struct zint_symbol *symbol, unsigned char source[], int length); /* PLANET */
INTERNAL int postnet(struct zint_symbol *symbol, unsigned char source[], int length); /* Postnet */
INTERNAL int planet(struct zint_symbol *symbol, unsigned char source[], int length); /* PLANET */
/* Intelligent Mail (aka USPS OneCode) */
INTERNAL int imail(struct zint_symbol *symbol, unsigned char source[], int length);
INTERNAL int royal_plot(struct zint_symbol *symbol, unsigned char source[], int length); /* RM4SCC */
/* Australia Post 4-state */
INTERNAL int australia_post(struct zint_symbol *symbol, unsigned char source[], int length);
INTERNAL int usps_imail(struct zint_symbol *symbol, unsigned char source[], int length);
INTERNAL int rm4scc(struct zint_symbol *symbol, unsigned char source[], int length); /* RM4SCC */
INTERNAL int auspost(struct zint_symbol *symbol, unsigned char source[], int length); /* Australia Post 4-state */
INTERNAL int code16k(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 16k */
INTERNAL int pdf417enc(struct zint_symbol *symbol, unsigned char source[], int length); /* PDF417 */
INTERNAL int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[], int length); /* Micro PDF417 */
INTERNAL int pdf417(struct zint_symbol *symbol, unsigned char source[], int length); /* PDF417 */
INTERNAL int micropdf417(struct zint_symbol *symbol, unsigned char chaine[], int length); /* Micro PDF417 */
INTERNAL int maxicode(struct zint_symbol *symbol, unsigned char source[], int length); /* Maxicode */
INTERNAL int rss14(struct zint_symbol *symbol, unsigned char source[], int length); /* RSS-14 */
INTERNAL int rsslimited(struct zint_symbol *symbol, unsigned char source[], int length); /* RSS Limited */
INTERNAL int rssexpanded(struct zint_symbol *symbol, unsigned char source[], int length); /* RSS Expanded */
INTERNAL int dbar_omn(struct zint_symbol *symbol, unsigned char source[], int length); /* RSS-14 */
INTERNAL int dbar_ltd(struct zint_symbol *symbol, unsigned char source[], int length); /* RSS Limited */
INTERNAL int dbar_exp(struct zint_symbol *symbol, unsigned char source[], int length); /* RSS Expanded */
INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int length); /* Composite Symbology */
INTERNAL int kix_code(struct zint_symbol *symbol, unsigned char source[], int length); /* TNT KIX Code */
INTERNAL int kix(struct zint_symbol *symbol, unsigned char source[], int length); /* TNT KIX Code */
INTERNAL int aztec(struct zint_symbol *symbol, unsigned char source[], int length); /* Aztec Code */
INTERNAL int code32(struct zint_symbol *symbol, unsigned char source[], int length); /* Italian Pharmacode */
INTERNAL int daft_code(struct zint_symbol *symbol, unsigned char source[], int length); /* DAFT Code */
INTERNAL int ean_14(struct zint_symbol *symbol, unsigned char source[], int length); /* EAN-14 */
INTERNAL int nve_18(struct zint_symbol *symbol, unsigned char source[], int length); /* NVE-18 */
INTERNAL int daft(struct zint_symbol *symbol, unsigned char source[], int length); /* DAFT Code */
INTERNAL int ean14(struct zint_symbol *symbol, unsigned char source[], int length); /* EAN-14 */
INTERNAL int nve18(struct zint_symbol *symbol, unsigned char source[], int length); /* NVE-18 */
INTERNAL int microqr(struct zint_symbol *symbol, unsigned char source[], int length); /* Micro QR Code */
INTERNAL int aztec_runes(struct zint_symbol *symbol, unsigned char source[], int length); /* Aztec Runes */
INTERNAL int korea_post(struct zint_symbol *symbol, unsigned char source[], int length); /* Korea Post */
INTERNAL int japan_post(struct zint_symbol *symbol, unsigned char source[], int length); /* Japanese Post */
INTERNAL int code_49(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 49 */
INTERNAL int channel_code(struct zint_symbol *symbol, unsigned char source[], int length); /* Channel Code */
INTERNAL int code_one(struct zint_symbol *symbol, unsigned char source[], int length); /* Code One */
INTERNAL int grid_matrix(struct zint_symbol *symbol, unsigned char source[], int length); /* Grid Matrix */
INTERNAL int han_xin(struct zint_symbol *symbol, unsigned char source[], int length); /* Han Xin */
INTERNAL int azrune(struct zint_symbol *symbol, unsigned char source[], int length); /* Aztec Runes */
INTERNAL int koreapost(struct zint_symbol *symbol, unsigned char source[], int length); /* Korea Post */
INTERNAL int japanpost(struct zint_symbol *symbol, unsigned char source[], int length); /* Japanese Post */
INTERNAL int code49(struct zint_symbol *symbol, unsigned char source[], int length); /* Code 49 */
INTERNAL int channel(struct zint_symbol *symbol, unsigned char source[], int length); /* Channel Code */
INTERNAL int codeone(struct zint_symbol *symbol, unsigned char source[], int length); /* Code One */
INTERNAL int gridmatrix(struct zint_symbol *symbol, unsigned char source[], int length); /* Grid Matrix */
INTERNAL int hanxin(struct zint_symbol *symbol, unsigned char source[], int length); /* Han Xin */
INTERNAL int dotcode(struct zint_symbol *symbol, unsigned char source[], int length); /* DotCode */
INTERNAL int codablock(struct zint_symbol *symbol, unsigned char source[], int length); /* Codablock */
INTERNAL int codablockf(struct zint_symbol *symbol, unsigned char source[], int length); /* Codablock */
INTERNAL int upnqr(struct zint_symbol *symbol, unsigned char source[], int length); /* UPNQR */
INTERNAL int qr_code(struct zint_symbol *symbol, unsigned char source[], int length); /* QR Code */
INTERNAL int dmatrix(struct zint_symbol *symbol, unsigned char source[], int length); /* Data Matrix (IEC16022) */
INTERNAL int qrcode(struct zint_symbol *symbol, unsigned char source[], int length); /* QR Code */
INTERNAL int datamatrix(struct zint_symbol *symbol, unsigned char source[], int length); /* Data Matrix (IEC16022) */
/* VIN Code (Vehicle Identification Number) */
INTERNAL int vin(struct zint_symbol *symbol, unsigned char source[], int length);
/* Royal Mail 4-state Mailmark */
INTERNAL int mailmark(struct zint_symbol *symbol, unsigned char source[], int length);
INTERNAL int ultracode(struct zint_symbol *symbol, unsigned char source[], int length); /* Ultracode */
INTERNAL int ultra(struct zint_symbol *symbol, unsigned char source[], int length); /* Ultracode */
INTERNAL int rmqr(struct zint_symbol *symbol, unsigned char source[], int length); /* rMQR */
INTERNAL int dpd_parcel(struct zint_symbol *symbol, unsigned char source[], int length); /* DPD Code */
INTERNAL int dpd(struct zint_symbol *symbol, unsigned char source[], int length); /* DPD Code */
INTERNAL int plot_raster(struct zint_symbol *symbol, int rotate_angle, int file_type); /* Plot to PNG/BMP/PCX */
INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_type); /* Plot to EPS/EMF/SVG */
@ -299,7 +294,7 @@ static int dump_plot(struct zint_symbol *symbol) {
/* Process health industry bar code data */
static int hibc(struct zint_symbol *symbol, unsigned char source[], int length) {
int i;
int counter, error_number;
int counter, error_number = 0;
char to_process[113], check_digit;
/* without "+" and check: max 110 characters in HIBC 2.6 */
@ -308,10 +303,9 @@ static int hibc(struct zint_symbol *symbol, unsigned char source[], int length)
return ZINT_ERROR_TOO_LONG;
}
to_upper(source);
error_number = is_sane(TECHNETIUM, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
if (is_sane(TECHNETIUM, source, length) != 0) {
strcpy(symbol->errtxt, "203: Invalid character in data (alphanumerics, space and \"-.$/+%\" only)");
return error_number;
return ZINT_ERROR_INVALID_DATA;
}
counter = 41;
@ -355,35 +349,35 @@ static int hibc(struct zint_symbol *symbol, unsigned char source[], int length)
switch (symbol->symbology) {
case BARCODE_HIBC_128:
error_number = code_128(symbol, (unsigned char *) to_process, length);
error_number = code128(symbol, (unsigned char *) to_process, length);
ustrcpy(symbol->text, "*");
ustrcat(symbol->text, to_process);
ustrcat(symbol->text, "*");
break;
case BARCODE_HIBC_39:
symbol->option_2 = 0;
error_number = c39(symbol, (unsigned char *) to_process, length);
error_number = code39(symbol, (unsigned char *) to_process, length);
ustrcpy(symbol->text, "*");
ustrcat(symbol->text, to_process);
ustrcat(symbol->text, "*");
break;
case BARCODE_HIBC_DM:
error_number = dmatrix(symbol, (unsigned char *) to_process, length);
error_number = datamatrix(symbol, (unsigned char *) to_process, length);
break;
case BARCODE_HIBC_QR:
error_number = qr_code(symbol, (unsigned char *) to_process, length);
error_number = qrcode(symbol, (unsigned char *) to_process, length);
break;
case BARCODE_HIBC_PDF:
error_number = pdf417enc(symbol, (unsigned char *) to_process, length);
error_number = pdf417(symbol, (unsigned char *) to_process, length);
break;
case BARCODE_HIBC_MICPDF:
error_number = micro_pdf417(symbol, (unsigned char *) to_process, length);
error_number = micropdf417(symbol, (unsigned char *) to_process, length);
break;
case BARCODE_HIBC_AZTEC:
error_number = aztec(symbol, (unsigned char *) to_process, length);
break;
case BARCODE_HIBC_BLOCKF:
error_number = codablock(symbol, (unsigned char *) to_process, length);
error_number = codablockf(symbol, (unsigned char *) to_process, length);
break;
}
@ -542,6 +536,41 @@ static int has_hrt(const int symbology) {
return 1;
}
/* Used for dispatching barcodes and for whether symbol id valid */
typedef int (*barcode_func_t)(struct zint_symbol *, unsigned char *, int);
static const barcode_func_t barcode_funcs[146] = {
NULL, code11, c25standard, c25inter, c25iata, /*0-4*/
NULL, c25logic, c25ind, code39, excode39, /*5-9*/
NULL, NULL, NULL, eanx, eanx, /*10-14*/
NULL, gs1_128, NULL, codabar, NULL, /*15-19*/
code128, dpleit, dpident, code16k, code49, /*20-24*/
code93, NULL, NULL, flat, dbar_omn, /*25-29*/
dbar_ltd, dbar_exp, telepen, NULL, eanx, /*30-34*/
eanx, NULL, eanx, eanx, NULL, /*35-39*/
postnet, NULL, NULL, NULL, NULL, /*40-44*/
NULL, NULL, msi_plessey, NULL, fim, /*45-49*/
code39, pharma, pzn, pharma_two, NULL, /*50-54*/
pdf417, pdf417, maxicode, qrcode, NULL, /*55-59*/
code128, NULL, NULL, auspost, NULL, /*60-64*/
NULL, auspost, auspost, auspost, eanx, /*65-69*/
rm4scc, datamatrix, ean14, vin, codablockf, /*70-74*/
nve18, japanpost, koreapost, NULL, dbar_omn, /*75-79*/
dbar_omn, dbar_exp, planet, NULL, micropdf417, /*80-84*/
usps_imail, plessey, telepen_num, NULL, itf14, /*85-89*/
kix, NULL, aztec, daft, NULL, /*90-94*/
NULL, dpd, microqr, hibc, hibc, /*95-99*/
NULL, NULL, hibc, NULL, hibc, /*100-104*/
NULL, hibc, NULL, hibc, NULL, /*105-109*/
hibc, NULL, hibc, NULL, NULL, /*110-114*/
dotcode, hanxin, NULL, NULL, NULL, /*115-119*/
NULL, mailmark, NULL, NULL, NULL, /*120-124*/
NULL, NULL, NULL, azrune, code32, /*125-129*/
composite, composite, composite, composite, composite, /*130-134*/
composite, composite, composite, composite, composite, /*135-139*/
channel, codeone, gridmatrix, upnqr, ultra, /*140-144*/
rmqr,
};
static int reduced_charset(struct zint_symbol *symbol, unsigned char *source, int length);
static int extended_or_reduced_charset(struct zint_symbol *symbol, unsigned char *source, const int length) {
@ -549,17 +578,13 @@ static int extended_or_reduced_charset(struct zint_symbol *symbol, unsigned char
switch (symbol->symbology) {
/* These are the "elite" standards which have support for specific character sets */
case BARCODE_QRCODE: error_number = qr_code(symbol, source, length);
break;
case BARCODE_MICROQR: error_number = microqr(symbol, source, length);
break;
case BARCODE_GRIDMATRIX: error_number = grid_matrix(symbol, source, length);
break;
case BARCODE_HANXIN: error_number = han_xin(symbol, source, length);
break;
case BARCODE_UPNQR: error_number = upnqr(symbol, source, length);
break;
case BARCODE_RMQR: error_number = rmqr(symbol, source, length);
case BARCODE_QRCODE:
case BARCODE_MICROQR:
case BARCODE_GRIDMATRIX:
case BARCODE_HANXIN:
case BARCODE_UPNQR:
case BARCODE_RMQR:
error_number = (*barcode_funcs[symbol->symbology])(symbol, source, length);
break;
default: error_number = reduced_charset(symbol, source, length);
break;
@ -568,8 +593,8 @@ static int extended_or_reduced_charset(struct zint_symbol *symbol, unsigned char
return error_number;
}
static int reduced_charset(struct zint_symbol *symbol, unsigned char *source, int length) {
/* These are the "norm" standards which only support Latin-1 at most, though a few support ECI */
static int reduced_charset(struct zint_symbol *symbol, unsigned char *source, int length) {
int error_number = 0;
unsigned char *preprocessed = source;
@ -594,169 +619,7 @@ static int reduced_charset(struct zint_symbol *symbol, unsigned char *source, in
}
}
switch (symbol->symbology) {
case BARCODE_C25STANDARD: error_number = matrix_two_of_five(symbol, preprocessed, length);
break;
case BARCODE_C25IND: error_number = industrial_two_of_five(symbol, preprocessed, length);
break;
case BARCODE_C25INTER: error_number = interleaved_two_of_five(symbol, preprocessed, length);
break;
case BARCODE_C25IATA: error_number = iata_two_of_five(symbol, preprocessed, length);
break;
case BARCODE_C25LOGIC: error_number = logic_two_of_five(symbol, preprocessed, length);
break;
case BARCODE_DPLEIT: error_number = dpleit(symbol, preprocessed, length);
break;
case BARCODE_DPIDENT: error_number = dpident(symbol, preprocessed, length);
break;
case BARCODE_UPCA:
case BARCODE_UPCA_CHK:
case BARCODE_UPCE:
case BARCODE_UPCE_CHK:
case BARCODE_EANX:
case BARCODE_EANX_CHK:
case BARCODE_ISBNX:
error_number = eanx(symbol, preprocessed, length);
break;
case BARCODE_GS1_128: error_number = ean_128(symbol, preprocessed, length);
break;
case BARCODE_CODE39: error_number = c39(symbol, preprocessed, length);
break;
case BARCODE_PZN: error_number = pharmazentral(symbol, preprocessed, length);
break;
case BARCODE_EXCODE39: error_number = ec39(symbol, preprocessed, length);
break;
case BARCODE_CODABAR: error_number = codabar(symbol, preprocessed, length);
break;
case BARCODE_CODE93: error_number = c93(symbol, preprocessed, length);
break;
case BARCODE_LOGMARS: error_number = c39(symbol, preprocessed, length);
break;
case BARCODE_CODE128:
case BARCODE_CODE128B:
error_number = code_128(symbol, preprocessed, length);
break;
case BARCODE_NVE18: error_number = nve_18(symbol, preprocessed, length);
break;
case BARCODE_CODE11: error_number = code_11(symbol, preprocessed, length);
break;
case BARCODE_MSI_PLESSEY: error_number = msi_handle(symbol, preprocessed, length);
break;
case BARCODE_TELEPEN: error_number = telepen(symbol, preprocessed, length);
break;
case BARCODE_TELEPEN_NUM: error_number = telepen_num(symbol, preprocessed, length);
break;
case BARCODE_PHARMA: error_number = pharma_one(symbol, preprocessed, length);
break;
case BARCODE_PLESSEY: error_number = plessey(symbol, preprocessed, length);
break;
case BARCODE_ITF14: error_number = itf14(symbol, preprocessed, length);
break;
case BARCODE_FLAT: error_number = flattermarken(symbol, preprocessed, length);
break;
case BARCODE_FIM: error_number = fim(symbol, preprocessed, length);
break;
case BARCODE_POSTNET: error_number = post_plot(symbol, preprocessed, length);
break;
case BARCODE_PLANET: error_number = planet_plot(symbol, preprocessed, length);
break;
case BARCODE_RM4SCC: error_number = royal_plot(symbol, preprocessed, length);
break;
case BARCODE_AUSPOST:
case BARCODE_AUSREPLY:
case BARCODE_AUSROUTE:
case BARCODE_AUSREDIRECT:
error_number = australia_post(symbol, preprocessed, length);
break;
case BARCODE_CODE16K: error_number = code16k(symbol, preprocessed, length);
break;
case BARCODE_PHARMA_TWO: error_number = pharma_two(symbol, preprocessed, length);
break;
case BARCODE_USPS_IMAIL: error_number = imail(symbol, preprocessed, length);
break;
case BARCODE_DBAR_OMN:
case BARCODE_DBAR_STK:
case BARCODE_DBAR_OMNSTK:
error_number = rss14(symbol, preprocessed, length);
break;
case BARCODE_DBAR_LTD: error_number = rsslimited(symbol, preprocessed, length);
break;
case BARCODE_DBAR_EXP:
case BARCODE_DBAR_EXPSTK:
error_number = rssexpanded(symbol, preprocessed, length);
break;
case BARCODE_EANX_CC:
case BARCODE_GS1_128_CC:
case BARCODE_DBAR_OMN_CC:
case BARCODE_DBAR_LTD_CC:
case BARCODE_DBAR_EXP_CC:
case BARCODE_UPCA_CC:
case BARCODE_UPCE_CC:
case BARCODE_DBAR_STK_CC:
case BARCODE_DBAR_OMNSTK_CC:
case BARCODE_DBAR_EXPSTK_CC:
error_number = composite(symbol, preprocessed, length);
break;
case BARCODE_KIX: error_number = kix_code(symbol, preprocessed, length);
break;
case BARCODE_CODE32: error_number = code32(symbol, preprocessed, length);
break;
case BARCODE_DAFT: error_number = daft_code(symbol, preprocessed, length);
break;
case BARCODE_EAN14:
error_number = ean_14(symbol, preprocessed, length);
break;
case BARCODE_AZRUNE: error_number = aztec_runes(symbol, preprocessed, length);
break;
case BARCODE_KOREAPOST: error_number = korea_post(symbol, preprocessed, length);
break;
case BARCODE_HIBC_128:
case BARCODE_HIBC_39:
case BARCODE_HIBC_DM:
case BARCODE_HIBC_QR:
case BARCODE_HIBC_PDF:
case BARCODE_HIBC_MICPDF:
case BARCODE_HIBC_AZTEC:
case BARCODE_HIBC_BLOCKF:
error_number = hibc(symbol, preprocessed, length);
break;
case BARCODE_JAPANPOST: error_number = japan_post(symbol, preprocessed, length);
break;
case BARCODE_CODE49: error_number = code_49(symbol, preprocessed, length);
break;
case BARCODE_CHANNEL: error_number = channel_code(symbol, preprocessed, length);
break;
case BARCODE_CODEONE: error_number = code_one(symbol, preprocessed, length);
break;
case BARCODE_DATAMATRIX: error_number = dmatrix(symbol, preprocessed, length);
break;
case BARCODE_PDF417:
case BARCODE_PDF417COMP:
error_number = pdf417enc(symbol, preprocessed, length);
break;
case BARCODE_MICROPDF417: error_number = micro_pdf417(symbol, preprocessed, length);
break;
case BARCODE_MAXICODE: error_number = maxicode(symbol, preprocessed, length);
break;
case BARCODE_AZTEC: error_number = aztec(symbol, preprocessed, length);
break;
case BARCODE_DOTCODE: error_number = dotcode(symbol, preprocessed, length);
break;
case BARCODE_CODABLOCKF: error_number = codablock(symbol, preprocessed, length);
break;
case BARCODE_VIN: error_number = vin(symbol, preprocessed, length);
break;
case BARCODE_MAILMARK: error_number = mailmark(symbol, preprocessed, length);
break;
case BARCODE_ULTRA: error_number = ultracode(symbol, preprocessed, length);
break;
case BARCODE_DPD: error_number = dpd_parcel(symbol, preprocessed, length);
break;
default: /* Should never happen */
strcpy(symbol->errtxt, "001: Internal error"); /* Not reached */
error_number = ZINT_ERROR_ENCODING_PROBLEM;
break;
}
error_number = (*barcode_funcs[symbol->symbology])(symbol, preprocessed, length);
return error_number;
}
@ -1484,31 +1347,14 @@ int ZBarcode_Encode_File_and_Buffer_Vector(struct zint_symbol *symbol, const cha
return error_number;
}
int ZBarcode_ValidID(int symbol_id) {
/* Checks whether a symbology is supported */
static const unsigned char ids[146] = {
0, 1, 2, 3, 4, 0, 6, 7, 8, 9,
0, 0, 0, 13, 14, 0, 16, 0, 18, 0,
20, 21, 22, 23, 24, 25, 0, 0, 28, 29,
30, 31, 32, 0, 34, 35, 0, 37, 38, 0,
40, 0, 0, 0, 0, 0, 0, 47, 0, 49,
50, 51, 52, 53, 0, 55, 56, 57, 58, 0,
60, 0, 0, 63, 0, 0, 66, 67, 68, 69,
70, 71, 72, 73, 74, 75, 76, 77, 0, 79,
80, 81, 82, 0, 84, 85, 86, 87, 0, 89,
90, 0, 92, 93, 0, 0, 96, 97, 98, 99,
0, 0, 102, 0, 104, 0, 106, 0, 108, 0,
110, 0, 112, 0, 0, 115, 116, 0, 0, 0,
0, 121, 0, 0, 0, 0, 0, 0, 128, 129,
130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
140, 141, 142, 143, 144, 145,
};
int ZBarcode_ValidID(int symbol_id) {
if (symbol_id <= 0 || symbol_id > 145) {
return 0;
}
return ids[symbol_id] != 0;
return barcode_funcs[symbol_id] != NULL;
}
/* Return the capability flags for symbology `symbol_id` that match `cap_flag` */
@ -1628,6 +1474,36 @@ unsigned int ZBarcode_Cap(int symbol_id, unsigned int cap_flag) {
break;
}
}
if ((cap_flag & ZINT_CAP_COMPLIANT_HEIGHT) && !is_fixed_ratio(symbol_id)) {
switch (symbol_id) {
/* These don't have a compliant height defined */
case BARCODE_CODE11: /* TODO: Find doc */
case BARCODE_C25STANDARD: /* For C25 only have doc for C25INTER */
case BARCODE_C25IATA:
case BARCODE_C25LOGIC:
case BARCODE_C25IND:
case BARCODE_CODE128: /* Left to application */
case BARCODE_CODE128B:
case BARCODE_DPLEIT: /* TODO: Find doc */
case BARCODE_DPIDENT: /* TODO: Find doc */
case BARCODE_FLAT: /* TODO: Find doc */
case BARCODE_MSI_PLESSEY: /* TODO: Find doc */
case BARCODE_PDF417: /* Has compliant height but already warns & uses for default */
case BARCODE_PDF417COMP:
case BARCODE_VIN: /* Spec unlikely */
case BARCODE_KOREAPOST: /* TODO: Find doc */
case BARCODE_MICROPDF417: /* See PDF417 */
case BARCODE_PLESSEY: /* TODO: Find doc */
case BARCODE_DAFT: /* Generic */
case BARCODE_HIBC_128: /* See CODE128 */
case BARCODE_HIBC_PDF: /* See PDF417 */
case BARCODE_HIBC_MICPDF: /* See PDF417 */
break;
default:
result |= ZINT_CAP_COMPLIANT_HEIGHT;
break;
}
}
return result;
}

View File

@ -33,9 +33,11 @@
/*
* Developed in accordance with "Royal Mail Mailmark barcode C encoding and deconding instructions"
* (https://www.royalmail.com/sites/default/files/Mailmark-4-state-barcode-C-encoding-and-decoding-instructions-Sept-2015.pdf)
* (https://www.royalmail.com/sites/default/files/
* Mailmark-4-state-barcode-C-encoding-and-decoding-instructions-Sept-2015.pdf)
* and "Royal Mail Mailmark barcode L encoding and decoding"
* (https://www.royalmail.com/sites/default/files/Mailmark-4-state-barcode-L-encoding-and-decoding-instructions-Sept-2015.pdf)
* (https://www.royalmail.com/sites/default/files/
* Mailmark-4-state-barcode-L-encoding-and-decoding-instructions-Sept-2015.pdf)
*
*/
@ -182,21 +184,21 @@ INTERNAL int mailmark(struct zint_symbol *symbol, unsigned char source[], int le
// Format is in the range 0-4
format = ctoi(local_source[0]);
if ((format < 0) || (format > 4)) {
strcpy(symbol->errtxt, "582: Format out of range (0 to 4)");
strcpy(symbol->errtxt, "582: Format (1st character) out of range (0 to 4)");
return ZINT_ERROR_INVALID_DATA;
}
// Version ID is in the range 1-4
version_id = ctoi(local_source[1]) - 1;
if ((version_id < 0) || (version_id > 3)) {
strcpy(symbol->errtxt, "583: Version ID out of range (1 to 4)");
strcpy(symbol->errtxt, "583: Version ID (2nd character) out of range (1 to 4)");
return ZINT_ERROR_INVALID_DATA;
}
// Class is in the range 0-9,A-E
mail_class = ctoi(local_source[2]);
if ((mail_class < 0) || (mail_class > 14)) {
strcpy(symbol->errtxt, "584: Class out of range (0 to 9 and A to E)");
strcpy(symbol->errtxt, "584: Class (3rd character) out of range (0 to 9 and A to E)");
return ZINT_ERROR_INVALID_DATA;
}
@ -207,7 +209,7 @@ INTERNAL int mailmark(struct zint_symbol *symbol, unsigned char source[], int le
supply_chain_id *= 10;
supply_chain_id += ctoi(local_source[i]);
} else {
strcpy(symbol->errtxt, "585: Invalid Supply Chain ID (digits only)");
sprintf(symbol->errtxt, "585: Invalid Supply Chain ID at character %d (digits only)", i);
return ZINT_ERROR_INVALID_DATA;
}
}
@ -219,7 +221,7 @@ INTERNAL int mailmark(struct zint_symbol *symbol, unsigned char source[], int le
item_id *= 10;
item_id += ctoi(local_source[i]);
} else {
strcpy(symbol->errtxt, "586: Invalid Item ID (digits only)");
sprintf(symbol->errtxt, "586: Invalid Item ID at character %d (digits only)", i);
return ZINT_ERROR_INVALID_DATA;
}
}
@ -273,7 +275,7 @@ INTERNAL int mailmark(struct zint_symbol *symbol, unsigned char source[], int le
// Verify postcode type
if (postcode_type != 7) {
if (verify_postcode(postcode, postcode_type) != 0) {
strcpy(symbol->errtxt, "587: Invalid postcode");
sprintf(symbol->errtxt, "587: Invalid postcode \"%s\"", postcode);
return ZINT_ERROR_INVALID_DATA;
}
}
@ -487,22 +489,24 @@ INTERNAL int mailmark(struct zint_symbol *symbol, unsigned char source[], int le
j += 2;
}
#ifdef COMPLIANT_HEIGHTS
if (symbol->output_options & COMPLIANT_HEIGHT) {
/* Royal Mail Mailmark Barcode Definition Document (15 Sept 2015) Section 3.5.1
https://www.royalmail.com/sites/default/files/Royal-Mail-Mailmark-barcode-definition-document-September-2015.pdf
Using bar pitch as X (25.4mm / 42.3) ~ 0.6mm based on 21.2 bars + 21.1 spaces per 25.4mm (bar width 0.38-63mm)
(https://www.royalmail.com/sites/default/files/
Royal-Mail-Mailmark-barcode-definition-document-September-2015.pdf)
Using bar pitch as X (25.4mm / 42.3) ~ 0.6mm based on 21.2 bars + 21.1 spaces per 25.4mm (bar width
0.38mm - 0.63mm)
Using recommended 1.9mm and 1.3mm heights for Ascender/Descenders and Trackers resp. as defaults
Min height 4.22mm * 39 (max pitch) / 25.4mm ~ 6.47, max height 5.84mm * 47 (min pitch) / 25.4mm ~ 10.8
*/
symbol->row_height[0] = (float) ((1.9 * 42.3) / 25.4); /* ~3.16 */
symbol->row_height[1] = (float) ((1.3 * 42.3) / 25.4); /* ~2.16 */
symbol->row_height[0] = stripf((1.9f * 42.3f) / 25.4f); /* ~3.16 */
symbol->row_height[1] = stripf((1.3f * 42.3f) / 25.4f); /* ~2.16 */
/* Note using max X for minimum and min X for maximum */
error_number = daft_set_height(symbol, (float) ((4.22 * 39) / 25.4), (float) ((5.84 * 47) / 25.4));
#else
error_number = daft_set_height(symbol, stripf((4.22f * 39) / 25.4f), stripf((5.84f * 47) / 25.4f));
} else {
symbol->row_height[0] = 4.0f;
symbol->row_height[1] = 2.0f;
daft_set_height(symbol, 0.0f, 0.0f);
#endif
(void) daft_set_height(symbol, 0.0f, 0.0f);
}
symbol->rows = 3;
symbol->width = j - 1;

View File

@ -34,7 +34,7 @@
#include <stdio.h>
#include "common.h"
INTERNAL int c39(struct zint_symbol *symbol, unsigned char source[], int length);
INTERNAL int code39(struct zint_symbol *symbol, unsigned char source[], int length);
/* Codabar table checked against EN 798:1995 */
@ -47,7 +47,7 @@ static const char *CodaTable[20] = {
"21212111", "11212121", "11221211", "12121121", "11121221", "11122211"
};
INTERNAL int pharma_one(struct zint_symbol *symbol, unsigned char source[], int length) {
INTERNAL int pharma(struct zint_symbol *symbol, unsigned char source[], int length) {
/* "Pharmacode can represent only a single integer from 3 to 131070. Unlike other
commonly used one-dimensional barcode schemes, pharmacode does not store the data in a
form corresponding to the human-readable digits; the number is encoded in binary, rather
@ -62,7 +62,7 @@ INTERNAL int pharma_one(struct zint_symbol *symbol, unsigned char source[], int
(http://www.gomaro.ch/ftproot/Laetus_PHARMA-CODE.pdf) */
unsigned long int tester;
int counter, error_number, h;
int counter, error_number = 0, h;
char inter[18] = {0}; /* 131070 -> 17 bits */
char dest[64]; /* 17 * 2 + 1 */
@ -70,10 +70,9 @@ INTERNAL int pharma_one(struct zint_symbol *symbol, unsigned char source[], int
strcpy(symbol->errtxt, "350: Input too long (6 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
if (is_sane(NEON, source, length) != 0) {
strcpy(symbol->errtxt, "351: Invalid character in data (digits only)");
return error_number;
return ZINT_ERROR_INVALID_DATA;
}
tester = atoi((char *) source);
@ -105,12 +104,12 @@ INTERNAL int pharma_one(struct zint_symbol *symbol, unsigned char source[], int
expand(symbol, dest);
#ifdef COMPLIANT_HEIGHTS
if (symbol->output_options & COMPLIANT_HEIGHT) {
/* Laetus Pharmacode Guide 1.2 Standard one-track height 8mm / 0.5mm (X) */
error_number = set_height(symbol, 16.0f, 0.0f, 0.0f, 0 /*no_errtxt*/);
#else
} else {
(void) set_height(symbol, 0.0f, 50.0f, 0.0f, 1 /*no_errtxt*/);
#endif
}
return error_number;
}
@ -173,10 +172,9 @@ INTERNAL int pharma_two(struct zint_symbol *symbol, unsigned char source[], int
strcpy(symbol->errtxt, "354: Input too long (8 character maximum");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
if (is_sane(NEON, source, length) != 0) {
strcpy(symbol->errtxt, "355: Invalid character in data (digits only)");
return error_number;
return ZINT_ERROR_INVALID_DATA;
}
error_number = pharma_two_calc(symbol, source, height_pattern);
if (error_number != 0) {
@ -197,13 +195,13 @@ INTERNAL int pharma_two(struct zint_symbol *symbol, unsigned char source[], int
symbol->rows = 2;
symbol->width = writer - 1;
#ifdef COMPLIANT_HEIGHTS
if (symbol->output_options & COMPLIANT_HEIGHT) {
/* Laetus Pharmacode Guide 1.4
Two-track height min 8mm / 2mm (X max) = 4, standard 8mm / 1mm = 8, max 12mm / 0.8mm (X min) = 15 */
error_number = set_height(symbol, 2.0f, 8.0f, 15.0f, 0 /*no_errtxt*/);
#else
} else {
(void) set_height(symbol, 0.0f, 10.0f, 0.0f, 1 /*no_errtxt*/);
#endif
}
return error_number;
}
@ -211,11 +209,11 @@ INTERNAL int pharma_two(struct zint_symbol *symbol, unsigned char source[], int
/* The Codabar system consisting of simple substitution */
INTERNAL int codabar(struct zint_symbol *symbol, unsigned char source[], int length) {
int i, error_number;
static const char calcium[] = CALCIUM;
int i, error_number = 0;
char dest[512];
int add_checksum, count = 0, checksum;
int add_checksum, count = 0, checksum = 0;
int d_chars = 0;
float height;
strcpy(dest, "");
@ -244,21 +242,23 @@ INTERNAL int codabar(struct zint_symbol *symbol, unsigned char source[], int len
}
/* And must not use A, B, C or D otherwise (BS EN 798:1995 4.3.2) */
error_number = is_sane(CALCIUM_INNER, source + 1, length - 2);
if (error_number) {
if (is_sane(CALCIUM, source + 1, length - 2) == 0) {
if (is_sane(CALCIUM_INNER, source + 1, length - 2) != 0) {
if (is_sane(calcium, source + 1, length - 2) == 0) {
strcpy(symbol->errtxt, "363: Cannot contain \"A\", \"B\", \"C\" or \"D\"");
} else {
sprintf(symbol->errtxt, "357: Invalid character in data (\"%s\" only)", CALCIUM);
sprintf(symbol->errtxt, "357: Invalid character in data (\"%s\" only)", calcium);
}
return error_number;
return ZINT_ERROR_INVALID_DATA;
}
add_checksum = symbol->option_2 == 1;
/* Add check character: 1 don't show to HRT, 2 do show to HRT
(unfortunately to maintain back-compatibility, this is reverse of C25) */
add_checksum = symbol->option_2 == 1 || symbol->option_2 == 2;
for (i = 0; i < length; i++) {
static const char calcium[] = CALCIUM;
if (add_checksum) {
/* BS EN 798:1995 A.3 suggests using ISO 7064 algorithm but leaves it application defined.
Following BWIPP and TEC-IT, use this simple mod-16 algorithm (not in ISO 7064) */
count += strchr(calcium, source[i]) - calcium;
if (i + 1 == length) {
checksum = count % 16;
@ -266,7 +266,7 @@ INTERNAL int codabar(struct zint_symbol *symbol, unsigned char source[], int len
checksum = 16 - checksum;
}
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("Codabar: %s, count %d, checksum %d\n", source, count, checksum);
printf("Codabar: %s, count %d, checksum %d (%c)\n", source, count, checksum, calcium[checksum]);
}
strcat(dest, CodaTable[checksum]);
}
@ -279,23 +279,29 @@ INTERNAL int codabar(struct zint_symbol *symbol, unsigned char source[], int len
expand(symbol, dest);
#ifdef COMPLIANT_HEIGHTS
/* BS EN 798:1995 4.4.1 (d) max of 5mm / 0.191mm (X) ~ 26.178 or 15% of width where (taking N = narrow/wide ratio
as 2 and I = X) width = ((2 * N + 5) * C + (N 1) * (D + 2)) * X + I * (C 1) + 2Q
if (symbol->output_options & COMPLIANT_HEIGHT) {
/* BS EN 798:1995 4.4.1 (d) max of 5mm / 0.191mm (X) ~ 26.178 or 15% of width where (taking N = narrow/wide
ratio as 2 and I = X) width = ((2 * N + 5) * C + (N 1) * (D + 2)) * X + I * (C 1) + 2Q
= ((4 + 5) * C + (D + 2) + C - 1 + 2 * 10) * X = (10 * C + D + 21) * X
Length (C) includes start/stop chars */
height = (float) ((10.0 * ((add_checksum ? length + 1 : length) + 2.0) + d_chars + 21.0) * 0.15);
if (height < (float) (5.0 / 0.191)) {
height = (float) (5.0 / 0.191);
const float min_height_min = stripf(5.0f / 0.191f);
float min_height = stripf((10.0f * ((add_checksum ? length + 1 : length) + 2.0f) + d_chars + 21.0f) * 0.15f);
if (min_height < min_height_min) {
min_height = min_height_min;
}
/* Using 50 as default as none recommended */
error_number = set_height(symbol, height, height > 50.0f ? height : 50.0f, 0.0f, 0 /*no_errtxt*/);
#else
height = 50.0f;
(void) set_height(symbol, 0.0f, height, 0.0f, 1 /*no_errtxt*/);
#endif
error_number = set_height(symbol, min_height, min_height > 50.0f ? min_height : 50.0f, 0.0f, 0 /*no_errtxt*/);
} else {
(void) set_height(symbol, 0.0f, 50.0f, 0.0f, 1 /*no_errtxt*/);
}
ustrcpy(symbol->text, source);
if (symbol->option_2 == 2) {
symbol->text[length - 1] = calcium[checksum]; /* Place before final A/B/C/D character (BS EN 798:1995 A.3) */
symbol->text[length] = source[length - 1];
symbol->text[length + 1] = '\0';
}
return error_number;
}
@ -312,10 +318,9 @@ INTERNAL int code32(struct zint_symbol *symbol, unsigned char source[], int leng
strcpy(symbol->errtxt, "360: Input too long (8 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
if (is_sane(NEON, source, length) != 0) {
strcpy(symbol->errtxt, "361: Invalid character in data (digits only)");
return error_number;
return ZINT_ERROR_INVALID_DATA;
}
/* Add leading zeros as required */
@ -361,20 +366,22 @@ INTERNAL int code32(struct zint_symbol *symbol, unsigned char source[], int leng
}
risultante[6] = '\0';
/* Plot the barcode using Code 39 */
error_number = c39(symbol, (unsigned char *) risultante, (int) strlen(risultante));
error_number = code39(symbol, (unsigned char *) risultante, (int) strlen(risultante));
if (error_number != 0) { /* Should never happen */
return error_number; /* Not reached */
}
#ifdef COMPLIANT_HEIGHTS
if (symbol->output_options & COMPLIANT_HEIGHT) {
/* Allegato A Caratteristiche tecniche del bollino farmaceutico
https://www.gazzettaufficiale.it/do/atto/serie_generale/caricaPdf?cdimg=14A0566800100010110001&dgu=2014-07-18&art.dataPubblicazioneGazzetta=2014-07-18&art.codiceRedazionale=14A05668&art.num=1&art.tiposerie=SG
(https://www.gazzettaufficiale.it/do/atto/serie_generale/caricaPdf?cdimg=14A0566800100010110001
&dgu=2014-07-18&art.dataPubblicazioneGazzetta=2014-07-18&art.codiceRedazionale=14A05668&art.num=1
&art.tiposerie=SG)
X given as 0.250mm; height (and quiet zones) left to ISO/IEC 16388:2007 (Code 39)
So min height 5mm = 5mm / 0.25mm = 20 > 15% of width, i.e. (10 * 8 + 19) * 0.15 = 14.85 */
error_number = set_height(symbol, 20.0f, 20.0f, 0.0f, 0 /*no_errtxt*/); /* Use as default also */
#else
} else {
(void) set_height(symbol, 0.0f, 50.0f, 0.0f, 1 /*no_errtxt*/);
#endif
}
/* Override the normal text output with the Pharmacode number */
ustrcpy(symbol->text, "A");

View File

@ -611,7 +611,7 @@ INTERNAL float output_large_bar_height(struct zint_symbol *symbol, int si) {
if (zero_count) {
large_bar_height = (symbol->height - fixed_height) / zero_count;
if (large_bar_height <= 0.0f) { /* Shouldn't happen but protect against memory access violations */
large_bar_height = 0.01f; /* Token positive value */
large_bar_height = 0.0078125f; /* Token positive value (exact float 2**-6) */
symbol->height = large_bar_height * zero_count + fixed_height;
}
if (si && !isfintf(large_bar_height * si)) {

View File

@ -508,7 +508,7 @@ static void numbprocess(int *chainemc, int *mclength, const unsigned char chaine
}
}
/* Initial processing of data, shared by `pdf417enc()` and `micro_pdf417()` */
/* Initial processing of data, shared by `pdf417()` and `micropdf417()` */
static int pdf417_initial(struct zint_symbol *symbol, unsigned char chaine[], const int length, const int is_micro,
int chainemc[PDF417_MAX_LEN], int *p_mclength, int structapp_cws[18], int *p_structapp_cp) {
int i, indexchaine, indexliste, mode;
@ -661,7 +661,7 @@ static int pdf417_initial(struct zint_symbol *symbol, unsigned char chaine[], co
}
/* 366 */
static int pdf417(struct zint_symbol *symbol, unsigned char chaine[], const int length) {
static int pdf417_enc(struct zint_symbol *symbol, unsigned char chaine[], const int length) {
int i, k, j, longueur, loop, mccorrection[520] = {0}, offset;
int total, chainemc[PDF417_MAX_LEN], mclength, c1, c2, c3, dummy[35];
char pattern[580];
@ -872,7 +872,7 @@ static int pdf417(struct zint_symbol *symbol, unsigned char chaine[], const int
}
/* 345 */
INTERNAL int pdf417enc(struct zint_symbol *symbol, unsigned char source[], int length) {
INTERNAL int pdf417(struct zint_symbol *symbol, unsigned char source[], int length) {
int codeerr, error_number;
error_number = 0;
@ -895,7 +895,7 @@ INTERNAL int pdf417enc(struct zint_symbol *symbol, unsigned char source[], int l
}
/* 349 */
codeerr = pdf417(symbol, source, length);
codeerr = pdf417_enc(symbol, source, length);
/* 352 */
if (codeerr != 0) {
@ -907,7 +907,7 @@ INTERNAL int pdf417enc(struct zint_symbol *symbol, unsigned char source[], int l
}
/* like PDF417 only much smaller! */
INTERNAL int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[], int length) {
INTERNAL int micropdf417(struct zint_symbol *symbol, unsigned char chaine[], int length) {
int i, k, j, longueur, mccorrection[50] = {0}, offset;
int total, chainemc[PDF417_MAX_LEN], mclength, error_number = 0;
char pattern[580];

View File

@ -55,16 +55,15 @@ INTERNAL int plessey(struct zint_symbol *symbol, unsigned char source[], int len
unsigned char *checkptr;
static const char grid[9] = {1, 1, 1, 1, 0, 1, 0, 0, 1};
char dest[554]; /* 8 + 65 * 8 + 8 * 2 + 9 + 1 = 554 */
int error_number;
int error_number = 0;
if (length > 65) {
strcpy(symbol->errtxt, "370: Input too long (65 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(SSET, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
if (is_sane(SSET, source, length) != 0) {
strcpy(symbol->errtxt, "371: Invalid character in data (digits and \"ABCDEF\" only)");
return error_number;
return ZINT_ERROR_INVALID_DATA;
}
if (!(checkptr = (unsigned char *) calloc(1, length * 4 + 8))) {
@ -155,7 +154,8 @@ static char msi_check_digit_mod11(const unsigned char source[], const int length
}
/* Plain MSI Plessey - does not calculate any check character */
static void msi_plessey(struct zint_symbol *symbol, const unsigned char source[], const int length, char dest[]) {
static void msi_plessey_nomod(struct zint_symbol *symbol, const unsigned char source[], const int length,
char dest[]) {
int i;
@ -290,8 +290,8 @@ static void msi_plessey_mod1110(struct zint_symbol *symbol, const unsigned char
}
}
INTERNAL int msi_handle(struct zint_symbol *symbol, unsigned char source[], int length) {
int error_number;
INTERNAL int msi_plessey(struct zint_symbol *symbol, unsigned char source[], int length) {
int error_number = 0;
char dest[550]; /* 2 + 65 * 8 + 3 * 8 + 3 + 1 = 550 */
int check_option = symbol->option_2;
int no_checktext = 0;
@ -300,8 +300,7 @@ INTERNAL int msi_handle(struct zint_symbol *symbol, unsigned char source[], int
strcpy(symbol->errtxt, "372: Input too long (65 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number != 0) {
if (is_sane(NEON, source, length) != 0) {
strcpy(symbol->errtxt, "377: Invalid character in data (digits only)");
return ZINT_ERROR_INVALID_DATA;
}
@ -318,7 +317,7 @@ INTERNAL int msi_handle(struct zint_symbol *symbol, unsigned char source[], int
strcpy(dest, "21");
switch (check_option) {
case 0: msi_plessey(symbol, source, length, dest);
case 0: msi_plessey_nomod(symbol, source, length, dest);
break;
case 1: msi_plessey_mod10(symbol, source, length, no_checktext, dest);
break;

View File

@ -95,41 +95,39 @@ static int usps_set_height(struct zint_symbol *symbol, const int no_errtxt) {
int error_number = 0;
float h_ratio; /* Half ratio */
#ifdef COMPLIANT_HEIGHTS
symbol->row_height[0] = 0.075f * 43; /* 3.225 */
symbol->row_height[1] = 0.05f * 43; /* 2.15 */
#else
if (symbol->output_options & COMPLIANT_HEIGHT) {
symbol->row_height[0] = stripf(0.075f * 43); /* 3.225 */
symbol->row_height[1] = stripf(0.05f * 43); /* 2.15 */
} else {
symbol->row_height[0] = 6.0f;
symbol->row_height[1] = 6.0f;
#endif
}
if (symbol->height) {
h_ratio = symbol->row_height[1] / (symbol->row_height[0] + symbol->row_height[1]); /* 0.4 */
symbol->row_height[1] = symbol->height * h_ratio;
symbol->row_height[1] = stripf(symbol->height * h_ratio);
if (symbol->row_height[1] < 0.5f) { /* Absolute minimum */
symbol->row_height[1] = 0.5f;
symbol->row_height[0] = 0.5f / h_ratio - 0.5f; /* 0.75 */
symbol->row_height[0] = stripf(0.5f / h_ratio - 0.5f); /* 0.75 */
} else {
symbol->row_height[0] = symbol->height - symbol->row_height[1];
symbol->row_height[0] = stripf(symbol->height - symbol->row_height[1]);
}
}
symbol->height = symbol->row_height[0] + symbol->row_height[1];
symbol->height = stripf(symbol->row_height[0] + symbol->row_height[1]);
#ifdef COMPLIANT_HEIGHTS
if (symbol->output_options & COMPLIANT_HEIGHT) {
if (symbol->height < 4.6f || symbol->height > 9.0f) {
error_number = ZINT_WARN_NONCOMPLIANT;
if (!no_errtxt) {
strcpy(symbol->errtxt, "498: Height not compliant with standards");
}
}
#else
(void)&no_errtxt;
#endif
}
return error_number;
}
/* Handles the PostNet system used for Zip codes in the US */
static int postnet(struct zint_symbol *symbol, unsigned char source[], char dest[], int length) {
static int postnet_enc(struct zint_symbol *symbol, unsigned char source[], char dest[], int length) {
int i, sum, check_digit;
int error_number = 0;
@ -141,7 +139,7 @@ static int postnet(struct zint_symbol *symbol, unsigned char source[], char dest
strcpy(symbol->errtxt, "479: Input length is not standard (5, 9 or 11 characters)");
error_number = ZINT_WARN_NONCOMPLIANT;
}
if (is_sane(NEON, source, length) == ZINT_ERROR_INVALID_DATA) {
if (is_sane(NEON, source, length) != 0) {
strcpy(symbol->errtxt, "481: Invalid character in data (digits only)");
return ZINT_ERROR_INVALID_DATA;
}
@ -165,13 +163,13 @@ static int postnet(struct zint_symbol *symbol, unsigned char source[], char dest
}
/* Puts PostNet barcodes into the pattern matrix */
INTERNAL int post_plot(struct zint_symbol *symbol, unsigned char source[], int length) {
INTERNAL int postnet(struct zint_symbol *symbol, unsigned char source[], int length) {
char height_pattern[256]; /* 5 + 38 * 5 + 5 + 5 + 1 = 206 */
unsigned int loopey, h;
int writer;
int error_number, warn_number;
error_number = postnet(symbol, source, height_pattern, length);
error_number = postnet_enc(symbol, source, height_pattern, length);
if (error_number >= ZINT_ERROR) {
return error_number;
}
@ -193,7 +191,7 @@ INTERNAL int post_plot(struct zint_symbol *symbol, unsigned char source[], int l
}
/* Handles the PLANET system used for item tracking in the US */
static int planet(struct zint_symbol *symbol, unsigned char source[], char dest[], int length) {
static int planet_enc(struct zint_symbol *symbol, unsigned char source[], char dest[], int length) {
int i, sum, check_digit;
int error_number = 0;
@ -205,7 +203,7 @@ static int planet(struct zint_symbol *symbol, unsigned char source[], char dest[
strcpy(symbol->errtxt, "478: Input length is not standard (11 or 13 characters)");
error_number = ZINT_WARN_NONCOMPLIANT;
}
if (is_sane(NEON, source, length) == ZINT_ERROR_INVALID_DATA) {
if (is_sane(NEON, source, length) != 0) {
strcpy(symbol->errtxt, "483: Invalid character in data (digits only)");
return ZINT_ERROR_INVALID_DATA;
}
@ -229,13 +227,13 @@ static int planet(struct zint_symbol *symbol, unsigned char source[], char dest[
}
/* Puts PLANET barcodes into the pattern matrix */
INTERNAL int planet_plot(struct zint_symbol *symbol, unsigned char source[], int length) {
INTERNAL int planet(struct zint_symbol *symbol, unsigned char source[], int length) {
char height_pattern[256]; /* 5 + 38 * 5 + 5 + 5 + 1 = 206 */
unsigned int loopey, h;
int writer;
int error_number, warn_number;
error_number = planet(symbol, source, height_pattern, length);
error_number = planet_enc(symbol, source, height_pattern, length);
if (error_number >= ZINT_ERROR) {
return error_number;
}
@ -257,18 +255,17 @@ INTERNAL int planet_plot(struct zint_symbol *symbol, unsigned char source[], int
}
/* Korean Postal Authority */
INTERNAL int korea_post(struct zint_symbol *symbol, unsigned char source[], int length) {
int total, loop, check, zeroes, error_number;
INTERNAL int koreapost(struct zint_symbol *symbol, unsigned char source[], int length) {
int total, loop, check, zeroes, error_number = 0;
char localstr[8], dest[80];
if (length > 6) {
strcpy(symbol->errtxt, "484: Input too long (6 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
if (is_sane(NEON, source, length) != 0) {
strcpy(symbol->errtxt, "485: Invalid character in data (digits only)");
return error_number;
return ZINT_ERROR_INVALID_DATA;
}
zeroes = 6 - length;
memset(localstr, '0', zeroes);
@ -333,14 +330,14 @@ INTERNAL int fim(struct zint_symbol *symbol, unsigned char source[], int length)
expand(symbol, dest);
#ifdef COMPLIANT_HEIGHTS
if (symbol->output_options & COMPLIANT_HEIGHT) {
/* USPS Domestic Mail Manual (USPS DMM 300) Jan 8, 2006 (updated 2011) 708.9.3
X 0.03125" (1/32) +- 0.008" so X max 0.03925", height 0.625" (5/8) +- 0.125" (1/8) */
error_number = set_height(symbol, (float) (0.5 / 0.03925), 20.0f /*0.625 / 0.03125*/, (float) (0.75 / 0.02415),
0 /*no_errtxt*/);
#else
error_number = set_height(symbol, stripf(0.5f / 0.03925f), 20.0f /*0.625 / 0.03125*/,
stripf(0.75f / 0.02415f), 0 /*no_errtxt*/);
} else {
(void) set_height(symbol, 0.0f, 50.0f, 0.0f, 1 /*no_errtxt*/);
#endif
}
return error_number;
}
@ -352,36 +349,34 @@ INTERNAL int daft_set_height(struct zint_symbol *symbol, float min_height, float
float t_ratio; /* Tracker ratio */
if (symbol->height) {
t_ratio = symbol->row_height[1] / (symbol->row_height[0] * 2 + symbol->row_height[1]);
symbol->row_height[1] = symbol->height * t_ratio;
t_ratio = stripf(symbol->row_height[1] / stripf(symbol->row_height[0] * 2 + symbol->row_height[1]));
symbol->row_height[1] = stripf(symbol->height * t_ratio);
if (symbol->row_height[1] < 0.5f) { /* Absolute minimum */
symbol->row_height[1] = 0.5f;
symbol->row_height[0] = 0.25f / t_ratio - 0.25f;
symbol->row_height[0] = stripf(0.25f / t_ratio - 0.25f);
} else {
symbol->row_height[0] = (symbol->height - symbol->row_height[1]) / 2.0f;
symbol->row_height[0] = stripf(stripf(symbol->height - symbol->row_height[1]) / 2.0f);
}
if (symbol->row_height[0] < 0.5f) {
symbol->row_height[0] = 0.5f;
symbol->row_height[1] = t_ratio / (1.0f - t_ratio);
symbol->row_height[1] = stripf(t_ratio / (1.0f - t_ratio));
}
}
symbol->row_height[2] = symbol->row_height[0];
symbol->height = symbol->row_height[0] + symbol->row_height[1] + symbol->row_height[2];
symbol->height = stripf(stripf(symbol->row_height[0] + symbol->row_height[1]) + symbol->row_height[2]);
#ifdef COMPLIANT_HEIGHTS
if (symbol->output_options & COMPLIANT_HEIGHT) {
if ((min_height && symbol->height < min_height) || (max_height && symbol->height > max_height)) {
error_number = ZINT_WARN_NONCOMPLIANT;
strcpy(symbol->errtxt, "499: Height not compliant with standards");
}
#else
(void)min_height; (void)max_height;
#endif
}
return error_number;
}
/* Handles the 4 State barcodes used in the UK by Royal Mail */
static char rm4scc(unsigned char source[], char dest[], int length) {
static char rm4scc_enc(unsigned char source[], char dest[], int length) {
int i;
int top, bottom, row, column, check_digit;
char values[3], set_copy[] = KRSET;
@ -418,11 +413,11 @@ static char rm4scc(unsigned char source[], char dest[], int length) {
}
/* Puts RM4SCC into the data matrix */
INTERNAL int royal_plot(struct zint_symbol *symbol, unsigned char source[], int length) {
INTERNAL int rm4scc(struct zint_symbol *symbol, unsigned char source[], int length) {
char height_pattern[210];
int loopey, h;
int writer;
int error_number;
int error_number = 0;
strcpy(height_pattern, "");
if (length > 50) {
@ -430,12 +425,11 @@ INTERNAL int royal_plot(struct zint_symbol *symbol, unsigned char source[], int
return ZINT_ERROR_TOO_LONG;
}
to_upper(source);
error_number = is_sane(KRSET, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
if (is_sane(KRSET, source, length) != 0) {
strcpy(symbol->errtxt, "489: Invalid character in data (alphanumerics only)");
return error_number;
return ZINT_ERROR_INVALID_DATA;
}
/*check = */rm4scc(source, height_pattern, length);
/*check = */rm4scc_enc(source, height_pattern, length);
writer = 0;
h = (int) strlen(height_pattern);
@ -450,21 +444,22 @@ INTERNAL int royal_plot(struct zint_symbol *symbol, unsigned char source[], int
writer += 2;
}
#ifdef COMPLIANT_HEIGHTS
if (symbol->output_options & COMPLIANT_HEIGHT) {
/* Royal Mail Know How User's Manual Appendix C: using CBC
https://web.archive.org/web/20120120060743/http://www.royalmail.com/sites/default/files/docs/pdf/Know How 2006 PIP vs 1.6a Accepted Changes.pdf
Bar pitch and min/maxes same as Mailmark, so using recommendations from Royal Mail Mailmark Barcode Definition
Document (15 Sept 2015) Section 3.5.1
(https://web.archive.org/web/20120120060743/
http://www.royalmail.com/sites/default/files/docs/pdf/Know How 2006 PIP vs 1.6a Accepted Changes.pdf)
Bar pitch and min/maxes same as Mailmark, so using recommendations from
Royal Mail Mailmark Barcode Definition Document (15 Sept 2015) Section 3.5.1
*/
symbol->row_height[0] = (float) ((1.9 * 42.3) / 25.4); /* ~3.16 */
symbol->row_height[1] = (float) ((1.3 * 42.3) / 25.4); /* ~2.16 */
symbol->row_height[0] = stripf((1.9f * 42.3f) / 25.4f); /* ~3.16 */
symbol->row_height[1] = stripf((1.3f * 42.3f) / 25.4f); /* ~2.16 */
/* Note using max X for minimum and min X for maximum */
error_number = daft_set_height(symbol, (float) ((4.22 * 39) / 25.4), (float) ((5.84 * 47) / 25.4));
#else
error_number = daft_set_height(symbol, stripf((4.22f * 39) / 25.4f), stripf((5.84f * 47) / 25.4f));
} else {
symbol->row_height[0] = 3.0f;
symbol->row_height[1] = 2.0f;
error_number = daft_set_height(symbol, 0.0f, 0.0f);
#endif
(void) daft_set_height(symbol, 0.0f, 0.0f);
}
symbol->rows = 3;
symbol->width = writer - 1;
@ -474,11 +469,11 @@ INTERNAL int royal_plot(struct zint_symbol *symbol, unsigned char source[], int
/* Handles Dutch Post TNT KIX symbols
The same as RM4SCC but without check digit
Specification at http://www.tntpost.nl/zakelijk/klantenservice/downloads/kIX_code/download.aspx */
INTERNAL int kix_code(struct zint_symbol *symbol, unsigned char source[], int length) {
INTERNAL int kix(struct zint_symbol *symbol, unsigned char source[], int length) {
char height_pattern[75], localstr[20];
int loopey;
int writer, i, h;
int error_number;
int error_number = 0;
strcpy(height_pattern, "");
if (length > 18) {
@ -486,10 +481,9 @@ INTERNAL int kix_code(struct zint_symbol *symbol, unsigned char source[], int le
return ZINT_ERROR_TOO_LONG;
}
to_upper(source);
error_number = is_sane(KRSET, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
if (is_sane(KRSET, source, length) != 0) {
strcpy(symbol->errtxt, "491: Invalid character in data (alphanumerics only)");
return error_number;
return ZINT_ERROR_INVALID_DATA;
}
ustrcpy(localstr, source);
@ -512,17 +506,17 @@ INTERNAL int kix_code(struct zint_symbol *symbol, unsigned char source[], int le
writer += 2;
}
#ifdef COMPLIANT_HEIGHTS
if (symbol->output_options & COMPLIANT_HEIGHT) {
/* Dimensions same as RM4SCC */
symbol->row_height[0] = (float) ((1.9 * 42.3) / 25.4); /* ~3.16 */
symbol->row_height[1] = (float) ((1.3 * 42.3) / 25.4); /* ~2.16 */
symbol->row_height[0] = stripf((1.9f * 42.3f) / 25.4f); /* ~3.16 */
symbol->row_height[1] = stripf((1.3f * 42.3f) / 25.4f); /* ~2.16 */
/* Note using max X for minimum and min X for maximum */
error_number = daft_set_height(symbol, (float) ((4.22 * 39) / 25.4), (float) ((5.84 * 47) / 25.4));
#else
error_number = daft_set_height(symbol, stripf((4.22f * 39) / 25.4f), stripf((5.84f * 47) / 25.4f));
} else {
symbol->row_height[0] = 3.0f;
symbol->row_height[1] = 2.0f;
error_number = daft_set_height(symbol, 0.0f, 0.0f);
#endif
(void) daft_set_height(symbol, 0.0f, 0.0f);
}
symbol->rows = 3;
symbol->width = writer - 1;
@ -530,10 +524,10 @@ INTERNAL int kix_code(struct zint_symbol *symbol, unsigned char source[], int le
}
/* Handles DAFT Code symbols */
INTERNAL int daft_code(struct zint_symbol *symbol, unsigned char source[], int length) {
INTERNAL int daft(struct zint_symbol *symbol, unsigned char source[], int length) {
char height_pattern[100];
unsigned int loopey, h;
int writer, i, error_number;
int writer, i;
strcpy(height_pattern, "");
if (length > 50) {
@ -541,11 +535,10 @@ INTERNAL int daft_code(struct zint_symbol *symbol, unsigned char source[], int l
return ZINT_ERROR_TOO_LONG;
}
to_upper(source);
error_number = is_sane(DAFTSET, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
if (is_sane(DAFTSET, source, length) != 0) {
strcpy(symbol->errtxt, "493: Invalid character in data (\"D\", \"A\", \"F\" and \"T\" only)");
return error_number;
return ZINT_ERROR_INVALID_DATA;
}
for (i = 0; i < length; i++) {
@ -578,12 +571,12 @@ INTERNAL int daft_code(struct zint_symbol *symbol, unsigned char source[], int l
/* Allow ratio of tracker to be specified in thousandths */
if (symbol->option_2 >= 50 && symbol->option_2 <= 900) {
float t_ratio = symbol->option_2 / 1000.0f;
const float t_ratio = symbol->option_2 / 1000.0f;
if (symbol->height < 0.5f) {
symbol->height = 8.0f;
}
symbol->row_height[1] = symbol->height * t_ratio;
symbol->row_height[0] = (float) ((symbol->height - symbol->row_height[1]) / 2.0);
symbol->row_height[1] = stripf(symbol->height * t_ratio);
symbol->row_height[0] = stripf((symbol->height - symbol->row_height[1]) / 2.0);
} else {
symbol->row_height[0] = 3.0f;
symbol->row_height[1] = 2.0f;
@ -594,22 +587,21 @@ INTERNAL int daft_code(struct zint_symbol *symbol, unsigned char source[], int l
symbol->rows = 3;
symbol->width = writer - 1;
return error_number;
return 0;
}
/* Flattermarken - Not really a barcode symbology! */
INTERNAL int flattermarken(struct zint_symbol *symbol, unsigned char source[], int length) {
int loop, error_number;
INTERNAL int flat(struct zint_symbol *symbol, unsigned char source[], int length) {
int loop, error_number = 0;
char dest[512]; /* 90 * 4 + 1 ~ */
if (length > 90) {
strcpy(symbol->errtxt, "494: Input too long (90 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, length);
if (error_number == ZINT_ERROR_INVALID_DATA) {
if (is_sane(NEON, source, length) != 0) {
strcpy(symbol->errtxt, "495: Invalid character in data (digits only)");
return error_number;
return ZINT_ERROR_INVALID_DATA;
}
*dest = '\0';
for (loop = 0; loop < length; loop++) {
@ -624,8 +616,8 @@ INTERNAL int flattermarken(struct zint_symbol *symbol, unsigned char source[], i
}
/* Japanese Postal Code (Kasutama Barcode) */
INTERNAL int japan_post(struct zint_symbol *symbol, unsigned char source[], int length) {
int error_number, h;
INTERNAL int japanpost(struct zint_symbol *symbol, unsigned char source[], int length) {
int error_number = 0, h;
char pattern[69];
int writer, loopey, inter_posn, i, sum, check;
char check_char;
@ -645,7 +637,7 @@ INTERNAL int japan_post(struct zint_symbol *symbol, unsigned char source[], int
ustrcpy(local_source, source);
to_upper(local_source);
if (is_sane(SHKASUTSET, local_source, length) == ZINT_ERROR_INVALID_DATA) {
if (is_sane(SHKASUTSET, local_source, length) != 0) {
strcpy(symbol->errtxt, "497: Invalid character in data (alphanumerics and \"-\" only)");
return ZINT_ERROR_INVALID_DATA;
}
@ -722,19 +714,19 @@ INTERNAL int japan_post(struct zint_symbol *symbol, unsigned char source[], int
symbol->rows = 3;
symbol->width = writer - 1;
#ifdef COMPLIANT_HEIGHTS
if (symbol->output_options & COMPLIANT_HEIGHT) {
/* Japan Post Zip/Barcode Manual pp.11-12 https://www.post.japanpost.jp/zipcode/zipmanual/p11.html
X 0.6mm (0.5mm - 0.7mm)
Tracker height 1.2mm (1.05mm - 1.35mm) / 0.6mm = 2,
Ascender/descender = 1.2mm (Full 3.6mm (3.4mm - 3.6mm, max preferred) less T divided by 2) / 0.6mm = 2 */
symbol->row_height[0] = 2.0f;
symbol->row_height[1] = 2.0f;
error_number = daft_set_height(symbol, (float) (3.4 / 0.7) /*~4.857*/, 3.6f / 0.5f /*7.2*/);
#else
error_number = daft_set_height(symbol, stripf(3.4f / 0.7f) /*~4.857*/, stripf(3.6f / 0.5f) /*7.2*/);
} else {
symbol->row_height[0] = 3.0f;
symbol->row_height[1] = 2.0f;
error_number = daft_set_height(symbol, 0.0f, 0.0f);
#endif
(void) daft_set_height(symbol, 0.0f, 0.0f);
}
return error_number;
}

View File

@ -1538,7 +1538,7 @@ static int getBinaryLength(const int version, char inputMode[], const unsigned i
return count;
}
INTERNAL int qr_code(struct zint_symbol *symbol, unsigned char source[], int length) {
INTERNAL int qrcode(struct zint_symbol *symbol, unsigned char source[], int length) {
int i, j, est_binlen, prev_est_binlen;
int ecc_level, autosize, version, max_cw, target_codewords, blocks, size;
int bitmask, gs1;

View File

@ -158,7 +158,7 @@ static void getRSSwidths(int widths[], int val, int n, const int elements, const
}
/* Set GTIN-14 human readable text */
static void rss_set_gtin14_hrt(struct zint_symbol *symbol, const unsigned char *source, const int src_len) {
static void dbar_set_gtin14_hrt(struct zint_symbol *symbol, const unsigned char *source, const int src_len) {
int i;
unsigned char *hrt = symbol->text + 4;
@ -175,7 +175,7 @@ static void rss_set_gtin14_hrt(struct zint_symbol *symbol, const unsigned char *
}
/* Expand from a width pattern to a bit pattern */
static int rss_expand(struct zint_symbol *symbol, int writer, int *p_latch, const int width) {
static int dbar_expand(struct zint_symbol *symbol, int writer, int *p_latch, const int width) {
int j;
int latch = *p_latch;
@ -194,7 +194,7 @@ static int rss_expand(struct zint_symbol *symbol, int writer, int *p_latch, cons
}
/* Adjust top/bottom separator for finder patterns */
static void rss14_finder_adjust(struct zint_symbol *symbol, const int separator_row, const int above_below,
static void dbar_omn_finder_adjust(struct zint_symbol *symbol, const int separator_row, const int above_below,
const int finder_start) {
int i, finder_end;
int module_row = separator_row + above_below;
@ -219,7 +219,7 @@ static void rss14_finder_adjust(struct zint_symbol *symbol, const int separator_
}
/* Top/bottom separator for DataBar */
static void rss14_separator(struct zint_symbol *symbol, int width, const int separator_row, const int above_below,
static void dbar_omn_separator(struct zint_symbol *symbol, int width, const int separator_row, const int above_below,
const int finder_start, const int finder2_start, const int bottom_finder_value_3) {
int i, finder_end, finder_value_3_set;
int module_row = separator_row + above_below;
@ -242,16 +242,16 @@ static void rss14_separator(struct zint_symbol *symbol, int width, const int sep
}
} else {
if (finder_start) {
rss14_finder_adjust(symbol, separator_row, above_below, finder_start);
dbar_omn_finder_adjust(symbol, separator_row, above_below, finder_start);
}
if (finder2_start) {
rss14_finder_adjust(symbol, separator_row, above_below, finder2_start);
dbar_omn_finder_adjust(symbol, separator_row, above_below, finder2_start);
}
}
}
/* Set Databar Stacked height, maintaining 5:7 ratio of the 2 main row heights */
INTERNAL int rss14_stk_set_height(struct zint_symbol *symbol, const int first_row) {
INTERNAL int dbar_omnstk_set_height(struct zint_symbol *symbol, const int first_row) {
int error_number = 0;
float fixed_height = 0.0f;
int second_row = first_row + 2; /* 2 row separator */
@ -263,33 +263,33 @@ INTERNAL int rss14_stk_set_height(struct zint_symbol *symbol, const int first_ro
}
}
if (symbol->height) {
symbol->row_height[first_row] = (symbol->height - fixed_height) * symbol->row_height[first_row] /
(symbol->row_height[first_row] + symbol->row_height[second_row]);
symbol->row_height[first_row] = stripf((symbol->height - fixed_height) * symbol->row_height[first_row] /
(symbol->row_height[first_row] + symbol->row_height[second_row]));
if (symbol->row_height[first_row] < 0.5f) { /* Absolute minimum */
symbol->row_height[first_row] = 0.5f;
symbol->row_height[second_row] = 0.7f;
} else {
symbol->row_height[second_row] = symbol->height - fixed_height - symbol->row_height[first_row];
symbol->row_height[second_row] = stripf(symbol->height - fixed_height - symbol->row_height[first_row]);
if (symbol->row_height[second_row] < 0.7f) {
symbol->row_height[second_row] = 0.7f;
}
}
}
symbol->height = symbol->row_height[first_row] + symbol->row_height[second_row] + fixed_height;
symbol->height = stripf(stripf(symbol->row_height[first_row] + symbol->row_height[second_row]) + fixed_height);
#ifdef COMPLIANT_HEIGHTS
if (symbol->output_options & COMPLIANT_HEIGHT) {
if (symbol->row_height[first_row] < 5.0f || symbol->row_height[second_row] < 7.0f) {
error_number = ZINT_WARN_NONCOMPLIANT;
strcpy(symbol->errtxt, "379: Height not compliant with standards");
}
#endif
}
return error_number;
}
/* GS1 DataBar Omnidirectional/Truncated/Stacked, allowing for composite if `cc_rows` set */
INTERNAL int rss14_cc(struct zint_symbol *symbol, unsigned char source[], int src_len, const int cc_rows) {
int error_number, i;
INTERNAL int dbar_omn_cc(struct zint_symbol *symbol, unsigned char source[], int src_len, const int cc_rows) {
int error_number = 0, i;
large_int accum;
uint64_t left_pair, right_pair;
int data_character[4] = {0}, data_group[4] = {0}, v_odd[4], v_even[4];
@ -304,10 +304,9 @@ INTERNAL int rss14_cc(struct zint_symbol *symbol, unsigned char source[], int sr
strcpy(symbol->errtxt, "380: Input too long (14 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, src_len);
if (error_number == ZINT_ERROR_INVALID_DATA) {
if (is_sane(NEON, source, src_len) != 0) {
strcpy(symbol->errtxt, "381: Invalid character in data (digits only)");
return error_number;
return ZINT_ERROR_INVALID_DATA;
}
if (src_len == 14) { /* Verify check digit */
@ -405,7 +404,7 @@ INTERNAL int rss14_cc(struct zint_symbol *symbol, unsigned char source[], int sr
v_odd[2] = (data_character[2] - g_sum_table[data_group[2]]) / t_table[data_group[2]];
v_even[2] = (data_character[2] - g_sum_table[data_group[2]]) % t_table[data_group[2]];
/* Use RSS subset width algorithm */
/* Use DataBar subset width algorithm */
for (i = 0; i < 4; i++) {
if ((i == 0) || (i == 2)) {
getRSSwidths(widths, v_odd[i], modules_odd[data_group[i]], 4, widest_odd[data_group[i]], 1);
@ -477,21 +476,21 @@ INTERNAL int rss14_cc(struct zint_symbol *symbol, unsigned char source[], int sr
writer = 0;
latch = 0;
for (i = 0; i < 46; i++) {
writer = rss_expand(symbol, writer, &latch, total_widths[i]);
writer = dbar_expand(symbol, writer, &latch, total_widths[i]);
}
if (symbol->width < writer) {
symbol->width = writer;
}
if (symbol->symbology == BARCODE_DBAR_OMN_CC) {
/* separator pattern for composite symbol */
rss14_separator(symbol, 96, separator_row, 1 /*above*/, 18, 63, 0 /*bottom_finder_value_3*/);
dbar_omn_separator(symbol, 96, separator_row, 1 /*above*/, 18, 63, 0 /*bottom_finder_value_3*/);
}
symbol->rows = symbol->rows + 1;
/* Set human readable text */
rss_set_gtin14_hrt(symbol, source, src_len);
dbar_set_gtin14_hrt(symbol, source, src_len);
#ifdef COMPLIANT_HEIGHTS
if (symbol->output_options & COMPLIANT_HEIGHT) {
/* Minimum height is 13X for truncated symbol ISO/IEC 24724:2011 5.3.1
Default height is 33X for DataBar Omnidirectional ISO/IEC 24724:2011 5.2 */
if (symbol->symbology == BARCODE_DBAR_OMN_CC) {
@ -499,20 +498,20 @@ INTERNAL int rss14_cc(struct zint_symbol *symbol, unsigned char source[], int sr
} else {
error_number = set_height(symbol, 13.0f, 33.0f, 0.0f, 0 /*no_errtxt*/);
}
#else
} else {
if (symbol->symbology == BARCODE_DBAR_OMN_CC) {
symbol->height = 14.0f; /* 14X truncated min row height used (should be 13X) */
} else {
(void) set_height(symbol, 0.0f, 50.0f, 0.0f, 1 /*no_errtxt*/);
}
#endif
}
} else if ((symbol->symbology == BARCODE_DBAR_STK) || (symbol->symbology == BARCODE_DBAR_STK_CC)) {
/* top row */
writer = 0;
latch = 0;
for (i = 0; i < 23; i++) {
writer = rss_expand(symbol, writer, &latch, total_widths[i]);
writer = dbar_expand(symbol, writer, &latch, total_widths[i]);
}
set_module(symbol, symbol->rows, writer);
unset_module(symbol, symbol->rows, writer + 1);
@ -525,7 +524,7 @@ INTERNAL int rss14_cc(struct zint_symbol *symbol, unsigned char source[], int sr
writer = 2;
latch = 1;
for (i = 23; i < 46; i++) {
writer = rss_expand(symbol, writer, &latch, total_widths[i]);
writer = dbar_expand(symbol, writer, &latch, total_widths[i]);
}
symbol->row_height[symbol->rows] = 7.0f; /* ISO/IEC 24724:2011 5.3.2.1 set to 7X */
@ -549,15 +548,15 @@ INTERNAL int rss14_cc(struct zint_symbol *symbol, unsigned char source[], int sr
if (symbol->symbology == BARCODE_DBAR_STK_CC) {
/* separator pattern for composite symbol */
rss14_separator(symbol, 50, separator_row, 1 /*above*/, 18, 0, 0 /*bottom_finder_value_3*/);
dbar_omn_separator(symbol, 50, separator_row, 1 /*above*/, 18, 0, 0 /*bottom_finder_value_3*/);
}
symbol->rows = symbol->rows + 1;
if (symbol->width < 50) {
symbol->width = 50;
}
if (symbol->symbology != BARCODE_DBAR_STK_CC) { /* Composite calls rss14_stk_set_height() itself */
error_number = rss14_stk_set_height(symbol, 0 /*first_row*/);
if (symbol->symbology != BARCODE_DBAR_STK_CC) { /* Composite calls dbar_omnstk_set_height() itself */
error_number = dbar_omnstk_set_height(symbol, 0 /*first_row*/);
}
} else if ((symbol->symbology == BARCODE_DBAR_OMNSTK) || (symbol->symbology == BARCODE_DBAR_OMNSTK_CC)) {
@ -565,7 +564,7 @@ INTERNAL int rss14_cc(struct zint_symbol *symbol, unsigned char source[], int sr
writer = 0;
latch = 0;
for (i = 0; i < 23; i++) {
writer = rss_expand(symbol, writer, &latch, total_widths[i]);
writer = dbar_expand(symbol, writer, &latch, total_widths[i]);
}
set_module(symbol, symbol->rows, writer);
unset_module(symbol, symbol->rows, writer + 1);
@ -577,7 +576,7 @@ INTERNAL int rss14_cc(struct zint_symbol *symbol, unsigned char source[], int sr
writer = 2;
latch = 1;
for (i = 23; i < 46; i++) {
writer = rss_expand(symbol, writer, &latch, total_widths[i]);
writer = dbar_expand(symbol, writer, &latch, total_widths[i]);
}
/* middle separator */
@ -587,12 +586,12 @@ INTERNAL int rss14_cc(struct zint_symbol *symbol, unsigned char source[], int sr
symbol->row_height[symbol->rows - 2] = 1;
/* top separator */
rss14_separator(symbol, 50, symbol->rows - 3, -1 /*below*/, 18, 0, 0 /*bottom_finder_value_3*/);
dbar_omn_separator(symbol, 50, symbol->rows - 3, -1 /*below*/, 18, 0, 0 /*bottom_finder_value_3*/);
symbol->row_height[symbol->rows - 3] = 1;
/* bottom separator */
/* 17 == 2 (guard) + 15 (inner char); +2 to skip over finder elements 4 & 5 (right to left) */
rss14_separator(symbol, 50, symbol->rows - 1, 1 /*above*/, 17 + 2, 0, c_right == 3);
dbar_omn_separator(symbol, 50, symbol->rows - 1, 1 /*above*/, 17 + 2, 0, c_right == 3);
symbol->row_height[symbol->rows - 1] = 1;
if (symbol->width < 50) {
symbol->width = 50;
@ -600,7 +599,7 @@ INTERNAL int rss14_cc(struct zint_symbol *symbol, unsigned char source[], int sr
if (symbol->symbology == BARCODE_DBAR_OMNSTK_CC) {
/* separator pattern for composite symbol */
rss14_separator(symbol, 50, separator_row, 1 /*above*/, 18, 0, 0 /*bottom_finder_value_3*/);
dbar_omn_separator(symbol, 50, separator_row, 1 /*above*/, 18, 0, 0 /*bottom_finder_value_3*/);
}
symbol->rows = symbol->rows + 1;
@ -608,11 +607,11 @@ INTERNAL int rss14_cc(struct zint_symbol *symbol, unsigned char source[], int sr
if (symbol->symbology == BARCODE_DBAR_OMNSTK_CC) {
symbol->height = symbol->height ? 33.0f : 66.0f; /* Pass back min row or default height */
} else {
#ifdef COMPLIANT_HEIGHTS
if (symbol->output_options & COMPLIANT_HEIGHT) {
error_number = set_height(symbol, 33.0f, 66.0f, 0.0f, 0 /*no_errtxt*/);
#else
} else {
(void) set_height(symbol, 0.0f, 66.0f, 0.0f, 1 /*no_errtxt*/);
#endif
}
}
}
@ -620,13 +619,13 @@ INTERNAL int rss14_cc(struct zint_symbol *symbol, unsigned char source[], int sr
}
/* GS1 DataBar Omnidirectional/Truncated/Stacked */
INTERNAL int rss14(struct zint_symbol *symbol, unsigned char source[], int src_len) {
return rss14_cc(symbol, source, src_len, 0 /*cc_rows*/);
INTERNAL int dbar_omn(struct zint_symbol *symbol, unsigned char source[], int src_len) {
return dbar_omn_cc(symbol, source, src_len, 0 /*cc_rows*/);
}
/* GS1 DataBar Limited, allowing for composite if `cc_rows` set */
INTERNAL int rsslimited_cc(struct zint_symbol *symbol, unsigned char source[], int src_len, const int cc_rows) {
int error_number, i;
INTERNAL int dbar_ltd_cc(struct zint_symbol *symbol, unsigned char source[], int src_len, const int cc_rows) {
int error_number = 0, i;
large_int accum;
uint64_t left_character, right_character;
int left_group, right_group, left_odd, left_even, right_odd, right_even;
@ -642,10 +641,9 @@ INTERNAL int rsslimited_cc(struct zint_symbol *symbol, unsigned char source[], i
strcpy(symbol->errtxt, "382: Input too long (14 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
error_number = is_sane(NEON, source, src_len);
if (error_number == ZINT_ERROR_INVALID_DATA) {
if (is_sane(NEON, source, src_len) != 0) {
strcpy(symbol->errtxt, "383: Invalid character in data (digits only)");
return error_number;
return ZINT_ERROR_INVALID_DATA;
}
if (src_len == 14) { /* Verify check digit */
@ -778,7 +776,7 @@ INTERNAL int rsslimited_cc(struct zint_symbol *symbol, unsigned char source[], i
writer = 0;
latch = 0;
for (i = 0; i < 47; i++) {
writer = rss_expand(symbol, writer, &latch, total_widths[i]);
writer = dbar_expand(symbol, writer, &latch, total_widths[i]);
}
if (symbol->width < writer) {
symbol->width = writer;
@ -795,29 +793,29 @@ INTERNAL int rsslimited_cc(struct zint_symbol *symbol, unsigned char source[], i
}
/* Set human readable text */
rss_set_gtin14_hrt(symbol, source, src_len);
dbar_set_gtin14_hrt(symbol, source, src_len);
/* ISO/IEC 24724:2011 6.2 10X minimum height, use as default also */
if (symbol->symbology == BARCODE_DBAR_LTD_CC) {
symbol->height = 10.0f; /* Pass back min row == default height */
} else {
#ifdef COMPLIANT_HEIGHTS
if (symbol->output_options & COMPLIANT_HEIGHT) {
error_number = set_height(symbol, 10.0f, 10.0f, 0.0f, 0 /*no_errtxt*/);
#else
} else {
(void) set_height(symbol, 0.0f, 50.0f, 0.0f, 1 /*no_errtxt*/);
#endif
}
}
return error_number;
}
/* GS1 DataBar Limited */
INTERNAL int rsslimited(struct zint_symbol *symbol, unsigned char source[], int src_len) {
return rsslimited_cc(symbol, source, src_len, 0 /*cc_rows*/);
INTERNAL int dbar_ltd(struct zint_symbol *symbol, unsigned char source[], int src_len) {
return dbar_ltd_cc(symbol, source, src_len, 0 /*cc_rows*/);
}
/* Check and convert date to RSS date value */
INTERNAL int rss_date(const unsigned char source[], const int src_posn) {
/* Check and convert date to DataBar date value */
INTERNAL int dbar_date(const unsigned char source[], const int src_posn) {
int yy = to_int(source + src_posn, 2);
int mm = to_int(source + src_posn + 2, 2);
int dd = to_int(source + src_posn + 4, 2);
@ -831,7 +829,7 @@ INTERNAL int rss_date(const unsigned char source[], const int src_posn) {
}
/* Handles all data encodation from section 7.2.5 of ISO/IEC 24724 */
static int rssexp_binary_string(struct zint_symbol *symbol, const unsigned char source[], char binary_string[],
static int dbar_exp_binary_string(struct zint_symbol *symbol, const unsigned char source[], char binary_string[],
int cols_per_row, int *p_bp) {
int encoding_method, i, j, read_posn, debug = (symbol->debug & ZINT_DEBUG_PRINT), mode = NUMERIC;
char last_digit = '\0';
@ -884,7 +882,7 @@ static int rssexp_binary_string(struct zint_symbol *symbol, const unsigned char
} else if ((length == 34) && (source[26] == '1')
&& (source[27] == '1' || source[27] == '3' || source[27] == '5' || source[27] == '7')
&& rss_date(source, 28) >= 0) {
&& dbar_date(source, 28) >= 0) {
/* (01), (310x) and (11) - metric weight and production date */
/* (01), (310x) and (13) - metric weight and packaging date */
@ -915,7 +913,7 @@ static int rssexp_binary_string(struct zint_symbol *symbol, const unsigned char
} else if ((length == 34) && (source[26] == '1')
&& (source[27] == '1' || source[27] == '3' || source[27] == '5' || source[27] == '7')
&& rss_date(source, 28) >= 0) {
&& dbar_date(source, 28) >= 0) {
/* (01), (320x) and (11) - English weight and production date */
/* (01), (320x) and (13) - English weight and packaging date */
@ -1045,7 +1043,7 @@ static int rssexp_binary_string(struct zint_symbol *symbol, const unsigned char
if (length == 34) {
/* Date information is included */
group_val = rss_date(source, 28);
group_val = dbar_date(source, 28);
} else {
group_val = 38400;
}
@ -1172,7 +1170,7 @@ static int rssexp_binary_string(struct zint_symbol *symbol, const unsigned char
}
/* Separator for DataBar Expanded Stacked and DataBar Expanded Composite */
static void rssexp_separator(struct zint_symbol *symbol, int width, const int cols, const int separator_row,
static void dbar_exp_separator(struct zint_symbol *symbol, int width, const int cols, const int separator_row,
const int above_below, const int special_case_row, const int left_to_right, const int odd_last_row,
int *p_v2_latch) {
int i, i_start, i_end, j, k;
@ -1239,7 +1237,7 @@ static void rssexp_separator(struct zint_symbol *symbol, int width, const int co
}
/* GS1 DataBar Expanded, setting linkage for composite if `cc_rows` set */
INTERNAL int rssexpanded_cc(struct zint_symbol *symbol, unsigned char source[], int src_len, const int cc_rows) {
INTERNAL int dbar_exp_cc(struct zint_symbol *symbol, unsigned char source[], int src_len, const int cc_rows) {
int error_number, warn_number = 0;
int i, j, k, p, codeblocks, data_chars, vs, group, v_odd, v_even;
int latch;
@ -1298,7 +1296,7 @@ INTERNAL int rssexpanded_cc(struct zint_symbol *symbol, unsigned char source[],
}
}
error_number = rssexp_binary_string(symbol, reduced, binary_string, cols_per_row, &bp);
error_number = dbar_exp_binary_string(symbol, reduced, binary_string, cols_per_row, &bp);
if (error_number != 0) {
return error_number;
}
@ -1431,7 +1429,7 @@ INTERNAL int rssexpanded_cc(struct zint_symbol *symbol, unsigned char source[],
writer = 0;
latch = 0;
for (i = 0; i < pattern_width; i++) {
writer = rss_expand(symbol, writer, &latch, elements[i]);
writer = dbar_expand(symbol, writer, &latch, elements[i]);
}
if (symbol->width < writer) {
symbol->width = writer;
@ -1534,7 +1532,7 @@ INTERNAL int rssexpanded_cc(struct zint_symbol *symbol, unsigned char source[],
writer = 0;
for (i = 0; i < elements_in_sub; i++) {
writer = rss_expand(symbol, writer, &latch, sub_elements[i]);
writer = dbar_expand(symbol, writer, &latch, sub_elements[i]);
}
if (symbol->width < writer) {
symbol->width = writer;
@ -1550,14 +1548,14 @@ INTERNAL int rssexpanded_cc(struct zint_symbol *symbol, unsigned char source[],
symbol->row_height[symbol->rows - 2] = 1;
/* bottom separator pattern (above current row) */
rssexp_separator(symbol, writer, reader, symbol->rows - 1, 1 /*above*/, special_case_row,
dbar_exp_separator(symbol, writer, reader, symbol->rows - 1, 1 /*above*/, special_case_row,
left_to_right, odd_last_row, &v2_latch);
symbol->row_height[symbol->rows - 1] = 1;
}
if (current_row != stack_rows) {
/* top separator pattern (below current row) */
rssexp_separator(symbol, writer, reader, symbol->rows + 1, -1 /*below*/, 0 /*special_case_row*/,
dbar_exp_separator(symbol, writer, reader, symbol->rows + 1, -1 /*below*/, 0 /*special_case_row*/,
left_to_right, 0 /*odd_last_row*/, &v2_latch);
symbol->row_height[symbol->rows + 1] = 1;
}
@ -1569,7 +1567,7 @@ INTERNAL int rssexpanded_cc(struct zint_symbol *symbol, unsigned char source[],
if (symbol->symbology == BARCODE_DBAR_EXP_CC || symbol->symbology == BARCODE_DBAR_EXPSTK_CC) {
/* Composite separator */
rssexp_separator(symbol, symbol->width, 4, separator_row, 1 /*above*/, 0 /*special_case_row*/,
dbar_exp_separator(symbol, symbol->width, 4, separator_row, 1 /*above*/, 0 /*special_case_row*/,
1 /*left_to_right*/, 0 /*odd_last_row*/, NULL);
}
@ -1578,21 +1576,21 @@ INTERNAL int rssexpanded_cc(struct zint_symbol *symbol, unsigned char source[],
if (symbol->symbology == BARCODE_DBAR_EXP_CC || symbol->symbology == BARCODE_DBAR_EXPSTK_CC) {
symbol->height = symbol->height ? 34.0f : 34.0f * stack_rows; /* Pass back min row or default height */
} else {
#ifdef COMPLIANT_HEIGHTS
if (symbol->output_options & COMPLIANT_HEIGHT) {
if (warn_number) {
(void) set_height(symbol, 34.0f, 34.0f * stack_rows, 0.0f, 0 /*no_errtxt*/);
} else {
warn_number = set_height(symbol, 34.0f, 34.0f * stack_rows, 0.0f, 0 /*no_errtxt*/);
}
#else
} else {
(void) set_height(symbol, 0.0f, 34.0f * stack_rows, 0.0f, 1 /*no_errtxt*/);
#endif
}
}
return error_number ? error_number : warn_number;
}
/* GS1 DataBar Expanded */
INTERNAL int rssexpanded(struct zint_symbol *symbol, unsigned char source[], int src_len) {
return rssexpanded_cc(symbol, source, src_len, 0 /*cc_rows*/);
INTERNAL int dbar_exp(struct zint_symbol *symbol, unsigned char source[], int src_len) {
return dbar_exp_cc(symbol, source, src_len, 0 /*cc_rows*/);
}

View File

@ -40,22 +40,38 @@
#include "common.h"
static char *TeleTable[] = {
"31313131", "1131313111", "33313111", "1111313131", "3111313111", "11333131", "13133131", "111111313111",
"31333111", "1131113131", "33113131", "1111333111", "3111113131", "1113133111", "1311133111", "111111113131",
"3131113111", "11313331", "333331", "111131113111", "31113331", "1133113111", "1313113111", "1111113331",
"31131331", "113111113111", "3311113111", "1111131331", "311111113111", "1113111331", "1311111331", "11111111113111",
"31313311", "1131311131", "33311131", "1111313311", "3111311131", "11333311", "13133311", "111111311131",
"31331131", "1131113311", "33113311", "1111331131", "3111113311", "1113131131", "1311131131", "111111113311",
"3131111131", "1131131311", "33131311", "111131111131", "3111131311", "1133111131", "1313111131", "111111131311",
"3113111311", "113111111131", "3311111131", "111113111311", "311111111131", "111311111311", "131111111311", "11111111111131",
"3131311111", "11313133", "333133", "111131311111", "31113133", "1133311111", "1313311111", "1111113133",
"313333", "113111311111", "3311311111", "11113333", "311111311111", "11131333", "13111333", "11111111311111",
"31311133", "1131331111", "33331111", "1111311133", "3111331111", "11331133", "13131133", "111111331111",
"3113131111", "1131111133", "33111133", "111113131111", "3111111133", "111311131111", "131111131111", "111111111133",
"31311313", "113131111111", "3331111111", "1111311313", "311131111111", "11331313", "13131313", "11111131111111",
"3133111111", "1131111313", "33111313", "111133111111", "3111111313", "111313111111", "131113111111", "111111111313",
"313111111111", "1131131113", "33131113", "11113111111111", "3111131113", "113311111111", "131311111111", "111111131113",
"3113111113", "11311111111111", "331111111111", "111113111113", "31111111111111", "111311111113", "131111111113", "1111111111111111",
"31313131", "1131313111", "33313111", "1111313131",
"3111313111", "11333131", "13133131", "111111313111",
"31333111", "1131113131", "33113131", "1111333111",
"3111113131", "1113133111", "1311133111", "111111113131",
"3131113111", "11313331", "333331", "111131113111",
"31113331", "1133113111", "1313113111", "1111113331",
"31131331", "113111113111", "3311113111", "1111131331",
"311111113111", "1113111331", "1311111331", "11111111113111",
"31313311", "1131311131", "33311131", "1111313311",
"3111311131", "11333311", "13133311", "111111311131",
"31331131", "1131113311", "33113311", "1111331131",
"3111113311", "1113131131", "1311131131", "111111113311",
"3131111131", "1131131311", "33131311", "111131111131",
"3111131311", "1133111131", "1313111131", "111111131311",
"3113111311", "113111111131", "3311111131", "111113111311",
"311111111131", "111311111311", "131111111311", "11111111111131",
"3131311111", "11313133", "333133", "111131311111",
"31113133", "1133311111", "1313311111", "1111113133",
"313333", "113111311111", "3311311111", "11113333",
"311111311111", "11131333", "13111333", "11111111311111",
"31311133", "1131331111", "33331111", "1111311133",
"3111331111", "11331133", "13131133", "111111331111",
"3113131111", "1131111133", "33111133", "111113131111",
"3111111133", "111311131111", "131111131111", "111111111133",
"31311313", "113131111111", "3331111111", "1111311313",
"311131111111", "11331313", "13131313", "11111131111111",
"3133111111", "1131111313", "33111313", "111133111111",
"3111111313", "111313111111", "131113111111", "111111111313",
"313111111111", "1131131113", "33131113", "11113111111111",
"3111131113", "113311111111", "131311111111", "111111131113",
"3113111113", "11311111111111", "331111111111", "111113111113",
"31111111111111", "111311111113", "131111111113", "1111111111111111",
};
INTERNAL int telepen(struct zint_symbol *symbol, unsigned char source[], int src_len) {
@ -97,13 +113,13 @@ INTERNAL int telepen(struct zint_symbol *symbol, unsigned char source[], int src
expand(symbol, dest);
#ifdef COMPLIANT_HEIGHTS
/* Default height from various Telepen docs is based on default 26pt at X 0.01125" (average of 0.01" - 0.0125")
= (26 / 72) / 0.01125 ~ 32; no min height specified */
if (symbol->output_options & COMPLIANT_HEIGHT) {
/* Default height from various Telepen docs is based on default 26pt at X 0.01125"
(average of 0.01" - 0.0125") = (26 / 72) / 0.01125 ~ 32; no min height specified */
(void) set_height(symbol, 0.0f, 32.0f, 0, 1 /*no_errtxt*/);
#else
} else {
(void) set_height(symbol, 0.0f, 50.0f, 0, 1 /*no_errtxt*/);
#endif
}
for (i = 0; i < src_len; i++) {
if (source[i] == '\0') {
@ -118,7 +134,7 @@ INTERNAL int telepen(struct zint_symbol *symbol, unsigned char source[], int src
INTERNAL int telepen_num(struct zint_symbol *symbol, unsigned char source[], int src_len) {
int count, check_digit, glyph;
int error_number;
int error_number = 0;
int i;
char dest[521]; /* 12 (start) + 30 * 16 (max for DELs) + 16 (check digit) + 12 (stop) + 1 = 521 */
unsigned char temp[64];
@ -131,10 +147,9 @@ INTERNAL int telepen_num(struct zint_symbol *symbol, unsigned char source[], int
}
ustrcpy(temp, source);
to_upper(temp);
error_number = is_sane(SODIUM, temp, src_len);
if (error_number == ZINT_ERROR_INVALID_DATA) {
if (is_sane(SODIUM, temp, src_len) != 0) {
strcpy(symbol->errtxt, "393: Invalid character in data (digits and \"X\" only)");
return error_number;
return ZINT_ERROR_INVALID_DATA;
}
/* Add a leading zero if required */
@ -178,11 +193,11 @@ INTERNAL int telepen_num(struct zint_symbol *symbol, unsigned char source[], int
expand(symbol, dest);
#ifdef COMPLIANT_HEIGHTS
if (symbol->output_options & COMPLIANT_HEIGHT) {
(void) set_height(symbol, 0.0f, 32.0f, 0, 1 /*no_errtxt*/); /* Same as alphanumeric Telepen */
#else
} else {
(void) set_height(symbol, 0.0f, 50.0f, 0, 1 /*no_errtxt*/);
#endif
}
ustrcpy(symbol->text, temp);
return error_number;

View File

@ -150,10 +150,10 @@ static void test_input(int index, int debug) {
/* 3*/ { BARCODE_AUSPOST, "12345678ABcd!", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 404: Invalid character in data (alphanumerics, space and \"#\" only)" },
/* 4*/ { BARCODE_AUSPOST, "12345678ABcd#", 0, 3, 103, "" },
/* 5*/ { BARCODE_AUSPOST, "1234567890123456", 0, 3, 103, "" },
/* 6*/ { BARCODE_AUSPOST, "123456789012345A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 402: Invalid character in data (digits only for lengths 16 and 23)" },
/* 6*/ { BARCODE_AUSPOST, "123456789012345A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 402: Invalid character in data (digits only for length 16)" },
/* 7*/ { BARCODE_AUSPOST, "12345678ABCDefgh #", 0, 3, 133, "" }, // Length 18
/* 8*/ { BARCODE_AUSPOST, "12345678901234567890123", 0, 3, 133, "" },
/* 9*/ { BARCODE_AUSPOST, "1234567890123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 402: Invalid character in data (digits only for lengths 16 and 23)" },
/* 9*/ { BARCODE_AUSPOST, "1234567890123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 406: Invalid character in data (digits only for length 23)" },
/* 10*/ { BARCODE_AUSPOST, "1234567", ZINT_ERROR_TOO_LONG, -1, -1, "Error 401: Auspost input is wrong length (8, 13, 16, 18 or 23 characters only)" }, // No leading zeroes added
/* 11*/ { BARCODE_AUSREPLY, "12345678", 0, 3, 73, "" },
/* 12*/ { BARCODE_AUSREPLY, "1234567", 0, 3, 73, "" }, // Leading zeroes added

View File

@ -270,7 +270,8 @@ static void test_input(int index, int debug) {
/* 32*/ { -1, -1, -1, { 0, 2, "" }, "123456789012ABCDEFGHI", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 712: Structured Append index out of range (1-2)", },
/* 33*/ { -1, -1, -1, { 3, 2, "" }, "123456789012ABCDEFGHI", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 712: Structured Append index out of range (1-2)", },
/* 34*/ { -1, -1, -1, { 1, 2, "1" }, "123456789012ABCDEFGHI", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 713: Structured Append ID not available for Code One", },
/* 35*/ { -1, -1, 9, { 1, 2, "" }, "123456789012ABCDEFGHI", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 714: Structured Append not supported for Version S", },
/* 35*/ { -1, -1, 9, { 1, 2, "" }, "123456789012ABCDEFGHI", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 714: Structured Append not available for Version S", },
/* 36*/ { -1, -1, 9, { 3, 2, "" }, "123456789012ABCDEFGHI", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 714: Structured Append not available for Version S", }, // Trumps other checking
};
int data_size = ARRAY_SIZE(data);
int i, length, ret;

View File

@ -471,10 +471,10 @@ static void test_cap(int index) {
/* 0*/ { BARCODE_CODE128, ZINT_CAP_HRT, ZINT_CAP_HRT },
/* 1*/ { BARCODE_CODE128, ZINT_CAP_HRT | ZINT_CAP_STACKABLE | ZINT_CAP_GS1, ZINT_CAP_HRT | ZINT_CAP_STACKABLE },
/* 2*/ { BARCODE_PDF417, ZINT_CAP_HRT | ZINT_CAP_ECI | ZINT_CAP_GS1 | ZINT_CAP_READER_INIT | ZINT_CAP_FULL_MULTIBYTE, ZINT_CAP_ECI | ZINT_CAP_READER_INIT },
/* 3*/ { BARCODE_QRCODE, ZINT_CAP_HRT | ZINT_CAP_ECI | ZINT_CAP_GS1 | ZINT_CAP_DOTTY | ZINT_CAP_READER_INIT | ZINT_CAP_FULL_MULTIBYTE | ZINT_CAP_MASK | ZINT_CAP_STRUCTAPP, ZINT_CAP_ECI | ZINT_CAP_GS1 | ZINT_CAP_DOTTY | ZINT_CAP_FULL_MULTIBYTE | ZINT_CAP_MASK | ZINT_CAP_STRUCTAPP },
/* 4*/ { BARCODE_EANX_CC, ZINT_CAP_HRT | ZINT_CAP_COMPOSITE | ZINT_CAP_EXTENDABLE | ZINT_CAP_ECI | ZINT_CAP_GS1 | ZINT_CAP_QUIET_ZONES, ZINT_CAP_HRT | ZINT_CAP_COMPOSITE | ZINT_CAP_EXTENDABLE | ZINT_CAP_GS1 | ZINT_CAP_QUIET_ZONES },
/* 3*/ { BARCODE_QRCODE, ZINT_CAP_HRT | ZINT_CAP_ECI | ZINT_CAP_GS1 | ZINT_CAP_DOTTY | ZINT_CAP_READER_INIT | ZINT_CAP_FULL_MULTIBYTE | ZINT_CAP_MASK | ZINT_CAP_STRUCTAPP | ZINT_CAP_COMPLIANT_HEIGHT, ZINT_CAP_ECI | ZINT_CAP_GS1 | ZINT_CAP_DOTTY | ZINT_CAP_FULL_MULTIBYTE | ZINT_CAP_MASK | ZINT_CAP_STRUCTAPP },
/* 4*/ { BARCODE_EANX_CC, ZINT_CAP_HRT | ZINT_CAP_COMPOSITE | ZINT_CAP_EXTENDABLE | ZINT_CAP_ECI | ZINT_CAP_GS1 | ZINT_CAP_QUIET_ZONES | ZINT_CAP_COMPLIANT_HEIGHT, ZINT_CAP_HRT | ZINT_CAP_COMPOSITE | ZINT_CAP_EXTENDABLE | ZINT_CAP_GS1 | ZINT_CAP_QUIET_ZONES | ZINT_CAP_COMPLIANT_HEIGHT },
/* 5*/ { BARCODE_HANXIN, ZINT_CAP_DOTTY | ZINT_CAP_QUIET_ZONES | ZINT_CAP_FIXED_RATIO | ZINT_CAP_FULL_MULTIBYTE | ZINT_CAP_MASK, ZINT_CAP_DOTTY | ZINT_CAP_FIXED_RATIO | ZINT_CAP_FULL_MULTIBYTE | ZINT_CAP_MASK },
/* 6*/ { BARCODE_CODE11, ZINT_CAP_DOTTY | ZINT_CAP_FIXED_RATIO | ZINT_CAP_FIXED_RATIO | ZINT_CAP_READER_INIT | ZINT_CAP_FULL_MULTIBYTE, 0 },
/* 6*/ { BARCODE_CODE11, ZINT_CAP_DOTTY | ZINT_CAP_FIXED_RATIO | ZINT_CAP_FIXED_RATIO | ZINT_CAP_READER_INIT | ZINT_CAP_FULL_MULTIBYTE | ZINT_CAP_COMPLIANT_HEIGHT, 0 },
/* 7*/ { BARCODE_POSTNET, ZINT_CAP_HRT | ZINT_CAP_STACKABLE | ZINT_CAP_EXTENDABLE | ZINT_CAP_COMPOSITE | ZINT_CAP_ECI | ZINT_CAP_GS1 | ZINT_CAP_DOTTY | ZINT_CAP_FIXED_RATIO | ZINT_CAP_READER_INIT | ZINT_CAP_FULL_MULTIBYTE | ZINT_CAP_MASK | ZINT_CAP_STRUCTAPP, 0 },
/* 8*/ { 0, 0, 0 },
};
@ -495,6 +495,95 @@ static void test_cap(int index) {
testFinish();
}
static void test_cap_compliant_height() {
int symbol_id;
int ret;
testStart("test_cap_compliant_height");
for (symbol_id = 1; symbol_id <= BARCODE_RMQR; symbol_id++) {
if (!ZBarcode_ValidID(symbol_id)) continue;
ret = ZBarcode_Cap(symbol_id, ZINT_CAP_COMPLIANT_HEIGHT);
switch (symbol_id) {
//case BARCODE_CODE11: /* TODO: Find doc */
case BARCODE_C25INTER:
case BARCODE_CODE39:
case BARCODE_EXCODE39:
case BARCODE_EANX:
case BARCODE_EANX_CHK:
case BARCODE_GS1_128:
case BARCODE_CODABAR:
//case BARCODE_DPLEIT: /* TODO: Find doc */
//case BARCODE_DPIDENT: /* TODO: Find doc */
case BARCODE_CODE16K:
case BARCODE_CODE49:
case BARCODE_CODE93:
//case BARCODE_FLAT: /* TODO: Find doc */
case BARCODE_DBAR_OMN:
case BARCODE_DBAR_LTD:
case BARCODE_DBAR_EXP:
case BARCODE_TELEPEN:
case BARCODE_UPCA:
case BARCODE_UPCA_CHK:
case BARCODE_UPCE:
case BARCODE_UPCE_CHK:
case BARCODE_POSTNET:
//case BARCODE_MSI_PLESSEY: /* TODO: Find doc */
case BARCODE_FIM:
case BARCODE_LOGMARS:
case BARCODE_PHARMA:
case BARCODE_PZN:
case BARCODE_PHARMA_TWO:
case BARCODE_AUSPOST:
case BARCODE_AUSREPLY:
case BARCODE_AUSROUTE:
case BARCODE_AUSREDIRECT:
case BARCODE_ISBNX:
case BARCODE_RM4SCC:
case BARCODE_EAN14:
//case BARCODE_VIN: /* Spec unlikely */
case BARCODE_CODABLOCKF:
case BARCODE_NVE18:
case BARCODE_JAPANPOST:
//case BARCODE_KOREAPOST: /* TODO: Find doc */
case BARCODE_DBAR_STK:
case BARCODE_DBAR_OMNSTK:
case BARCODE_DBAR_EXPSTK:
case BARCODE_PLANET:
case BARCODE_USPS_IMAIL:
//case BARCODE_PLESSEY: /* TODO: Find doc */
case BARCODE_TELEPEN_NUM:
case BARCODE_ITF14:
case BARCODE_KIX:
case BARCODE_DPD:
case BARCODE_HIBC_39:
case BARCODE_HIBC_BLOCKF:
case BARCODE_MAILMARK:
case BARCODE_CODE32:
case BARCODE_EANX_CC:
case BARCODE_GS1_128_CC:
case BARCODE_DBAR_OMN_CC:
case BARCODE_DBAR_LTD_CC:
case BARCODE_DBAR_EXP_CC:
case BARCODE_UPCA_CC:
case BARCODE_UPCE_CC:
case BARCODE_DBAR_STK_CC:
case BARCODE_DBAR_OMNSTK_CC:
case BARCODE_DBAR_EXPSTK_CC:
case BARCODE_CHANNEL:
assert_equal(ret, ZINT_CAP_COMPLIANT_HEIGHT, "symbol_id %d (%s) ret 0x%X != ZINT_CAP_COMPLIANT_HEIGHT\n", symbol_id, testUtilBarcodeName(symbol_id), ret);
break;
default:
assert_zero(ret, "symbol_id %d (%s) ret 0x%X non-zero\n", symbol_id, testUtilBarcodeName(symbol_id), ret);
break;
}
}
testFinish();
}
static void test_encode_file_empty(void) {
int ret;
struct zint_symbol *symbol;
@ -950,6 +1039,7 @@ int main(int argc, char *argv[]) {
{ "test_input_mode", test_input_mode, 1, 0, 1 },
{ "test_escape_char_process", test_escape_char_process, 1, 1, 1 },
{ "test_cap", test_cap, 1, 0, 0 },
{ "test_cap_compliant_height", test_cap_compliant_height, 0, 0, 0 },
{ "test_encode_file_empty", test_encode_file_empty, 0, 0, 0 },
{ "test_encode_file_too_large", test_encode_file_too_large, 0, 0, 0 },
{ "test_encode_file_unreadable", test_encode_file_unreadable, 0, 0, 0 },

View File

@ -103,10 +103,13 @@ static void test_hrt(int index, int debug) {
/* 0*/ { BARCODE_CODABAR, -1, "A1234B", "A1234B" },
/* 1*/ { BARCODE_CODABAR, -1, "a1234c", "A1234C" }, // Converts to upper
/* 2*/ { BARCODE_CODABAR, 1, "A1234B", "A1234B" }, // Check not included
/* 3*/ { BARCODE_PHARMA, -1, "123456", "" }, // None
/* 4*/ { BARCODE_PHARMA_TWO, -1, "123456", "" }, // None
/* 5*/ { BARCODE_CODE32, -1, "123456", "A001234564" },
/* 6*/ { BARCODE_CODE32, -1, "12345678", "A123456788" },
/* 3*/ { BARCODE_CODABAR, 2, "A1234B", "A12345B" }, // Check included
/* 4*/ { BARCODE_CODABAR, 1, "A123456A", "A123456A" }, // Check not included
/* 5*/ { BARCODE_CODABAR, 2, "A123456A", "A123456$A" }, // Check included
/* 6*/ { BARCODE_PHARMA, -1, "123456", "" }, // None
/* 7*/ { BARCODE_PHARMA_TWO, -1, "123456", "" }, // None
/* 8*/ { BARCODE_CODE32, -1, "123456", "A001234564" },
/* 9*/ { BARCODE_CODE32, -1, "12345678", "A123456788" },
};
int data_size = ARRAY_SIZE(data);
int i, length, ret;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -648,6 +648,7 @@ const char *testUtilOutputOptionsName(int output_options) {
{ "OUT_BUFFER_INTERMEDIATE", OUT_BUFFER_INTERMEDIATE, 1024 },
{ "BARCODE_QUIET_ZONES", BARCODE_QUIET_ZONES, 2048 },
{ "BARCODE_NO_QUIET_ZONES", BARCODE_NO_QUIET_ZONES, 4096 },
{ "COMPLIANT_HEIGHT", COMPLIANT_HEIGHT, 0x2000 },
};
static int const data_size = ARRAY_SIZE(data);
int set = 0;

View File

@ -872,7 +872,7 @@ static int ultra_generate_codewords(struct zint_symbol *symbol, const unsigned c
return codeword_count;
}
INTERNAL int ultracode(struct zint_symbol *symbol, unsigned char source[], int length) {
INTERNAL int ultra(struct zint_symbol *symbol, unsigned char source[], int length) {
int data_cw_count = 0;
int acc, qcc;
int scr[3] = {0}, scr_cw_count = 0; /* Symbol Control Region (only if have Structured Append) */

View File

@ -31,8 +31,8 @@
/* vim: set ts=4 sw=4 et : */
#define SODIUM "0123456789+"
#define ISBN_SANE "0123456789X"
#define ISBN_ADDON_SANE "0123456789Xx+"
#define ISBNX_SANE "0123456789X"
#define ISBNX_ADDON_SANE "0123456789Xx+"
#define EAN2 102
#define EAN5 105
@ -108,7 +108,6 @@ static void upca_draw(const unsigned char source[], const int length, char dest[
/* Make a UPC-A barcode, allowing for composite if `cc_rows` set */
static int upca_cc(struct zint_symbol *symbol, const unsigned char source[], int length, char dest[], int cc_rows) {
unsigned char *gtin = symbol->text;
float height;
int error_number = 0;
ustrcpy(gtin, source);
@ -130,23 +129,23 @@ static int upca_cc(struct zint_symbol *symbol, const unsigned char source[], int
upca_draw(gtin, length, dest);
#ifdef COMPLIANT_HEIGHTS
if (symbol->output_options & COMPLIANT_HEIGHT) {
/* BS EN 797:1996 4.5.1 Nominal dimensions 22.85mm / 0.33mm (X) ~ 69.24,
same as minimum GS1 General Specifications 21.0.1 5.12.3.1 */
height = (float) (22.85 / 0.33);
const float height = stripf(22.85f / 0.33f);
if (symbol->symbology == BARCODE_UPCA_CC) {
symbol->height = height; /* Pass back min row == default height */
} else {
error_number = set_height(symbol, height, height, 0.0f, 0 /*no_errtxt*/);
}
#else
height = 50.0f;
} else {
const float height = 50.0f;
if (symbol->symbology == BARCODE_UPCA_CC) {
symbol->height = height - cc_rows * 2 - 6.0f;
} else {
(void) set_height(symbol, 0.0f, height, 0.0f, 1 /*no_errtxt*/);
}
#endif
}
return error_number;
}
@ -163,7 +162,6 @@ static int upce_cc(struct zint_symbol *symbol, unsigned char source[], int lengt
char src_check_digit = '\0';
unsigned char equivalent[12];
unsigned char *hrt = symbol->text;
float height;
int error_number = 0;
if (length == 8 || symbol->symbology == BARCODE_UPCE_CHK) {
@ -297,23 +295,23 @@ static int upce_cc(struct zint_symbol *symbol, unsigned char source[], int lengt
printf("UPC-E: %s, equivalent: %s, hrt: %s, Check digit: %c\n", source, equivalent, hrt, check_digit);
}
#ifdef COMPLIANT_HEIGHTS
if (symbol->output_options & COMPLIANT_HEIGHT) {
/* BS EN 797:1996 4.5.1 Nominal dimensions 22.85mm / 0.33mm (X) ~ 69.24,
same as minimum GS1 General Specifications 21.0.1 5.12.3.1 */
height = (float) (22.85 / 0.33);
const float height = stripf(22.85f / 0.33f);
if (symbol->symbology == BARCODE_UPCE_CC) {
symbol->height = height; /* Pass back min row == default height */
} else {
error_number = set_height(symbol, height, height, 0.0f, 0 /*no_errtxt*/);
}
#else
height = 50.0f;
} else {
const float height = 50.0f;
if (symbol->symbology == BARCODE_UPCE_CC) {
symbol->height = height - cc_rows * 2 - 6.0f;
} else {
(void) set_height(symbol, 0.0f, height, 0.0f, 1 /*no_errtxt*/);
}
#endif
}
return error_number;
}
@ -390,7 +388,6 @@ static int ean13_cc(struct zint_symbol *symbol, const unsigned char source[], in
int i, half_way;
char parity[6];
unsigned char *gtin = symbol->text;
float height;
int error_number = 0;
parity[0] = '\0';
@ -437,23 +434,23 @@ static int ean13_cc(struct zint_symbol *symbol, const unsigned char source[], in
/* stop character */
strcat(dest, "111");
#ifdef COMPLIANT_HEIGHTS
if (symbol->output_options & COMPLIANT_HEIGHT) {
/* BS EN 797:1996 4.5.1 Nominal dimensions 22.85mm / 0.33mm (X) ~ 69.24,
same as minimum GS1 General Specifications 21.0.1 5.12.3.1 */
height = (float) (22.85 / 0.33);
const float height = stripf(22.85f / 0.33f);
if (symbol->symbology == BARCODE_EANX_CC) {
symbol->height = height; /* Pass back min row == default height */
} else {
error_number = set_height(symbol, height, height, 0.0f, 0 /*no_errtxt*/);
}
#else
height = 50.0f;
} else {
const float height = 50.0f;
if (symbol->symbology == BARCODE_EANX_CC) {
symbol->height = height - cc_rows * 2 - 6.0f;
} else {
(void) set_height(symbol, 0.0f, height, 0.0f, 1 /*no_errtxt*/);
}
#endif
}
return error_number;
}
@ -465,7 +462,6 @@ static int ean13(struct zint_symbol *symbol, const unsigned char source[], int l
static int ean8_cc(struct zint_symbol *symbol, const unsigned char source[], int length, char dest[], int cc_rows) {
/* EAN-8 is basically the same as UPC-A but with fewer digits */
unsigned char *gtin = symbol->text;
float height;
int error_number = 0;
ustrcpy(gtin, source);
@ -487,23 +483,23 @@ static int ean8_cc(struct zint_symbol *symbol, const unsigned char source[], int
upca_draw(gtin, length, dest);
#ifdef COMPLIANT_HEIGHTS
if (symbol->output_options & COMPLIANT_HEIGHT) {
/* BS EN 797:1996 4.5.1 Nominal dimensions 18.23mm / 0.33mm (X) ~ 55.24,
same as minimum GS1 General Specifications 21.0.1 5.12.3.1 */
height = (float) (18.23 / 0.33);
const float height = stripf(18.23f / 0.33f);
if (symbol->symbology == BARCODE_EANX_CC) {
symbol->height = height; /* Pass back min row == default height */
} else {
error_number = set_height(symbol, height, height, 0.0f, 0 /*no_errtxt*/);
}
#else
height = 50.0f;
} else {
const float height = 50.0f;
if (symbol->symbology == BARCODE_EANX_CC) {
symbol->height = height - cc_rows * 2 - 6.0f;
} else {
(void) set_height(symbol, 0.0f, height, 0.0f, 1 /*no_errtxt*/);
}
#endif
}
return error_number;
}
@ -514,7 +510,7 @@ static int ean8(struct zint_symbol *symbol, const unsigned char source[], int le
}
/* For ISBN(10) and SBN only */
static char isbn_check(const unsigned char source[], const int length) {
static char isbnx_check(const unsigned char source[], const int length) {
int i, weight, sum, check;
char check_char;
@ -535,15 +531,14 @@ static char isbn_check(const unsigned char source[], const int length) {
}
/* Make an EAN-13 barcode from an SBN or ISBN */
static int isbn(struct zint_symbol *symbol, unsigned char source[], const int src_len, char dest[]) {
int i, error_number;
static int isbnx(struct zint_symbol *symbol, unsigned char source[], const int src_len, char dest[]) {
int i;
char check_digit;
to_upper(source);
error_number = is_sane(ISBN_SANE, source, src_len);
if (error_number == ZINT_ERROR_INVALID_DATA) {
if (is_sane(ISBNX_SANE, source, src_len) != 0) {
strcpy(symbol->errtxt, "277: Invalid character in data (digits and \"X\" only)");
return error_number;
return ZINT_ERROR_INVALID_DATA;
}
/* Input must be 9, 10 or 13 characters */
@ -560,10 +555,9 @@ static int isbn(struct zint_symbol *symbol, unsigned char source[], const int sr
}
/* "X" can only occur in last position */
error_number = is_sane(NEON, source, 12);
if (error_number == ZINT_ERROR_INVALID_DATA) {
if (is_sane(NEON, source, 12) != 0) {
strcpy(symbol->errtxt, "282: Invalid character in data, \"X\" allowed in last position only");
return error_number;
return ZINT_ERROR_INVALID_DATA;
}
check_digit = gs1_check_digit(source, 12);
@ -584,13 +578,12 @@ static int isbn(struct zint_symbol *symbol, unsigned char source[], const int sr
}
/* "X" can only occur in last position */
error_number = is_sane(NEON, source, 9);
if (error_number == ZINT_ERROR_INVALID_DATA) {
if (is_sane(NEON, source, 9) != 0) {
strcpy(symbol->errtxt, "296: Invalid character in data, \"X\" allowed in last position only");
return error_number;
return ZINT_ERROR_INVALID_DATA;
}
check_digit = isbn_check(source, 9);
check_digit = isbnx_check(source, 9);
if (check_digit != source[9]) {
sprintf(symbol->errtxt, "281: Invalid %s check digit '%c', expecting '%c'", src_len == 9 ? "SBN" : "ISBN",
source[9], check_digit);
@ -758,10 +751,9 @@ INTERNAL int eanx_cc(struct zint_symbol *symbol, unsigned char source[], int src
char dest[1000] = {0};
int latch, reader, writer;
int with_addon;
int error_number, i, plus_count;
int error_number = 0, i, plus_count;
int addon_gap = 0;
int first_part_len, second_part_len;
float height;
latch = FALSE;
writer = 0;
@ -772,16 +764,14 @@ INTERNAL int eanx_cc(struct zint_symbol *symbol, unsigned char source[], int src
}
if (symbol->symbology != BARCODE_ISBNX) {
/* ISBN has its own sanity routine */
error_number = is_sane(SODIUM, source, src_len);
if (error_number == ZINT_ERROR_INVALID_DATA) {
if (is_sane(SODIUM, source, src_len) != 0) {
strcpy(symbol->errtxt, "284: Invalid character in data (digits and \"+\" only)");
return error_number;
return ZINT_ERROR_INVALID_DATA;
}
} else {
error_number = is_sane(ISBN_ADDON_SANE, source, src_len);
if (error_number == ZINT_ERROR_INVALID_DATA) {
if (is_sane(ISBNX_ADDON_SANE, source, src_len) != 0) {
strcpy(symbol->errtxt, "285: Invalid character in data (digits, \"X\" and \"+\" only)");
return error_number;
return ZINT_ERROR_INVALID_DATA;
}
/* Add-on will be checked separately to be numeric only below */
}
@ -845,25 +835,23 @@ INTERNAL int eanx_cc(struct zint_symbol *symbol, unsigned char source[], int src
switch (first_part_len) {
case 2: ean_add_on(first_part, first_part_len, dest, 0);
ustrcpy(symbol->text, first_part);
#ifdef COMPLIANT_HEIGHTS
if (symbol->output_options & COMPLIANT_HEIGHT) {
/* 21.9mm from GS1 General Specifications 5.2.6.6, Figure 5.2.6.6-5 */
height = (float) (21.9 / 0.33); /* 21.9mm / 0.33mm ~ 66.36 */
const float height = stripf(21.9f / 0.33f); /* 21.9mm / 0.33mm ~ 66.36 */
error_number = set_height(symbol, height, height, 0.0f, 0 /*no_errtxt*/);
#else
height = 50.0f;
(void) set_height(symbol, 0.0f, height, 0.0f, 1 /*no_errtxt*/);
#endif
} else {
(void) set_height(symbol, 0.0f, 50.0f, 0.0f, 1 /*no_errtxt*/);
}
break;
case 5: ean_add_on(first_part, first_part_len, dest, 0);
ustrcpy(symbol->text, first_part);
#ifdef COMPLIANT_HEIGHTS
if (symbol->output_options & COMPLIANT_HEIGHT) {
/* 21.9mm from GS1 General Specifications 5.2.6.6, Figure 5.2.6.6-6 */
height = (float) (21.9 / 0.33); /* 21.9mm / 0.33mm ~ 66.36 */
const float height = stripf(21.9f / 0.33f); /* 21.9mm / 0.33mm ~ 66.36 */
error_number = set_height(symbol, height, height, 0.0f, 0 /*no_errtxt*/);
#else
height = 50.0f;
(void) set_height(symbol, 0.0f, height, 0.0f, 1 /*no_errtxt*/);
#endif
} else {
(void) set_height(symbol, 0.0f, 50.0f, 0.0f, 1 /*no_errtxt*/);
}
break;
case 7:
case 8: error_number = ean8(symbol, first_part, first_part_len, dest);
@ -961,7 +949,7 @@ INTERNAL int eanx_cc(struct zint_symbol *symbol, unsigned char source[], int src
}
break;
case BARCODE_ISBNX:
error_number = isbn(symbol, first_part, first_part_len, dest);
error_number = isbnx(symbol, first_part, first_part_len, dest);
break;
}
@ -972,10 +960,9 @@ INTERNAL int eanx_cc(struct zint_symbol *symbol, unsigned char source[], int src
second_part_len = (int) ustrlen(second_part);
if (symbol->symbology == BARCODE_ISBNX) { /* Need to further check that add-on numeric only */
error_number = is_sane(NEON, second_part, second_part_len);
if (error_number == ZINT_ERROR_INVALID_DATA) {
if (is_sane(NEON, second_part, second_part_len) != 0) {
strcpy(symbol->errtxt, "295: Invalid add-on data (digits only)");
return error_number;
return ZINT_ERROR_INVALID_DATA;
}
}

View File

@ -30,8 +30,6 @@
*/
/* vim: set ts=4 sw=4 et : */
#include <math.h>
#ifdef _MSC_VER
#include <malloc.h>
#endif

View File

@ -110,7 +110,7 @@ extern "C" {
int fontsize; /* Unused */
int input_mode; /* Encoding of input data (see DATA_MODE etc below). Default DATA_MODE */
int eci; /* Extended Channel Interpretation. Default 0 (none) */
float dot_size; /* Size of dots used in BARCODE_DOTTY_MODE */
float dot_size; /* Size of dots used in BARCODE_DOTTY_MODE. Default 0.8 */
float guard_descent; /* Height in X-dimensions that UPC/EAN guard bars descend. Default 5 */
struct zint_structapp structapp; /* Structured Append info. Default structapp.count 0 (none) */
int warn_level; /* Affects error/warning value returned by Zint API (see WARN_XXX below) */
@ -255,29 +255,31 @@ extern "C" {
#define BARCODE_RMQR 145 /* Rectangular Micro QR Code (rMQR) */
/* Output options (`symbol->output_options`) */
#define BARCODE_NO_ASCII 1 /* Legacy (no-op) */
#define BARCODE_BIND 2 /* Boundary bars above & below the symbol and between stacked symbols */
#define BARCODE_BOX 4 /* Box around symbol */
#define BARCODE_STDOUT 8 /* Output to stdout */
#define READER_INIT 16 /* Reader Initialisation (Programming) */
#define SMALL_TEXT 32 /* Use smaller font */
#define BOLD_TEXT 64 /* Use bold font */
#define CMYK_COLOUR 128 /* CMYK colour space (Encapsulated PostScript and TIF) */
#define BARCODE_DOTTY_MODE 256 /* Plot a matrix symbol using dots rather than squares */
#define GS1_GS_SEPARATOR 512 /* Use GS instead of FNC1 as GS1 separator (Data Matrix) */
#define OUT_BUFFER_INTERMEDIATE 1024 /* Return ASCII values in bitmap buffer (OUT_BUFFER only) */
#define BARCODE_QUIET_ZONES 2048 /* Add compliant quiet zones (additional to any specified whitespace) */
/* Note: CODE16K, CODE49, CODABLOCKF, ITF14, UPC/EAN have default quiet zones */
#define BARCODE_NO_QUIET_ZONES 4096 /* Disable quiet zones, notably those with defaults as listed above */
#define BARCODE_NO_ASCII 0x0001 /* Legacy (no-op) */
#define BARCODE_BIND 0x0002 /* Boundary bars above & below the symbol and between stacked symbols */
#define BARCODE_BOX 0x0004 /* Box around symbol */
#define BARCODE_STDOUT 0x0008 /* Output to stdout */
#define READER_INIT 0x0010 /* Reader Initialisation (Programming) */
#define SMALL_TEXT 0x0020 /* Use smaller font */
#define BOLD_TEXT 0x0040 /* Use bold font */
#define CMYK_COLOUR 0x0080 /* CMYK colour space (Encapsulated PostScript and TIF) */
#define BARCODE_DOTTY_MODE 0x0100 /* Plot a matrix symbol using dots rather than squares */
#define GS1_GS_SEPARATOR 0x0200 /* Use GS instead of FNC1 as GS1 separator (Data Matrix) */
#define OUT_BUFFER_INTERMEDIATE 0x0400 /* Return ASCII values in bitmap buffer (OUT_BUFFER only) */
#define BARCODE_QUIET_ZONES 0x0800 /* Add compliant quiet zones (additional to any specified whitespace) */
/* Note: CODE16K, CODE49, CODABLOCKF, ITF14, UPC/EAN have default quiet zones
*/
#define BARCODE_NO_QUIET_ZONES 0x1000 /* Disable quiet zones, notably those with defaults as listed above */
#define COMPLIANT_HEIGHT 0x2000 /* Warn if height not compliant and use standard height (if any) as default */
/* Input data types (`symbol->input_mode`) */
#define DATA_MODE 0 /* Binary */
#define UNICODE_MODE 1 /* UTF-8 */
#define GS1_MODE 2 /* GS1 */
/* The following may be OR-ed with above */
#define ESCAPE_MODE 8 /* Process escape sequences */
#define GS1PARENS_MODE 16 /* Process parentheses as GS1 AI delimiters (instead of square brackets) */
#define GS1NOCHECK_MODE 32 /* Do not check validity of GS1 data (except that printable ASCII only) */
#define ESCAPE_MODE 0x0008 /* Process escape sequences */
#define GS1PARENS_MODE 0x0010 /* Process parentheses as GS1 AI delimiters (instead of square brackets) */
#define GS1NOCHECK_MODE 0x0020 /* Do not check validity of GS1 data (except that printable ASCII only) */
/* Data Matrix specific options (`symbol->option_3`) */
#define DM_SQUARE 100 /* Only consider square versions on automatic symbol size selection */
@ -323,13 +325,14 @@ extern "C" {
#define ZINT_CAP_FULL_MULTIBYTE 0x0400 /* Supports full-multibyte option? */
#define ZINT_CAP_MASK 0x0800 /* Is mask selectable? */
#define ZINT_CAP_STRUCTAPP 0x1000 /* Supports Structured Append? */
#define ZINT_CAP_COMPLIANT_HEIGHT 0x2000 /* Has compliant height? */
/* The largest amount of data that can be encoded is 4350 4-byte UTF-8 chars in Han Xin Code */
#define ZINT_MAX_DATA_LEN 17400
/* Debug flags (debug) */
#define ZINT_DEBUG_PRINT 1 /* Print debug info (if any) to stdout */
#define ZINT_DEBUG_TEST 2 /* For internal test use only */
#define ZINT_DEBUG_PRINT 0x0001 /* Print debug info (if any) to stdout */
#define ZINT_DEBUG_TEST 0x0002 /* For internal test use only */
#ifdef _WIN32
# if defined(DLL_EXPORT) || defined(PIC) || defined(_USRDLL)

View File

@ -21,6 +21,9 @@ target_include_directories(${PROJECT_NAME} PUBLIC "${CMAKE_SOURCE_DIR}/backend")
target_link_libraries(${PROJECT_NAME} zint Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Gui)
if(ZINT_TEST AND NOT WIN32) # Fails with "Test not available without configuration" on Windows so skip
add_subdirectory(tests)
endif()
install(TARGETS ${PROJECT_NAME} ${INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES qzint.h DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel)

View File

@ -65,6 +65,7 @@ namespace Zint {
m_gssep = false;
m_quiet_zones = false;
m_no_quiet_zones = false;
m_compliant_height = false;
m_reader_init = false;
m_rotate_angle = 0;
m_debug = false;
@ -95,6 +96,9 @@ namespace Zint {
if (m_no_quiet_zones) {
m_zintSymbol->output_options |= BARCODE_NO_QUIET_ZONES;
}
if (m_compliant_height) {
m_zintSymbol->output_options |= COMPLIANT_HEIGHT;
}
m_zintSymbol->border_width = m_borderWidth;
m_zintSymbol->option_1 = m_option_1;
m_zintSymbol->option_2 = m_option_2;
@ -153,6 +157,8 @@ namespace Zint {
m_whitespace = m_zintSymbol->whitespace_width;
m_vwhitespace = m_zintSymbol->whitespace_height;
emit encoded();
} else {
emit errored();
}
}
@ -236,8 +242,12 @@ namespace Zint {
m_dotty = dotty;
}
void QZint::setDotSize(float dot_size) {
m_dot_size = dot_size;
float QZint::dotSize() const {
return m_dot_size;
}
void QZint::setDotSize(float dotSize) {
m_dot_size = dotSize;
}
float QZint::guardDescent() const {
@ -248,6 +258,18 @@ namespace Zint {
m_guardDescent = guardDescent;
}
int QZint::structAppCount() const {
return m_structapp.count;
}
int QZint::structAppIndex() const {
return m_structapp.index;
}
QString QZint::structAppID() const {
return m_structapp.id;
}
void QZint::setStructApp(const int count, const int index, const QString& id) {
if (count) {
m_structapp.count = count;
@ -289,6 +311,10 @@ namespace Zint {
m_bgColor = bgColor;
}
bool QZint::cmyk() const {
return m_cmyk;
}
void QZint::setCMYK(bool cmyk) {
m_cmyk = cmyk;
}
@ -311,21 +337,33 @@ namespace Zint {
return m_borderWidth;
}
void QZint::setBorderWidth(int boderWidth) {
if (boderWidth < 0 || boderWidth > 16)
boderWidth = 0;
m_borderWidth = boderWidth;
void QZint::setBorderWidth(int borderWidth) {
if (borderWidth < 0 || borderWidth > 16)
borderWidth = 0;
m_borderWidth = borderWidth;
}
int QZint::whitespace() const {
return m_whitespace;
}
void QZint::setWhitespace(int whitespace) {
m_whitespace = whitespace;
}
void QZint::setVWhitespace(int vwhitespace) {
m_vwhitespace = vwhitespace;
int QZint::vWhitespace() const {
return m_vwhitespace;
}
void QZint::setFontSetting(int fontSettingIndex) {
void QZint::setVWhitespace(int vWhitespace) {
m_vwhitespace = vWhitespace;
}
int QZint::fontSetting() const {
return m_fontSetting;
}
void QZint::setFontSetting(int fontSettingIndex) { // Sets from comboBox index
if (fontSettingIndex == 1) {
m_fontSetting = BOLD_TEXT;
} else if (fontSettingIndex == 2) {
@ -337,27 +375,59 @@ namespace Zint {
}
}
void QZint::setShowText(bool show) {
m_show_hrt = show;
void QZint::setFontSettingValue(int fontSetting) { // Sets literal value
if ((fontSetting & (BOLD_TEXT | SMALL_TEXT)) == fontSetting) {
m_fontSetting = fontSetting;
} else {
m_fontSetting = 0;
}
}
void QZint::setGSSep(bool gssep) {
m_gssep = gssep;
bool QZint::showText() const {
return m_show_hrt;
}
int QZint::rotateAngle() const {
return m_rotate_angle;
void QZint::setShowText(bool showText) {
m_show_hrt = showText;
}
bool QZint::gsSep() const {
return m_gssep;
}
void QZint::setGSSep(bool gsSep) {
m_gssep = gsSep;
}
bool QZint::quietZones() const {
return m_quiet_zones;
}
void QZint::setQuietZones(bool quietZones) {
m_quiet_zones = quietZones;
}
bool QZint::noQuietZones() const {
return m_no_quiet_zones;
}
void QZint::setNoQuietZones(bool noQuietZones) {
m_no_quiet_zones = noQuietZones;
}
void QZint::setRotateAngle(int rotateIndex) {
bool QZint::compliantHeight() const {
return m_compliant_height;
}
void QZint::setCompliantHeight(bool compliantHeight) {
m_compliant_height = compliantHeight;
}
int QZint::rotateAngle() const {
return m_rotate_angle;
}
void QZint::setRotateAngle(int rotateIndex) { // Sets from comboBox index
if (rotateIndex == 1) {
m_rotate_angle = 90;
} else if (rotateIndex == 2) {
@ -369,7 +439,23 @@ namespace Zint {
}
}
void QZint::setECI(int ECIIndex) {
void QZint::setRotateAngleValue(int rotateAngle) { // Sets literal value
if (rotateAngle == 90) {
m_rotate_angle = 90;
} else if (rotateAngle == 180) {
m_rotate_angle = 180;
} else if (rotateAngle == 270) {
m_rotate_angle = 270;
} else {
m_rotate_angle = 0;
}
}
int QZint::eci() const {
return m_eci;
}
void QZint::setECI(int ECIIndex) { // Sets from comboBox index
if (ECIIndex >= 1 && ECIIndex <= 11) {
m_eci = ECIIndex + 2;
} else if (ECIIndex >= 12 && ECIIndex <= 15) {
@ -383,16 +469,40 @@ namespace Zint {
}
}
void QZint::setGS1Parens(bool gs1parens) {
m_gs1parens = gs1parens;
void QZint::setECIValue(int eci) { // Sets literal value
if (eci < 3 || (eci > 30 && eci != 899) || eci == 14 || eci == 19) {
m_eci = 0;
} else {
m_eci = eci;
}
}
void QZint::setGS1NoCheck(bool gs1nocheck) {
m_gs1nocheck = gs1nocheck;
bool QZint::gs1Parens() const {
return m_gs1parens;
}
void QZint::setReaderInit(bool reader_init) {
m_reader_init = reader_init;
void QZint::setGS1Parens(bool gs1Parens) {
m_gs1parens = gs1Parens;
}
bool QZint::gs1NoCheck() const {
return m_gs1nocheck;
}
void QZint::setGS1NoCheck(bool gs1NoCheck) {
m_gs1nocheck = gs1NoCheck;
}
bool QZint::readerInit() const {
return m_reader_init;
}
void QZint::setReaderInit(bool readerInit) {
m_reader_init = readerInit;
}
bool QZint::debug() const {
return m_debug;
}
void QZint::setDebug(bool debug) {
@ -411,6 +521,7 @@ namespace Zint {
target_size_horiz = width;
target_size_vert = height;
}
QString QZint::error_message() const { return m_lastError; } /* Same as lastError() */
bool QZint::hasHRT(int symbology) const {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_HRT);
@ -444,12 +555,12 @@ namespace Zint {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_READER_INIT);
}
int QZint::getError() const {
return m_error;
bool QZint::hasCompliantHeight(int symbology) const {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_COMPLIANT_HEIGHT);
}
QString QZint::error_message() const {
return m_lastError;
int QZint::getError() const {
return m_error;
}
const QString& QZint::lastError() const {
@ -472,6 +583,7 @@ namespace Zint {
m_rotate_angle);
if (m_error >= ZINT_ERROR) {
m_lastError = m_zintSymbol->errtxt;
emit errored();
return false;
} else {
return true;

View File

@ -67,11 +67,15 @@ public:
bool dotty() const;
void setDotty(bool botty);
float dotSize() const;
void setDotSize(float dot_size);
float guardDescent() const;
void setGuardDescent(float guardDescent);
int structAppCount() const;
int structAppIndex() const;
QString structAppID() const;
void setStructApp(const int count, const int index, const QString& id);
void clearStructApp();
@ -81,38 +85,58 @@ public:
QColor bgColor() const;
void setBgColor(const QColor& bgColor);
bool cmyk() const;
void setCMYK(bool cmyk);
int borderType() const;
void setBorderType(int borderTypeIndex);
int borderWidth() const;
void setBorderWidth(int boderWidth);
void setBorderWidth(int borderWidth);
int whitespace() const;
void setWhitespace(int whitespace);
void setVWhitespace(int vwhitespace);
int vWhitespace() const;
void setVWhitespace(int vWhitespace);
void setFontSetting(int fontSettingIndex);
int fontSetting() const;
void setFontSetting(int fontSettingIndex); // Sets from comboBox index
void setFontSettingValue(int fontSetting); // Sets literal value
void setShowText(bool show);
bool showText() const;
void setShowText(bool showText);
void setGSSep(bool gssep);
bool gsSep() const;
void setGSSep(bool gsSep);
bool quietZones() const;
void setQuietZones(bool quietZones);
bool noQuietZones() const;
void setNoQuietZones(bool noQuietZones);
bool compliantHeight() const;
void setCompliantHeight(bool compliantHeight);
int rotateAngle() const;
void setRotateAngle(int rotateIndex);
void setRotateAngle(int rotateIndex); // Sets from comboBox index
void setRotateAngleValue(int rotateAngle); // Sets literal value
void setECI(int ECIIndex);
int eci() const;
void setECI(int ECIIndex); // Sets from comboBox index
void setECIValue(int eci); // Sets literal value
void setGS1Parens(bool gs1parens);
bool gs1Parens() const;
void setGS1Parens(bool gs1Parens);
void setGS1NoCheck(bool gs1nocheck);
bool gs1NoCheck() const;
void setGS1NoCheck(bool gs1NoCheck);
void setReaderInit(bool reader_init);
bool readerInit() const;
void setReaderInit(bool readerInit);
bool debug() const;
void setDebug(bool debug);
/* Legacy property getters/setters */
@ -120,10 +144,11 @@ public:
int width() const;
void setSecurityLevel(int securityLevel); /* option_2 */
int securityLevel() const;
void setPdf417CodeWords(int pdf417CodeWords); /* no op */
void setPdf417CodeWords(int pdf417CodeWords); /* No-op */
int pdf417CodeWords() const;
void setHideText(bool hide); /* setShowText(!hide) */
void setTargetSize(int width, int height);
QString error_message() const; /* Same as lastError() */
/* Test capabilities - ZBarcode_Cap() */
bool hasHRT(int symbology = 0) const;
@ -134,11 +159,10 @@ public:
bool isFixedRatio(int symbology = 0) const;
bool isDotty(int symbology = 0) const;
bool supportsReaderInit(int symbology = 0) const;
bool hasCompliantHeight(int symbology = 0) const;
int getError() const;
QString error_message() const;
const QString& lastError() const;
bool hasErrors() const;
@ -151,6 +175,7 @@ public:
signals:
void encoded();
void errored();
private:
void resetSymbol();
@ -190,6 +215,7 @@ private:
bool m_gssep;
bool m_quiet_zones;
bool m_no_quiet_zones;
bool m_compliant_height;
bool m_reader_init;
bool m_debug;

View File

@ -0,0 +1,22 @@
# Copyright (C) 2021 Robin Stuart <rstuart114@gmail.com>
# vim: set ts=4 sw=4 et :
cmake_minimum_required(VERSION 3.5)
project(QZint_tests LANGUAGES CXX)
enable_testing()
if(USE_QT6)
find_package(Qt6Test REQUIRED)
else()
find_package(Qt5Test REQUIRED)
endif()
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
add_executable(test_qzint test_qzint.cpp)
add_test(NAME qzint COMMAND test_qzint)
target_link_libraries(test_qzint PRIVATE QZint Qt${QT_VERSION_MAJOR}::Test)

View File

@ -0,0 +1,403 @@
/***************************************************************************
* Copyright (C) 2021 by Robin Stuart <rstuart114@gmail.com> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
/* vim: set ts=4 sw=4 et : */
#include <QtTest/QtTest>
#include "../qzint.h" /* Don't use <qzint.h> in case it's been changed */
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) ((int) (sizeof(x) / sizeof((x)[0])))
#endif
class TestQZint : public QObject
{
Q_OBJECT
public:
TestQZint() : m_skipIfFontUsed(false)
{
// Qt5 will trigger "detected memory leaks" if font used (libfontconfig) so skip if ASAN enabled
#if QT_VERSION < 0x60000
# if defined(__SANITIZE_ADDRESS__) || (defined(__has_feature) && __has_feature(address_sanitizer))
m_skipIfFontUsed = true;
# endif
#endif
}
virtual ~TestQZint() {} // Seems to be needed to generate vtable
private:
bool m_skipIfFontUsed; // Hack to get around Qt5 ASAN leaks
private slots:
void setGetTest()
{
Zint::QZint bc;
int symbology = BARCODE_CODE11;
bc.setSymbol(symbology);
QCOMPARE(bc.symbol(), symbology);
int inputMode = UNICODE_MODE;
bc.setInputMode(inputMode);
QCOMPARE(bc.inputMode(), inputMode);
QString text("text");
bc.setText(text);
QCOMPARE(bc.text(), text);
QString primaryMessage("primary message");
bc.setPrimaryMessage(primaryMessage);
QCOMPARE(bc.primaryMessage(), primaryMessage);
float height = 12.345f;
bc.setHeight(height);
QCOMPARE(bc.height(), height);
int option1 = 1;
bc.setOption1(option1);
QCOMPARE(bc.option1(), option1);
int option2 = 2;
bc.setOption2(option2);
QCOMPARE(bc.option2(), option2);
int option3 = 3;
bc.setOption3(option3);
QCOMPARE(bc.option3(), option3);
float scale = 0.678f;
bc.setScale(scale);
QCOMPARE(bc.scale(), scale);
bool dotty = true;
bc.setDotty(dotty);
QCOMPARE(bc.dotty(), dotty);
float dotSize = 1.234f;
bc.setDotSize(dotSize);
QCOMPARE(bc.dotSize(), dotSize);
float guardDescent = 0.678f;
bc.setGuardDescent(guardDescent);
QCOMPARE(bc.guardDescent(), guardDescent);
struct zint_structapp structapp = { 2, 3, "ID" };
bc.setStructApp(structapp.count, structapp.index, structapp.id);
QCOMPARE(bc.structAppCount(), structapp.count);
QCOMPARE(bc.structAppIndex(), structapp.index);
QCOMPARE(bc.structAppID(), QString(structapp.id));
QColor fgColor(0x12, 0x34, 0x45, 0x67);
bc.setFgColor(fgColor);
QCOMPARE(bc.fgColor(), fgColor);
QColor bgColor(0x89, 0xAB, 0xCD, 0xEF);
bc.setBgColor(bgColor);
QCOMPARE(bc.bgColor(), bgColor);
bool cmyk = true;
bc.setCMYK(cmyk);
QCOMPARE(bc.cmyk(), cmyk);
int borderTypes[] = { 0, BARCODE_BIND, BARCODE_BOX };
for (int i = 0; i < ARRAY_SIZE(borderTypes); i++) {
bc.setBorderType(i);
QCOMPARE(bc.borderType(), borderTypes[i]);
}
int borderWidth = 4;
bc.setBorderWidth(borderWidth);
QCOMPARE(bc.borderWidth(), borderWidth);
int whitespace = 5;
bc.setWhitespace(whitespace);
QCOMPARE(bc.whitespace(), whitespace);
int vWhitespace = 6;
bc.setVWhitespace(vWhitespace);
QCOMPARE(bc.vWhitespace(), vWhitespace);
int fontSettings[] = { 0, BOLD_TEXT, SMALL_TEXT, SMALL_TEXT | BOLD_TEXT };
for (int i = 0; i < ARRAY_SIZE(fontSettings); i++) {
bc.setFontSetting(i);
QCOMPARE(bc.fontSetting(), fontSettings[i]);
bc.setFontSettingValue(fontSettings[i]);
QCOMPARE(bc.fontSetting(), fontSettings[i]);
}
bc.setFontSetting(ARRAY_SIZE(fontSettings));
QCOMPARE(bc.fontSetting(), 0);
bc.setFontSetting(-1);
QCOMPARE(bc.fontSetting(), 0);
bc.setFontSettingValue(-1);
QCOMPARE(bc.fontSetting(), 0);
bc.setFontSettingValue(CMYK_COLOUR);
QCOMPARE(bc.fontSetting(), 0);
bool showText = false;
bc.setShowText(showText);
QCOMPARE(bc.showText(), showText);
bool gsSep = true;
bc.setGSSep(gsSep);
QCOMPARE(bc.gsSep(), gsSep);
bool quietZones = true;
bc.setQuietZones(quietZones);
QCOMPARE(bc.quietZones(), quietZones);
bool noQuietZones = true;
bc.setNoQuietZones(noQuietZones);
QCOMPARE(bc.noQuietZones(), noQuietZones);
bool compliantHeight = true;
bc.setCompliantHeight(compliantHeight);
QCOMPARE(bc.compliantHeight(), compliantHeight);
int rotateAngles[] = { 0, 90, 180, 270 };
for (int i = 0; i < ARRAY_SIZE(rotateAngles); i++) {
bc.setRotateAngle(i);
QCOMPARE(bc.rotateAngle(), rotateAngles[i]);
bc.setRotateAngleValue(rotateAngles[i]);
QCOMPARE(bc.rotateAngle(), rotateAngles[i]);
}
bc.setRotateAngle(ARRAY_SIZE(rotateAngles));
QCOMPARE(bc.rotateAngle(), 0);
bc.setRotateAngle(-1);
QCOMPARE(bc.rotateAngle(), 0);
bc.setRotateAngleValue(-1);
QCOMPARE(bc.rotateAngle(), 0);
bc.setRotateAngleValue(45);
QCOMPARE(bc.rotateAngle(), 0);
int ecis[] = {
0, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 15, 16, 17, 18, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30, 899,
};
for (int i = 0; i < ARRAY_SIZE(ecis); i++) {
bc.setECI(i);
QCOMPARE(bc.eci(), ecis[i]);
bc.setECIValue(ecis[i]);
QCOMPARE(bc.eci(), ecis[i]);
}
bc.setECI(ARRAY_SIZE(ecis));
QCOMPARE(bc.eci(), 0);
bc.setECI(-1);
QCOMPARE(bc.eci(), 0);
// See also setGetECIValueTest()
bool gs1Parens = true;
bc.setGS1Parens(gs1Parens);
QCOMPARE(bc.gs1Parens(), gs1Parens);
bool gs1NoCheck = true;
bc.setGS1NoCheck(gs1NoCheck);
QCOMPARE(bc.gs1NoCheck(), gs1NoCheck);
bool readerInit = true;
bc.setReaderInit(readerInit);
QCOMPARE(bc.readerInit(), readerInit);
bool debug = true;
bc.setDebug(debug);
QCOMPARE(bc.debug(), debug);
}
void setGetECIValueTest_data()
{
QTest::addColumn<int>("value");
QTest::addColumn<int>("eci");
QTest::newRow("-1") << -1 << 0;
QTest::newRow("0") << 0 << 0;
QTest::newRow("1") << 1 << 0;
QTest::newRow("2") << 2 << 0;
QTest::newRow("14") << 14 << 0;
QTest::newRow("19") << 19 << 0;
QTest::newRow("31") << 31 << 0;
QTest::newRow("898") << 898 << 0;
QTest::newRow("900") << 900 << 0;
QTest::newRow("1000") << 1000 << 0;
}
void setGetECIValueTest()
{
Zint::QZint bc;
QFETCH(int, value);
QFETCH(int, eci);
bc.setECIValue(value);
QCOMPARE(bc.eci(), eci);
}
void legacyTest()
{
Zint::QZint bc;
int width = 12;
bc.setWidth(width);
QCOMPARE(bc.width(), width);
QCOMPARE(bc.option1(), width);
int securityLevel = 2;
bc.setSecurityLevel(securityLevel);
QCOMPARE(bc.securityLevel(), securityLevel);
QCOMPARE(bc.option2(), securityLevel);
int pdf417CodeWords = 123;
bc.setPdf417CodeWords(pdf417CodeWords);
QCOMPARE(bc.pdf417CodeWords(), 0); // No-op
bool hideText = true;
bc.setHideText(hideText);
QCOMPARE(bc.showText(), !hideText);
// No get for target size
}
void capTest_data()
{
QTest::addColumn<int>("symbology");
QTest::addColumn<int>("cap_flag");
QTest::newRow("BARCODE_CODE11") << BARCODE_CODE11 << (ZINT_CAP_HRT);
QTest::newRow("BARCODE_CODE128") << BARCODE_CODE128 << (ZINT_CAP_HRT | ZINT_CAP_READER_INIT);
QTest::newRow("BARCODE_EANX") << BARCODE_EANX << (ZINT_CAP_HRT | ZINT_CAP_EXTENDABLE | ZINT_CAP_QUIET_ZONES | ZINT_CAP_COMPLIANT_HEIGHT);
QTest::newRow("BARCODE_QRCODE") << BARCODE_QRCODE << (ZINT_CAP_ECI | ZINT_CAP_GS1 | ZINT_CAP_DOTTY | ZINT_CAP_FIXED_RATIO);
}
void capTest()
{
Zint::QZint bc;
QFETCH(int, symbology);
QFETCH(int, cap_flag);
bc.setSymbol(symbology);
QCOMPARE(bc.hasHRT(), (cap_flag & ZINT_CAP_HRT) != 0);
QCOMPARE(bc.isExtendable(), (cap_flag & ZINT_CAP_EXTENDABLE) != 0);
QCOMPARE(bc.supportsECI(), (cap_flag & ZINT_CAP_ECI) != 0);
QCOMPARE(bc.supportsGS1(), (cap_flag & ZINT_CAP_GS1) != 0);
QCOMPARE(bc.hasDefaultQuietZones(), (cap_flag & ZINT_CAP_QUIET_ZONES) != 0);
QCOMPARE(bc.isFixedRatio(), (cap_flag & ZINT_CAP_FIXED_RATIO) != 0);
QCOMPARE(bc.isDotty(), (cap_flag & ZINT_CAP_DOTTY) != 0);
QCOMPARE(bc.supportsReaderInit(), (cap_flag & ZINT_CAP_READER_INIT) != 0);
QCOMPARE(bc.hasCompliantHeight(), (cap_flag & ZINT_CAP_COMPLIANT_HEIGHT) != 0);
}
void renderTest_data()
{
QTest::addColumn<int>("symbology");
QTest::addColumn<QString>("text");
QTest::addColumn<int>("getError");
QTest::addColumn<QString>("error_message");
QTest::newRow("BARCODE_QRCODE") << BARCODE_QRCODE << "1234" << 0 << "";
if (!m_skipIfFontUsed) {
QTest::newRow("BARCODE_QRCODE no text") << BARCODE_QRCODE << "" << ZINT_ERROR_INVALID_DATA << "Error 205: No input data";
}
}
void renderTest()
{
Zint::QZint bc;
bool bRet;
QPainter painter;
constexpr int width = 100, height = 100;
QPixmap paintDevice(width, height);
QRectF paintRect(0, 0, width, height);
Zint::QZint::AspectRatioMode mode;
QSignalSpy spyEncoded(&bc, SIGNAL(encoded()));
QSignalSpy spyErrored(&bc, SIGNAL(errored()));
mode = Zint::QZint::AspectRatioMode::KeepAspectRatio; // Legacy - ignored
QFETCH(int, symbology);
QFETCH(QString, text);
QFETCH(int, getError);
QFETCH(QString, error_message);
bc.setSymbol(symbology);
bc.setText(text);
bRet = painter.begin(&paintDevice);
QCOMPARE(bRet, true);
bc.render(painter, paintRect, mode);
bRet = painter.end();
QCOMPARE(bRet, true);
QCOMPARE(bc.getError(), getError);
QCOMPARE(bc.error_message(), error_message);
QCOMPARE(bc.lastError(), error_message);
QCOMPARE(bc.hasErrors(), getError != 0);
if (getError) {
QCOMPARE(spyEncoded.count(), 0);
QCOMPARE(spyErrored.count(), 1);
} else {
QCOMPARE(spyEncoded.count(), 1);
QCOMPARE(spyErrored.count(), 0);
}
}
void saveToFileTest_data()
{
QTest::addColumn<int>("symbology");
QTest::addColumn<QString>("text");
QTest::addColumn<QString>("fileName");
QTest::addColumn<bool>("expected_bRet");
QTest::newRow("BARCODE_DATAMATRIX gif") << BARCODE_DATAMATRIX << "1234" << "test_save_to_file.gif" << true;
QTest::newRow("BARCODE_DATAMATRIX unknown format") << BARCODE_DATAMATRIX << "1234" << "test_save_to_file.ext" << false;
}
void saveToFileTest()
{
Zint::QZint bc;
bool bRet;
int ret;
QFETCH(int, symbology);
QFETCH(QString, text);
QFETCH(QString, fileName);
QFETCH(bool, expected_bRet);
bc.setSymbol(symbology);
bc.setText(text);
bRet = bc.save_to_file(fileName);
QCOMPARE(bRet, expected_bRet);
if (bRet) {
ret = remove(fileName.toLatin1());
QCOMPARE(ret, 0);
}
}
};
QTEST_MAIN(TestQZint)
#include "test_qzint.moc"

View File

@ -130,6 +130,8 @@
2021-09-27 GL
- Added -structapp
- Split up -to parsing (could seg fault if given non-int for X0 or Y0)
2021-10-05 GL
- Added -compliantheight option
*/
#if defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
@ -452,6 +454,7 @@ static char help_message[] = "zint tcl(stub,obj) dll\n"
" -box bool: box around bar code, size set be -border\n"
/* cli option --cmyk not supported as no corresponding output */
" -cols integer: PDF417, Codablock F, DotCode: number of columns\n"
" -compliantheight bool: warn if height not compliant, and use standard default\n"
/* cli option --data is standard parameter */
" -dmre bool: Allow Data Matrix Rectangular Extended\n"
" -dotsize number: radius ratio of dots from 0.01 to 1.0\n"
@ -715,8 +718,9 @@ static int Encode(Tcl_Interp *interp, int objc,
/* Option list and indexes */
char *optionList[] = {
"-addongap", "-barcode", "-bg", "-bind", "-bold", "-border", "-box",
"-cols", "-dmre", "-dotsize", "-dotty", "-eci", "-fg", "-format",
"-fullmultibyte", "-gs1nocheck", "-gs1parens", "-gssep", "-guarddescent",
"-cols", "-compliantheight", "-dmre", "-dotsize", "-dotty",
"-eci", "-fg", "-format", "-fullmultibyte",
"-gs1nocheck", "-gs1parens", "-gssep", "-guarddescent",
"-height", "-init", "-mask", "-mode",
"-nobackground", "-noquietzones", "-notext", "-primary", "-quietzones",
"-reverse", "-rotate", "-rows", "-scale", "-scmvv",
@ -725,8 +729,9 @@ static int Encode(Tcl_Interp *interp, int objc,
NULL};
enum iOption {
iAddonGap, iBarcode, iBG, iBind, iBold, iBorder, iBox,
iCols, iDMRE, iDotSize, iDotty, iECI, iFG, iFormat,
iFullMultiByte, iGS1NoCheck, iGS1Parens, iGSSep, iGuardDescent,
iCols, iCompliantHeight, iDMRE, iDotSize, iDotty,
iECI, iFG, iFormat, iFullMultiByte,
iGS1NoCheck, iGS1Parens, iGSSep, iGuardDescent,
iHeight, iInit, iMask, iMode,
iNoBackground, iNoQuietZones, iNoText, iPrimary, iQuietZones,
iReverse, iRotate, iRows, iScale, iSCMvv,
@ -751,6 +756,7 @@ static int Encode(Tcl_Interp *interp, int objc,
case iBind:
case iBold:
case iBox:
case iCompliantHeight:
case iDMRE:
case iDotty:
case iGS1NoCheck:
@ -862,6 +868,13 @@ static int Encode(Tcl_Interp *interp, int objc,
my_symbol->output_options &= ~BARCODE_BOX;
}
break;
case iCompliantHeight:
if (intValue) {
my_symbol->output_options |= COMPLIANT_HEIGHT;
} else {
my_symbol->output_options &= ~COMPLIANT_HEIGHT;
}
break;
case iDotSize:
if (doubleValue < 0.01) {
Tcl_SetObjResult(interp,

View File

@ -1863,8 +1863,9 @@ purposes. The American Blood Commission adopted Codabar in 1977 as the standard
symbology for blood identification. Codabar can encode any length string
starting and ending with the letters A-D and containing between these letters
the numbers 0-9, dash (-), dollar ($), colon (:), slash (/), full stop (.) or
plus (+). No check digit is generated by default, but a modulo-16 one can be
added by setting option_2 = 1 or using --vers=1.
plus (+). No check characater is generated by default, but a modulo-16 one can
be added by setting option_2 = 1 or using --vers=1. To have the check character
appear in the Human Readable Text, set option_2 = 2 or --vers=2.
6.1.10 Pharmacode
-----------------
@ -2054,7 +2055,8 @@ in Codablock-F symbols.
Code 16K uses a Code 128 based system which can stack up to 16 rows in a block.
This gives a maximum data capacity of 77 characters or 154 numerical digits and
includes two modulo-107 check digits. Code 16K also supports extended ASCII
character encoding in the same manner as Code 128.
character encoding in the same manner as Code 128. GS1 data encoding is also
supported.
6.2.4 PDF417 (ISO 15438)
------------------------
@ -3171,7 +3173,7 @@ international standards:
> BS EN 797:1996 Bar coding - Symbology specifications - 'EAN/UPC'
> BS EN 798:1996 Bar coding - Symbology specifications - 'Codabar'
> ISO/IEC 12323:2005 AIDC technologies - Symbology specifications - Code 16K
> BS EN 12323:2005 AIDC technologies - Symbology specifications - Code 16K
> ISO/IEC 15417:2007 Information technology - Automatic identification and data
capture techniques - Code 128 bar code symbology specification
> ISO/IEC 15438:2015 Information technology - Automatic identification and data

View File

@ -127,6 +127,7 @@ static void usage(void) {
" --box Add a box around the symbol\n"
" --cmyk Use CMYK colour space in EPS/TIF symbols\n"
" --cols=NUMBER Set the number of data columns in symbol\n"
" --compliantheight Warn if height not compliant, and use standard default\n"
" -d, --data=DATA Set the symbol content\n"
" --direct Send output to stdout\n"
" --dmre Allow Data Matrix Rectangular Extended\n"
@ -856,8 +857,8 @@ int main(int argc, char **argv) {
while (no_getopt_error) {
enum options {
OPT_ADDONGAP = 128, OPT_BATCH, OPT_BINARY, OPT_BG, OPT_BIND, OPT_BOLD, OPT_BORDER,
OPT_BOX, OPT_CMYK, OPT_COLS, OPT_DIRECT, OPT_DMRE, OPT_DOTSIZE, OPT_DOTTY, OPT_DUMP,
OPT_ADDONGAP = 128, OPT_BATCH, OPT_BINARY, OPT_BG, OPT_BIND, OPT_BOLD, OPT_BORDER, OPT_BOX,
OPT_CMYK, OPT_COLS, OPT_COMPLIANTHEIGHT, OPT_DIRECT, OPT_DMRE, OPT_DOTSIZE, OPT_DOTTY, OPT_DUMP,
OPT_ECI, OPT_ESC, OPT_FG, OPT_FILETYPE, OPT_FONTSIZE, OPT_FULLMULTIBYTE,
OPT_GS1, OPT_GS1NOCHECK, OPT_GS1PARENS, OPT_GSSEP, OPT_GUARDDESCENT,
OPT_HEIGHT, OPT_INIT, OPT_MIRROR, OPT_MASK, OPT_MODE,
@ -879,6 +880,7 @@ int main(int argc, char **argv) {
{"box", 0, NULL, OPT_BOX},
{"cmyk", 0, NULL, OPT_CMYK},
{"cols", 1, NULL, OPT_COLS},
{"compliantheight", 0, NULL, OPT_COMPLIANTHEIGHT},
{"data", 1, NULL, 'd'},
{"direct", 0, NULL, OPT_DIRECT},
{"dmre", 0, NULL, OPT_DMRE},
@ -995,6 +997,9 @@ int main(int argc, char **argv) {
fflush(stderr);
}
break;
case OPT_COMPLIANTHEIGHT:
my_symbol->output_options |= COMPLIANT_HEIGHT;
break;
case OPT_DIRECT:
my_symbol->output_options |= BARCODE_STDOUT;
break;

View File

@ -220,6 +220,15 @@ static void arg_output_options(char *cmd, int output_options) {
if (output_options & GS1_GS_SEPARATOR) {
sprintf(cmd + (int) strlen(cmd), "%s--gssep", strlen(cmd) ? " " : "");
}
if (output_options & BARCODE_QUIET_ZONES) {
sprintf(cmd + (int) strlen(cmd), "%s--quietzones", strlen(cmd) ? " " : "");
}
if (output_options & BARCODE_NO_QUIET_ZONES) {
sprintf(cmd + (int) strlen(cmd), "%s--noquietzones", strlen(cmd) ? " " : "");
}
if (output_options & COMPLIANT_HEIGHT) {
sprintf(cmd + (int) strlen(cmd), "%s--compliantheight", strlen(cmd) ? " " : "");
}
}
}
@ -906,38 +915,39 @@ static void test_other_opts(int index, int debug) {
/* 5*/ { BARCODE_CODE128, "1", -1, " --fg=", "00000000", "" },
/* 6*/ { BARCODE_CODE128, "1", -1, " --fg=", "000000F", "Error 651: Malformed foreground colour target" },
/* 7*/ { BARCODE_CODE128, "1", -1, " --fg=", "000000FG", "Error 653: Malformed foreground colour target" },
/* 8*/ { BARCODE_CODE128, "1", -1, " --fontsize=", "10", "" },
/* 9*/ { BARCODE_CODE128, "1", -1, " --fontsize=", "101", "Warning 126: Font size out of range (0 to 100), ignoring" },
/* 10*/ { BARCODE_CODE128, "1", -1, " --nobackground", "", "" },
/* 11*/ { BARCODE_CODE128, "1", -1, " --noquietzones", "", "" },
/* 12*/ { BARCODE_CODE128, "1", -1, " --notext", "", "" },
/* 13*/ { BARCODE_CODE128, "1", -1, " --quietzones", "", "" },
/* 14*/ { BARCODE_CODE128, "1", -1, " --reverse", "", "" },
/* 15*/ { BARCODE_CODE128, "1", -1, " --werror", NULL, "" },
/* 16*/ { 19, "1", -1, " --werror", NULL, "Error 207: Codabar 18 not supported" },
/* 17*/ { BARCODE_GS1_128, "[01]12345678901231", -1, "", NULL, "" },
/* 18*/ { BARCODE_GS1_128, "0112345678901231", -1, "", NULL, "Error 252: Data does not start with an AI" },
/* 19*/ { BARCODE_GS1_128, "0112345678901231", -1, " --gs1nocheck", NULL, "Error 252: Data does not start with an AI" },
/* 20*/ { BARCODE_GS1_128, "[00]376104250021234569", -1, "", NULL, "" },
/* 21*/ { BARCODE_GS1_128, "[00]376104250021234568", -1, "", NULL, "Warning 261: AI (00) position 18: Bad checksum '8', expected '9'" },
/* 22*/ { BARCODE_GS1_128, "[00]376104250021234568", -1, " --gs1nocheck", NULL, "" },
/* 23*/ { BARCODE_GS1_128, "[00]376104250021234568", -1, " --werror", NULL, "Error 261: AI (00) position 18: Bad checksum '8', expected '9'" },
/* 24*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "1", "Error 155: Invalid Structured Append argument, expect \"index,count[,ID]\"" },
/* 25*/ { BARCODE_AZTEC, "1", -1, " --structapp=", ",", "Error 156: Structured Append index too short" },
/* 26*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "1234567890,", "Error 156: Structured Append index too long" },
/* 27*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "123456789,", "Error 159: Structured Append count too short" },
/* 28*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "123456789,1234567890", "Error 159: Structured Append count too long" },
/* 29*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "123456789,123456789,", "Error 158: Structured Append ID too short" },
/* 30*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "123456789,1234567890,", "Error 157: Structured Append count too long" },
/* 31*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "123456789,123456789,123456789012345678901234567890123", "Error 158: Structured Append ID too long" },
/* 32*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "123456789,123456789,12345678901234567890123456789012", "Error 701: Structured Append count out of range (2-26)" },
/* 33*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "26,26,12345678901234567890123456789012", "" },
/* 34*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "A,26,12345678901234567890123456789012", "Error 160: Invalid Structured Append index (digits only)" },
/* 35*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "26,A,12345678901234567890123456789012", "Error 161: Invalid Structured Append count (digits only)" },
/* 36*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "26,1,12345678901234567890123456789012", "Error 162: Invalid Structured Append count, must be >= 2" },
/* 37*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "0,2,12345678901234567890123456789012", "Error 163: Structured Append index out of range (1-2)" },
/* 38*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "3,2,12345678901234567890123456789012", "Error 163: Structured Append index out of range (1-2)" },
/* 39*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "2,3,12345678901234567890123456789012", "" },
/* 8*/ { BARCODE_CODE128, "1", -1, " --compliantheight", "", "" },
/* 9*/ { BARCODE_CODE128, "1", -1, " --fontsize=", "10", "" },
/* 10*/ { BARCODE_CODE128, "1", -1, " --fontsize=", "101", "Warning 126: Font size out of range (0 to 100), ignoring" },
/* 11*/ { BARCODE_CODE128, "1", -1, " --nobackground", "", "" },
/* 12*/ { BARCODE_CODE128, "1", -1, " --noquietzones", "", "" },
/* 13*/ { BARCODE_CODE128, "1", -1, " --notext", "", "" },
/* 14*/ { BARCODE_CODE128, "1", -1, " --quietzones", "", "" },
/* 15*/ { BARCODE_CODE128, "1", -1, " --reverse", "", "" },
/* 16*/ { BARCODE_CODE128, "1", -1, " --werror", NULL, "" },
/* 17*/ { 19, "1", -1, " --werror", NULL, "Error 207: Codabar 18 not supported" },
/* 18*/ { BARCODE_GS1_128, "[01]12345678901231", -1, "", NULL, "" },
/* 19*/ { BARCODE_GS1_128, "0112345678901231", -1, "", NULL, "Error 252: Data does not start with an AI" },
/* 20*/ { BARCODE_GS1_128, "0112345678901231", -1, " --gs1nocheck", NULL, "Error 252: Data does not start with an AI" },
/* 21*/ { BARCODE_GS1_128, "[00]376104250021234569", -1, "", NULL, "" },
/* 22*/ { BARCODE_GS1_128, "[00]376104250021234568", -1, "", NULL, "Warning 261: AI (00) position 18: Bad checksum '8', expected '9'" },
/* 23*/ { BARCODE_GS1_128, "[00]376104250021234568", -1, " --gs1nocheck", NULL, "" },
/* 24*/ { BARCODE_GS1_128, "[00]376104250021234568", -1, " --werror", NULL, "Error 261: AI (00) position 18: Bad checksum '8', expected '9'" },
/* 25*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "1", "Error 155: Invalid Structured Append argument, expect \"index,count[,ID]\"" },
/* 26*/ { BARCODE_AZTEC, "1", -1, " --structapp=", ",", "Error 156: Structured Append index too short" },
/* 27*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "1234567890,", "Error 156: Structured Append index too long" },
/* 28*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "123456789,", "Error 159: Structured Append count too short" },
/* 29*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "123456789,1234567890", "Error 159: Structured Append count too long" },
/* 30*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "123456789,123456789,", "Error 158: Structured Append ID too short" },
/* 31*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "123456789,1234567890,", "Error 157: Structured Append count too long" },
/* 32*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "123456789,123456789,123456789012345678901234567890123", "Error 158: Structured Append ID too long" },
/* 33*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "123456789,123456789,12345678901234567890123456789012", "Error 701: Structured Append count out of range (2-26)" },
/* 34*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "26,26,12345678901234567890123456789012", "" },
/* 35*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "A,26,12345678901234567890123456789012", "Error 160: Invalid Structured Append index (digits only)" },
/* 36*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "26,A,12345678901234567890123456789012", "Error 161: Invalid Structured Append count (digits only)" },
/* 37*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "26,1,12345678901234567890123456789012", "Error 162: Invalid Structured Append count, must be >= 2" },
/* 38*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "0,2,12345678901234567890123456789012", "Error 163: Structured Append index out of range (1-2)" },
/* 39*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "3,2,12345678901234567890123456789012", "Error 163: Structured Append index out of range (1-2)" },
/* 40*/ { BARCODE_AZTEC, "1", -1, " --structapp=", "2,3,12345678901234567890123456789012", "" },
};
int data_size = ARRAY_SIZE(data);
int i;

View File

@ -16,7 +16,7 @@
***************************************************************************/
/* vim: set ts=4 sw=4 et : */
#include <QDebug>
//#include <QDebug>
#include "barcodeitem.h"
BarcodeItem::BarcodeItem()

View File

@ -54,6 +54,9 @@ be set based on data</string>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="cmbAztecSize">
<property name="maxVisibleItems">
<number>21</number>
</property>
<property name="enabled">
<bool>false</bool>
</property>

View File

@ -25,12 +25,18 @@
<property name="title">
<string>Check Digits</string>
</property>
<property name="toolTip">
<string>Check digits options</string>
</property>
<layout class="QGridLayout" name="gridLayoutC11CheckDigits">
<item row="0" column="0">
<widget class="QRadioButton" name="radC11TwoCheckDigits">
<property name="text">
<string>&amp;Two (Mod-11)</string>
</property>
<property name="toolTip">
<string>Add 2 mod-11 check digits</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
@ -41,6 +47,9 @@
<property name="text">
<string>&amp;One (Mod-11)</string>
</property>
<property name="toolTip">
<string>Add 1 mod-11 check digit</string>
</property>
</widget>
</item>
<item row="1" column="0">
@ -48,6 +57,9 @@
<property name="text">
<string>&amp;No Check Digit</string>
</property>
<property name="toolTip">
<string>Do not add any check digits</string>
</property>
</widget>
</item>
</layout>

View File

@ -28,7 +28,8 @@
<string>&amp;Row Separator Height:</string>
</property>
<property name="toolTip">
<string>Height in X-dimensions of horizontal lines separating rows</string>
<string>Height in X-dimensions of horizontal lines
separating rows</string>
</property>
<property name="buddy">
<cstring>cmbC16kRowSepHeight</cstring>
@ -38,7 +39,8 @@
<item row="0" column="1">
<widget class="QComboBox" name="cmbC16kRowSepHeight">
<property name="toolTip">
<string>Height in X-dimensions of horizontal lines separating rows</string>
<string>Height in X-dimensions of horizontal lines
separating rows</string>
</property>
<item>
<property name="text">

View File

@ -21,7 +21,14 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<widget class="QGroupBox" name="grpC25Check">
<property name="title">
<string>Check Digit</string>
</property>
<property name="toolTip">
<string>Check digit options</string>
</property>
<layout class="QGridLayout" name="gridLayoutC25Check">
<item row="0" column="0">
<widget class="QRadioButton" name="radC25Stand">
<property name="text">
@ -31,7 +38,7 @@
<bool>true</bool>
</property>
<property name="toolTip">
<string>No check digit added</string>
<string>Do not add check digit</string>
</property>
</widget>
</item>
@ -41,21 +48,23 @@
<string>&amp;Check Digit</string>
</property>
<property name="toolTip">
<string>Add standard GS1 mod-10 weighted check digit</string>
<string>Add standard GS1 mod-10 check digit</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="radC25CheckHide">
<property name="text">
<string>Check Digit, Not Shown in &amp;Text</string>
<string>&amp;Hidden Check Digit</string>
</property>
<property name="toolTip">
<string>Add standard GS1 check digit but do not display in Human Readable Text</string>
<string>Add standard GS1 mod-10 check digit but
do not display in Human Readable Text</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">

View File

@ -21,21 +21,37 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<widget class="QGroupBox" name="grpC39Check">
<property name="title">
<string>Check Digit</string>
</property>
<property name="toolTip">
<string>Check character options</string>
</property>
<layout class="QGridLayout" name="gridLayoutCheck">
<item row="0" column="0">
<widget class="QRadioButton" name="radC39Stand">
<property name="text">
<string>&amp;No Check Digit</string>
</property>
<property name="toolTip">
<string>Do not add check character</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<item row="1" column="0" colspan="2">
<widget class="QRadioButton" name="radC39HIBC">
<property name="text">
<string>H&amp;IBC 39</string>
<string>H&amp;IBC 39 (Mod-43 Check Digit added)</string>
</property>
<property name="toolTip">
<string>Process data as a Health Industry Barcode (HIBC)
Labeler Identification Code (LIC)
For Provider Applications Standard (PAS), preface
the data with a slash &quot;/&quot;</string>
</property>
</widget>
</item>
@ -44,9 +60,13 @@
<property name="text">
<string>&amp;Mod-43 Check Digit</string>
</property>
<property name="toolTip">
<string>Add mod-43 check character</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">

View File

@ -28,7 +28,8 @@
<string>&amp;Row Separator Height:</string>
</property>
<property name="toolTip">
<string>Height in X-dimensions of horizontal lines separating rows</string>
<string>Height in X-dimensions of horizontal lines
separating rows</string>
</property>
<property name="buddy">
<cstring>cmbC49RowSepHeight</cstring>
@ -38,7 +39,8 @@
<item row="0" column="1">
<widget class="QComboBox" name="cmbC49RowSepHeight">
<property name="toolTip">
<string>Height in X-dimensions of horizontal lines separating rows</string>
<string>Height in X-dimensions of horizontal lines
separating rows</string>
</property>
<item>
<property name="text">

View File

@ -20,7 +20,8 @@
<string>Show &amp;Check Characters in Text</string>
</property>
<property name="toolTip">
<string>Display the 2 check characters in the Human Readable Text</string>
<string>Display the 2 check characters in
the Human Readable Text</string>
</property>
<property name="checked">
<bool>false</bool>

View File

@ -26,6 +26,17 @@
<property name="text" >
<string>&amp;Number of Channels:</string>
</property>
<property name="toolTip" >
<string>The number of channels determines the&lt;br /&gt;range of numbers that can be encoded&lt;table cellspacing=&quot;3&quot;&gt;
&gt;&lt;tr&gt;&lt;th align=left&gt;Channels&amp;nbsp;&lt;/th&gt;&lt;th align=left&gt;Range&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;3&amp;nbsp;&lt;/td&gt;&lt;td&gt;0 to 26&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;4&amp;nbsp;&lt;/td&gt;&lt;td&gt;0 to 292&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;5&amp;nbsp;&lt;/td&gt;&lt;td&gt;0 to 3493&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;6&amp;nbsp;&lt;/td&gt;&lt;td&gt;0 to 44072&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;7&amp;nbsp;&lt;/td&gt;&lt;td&gt;0 to 576688&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;8&amp;nbsp;&lt;/td&gt;&lt;td&gt;0 to 7742862&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</string>
</property>
<property name="alignment" >
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
@ -36,6 +47,17 @@
</item>
<item>
<widget class="QComboBox" name="cmbChannel" >
<property name="toolTip" >
<string>The number of channels determines the&lt;br /&gt;range of numbers that can be encoded&lt;table cellspacing=&quot;3&quot;&gt;
&gt;&lt;tr&gt;&lt;th align=left&gt;Channels&amp;nbsp;&lt;/th&gt;&lt;th align=left&gt;Range&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;3&amp;nbsp;&lt;/td&gt;&lt;td&gt;0 to 26&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;4&amp;nbsp;&lt;/td&gt;&lt;td&gt;0 to 292&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;5&amp;nbsp;&lt;/td&gt;&lt;td&gt;0 to 3493&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;6&amp;nbsp;&lt;/td&gt;&lt;td&gt;0 to 44072&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;7&amp;nbsp;&lt;/td&gt;&lt;td&gt;0 to 576688&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;8&amp;nbsp;&lt;/td&gt;&lt;td&gt;0 to 7742862&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</string>
</property>
<item>
<property name="text" >
<string>Automatic</string>

View File

@ -15,13 +15,49 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="chkCodabarCheck">
<widget class="QGroupBox" name="grpCodabarCheck">
<property name="title">
<string>Check Digit</string>
</property>
<property name="toolTip">
<string>Check character options</string>
</property>
<layout class="QGridLayout" name="gridLayoutCodabarCheck">
<item row="0" column="0">
<widget class="QRadioButton" name="radCodabarStand">
<property name="text">
<string>Add &amp;Check Character (Mod-16)</string>
<string>&amp;No Check Digit</string>
</property>
<property name="checked">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="toolTip">
<string>Do not add check character</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="radCodabarCheck">
<property name="text">
<string>&amp;Check Digit</string>
</property>
<property name="toolTip">
<string>Add mod-16 check character</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="radCodabarCheckHide">
<property name="text">
<string>&amp;Hidden Check Digit</string>
</property>
<property name="toolTip">
<string>Add mod-16 check character but do
not display in Human Readable Text</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>

View File

@ -599,7 +599,8 @@
<string>&amp;Row Separator Height:</string>
</property>
<property name="toolTip">
<string>Height in X-dimensions of horizontal lines separating rows</string>
<string>Height in X-dimensions of horizontal lines
separating rows</string>
</property>
<property name="buddy">
<cstring>cmbCbfRowSepHeight</cstring>
@ -609,7 +610,8 @@
<item row="2" column="1">
<widget class="QComboBox" name="cmbCbfRowSepHeight">
<property name="toolTip">
<string>Height in X-dimensions of horizontal lines separating rows</string>
<string>Height in X-dimensions of horizontal lines
separating rows</string>
</property>
<item>
<property name="text">

View File

@ -28,7 +28,11 @@
<string>Symbol Si&amp;ze:</string>
</property>
<property name="toolTip">
<string>Set size (version) of symbol</string>
<string>Set size (H x W) of symbol
Versions A to H have fixed heights and
fixed widths
Versions S and T have fixed heights but
variable widths</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
@ -40,8 +44,15 @@
</item>
<item row="0" column="1">
<widget class="QComboBox" name="cmbC1Size">
<property name="maxVisibleItems">
<number>11</number>
</property>
<property name="toolTip">
<string>Set size (version) of symbol</string>
<string>Set size (H x W) of symbol
Versions A to H have fixed heights and
fixed widths
Versions S and T have fixed heights but
variable widths</string>
</property>
<item>
<property name="text">
@ -149,7 +160,8 @@ formatted with Application Identifiers (AIs)
</property>
<property name="toolTip">
<string>Code One supports Structured Append of up to
128 symbols</string>
128 symbols (not available for Version S)
(ignored if disabled)</string>
</property>
<layout class="QGridLayout" name="gridLayoutC1StructApp">
<item row="0" column="0">

View File

@ -80,7 +80,7 @@
<string>Examples of tracker ratios:&lt;table cellspacing=&quot;3&quot;&gt;
&lt;tr&gt;&lt;td&gt;Australia Post&amp;nbsp;&lt;/td&gt;&lt;td&gt;26%&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Japan Post&amp;nbsp;&lt;/td&gt;&lt;td&gt;33%&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;PLANET, POSTNET&amp;nbsp;&lt;/td&gt;&lt;td&gt;40%&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;PLANET, POSTNET&amp;nbsp;&lt;/td&gt;&lt;td&gt;&lt;i&gt;25% (Tracker and Ascender only)&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Royal Mail, Dutch Post&amp;nbsp;&lt;/td&gt;&lt;td&gt;25.6%&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;USPS Intelligent Mail&amp;nbsp;&lt;/td&gt;&lt;td&gt;33.1%&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Default&amp;nbsp;&lt;/td&gt;&lt;td&gt;25%&lt;/td&gt;&lt;/tr&gt;

View File

@ -1050,9 +1050,6 @@ as 0 to 3 with the corners lit</string>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="cmbDotMask">
<property name="maxVisibleItems">
<number>8</number>
</property>
<property name="toolTip">
<string>Manually specify which mask to use
The prime masks 0&apos; to 3&apos; are the same

View File

@ -37,6 +37,9 @@
</item>
<item row="0" column="1">
<widget class="QComboBox" name="cmbGridSize">
<property name="maxVisibleItems">
<number>14</number>
</property>
<property name="toolTip">
<string>Set size (version) of symbol</string>
</property>
@ -197,7 +200,8 @@ error correction codewords</string>
<bool>false</bool>
</property>
<property name="toolTip">
<string>Use Hanzi multibyte encoding for binary and Latin data</string>
<string>Use Hanzi multibyte encoding for binary
and Latin data</string>
</property>
</widget>
</item>

View File

@ -27,6 +27,9 @@
<property name="text">
<string>Si&amp;ze:</string>
</property>
<property name="toolTip">
<string>Set size (version) of symbol</string>
</property>
<property name="buddy">
<cstring>cmbHXSize</cstring>
</property>
@ -37,6 +40,9 @@
<property name="maxVisibleItems">
<number>21</number>
</property>
<property name="toolTip">
<string>Set size (version) of symbol</string>
</property>
<item>
<property name="text">
<string>Automatic</string>
@ -469,6 +475,10 @@
<property name="text">
<string>E&amp;rror Correction:</string>
</property>
<property name="toolTip">
<string>Set percentage of capacity to use for
error correction codewords</string>
</property>
<property name="buddy">
<cstring>cmbHXECC</cstring>
</property>
@ -476,6 +486,10 @@
</item>
<item row="1" column="1">
<widget class="QComboBox" name="cmbHXECC">
<property name="toolTip">
<string>Set percentage of capacity to use for
error correction codewords</string>
</property>
<item>
<property name="text">
<string>Automatic</string>
@ -508,6 +522,9 @@
<property name="text">
<string>&amp;Mask:</string>
</property>
<property name="toolTip">
<string>Manually specify which mask to use</string>
</property>
<property name="buddy">
<cstring>cmbHXMask</cstring>
</property>
@ -515,8 +532,8 @@
</item>
<item row="2" column="1">
<widget class="QComboBox" name="cmbHXMask">
<property name="maxVisibleItems">
<number>4</number>
<property name="toolTip">
<string>Manually specify which mask to use</string>
</property>
<item>
<property name="text">
@ -556,7 +573,8 @@
<bool>false</bool>
</property>
<property name="toolTip">
<string>Use Hanzi multibyte encoding for binary and Latin data</string>
<string>Use Hanzi multibyte encoding for binary
and Latin data</string>
</property>
</widget>
</item>

View File

@ -26,6 +26,9 @@
<property name="text" >
<string>Si&amp;ze:</string>
</property>
<property name="toolTip">
<string>Set size (version) of symbol</string>
</property>
<property name="buddy">
<cstring>cmbMQRSize</cstring>
</property>
@ -33,6 +36,9 @@
</item>
<item row="0" column="1" >
<widget class="QComboBox" name="cmbMQRSize" >
<property name="toolTip">
<string>Set size (version) of symbol</string>
</property>
<item>
<property name="text">
<string>Automatic</string>
@ -65,6 +71,10 @@
<property name="text" >
<string>E&amp;rror Correction:</string>
</property>
<property name="toolTip">
<string>Set percentage of capacity to use for
error correction codewords</string>
</property>
<property name="buddy">
<cstring>cmbMQRECC</cstring>
</property>
@ -72,6 +82,10 @@
</item>
<item row="1" column="1" >
<widget class="QComboBox" name="cmbMQRECC" >
<property name="toolTip">
<string>Set percentage of capacity to use for
error correction codewords</string>
</property>
<item>
<property name="text">
<string>Automatic</string>
@ -99,6 +113,9 @@
<property name="text">
<string>&amp;Mask:</string>
</property>
<property name="toolTip">
<string>Manually specify which mask to use</string>
</property>
<property name="buddy">
<cstring>cmbMQRMask</cstring>
</property>
@ -106,8 +123,8 @@
</item>
<item row="2" column="1">
<widget class="QComboBox" name="cmbMQRMask">
<property name="maxVisibleItems">
<number>4</number>
<property name="toolTip">
<string>Manually specify which mask to use</string>
</property>
<item>
<property name="text">
@ -147,7 +164,8 @@
<bool>false</bool>
</property>
<property name="toolTip">
<string>Use Kanji multibyte encoding for binary and Latin data</string>
<string>Use Kanji multibyte encoding for binary
and Latin data</string>
</property>
</widget>
</item>

View File

@ -91,7 +91,8 @@ Mod-11 (NCR) uses NCR weightings</string>
<string>Do not show check digit(s) in &amp;Text</string>
</property>
<property name="toolTip">
<string>Add check digit(s) but do not display in Human Readable Text</string>
<string>Add check digit(s) but do not display
in Human Readable Text</string>
</property>
<property name="checked">
<bool>false</bool>

View File

@ -39,6 +39,9 @@
</item>
<item row="0" column="1" >
<widget class="QComboBox" name="cmbPDFCols" >
<property name="maxVisibleItems">
<number>21</number>
</property>
<property name="toolTip">
<string>Set number of data characters in a row</string>
</property>

View File

@ -312,9 +312,6 @@ error correction codewords</string>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="cmbQRMask">
<property name="maxVisibleItems">
<number>8</number>
</property>
<property name="toolTip">
<string>Manually specify which mask to use</string>
</property>
@ -428,7 +425,8 @@ the data with a slash &quot;/&quot;</string>
<bool>false</bool>
</property>
<property name="toolTip">
<string>Use Kanji multibyte encoding for binary and Latin data</string>
<string>Use Kanji multibyte encoding for binary
and Latin data</string>
</property>
</widget>
</item>

View File

@ -327,7 +327,8 @@ formatted with Application Identifiers (AIs)</string>
<bool>false</bool>
</property>
<property name="toolTip">
<string>Use Kanji multibyte encoding for binary and Latin data</string>
<string>Use Kanji multibyte encoding for binary
and Latin data</string>
</property>
</widget>
</item>

View File

@ -73,8 +73,7 @@ main symbol and add-on (if any)
<widget class="QLabel" name="lblUPCAGuardDescent">
<property name="toolTip">
<string>Height in X-dimensions that the guard bars
descend below the main bars
Default 5
descend below the main bars (default 5X)
(ignored if disabled)</string>
</property>
<property name="text">
@ -89,11 +88,12 @@ Default 5
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horzLayoutUPCAGuardDescent">
<item>
<widget class="QDoubleSpinBox" name="spnUPCAGuardDescent">
<property name="toolTip">
<string>Height in X-dimensions that the guard bars
descend below the main bars
Default 5
descend below the main bars (default 5X)
(ignored if disabled)</string>
</property>
<property name="prefix">
@ -120,8 +120,39 @@ Default 5
<property name="accelerated">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnUPCAGuardReset">
<property name="toolTip">
<string>Reset guard bars descent height
to default 5X</string>
</property>
<property name="text">
<string>&amp;Reset</string>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>

View File

@ -83,8 +83,7 @@ main symbol and add-on (if any)
<widget class="QLabel" name="lblUPCEANGuardDescent">
<property name="toolTip">
<string>Height in X-dimensions that the guard bars
descend below the main bars
Default 5
descend below the main bars (default 5X)
(ignored if disabled)</string>
</property>
<property name="text">
@ -99,11 +98,12 @@ Default 5
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horzLayoutUPCEANGuardDescent">
<item>
<widget class="QDoubleSpinBox" name="spnUPCEANGuardDescent">
<property name="toolTip">
<string>Height in X-dimensions that the guard bars
descend below the main bars
Default 5
descend below the main bars (default 5X)
(ignored if disabled)</string>
</property>
<property name="prefix">
@ -130,8 +130,39 @@ Default 5
<property name="accelerated">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnUPCEANGuardReset">
<property name="toolTip">
<string>Reset guard bars descent height
to default 5X</string>
</property>
<property name="text">
<string>&amp;Reset</string>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>

View File

@ -27,6 +27,10 @@
<property name="text">
<string>&amp;Import Character Prefix</string>
</property>
<property name="toolTip">
<string>Preface data with import character &apos;I&apos;
(not shown in Human Readable Text)</string>
</property>
<property name="checked">
<bool>false</bool>
</property>

View File

@ -30,6 +30,8 @@ int main(int argc, char *argv[])
QApplication app(argc, argv);
MainWindow w;
// Seem to need to do this before showing the window
w.setWindowTitle(w.windowTitle() + ' ' + MainWindow::get_zint_version());
w.show();
return app.exec();
}

View File

@ -41,9 +41,49 @@
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<layout class="QVBoxLayout" name="verticalLayoutMain">
<item>
<widget class="QGraphicsView" name="view"/>
<widget class="QGraphicsView" name="view">
<property name="minimumSize">
<size>
<width>0</width>
<height>10</height>
</size>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
</widget>
</item>
<item>
<widget class="QSplitter" name="errtxtBarContainer">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="visible">
<bool>false</bool>
</property>
<widget class="QStatusBar" name="errtxtBar">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="sizeGripEnabled">
<bool>false</bool>
</property>
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
@ -659,6 +699,8 @@ as delimiters for GS1 Application Identifiers
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayoutAutoHeight">
<item>
<widget class="QCheckBox" name="chkAutoHeight">
<property name="toolTip">
<string>Use default height
@ -672,6 +714,23 @@ as delimiters for GS1 Application Identifiers
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkCompliantHeight">
<property name="toolTip">
<string>Warn if height not compliant with specification
and use standard height (if any) for default
(ignored if disabled)</string>
</property>
<property name="text">
<string>Com&amp;pliant Height</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lblHeight">
<property name="enabled">
@ -701,6 +760,9 @@ as delimiters for GS1 Application Identifiers
<string>Overall symbol height in X-dimensions
(ignored if disabled)</string>
</property>
<property name="accelerated">
<bool>true</bool>
</property>
<property name="prefix">
<string/>
</property>
@ -722,9 +784,6 @@ as delimiters for GS1 Application Identifiers
<property name="value">
<double>50.000000000000000</double>
</property>
<property name="accelerated">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
@ -1156,19 +1215,19 @@ in X-dimensions</string>
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QPushButton" name="btnAbout">
<widget class="QPushButton" name="btnMenu">
<property name="toolTip">
<string>About Zint</string>
<string>Show menu</string>
</property>
<property name="text">
<string>Abo&amp;ut</string>
<string>Men&amp;u</string>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<widget class="QStatusBar" name="statusBar">
<property name="sizeGripEnabled">
<bool>false</bool>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -1176,7 +1235,7 @@ in X-dimensions</string>
<height>20</height>
</size>
</property>
</spacer>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="btnCopyBMP">
@ -1184,7 +1243,7 @@ in X-dimensions</string>
<string>Copy to clipboard as BMP</string>
</property>
<property name="text">
<string>Copy &amp;BMP</string>
<string> &amp;BMP</string>
</property>
</widget>
</item>
@ -1194,7 +1253,7 @@ in X-dimensions</string>
<string>Copy to clipboard as SVG</string>
</property>
<property name="text">
<string>Copy S&amp;VG</string>
<string> S&amp;VG</string>
</property>
</widget>
</item>

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2008 by BogDan Vatra <bogdan@licentia.eu> *
* Copyright (C) 2009-2020 by Robin Stuart <rstuart114@gmail.com> *
* Copyright (C) 2009-2021 by Robin Stuart <rstuart114@gmail.com> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@ -13,6 +13,7 @@
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
/* vim: set ts=4 sw=4 et : */
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
@ -26,6 +27,7 @@
#include "barcodeitem.h"
class QLabel;
class QShortcut;
class MainWindow : public QWidget, private Ui::mainWindow
{
@ -35,6 +37,8 @@ public:
MainWindow(QWidget *parent = 0, Qt::WindowFlags fl = Qt::WindowFlags());
~MainWindow();
static QString get_zint_version();
public slots:
void update_preview();
void change_options();
@ -42,72 +46,120 @@ public slots:
void on_bgcolor_clicked();
void composite_ui_set();
void composite_ean_check();
void maxi_scm();
void maxi_scm_ui_set();
void msi_plessey_ui_set();
void change_print_scale();
void change_cmyk();
void autoheight_ui_set();
void HRTShow_ui_set();
void dotty_ui_set();
void codeone_ui_set();
void structapp_ui_set();
void on_encoded();
void on_errored();
void filter_symbologies();
bool save();
void about();
void help();
void quit_now();
void menu();
void reset_colours();
int open_data_dialog();
int open_sequence_dialog();
void copy_to_clipboard_bmp();
void copy_to_clipboard_emf();
void copy_to_clipboard_eps();
void copy_to_clipboard_gif();
#ifndef NO_PNG
void copy_to_clipboard_png();
#endif
void copy_to_clipboard_pcx();
void copy_to_clipboard_svg();
void copy_to_clipboard_tif();
void copy_to_clipboard_errtxt();
void guard_reset_upcean();
void guard_reset_upca();
void view_context_menu(const QPoint &pos);
void errtxtBar_context_menu(const QPoint &pos);
protected:
void resizeEvent(QResizeEvent *event);
bool event(QEvent *event) override;
void combobox_item_enabled(QComboBox *comboBox, int index, bool enabled);
void upcean_addon_gap(const char *comboBoxName, const char *labelName, int base);
void upcean_guard_descent(const char *spnBoxName, const char *labelName);
void upcean_addon_gap(const QString &comboBoxName, const QString &labelName, int base);
void upcean_guard_descent(const QString &spnBoxName, const QString &labelName);
void guard_reset(const QString &spnBoxName);
void set_gs1_mode(bool gs1_mode);
void set_smaller_font(QLabel *note);
void set_smaller_font(const QString &labelName);
QObject *widget_obj(const char *name);
void createActions();
void createMenu();
void enableActions(bool enabled);
const char *get_setting_name(int symbology);
void copy_to_clipboard(const QString &filename, const QString &name, const char *mimeType = nullptr);
int get_button_group_index(const QStringList &children);
void set_radiobutton_from_setting(QSettings &settings, const QString &setting, const QStringList &children,
void errtxtBar_clear();
void errtxtBar_set(bool isError);
QPoint get_context_menu_pos(const QPoint &pos, QWidget *widget);
QWidget *get_widget(const QString &name);
const QString &get_setting_name(int symbology);
int get_rad_grp_index(const QStringList &names);
void set_rad_from_setting(QSettings &settings, const QString &setting, const QStringList &names,
int default_val = 0);
bool get_rad_val(const QString &name);
int get_combobox_index(const QString &child);
void set_combobox_from_setting(QSettings &settings, const QString &setting, const QString &child,
int default_val = 0);
int get_cmb_index(const QString &name);
void set_cmb_from_setting(QSettings &settings, const QString &setting, const QString &name, int default_val = 0);
int get_checkbox_val(const QString &child);
void set_checkbox_from_setting(QSettings &settings, const QString &setting, const QString &child,
int default_val = 0);
int get_chk_val(const QString &name);
void set_chk_from_setting(QSettings &settings, const QString &setting, const QString &name, int default_val = 0);
double get_doublespinbox_val(const QString &child);
void set_doublespinbox_from_setting(QSettings &settings, const QString &setting, const QString &child,
double get_dspn_val(const QString &name);
void set_dspn_from_setting(QSettings &settings, const QString &setting, const QString &name,
float default_val = 0.0f);
QString get_lineedit_val(const QString &child);
void set_lineedit_from_setting(QSettings &settings, const QString &setting, const QString &child,
const char *default_val = "");
QString get_txt_val(const QString &name);
void set_txt_from_setting(QSettings &settings, const QString &setting, const QString &name,
const QString &default_val);
int get_spinbox_val(const QString &child);
void set_spinbox_from_setting(QSettings &settings, const QString &setting, const QString &child,
int default_val = 0);
int get_spn_val(const QString &name);
void set_spn_from_setting(QSettings &settings, const QString &setting, const QString &name, int default_val = 0);
void save_sub_settings(QSettings &settings, int symbology);
void load_sub_settings(QSettings &settings, int symbology);
private slots:
bool save();
void about();
void quit_now();
void reset_view();
int open_data_dialog();
int open_sequence_dialog();
void copy_to_clipboard_svg();
void copy_to_clipboard_bmp();
private:
QColor m_fgcolor,m_bgcolor;
BarcodeItem m_bc;
QWidget *m_optionWidget;
QGraphicsScene *scene;
int m_symbology;
QShortcut *m_saveAsShortcut;
QMenu *m_menu;
QAction *m_copyBMPAct;
QAction *m_copyEMFAct;
QAction *m_copyEPSAct;
QAction *m_copyGIFAct;
QAction *m_copyPCXAct;
QAction *m_copyPNGAct;
QAction *m_copySVGAct;
QAction *m_copyTIFAct;
QAction *m_saveAsAct;
QAction *m_aboutAct;
QAction *m_helpAct;
QAction *m_quitAct;
QAction *m_copyErrtxtAct;
};
#endif

View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2013-2017 Cole Bemis
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

1
frontend_qt/res/copy.svg Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-copy"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>

After

Width:  |  Height:  |  Size: 351 B

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-download"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg>

After

Width:  |  Height:  |  Size: 370 B

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-help-circle"><circle cx="12" cy="12" r="10"></circle><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"></path><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>

After

Width:  |  Height:  |  Size: 365 B

1
frontend_qt/res/menu.svg Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-menu"><line x1="3" y1="12" x2="21" y2="12"></line><line x1="3" y1="6" x2="21" y2="6"></line><line x1="3" y1="18" x2="21" y2="18"></line></svg>

After

Width:  |  Height:  |  Size: 346 B

1
frontend_qt/res/x.svg Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>

After

Width:  |  Height:  |  Size: 299 B

View File

@ -32,5 +32,10 @@
<file>grpUPCEAN.ui</file>
<file>grpVIN.ui</file>
<file>res/zint-qt.ico</file>
<file>res/copy.svg</file>
<file>res/download.svg</file>
<file>res/help-circle.svg</file>
<file>res/menu.svg</file>
<file>res/x.svg</file>
</qresource>
</RCC>