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

@ -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
/* 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
(void) set_height(symbol, 0.0f, 5.0f, 0.0f, 1 /*no_errtxt*/);
#endif
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 {
(void) set_height(symbol, 0.0f, 5.0f, 0.0f, 1 /*no_errtxt*/);
}
}
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 (min_row_height < 8.0f) {
min_row_height = 8.0f;
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, 0.0f, 10.0f * rows, 0.0f, 1 /*no_errtxt*/);
}
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
symbol->output_options |= BARCODE_BIND;