- API: add new zint_symbol dpmm field for output resolution (BMP/

EMF/PCX/PNG/TIF only, i.e. excluding EPS, GIF & SVG)
- Add support for specifying scale by X-dimension and resolution
  with new option `--scalexdimdp` for CLI/Tcl & new API function
  `ZBarcode_Scale_From_XdimDp()` (+ `ZBarcode_XdimDp_From_Scale()`
  & `ZBarcode_Default_Xdim()`) and new GUI popup; manual: document
- BMP/EMF/PCX/PNG/TIF: use new `dpmm` resolution field (for EMF
  following Inkscape)
- backend_qt: add `dpmm()`, `vectorWidth()`, `vectorHeight()`,
  `noPng()`, `getVersion()`, `takesGS1AIData()`, & `XdimDp` stuff
  incl. new `QZintXdimDp` struct for passing around scale vars &
  use in `getAsCLI()`; add comments
- Raise `scale` limit to 200 (from 100) to allow for large dpmm
- output: create directories & subdirectories as necessary for
  output path using new function `out_fopen()` and use in BMP/EMF/
  EPS/GIF/PCX/PNG/SVG/TIF
- DPLEIT/DPIDENT: format HRT according to (incomplete)
  documentation, and set default height to 72X (from 50X)
- CODE128B renamed to CODE128AB as can use subsets A and/or B
- CODABAR: fix minimum height calc
- EMF: fix indexing of handles (zero-based not 1-based)
- GUI: fix symbology zap (previous technique of clearing and
  re-loading settings without doing a sync no longer works);
  fix UPCEAN guard descent enable
- MAILMARK: better error message if input < 14 characters
- GUI: add "Default" button for DAFT tracker ratio & enable/disable
  various default buttons; use new `takesGS1AIData()` to
  enable/disable GS1-specific checkboxes
- CLI: use new `validate_float()` to parse float options (7
  significant digits allowed only, no scientific notation)
- DATAMATRIX/GRIDMATRIX/PDF417/QR/ULTRA: micro-optimize structapp
  ID parse
- library/CLI: fiddle with static asserts (make CHAR_BIT sensitive,
  supposedly)
- win32/README: update building libpng (assembly removed)
- README.linux: document incompatibility of Qt6 >= 6.3
- manual: expand Barcode Studio waffle
- test suite: change range separator to hyphen and allow multiple
  excludes
This commit is contained in:
gitlost 2022-12-02 21:39:01 +00:00
parent 6393813cff
commit c8033695d9
127 changed files with 4032 additions and 1248 deletions

View file

@ -105,6 +105,7 @@ namespace Zint {
: m_zintSymbol(nullptr), m_symbol(BARCODE_CODE128), m_input_mode(UNICODE_MODE),
m_height(0.0f),
m_option_1(-1), m_option_2(0), m_option_3(0),
m_dpmm(0.0f),
m_scale(1.0f),
m_dotty(false), m_dot_size(4.0f / 5.0f),
m_guardDescent(5.0f),
@ -122,6 +123,7 @@ namespace Zint {
m_reader_init(false),
m_warn_level(WARN_DEFAULT), m_debug(false),
m_encodedWidth(0), m_encodedRows(0),
m_vectorWidth(0.0f), m_vectorHeight(0.0f),
m_error(0),
target_size_horiz(0), target_size_vert(0) // Legacy
{
@ -133,7 +135,7 @@ namespace Zint {
ZBarcode_Delete(m_zintSymbol);
}
void QZint::resetSymbol() {
bool QZint::resetSymbol() {
m_error = 0;
m_lastError.clear();
@ -142,7 +144,7 @@ namespace Zint {
} else if (!(m_zintSymbol = ZBarcode_Create())) {
m_error = ZINT_ERROR_MEMORY;
m_lastError = QSL("Insufficient memory for Zint structure");
return;
return false;
}
m_zintSymbol->symbology = m_symbol;
@ -194,27 +196,32 @@ namespace Zint {
m_zintSymbol->input_mode |= GS1NOCHECK_MODE;
}
m_zintSymbol->eci = m_eci;
m_zintSymbol->dpmm = m_dpmm;
m_zintSymbol->dot_size = m_dot_size;
m_zintSymbol->guard_descent = m_guardDescent;
m_zintSymbol->structapp = m_structapp;
m_zintSymbol->warn_level = m_warn_level;
m_zintSymbol->debug = m_debug ? ZINT_DEBUG_PRINT : 0;
return true;
}
void QZint::encode() {
resetSymbol();
if (m_segs.empty()) {
QByteArray bstr = m_text.toUtf8();
/* Note do our own rotation */
m_error = ZBarcode_Encode_and_Buffer_Vector(m_zintSymbol, (unsigned char *) bstr.data(), bstr.length(), 0);
} else {
struct zint_seg segs[maxSegs];
std::vector<QByteArray> bstrs;
int seg_count = convertSegs(segs, bstrs);
/* Note do our own rotation */
m_error = ZBarcode_Encode_Segs_and_Buffer_Vector(m_zintSymbol, segs, seg_count, 0);
if (resetSymbol()) {
if (m_segs.empty()) {
QByteArray bstr = m_text.toUtf8();
/* Note do our own rotation */
m_error = ZBarcode_Encode_and_Buffer_Vector(m_zintSymbol, (unsigned char *) bstr.data(),
bstr.length(), 0);
} else {
struct zint_seg segs[maxSegs];
std::vector<QByteArray> bstrs;
int seg_count = convertSegs(segs, bstrs);
/* Note do our own rotation */
m_error = ZBarcode_Encode_Segs_and_Buffer_Vector(m_zintSymbol, segs, seg_count, 0);
}
m_lastError = m_zintSymbol->errtxt;
}
m_lastError = m_zintSymbol->errtxt;
if (m_error < ZINT_ERROR) {
m_borderType = m_zintSymbol->output_options & (BARCODE_BIND | BARCODE_BOX | BARCODE_BIND_TOP);
@ -224,14 +231,17 @@ namespace Zint {
m_vwhitespace = m_zintSymbol->whitespace_height;
m_encodedWidth = m_zintSymbol->width;
m_encodedRows = m_zintSymbol->rows;
m_vectorWidth = m_zintSymbol->vector->width;
m_vectorHeight = m_zintSymbol->vector->height;
emit encoded();
} else {
m_encodedWidth = 0;
m_encodedRows = 0;
m_encodedWidth = m_encodedRows = 0;
m_vectorWidth = m_vectorHeight = 0.0f;
emit errored();
}
}
/* Symbology to use (see BARCODE_XXX) */
int QZint::symbol() const {
return m_symbol;
}
@ -240,6 +250,7 @@ namespace Zint {
m_symbol = symbol;
}
/* Input data encoding. Default UNICODE_MODE */
int QZint::inputMode() const {
return m_input_mode;
}
@ -248,19 +259,23 @@ namespace Zint {
m_input_mode = input_mode;
}
/* Input data (segment 0 text) */
QString QZint::text() const {
return m_text;
}
/* Set input data. Note: clears segs */
void QZint::setText(const QString& text) {
m_text = text;
m_segs.clear();
}
/* Input segments. */
std::vector<QZintSeg> QZint::segs() const {
return m_segs;
}
/* Set segments. Note: clears text and sets eci */
void QZint::setSegs(const std::vector<QZintSeg>& segs) {
m_segs = segs;
m_text.clear();
@ -269,6 +284,7 @@ namespace Zint {
}
}
/* Primary message (Maxicode, Composite) */
QString QZint::primaryMessage() const {
return m_primaryMessage;
}
@ -277,6 +293,7 @@ namespace Zint {
m_primaryMessage = primaryMessage;
}
/* Symbol height in X-dimensions */
float QZint::height() const {
return m_height;
}
@ -285,6 +302,7 @@ namespace Zint {
m_height = height;
}
/* Symbol-specific options (see "../docs/manual.txt") */
int QZint::option1() const {
return m_option_1;
}
@ -293,6 +311,7 @@ namespace Zint {
m_option_1 = option_1;
}
/* Symbol-specific options */
int QZint::option2() const {
return m_option_2;
}
@ -309,6 +328,7 @@ namespace Zint {
m_option_3 = option;
}
/* Scale factor when printing barcode, i.e. adjusts X-dimension */
float QZint::scale() const {
return m_scale;
}
@ -317,6 +337,16 @@ namespace Zint {
m_scale = scale;
}
/* Resolution of output in dots per mm (BMP/EMF/PCX/PNG/TIF only) */
float QZint::dpmm() const {
return m_dpmm;
}
void QZint::setDPMM(float dpmm) {
m_dpmm = dpmm;
}
/* Dotty mode */
bool QZint::dotty() const {
return m_dotty;
}
@ -325,6 +355,7 @@ namespace Zint {
m_dotty = dotty;
}
/* Size of dots used in BARCODE_DOTTY_MODE */
float QZint::dotSize() const {
return m_dot_size;
}
@ -333,6 +364,7 @@ namespace Zint {
m_dot_size = dotSize;
}
/* Height in X-dimensions that EAN/UPC guard bars descend */
float QZint::guardDescent() const {
return m_guardDescent;
}
@ -341,6 +373,7 @@ namespace Zint {
m_guardDescent = guardDescent;
}
/* Structured Append info */
int QZint::structAppCount() const {
return m_structapp.count;
}
@ -378,6 +411,7 @@ namespace Zint {
memset(&m_structapp, 0, sizeof(m_structapp));
}
/* Foreground colour */
QColor QZint::fgColor() const {
return m_fgColor;
}
@ -386,6 +420,7 @@ namespace Zint {
m_fgColor = fgColor;
}
/* Background colour */
QColor QZint::bgColor() const {
return m_bgColor;
}
@ -394,6 +429,7 @@ namespace Zint {
m_bgColor = bgColor;
}
/* Use CMYK colour space (Encapsulated PostScript and TIF) */
bool QZint::cmyk() const {
return m_cmyk;
}
@ -402,6 +438,7 @@ namespace Zint {
m_cmyk = cmyk;
}
/* Type of border above/below/around barcode */
int QZint::borderType() const {
return m_borderType;
}
@ -418,6 +455,7 @@ namespace Zint {
}
}
/* Size of border in X-dimensions */
int QZint::borderWidth() const {
return m_borderWidth;
}
@ -428,6 +466,7 @@ namespace Zint {
m_borderWidth = borderWidth;
}
/* Width in X-dimensions of whitespace to left & right of barcode */
int QZint::whitespace() const {
return m_whitespace;
}
@ -436,6 +475,7 @@ namespace Zint {
m_whitespace = whitespace;
}
/* Height in X-dimensions of whitespace above & below the barcode */
int QZint::vWhitespace() const {
return m_vwhitespace;
}
@ -444,6 +484,7 @@ namespace Zint {
m_vwhitespace = vWhitespace;
}
/* Type of font to use i.e. normal, small, bold or (vector only) small bold */
int QZint::fontSetting() const {
return m_fontSetting;
}
@ -468,6 +509,7 @@ namespace Zint {
}
}
/* Show (true) or hide (false) Human Readable Text */
bool QZint::showText() const {
return m_show_hrt;
}
@ -476,6 +518,7 @@ namespace Zint {
m_show_hrt = showText;
}
/* Set to true to use GS (Group Separator) instead of FNC1 as GS1 separator (Data Matrix) */
bool QZint::gsSep() const {
return m_gssep;
}
@ -484,6 +527,8 @@ namespace Zint {
m_gssep = gsSep;
}
/* Add compliant quiet zones (additional to any specified whitespace)
Note: CODE16K, CODE49, CODABLOCKF, ITF14, EAN/UPC have default quiet zones */
bool QZint::quietZones() const {
return m_quiet_zones;
}
@ -492,6 +537,7 @@ namespace Zint {
m_quiet_zones = quietZones;
}
/* Disable quiet zones, notably those with defaults as listed above */
bool QZint::noQuietZones() const {
return m_no_quiet_zones;
}
@ -500,6 +546,7 @@ namespace Zint {
m_no_quiet_zones = noQuietZones;
}
/* Warn if height not compliant and use standard height (if any) as default */
bool QZint::compliantHeight() const {
return m_compliant_height;
}
@ -508,6 +555,7 @@ namespace Zint {
m_compliant_height = compliantHeight;
}
/* Rotate barcode by angle (degrees 0, 90, 180 and 270) */
int QZint::rotateAngle() const {
return m_rotate_angle;
}
@ -536,6 +584,7 @@ namespace Zint {
}
}
/* Extended Channel Interpretation (segment 0 eci) */
int QZint::eci() const {
return m_eci;
}
@ -552,6 +601,7 @@ namespace Zint {
}
}
/* Process parentheses as GS1 AI delimiters (instead of square brackets) */
bool QZint::gs1Parens() const {
return m_gs1parens;
}
@ -560,6 +610,7 @@ namespace Zint {
m_gs1parens = gs1Parens;
}
/* Do not check validity of GS1 data (except that printable ASCII only) */
bool QZint::gs1NoCheck() const {
return m_gs1nocheck;
}
@ -568,6 +619,7 @@ namespace Zint {
m_gs1nocheck = gs1NoCheck;
}
/* Reader Initialisation (Programming) */
bool QZint::readerInit() const {
return m_reader_init;
}
@ -576,6 +628,7 @@ namespace Zint {
m_reader_init = readerInit;
}
/* Affects error/warning value returned by Zint API (see `getError()` below) */
int QZint::warnLevel() const {
return m_warn_level;
}
@ -584,6 +637,7 @@ namespace Zint {
m_warn_level = warnLevel;
}
/* Debugging flags */
bool QZint::debug() const {
return m_debug;
}
@ -592,6 +646,7 @@ namespace Zint {
m_debug = debug;
}
/* Symbol output info set by Zint on successful `render()` */
int QZint::encodedWidth() const { // Read-only, encoded width (no. of modules encoded)
return m_encodedWidth;
}
@ -600,7 +655,15 @@ namespace Zint {
return m_encodedRows;
}
/* Legacy */
float QZint::vectorWidth() const { // Read-only, scaled width
return m_vectorWidth;
}
float QZint::vectorHeight() const { // Read-only, scaled height
return m_vectorHeight;
}
/* Legacy property getters/setters */
void QZint::setWidth(int width) { setOption1(width); }
int QZint::width() const { return m_option_1; }
void QZint::setSecurityLevel(int securityLevel) { setOption2(securityLevel); }
@ -614,6 +677,7 @@ namespace Zint {
}
QString QZint::error_message() const { return m_lastError; } /* Same as lastError() */
/* Test capabilities - `ZBarcode_Cap()` */
bool QZint::hasHRT(int symbology) const {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_HRT);
}
@ -670,50 +734,63 @@ namespace Zint {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_COMPLIANT_HEIGHT);
}
/* Whether takes GS1 AI-delimited data */
bool QZint::takesGS1AIData(int symbology) const {
if (symbology == 0) {
symbology = m_symbol;
}
switch (symbology) {
case BARCODE_GS1_128:
case BARCODE_DBAR_EXP:
case BARCODE_DBAR_EXPSTK:
return true;
break;
default:
return symbology >= BARCODE_EANX_CC && symbology <= BARCODE_DBAR_EXPSTK_CC;
break;
}
}
/* Error or warning returned by Zint on `render()` or `save_to_file()` */
int QZint::getError() const {
return m_error;
}
/* Error message returned by Zint on `render()` or `save_to_file()` */
const QString& QZint::lastError() const {
return m_lastError;
}
/* Whether `lastError()` set */
bool QZint::hasErrors() const {
return m_lastError.length();
}
bool QZint::noPng() const {
return ZBarcode_NoPng() == 1;
}
int QZint::getVersion() const {
return ZBarcode_Version();
}
bool QZint::save_to_file(const QString& filename) {
resetSymbol();
strcpy(m_zintSymbol->outfile, filename.toLatin1().left(255));
if (m_segs.empty()) {
QByteArray bstr = m_text.toUtf8();
m_error = ZBarcode_Encode_and_Print(m_zintSymbol, (unsigned char *) bstr.data(), bstr.length(),
m_rotate_angle);
} else {
struct zint_seg segs[maxSegs];
std::vector<QByteArray> bstrs;
int seg_count = convertSegs(segs, bstrs);
m_error = ZBarcode_Encode_Segs_and_Print(m_zintSymbol, segs, seg_count, m_rotate_angle);
if (resetSymbol()) {
strcpy(m_zintSymbol->outfile, filename.toLatin1().left(255));
if (m_segs.empty()) {
QByteArray bstr = m_text.toUtf8();
m_error = ZBarcode_Encode_and_Print(m_zintSymbol, (unsigned char *) bstr.data(), bstr.length(),
m_rotate_angle);
} else {
struct zint_seg segs[maxSegs];
std::vector<QByteArray> bstrs;
int seg_count = convertSegs(segs, bstrs);
m_error = ZBarcode_Encode_Segs_and_Print(m_zintSymbol, segs, seg_count, m_rotate_angle);
}
}
if (m_error >= ZINT_ERROR) {
m_lastError = m_zintSymbol->errtxt;
m_encodedWidth = 0;
m_encodedRows = 0;
m_encodedWidth = m_encodedRows = 0;
m_vectorWidth = m_vectorHeight = 0.0f;
emit errored();
return false;
} else {
return true;
}
return true;
}
/* Convert `zint_vector_rect->colour` to Qt color */
Qt::GlobalColor QZint::colourToQtColor(int colour) {
switch (colour) {
case 1: // Cyan
@ -756,7 +833,8 @@ namespace Zint {
return i;
}
/* Note: legacy argument `mode` is not used */
/* Encode and display barcode in `paintRect` using `painter`.
Note: legacy argument `mode` is not used */
void QZint::render(QPainter& painter, const QRectF& paintRect, AspectRatioMode /*mode*/) {
struct zint_vector_rect *rect;
struct zint_vector_hexagon *hex;
@ -923,12 +1001,76 @@ namespace Zint {
painter.restore();
}
/* Returns the default X-dimension (`ZBarcode_Default_Xdim()`).
If `symbology` non-zero then used instead of `symbol()` */
float QZint::defaultXdim(int symbology) const {
return ZBarcode_Default_Xdim(symbology ? symbology : m_symbol);
}
/* Returns the scale to use for X-dimension `x_dim_mm` at `dpmm` for `filetype`.
If `symbology` non-zero then used instead of `symbol()` */
float QZint::getScaleFromXdimDp(float x_dim_mm, float dpmm, const QString& fileType, int symbology) const {
return ZBarcode_Scale_From_XdimDp(symbology ? symbology : m_symbol, x_dim_mm, dpmm, fileType.toLatin1());
}
/* Reverse of `getScaleFromXdimDp()` above, returning the X-dimension or dot density given the scale `scale`.
If `symbology` non-zero then used instead of `symbol()` */
float QZint::getXdimDpFromScale(float scale, float x_dim_mm_or_dpmm, const QString& fileType,
int symbology) const {
return ZBarcode_XdimDp_From_Scale(symbology ? symbology : m_symbol, scale, x_dim_mm_or_dpmm,
fileType.toLatin1());
}
/* Set `width_x_dim` and `height_x_dim` with estimated size of barcode based on X-dimension `x_dim`. To be called
after a successful `render()`. Returns false if `scale()` zero or render is in error, otherwise true */
bool QZint::getWidthHeightXdim(float x_dim, float &width_x_dim, float &height_x_dim) const {
if (m_scale == 0.0f || m_vectorWidth == 0.0f || m_vectorHeight == 0.0f) {
width_x_dim = height_x_dim = 0.0f;
return false;
}
const float scale = m_scale * 2.0f;
const float width = m_vectorWidth / scale;
const float height = m_vectorHeight / scale;
if (rotateAngle() == 90 || rotateAngle() == 270) { // Sideways - swop
width_x_dim = (height * x_dim);
height_x_dim = (width * x_dim);
} else {
width_x_dim = (width * x_dim);
height_x_dim = (height * x_dim);
}
return true;
}
/* Return the BARCODE_XXX name of `symbology` */
QString QZint::barcodeName(const int symbology) {
char buf[32];
if (ZBarcode_BarcodeName(symbology, buf) == 0) {
return QString(buf);
}
return QSL("");
}
/* Whether Zint library "libzint" built with PNG support or not */
bool QZint::noPng() {
return ZBarcode_NoPng() == 1;
}
/* Version of Zint library "libzint" linked to */
int QZint::getVersion() {
return ZBarcode_Version();
}
/* Translate settings into Command Line equivalent. Set `win` to use Windows escaping of data.
If `autoHeight` set then `--height=` option will not be emitted.
If HEIGHTPERROW_MODE set and non-zero `heightPerRow` given then use that for height instead of internal
height */
QString QZint::getAsCLI(const bool win, const bool longOptOnly, const bool barcodeNames, const bool noEXE,
const bool autoHeight, const float heightPerRow, const QString& outfile) const {
const bool autoHeight, const float heightPerRow, const QString& outfile,
const QZintXdimDpVars *xdimdpVars) const {
QString cmd(win && !noEXE ? QSL("zint.exe") : QSL("zint"));
char name_buf[32];
@ -1071,7 +1213,9 @@ namespace Zint {
arg_int(cmd, "--rows=", option3());
}
if (scale() != 1.0f) {
if (dpmm()) {
arg_scalexdimdp(cmd, "--scalexdimdp", scale(), dpmm(), symbol(), xdimdpVars);
} else if (scale() != 1.0f) {
arg_float(cmd, "--scale=", scale());
}
@ -1202,6 +1346,41 @@ namespace Zint {
}
}
}
void QZint::arg_scalexdimdp(QString& cmd, const char *const opt, const float scale, const float dpmm,
const int symbol, const QZintXdimDpVars *xdimdpVars) {
if (dpmm) {
float resolution = dpmm;
float x_dim;
const char *x_dim_units_str = "";
const char *resolution_units_str = "";
if (xdimdpVars && xdimdpVars->set) {
x_dim = xdimdpVars->x_dim;
resolution = xdimdpVars->resolution;
if (xdimdpVars->x_dim_units || xdimdpVars->resolution_units) {
x_dim_units_str = xdimdpVars->x_dim_units ? "in" : "mm";
resolution_units_str = xdimdpVars->resolution_units ? "dpi" : "dpmm";
}
} else {
x_dim = ZBarcode_XdimDp_From_Scale(symbol, scale, resolution, nullptr);
}
cmd += QString::asprintf(" %s=%g%s,%g%s",
opt, x_dim, x_dim_units_str, resolution, resolution_units_str);
}
}
/* Helper to return "GIF"/"SVG"(/"EMF") if `msg` false, "raster"/"vector"(/"EMF") otherwise
(EMF only if `symbol` is MaxiCode) */
const char *QZintXdimDpVars::getFileType(int symbol, const struct QZintXdimDpVars *vars, bool msg) {
static const char *filetypes[3] = { "GIF", "SVG", "EMF" };
static const char *msg_types[3] = { "raster", "vector", "EMF" };
if (!vars) return "";
const int idx = std::max(std::min(symbol == BARCODE_MAXICODE ? vars->filetype_maxicode
: vars->filetype, 2), 0);
return msg ? msg_types[idx] : filetypes[idx];
}
} /* namespace Zint */
/* vim: set ts=4 sw=4 et : */

View file

@ -16,9 +16,15 @@
***************************************************************************/
/* SPDX-License-Identifier: GPL-3.0-or-later */
/*
* For version, see "../backend/zintconfig.h"
* For documentation, see "../docs/manual.txt"
*/
#ifndef QZINT_H
#define QZINT_H
#include <QObject>
#include <QColor>
#include <QPainter>
#include "zint.h"
@ -29,148 +35,200 @@ namespace Zint
/* QString version of `struct zint_seg` */
class QZintSeg {
public:
QString m_text;
int m_eci;
QString m_text; // `seg->source` and `seg->length`
int m_eci; // `seg->eci`
QZintSeg();
QZintSeg(const QString& text, const int ECIIndex = 0); // `ECIIndex` is comboBox index (not ECI value)
};
struct QZintXdimDpVars; // Forward reference to Printing Scale settings, see end
/* Interface */
class QZint : public QObject
{
Q_OBJECT
public:
enum AspectRatioMode{ IgnoreAspectRatio = 0, KeepAspectRatio = 1, CenterBarCode = 2 }; /* Legacy - not used */
/* Legacy - not used */
enum AspectRatioMode{ IgnoreAspectRatio = 0, KeepAspectRatio = 1, CenterBarCode = 2 };
public:
QZint();
~QZint();
int symbol() const; /* Symbology */
/* Symbology to use (see BARCODE_XXX) */
int symbol() const; // `symbol->symbology`
void setSymbol(int symbol);
int inputMode() const;
/* Input data encoding. Default UNICODE_MODE */
int inputMode() const; // `symbol->input_mode`
void setInputMode(int input_mode);
/* Note text/eci and segs are mutally exclusive */
/* Input data (segment 0 text) */
QString text() const;
void setText(const QString& text); // Clears segs
/* Set input data. Note: clears segs */
void setText(const QString& text);
/* Input segments. */
std::vector<QZintSeg> segs() const;
void setSegs(const std::vector<QZintSeg>& segs); // Clears text and sets eci
/* Set segments. Note: clears text and sets eci */
void setSegs(const std::vector<QZintSeg>& segs);
QString primaryMessage() const;
/* Primary message (Maxicode, Composite) */
QString primaryMessage() const; // `symbol->primary`
void setPrimaryMessage(const QString& primaryMessage);
float height() const;
/* Symbol height in X-dimensions */
float height() const; // `symbol->height`
void setHeight(float height);
int option1() const;
/* Symbol-specific options (see "../docs/manual.txt") */
int option1() const; // `symbol->option_1`
void setOption1(int option_1);
int option2() const;
/* Symbol-specific options */
int option2() const; // `symbol->option_2`
void setOption2(int option);
int option3() const;
/* Symbol-specific options */
int option3() const; // `symbol->option_3`
void setOption3(int option);
float scale() const;
/* Scale factor when printing barcode, i.e. adjusts X-dimension */
float scale() const; // `symbol->scale`
void setScale(float scale);
bool dotty() const;
/* Resolution of output in dots per mm (BMP/EMF/PCX/PNG/TIF only) */
float dpmm() const; // `symbol->dpmm`
void setDPMM(float dpmm);
/* Dotty mode */
bool dotty() const; // `symbol->input_mode | BARCODE_DOTTY_MODE`
void setDotty(bool botty);
float dotSize() const;
/* Size of dots used in BARCODE_DOTTY_MODE */
float dotSize() const; // `symbol->dot_size`
void setDotSize(float dot_size);
float guardDescent() const;
/* Height in X-dimensions that EAN/UPC guard bars descend */
float guardDescent() const; // `symbol->guard_descent`
void setGuardDescent(float guardDescent);
int structAppCount() const;
int structAppIndex() const;
QString structAppID() const;
/* Structured Append info */
int structAppCount() const; // `symbol->structapp.count`
int structAppIndex() const; // `symbol->structapp.index`
QString structAppID() const; // `symbol->structapp.id`
void setStructApp(const int count, const int index, const QString& id);
void clearStructApp();
QColor fgColor() const;
/* Foreground colour */
QColor fgColor() const; // `symbol->fgcolour`
void setFgColor(const QColor& fgColor);
QColor bgColor() const;
/* Background colour */
QColor bgColor() const; // `symbol->bgcolour`
void setBgColor(const QColor& bgColor);
bool cmyk() const;
/* Use CMYK colour space (Encapsulated PostScript and TIF) */
bool cmyk() const; // `symbol->output_options | CMYK_COLOUR`
void setCMYK(bool cmyk);
int borderType() const;
/* Type of border above/below/around barcode */
int borderType() const; // `symbol->output_options | BARCODE_BIND | BARCODE_BOX | BARCODE_BIND_TOP`
void setBorderType(int borderTypeIndex);
int borderWidth() const;
/* Size of border in X-dimensions */
int borderWidth() const; // `symbol->border_width`
void setBorderWidth(int borderWidth);
int whitespace() const;
/* Width in X-dimensions of whitespace to left & right of barcode */
int whitespace() const; // `symbol->whitespace_width`
void setWhitespace(int whitespace);
int vWhitespace() const;
/* Height in X-dimensions of whitespace above & below the barcode */
int vWhitespace() const; // `symbol->whitespace_height`
void setVWhitespace(int vWhitespace);
int fontSetting() const;
/* Type of font to use i.e. normal, small, bold or (vector only) small bold */
int fontSetting() const; // `symbol->output_options | SMALL_TEXT | BOLD_TEXT`
void setFontSetting(int fontSettingIndex); // Sets from comboBox index
void setFontSettingValue(int fontSetting); // Sets literal value
bool showText() const;
/* Show (true) or hide (false) Human Readable Text */
bool showText() const; // `symbol->show_hrt`
void setShowText(bool showText);
bool gsSep() const;
/* Set to true to use GS (Group Separator) instead of FNC1 as GS1 separator (Data Matrix) */
bool gsSep() const; // `symbol->output_options | GS1_GS_SEPARATOR`
void setGSSep(bool gsSep);
bool quietZones() const;
/* Add compliant quiet zones (additional to any specified whitespace)
Note: CODE16K, CODE49, CODABLOCKF, ITF14, EAN/UPC have default quiet zones */
bool quietZones() const; // `symbol->output_options | BARCODE_QUIET_ZONES`
void setQuietZones(bool quietZones);
bool noQuietZones() const;
/* Disable quiet zones, notably those with defaults as listed above */
bool noQuietZones() const; // `symbol->output_options | BARCODE_NO_QUIET_ZONES`
void setNoQuietZones(bool noQuietZones);
bool compliantHeight() const;
/* Warn if height not compliant and use standard height (if any) as default */
bool compliantHeight() const; // `symbol->output_options | COMPLIANT_HEIGHT`
void setCompliantHeight(bool compliantHeight);
/* Rotate barcode by angle (degrees 0, 90, 180 and 270) */
int rotateAngle() const;
void setRotateAngle(int rotateIndex); // Sets from comboBox index
void setRotateAngleValue(int rotateAngle); // Sets literal value
int eci() const;
/* Extended Channel Interpretation (segment 0 eci) */
int eci() const; // `symbol->eci`
void setECI(int ECIIndex); // Sets from comboBox index
void setECIValue(int eci); // Sets literal value
bool gs1Parens() const;
/* Process parentheses as GS1 AI delimiters (instead of square brackets) */
bool gs1Parens() const; // `symbol->input_mode | GS1PARENS_MODE`
void setGS1Parens(bool gs1Parens);
bool gs1NoCheck() const;
/* Do not check validity of GS1 data (except that printable ASCII only) */
bool gs1NoCheck() const; // `symbol->input_mode | GS1NOCHECK_MODE`
void setGS1NoCheck(bool gs1NoCheck);
bool readerInit() const;
/* Reader Initialisation (Programming) */
bool readerInit() const; // `symbol->output_options | READER_INIT`
void setReaderInit(bool readerInit);
int warnLevel() const;
/* Affects error/warning value returned by Zint API (see `getError()` below) */
int warnLevel() const; // `symbol->warn_level`
void setWarnLevel(int warnLevel);
bool debug() const;
/* Debugging flags */
bool debug() const; // `symbol->debug`
void setDebug(bool debug);
/* Symbol output info set by Zint on successful `render()` */
int encodedWidth() const; // Read-only, encoded width (no. of modules encoded)
int encodedRows() const; // Read-only, no. of rows encoded
float vectorWidth() const; // Read-only, scaled width
float vectorHeight() const; // Read-only, scaled height
/* Legacy property getters/setters */
void setWidth(int width); /* option_1 */
void setWidth(int width); /* `symbol->option_1` */
int width() const;
void setSecurityLevel(int securityLevel); /* option_2 */
void setSecurityLevel(int securityLevel); /* `symbol->option_2` */
int securityLevel() const;
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() */
void setHideText(bool hide); /* `setShowText(!hide)` */
void setTargetSize(int width, int height); /* No-op */
QString error_message() const; /* Same as `lastError()` */
/* Test capabilities - ZBarcode_Cap() */
/* Test capabilities - `ZBarcode_Cap()` */
bool hasHRT(int symbology = 0) const;
bool isStackable(int symbology = 0) const;
bool isExtendable(int symbology = 0) const;
@ -186,20 +244,56 @@ public:
bool supportsStructApp(int symbology = 0) const;
bool hasCompliantHeight(int symbology = 0) const;
/* Whether takes GS1 AI-delimited data */
bool takesGS1AIData(int symbology = 0) const;
/* Error or warning returned by Zint on `render()` or `save_to_file()` */
int getError() const;
const QString& lastError() const;
bool hasErrors() const;
/* Error message returned by Zint on `render()` or `save_to_file()` */
const QString& lastError() const; // `symbol->errtxt`
bool save_to_file(const QString& filename);
/* Whether `lastError()` set */
bool hasErrors() const; // `symbol->errtxt`
/* Note: legacy argument `mode` is not used */
/* Encode and print barcode to file `filename`. Only sets `getError()` on error, not on warning */
bool save_to_file(const QString& filename); // `ZBarcode_Print()`
/* Encode and display barcode in `paintRect` using `painter`.
Note: legacy argument `mode` is not used */
void render(QPainter& painter, const QRectF& paintRect, AspectRatioMode mode = IgnoreAspectRatio);
/* Whether Zint library "libzint" built with PNG support or not (`ZBarcode_NoPng()`) */
bool noPng() const;
int getVersion() const;
/* Returns the default X-dimension (`ZBarcode_Default_Xdim()`).
If `symbology` non-zero then used instead of `symbol()` */
float defaultXdim(int symbology = 0) const;
/* Returns the scale to use for X-dimension `x_dim_mm` at `dpmm` for `filetype`.
If `symbology` non-zero then used instead of `symbol()` */
float getScaleFromXdimDp(float x_dim_mm, float dpmm, const QString& fileType, int symbology = 0) const;
// `ZBarcode_Scale_Xdim()`
/* Reverse of `getScaleFromXdimDp()` above, returning the X-dimension or dot density given the scale `scale`.
If `symbology` non-zero then used instead of `symbol()` */
float getXdimDpFromScale(float scale, float x_dim_mm_or_dpmm, const QString& fileType, int symbology = 0) const;
// `ZBarcode_XdimDp_From_Scale()`
/* Set `width_x_dim` and `height_x_dim` with estimated size of barcode based on X-dimension `x_dim`. To be called
after a successful `render()`. Returns false if `scale()` zero or render is in error, otherwise true */
bool getWidthHeightXdim(float x_dim, float &width_x_dim, float &height_x_dim) const;
/* Return the BARCODE_XXX name of `symbology` */
static QString barcodeName(const int symbology); // `ZBarcode_BarcodeName()`
/* Whether Zint library "libzint" built with PNG support or not */
static bool noPng(); // `ZBarcode_NoPng()`
/* Version of Zint library "libzint" linked to */
static int getVersion(); // `ZBarcode_Version()`
/* Translate settings into Command Line equivalent. Set `win` to use Windows escaping of data.
If `autoHeight` set then `--height=` option will not be emitted.
@ -207,18 +301,20 @@ public:
height */
QString getAsCLI(const bool win, const bool longOptOnly = false, const bool barcodeNames = false,
const bool noEXE = false, const bool autoHeight = false, const float heightPerRow = 0.0f,
const QString& outfile = "") const;
const QString& outfile = "", const QZintXdimDpVars *xdimdpVars = nullptr) const;
signals:
void encoded();
void errored();
void encoded(); // Emitted on successful `render()`
void errored(); // Emitted if an error (not warning) occurred on `render()`
private:
void resetSymbol();
void encode();
bool resetSymbol(); // Reset the symbol structure for encoding using member fields
void encode(); // `ZBarcode_Encode_and_Buffer_Vector()` or `ZBarcode_Encode_Segs_and_Buffer_Vector()`
/* Helper to convert `m_segs` to `struct zint_seg[]` */
int convertSegs(struct zint_seg segs[], std::vector<QByteArray>& bstrs);
/* Convert `zint_vector_rect->colour` to Qt color */
static Qt::GlobalColor colourToQtColor(int colour);
/* `getAsCLI()` helpers */
@ -232,6 +328,8 @@ private:
static void arg_float(QString& cmd, const char *const opt, const float val, const bool allowZero = false);
static void arg_structapp(QString& cmd, const char *const opt, const int count, const int index,
const QString& id, const bool win);
static void arg_scalexdimdp(QString& cmd, const char *const opt, const float scale, const float dpmm,
const int symbol, const QZintXdimDpVars *xdimdpVars);
private:
zint_symbol *m_zintSymbol;
@ -244,6 +342,7 @@ private:
int m_option_1;
int m_option_2;
int m_option_3;
float m_dpmm;
float m_scale;
bool m_dotty;
float m_dot_size;
@ -271,6 +370,8 @@ private:
bool m_debug;
int m_encodedWidth;
int m_encodedRows;
float m_vectorWidth;
float m_vectorHeight;
QString m_lastError;
int m_error;
@ -278,6 +379,21 @@ private:
int target_size_vert; /* Legacy */
};
/* Printing Scale settings */
struct QZintXdimDpVars {
double x_dim = 0.0; // X-dimension in `x_dim_units`
int x_dim_units = 0; // 0 for mm, 1 for inches
int resolution = 0; // Dot density in `resolution_units`
int resolution_units = 0; // 0 for dpmm, 1 for dpi
int filetype = 0; // For non-MaxiCode, 0 for GIF (raster), 1 for SVG (vector)
int filetype_maxicode = 0; // For MaxiCode only, 0 for GIF (raster), 1 for SVG (vector), 2 for EMF
int set = 0; // 1 if explicitly set, 0 if just defaults (in which case the struct isn't applicable to `dpmm()`)
/* Helper to return "GIF"/"SVG"(/"EMF") if `msg` false, "raster"/"vector"(/"EMF") otherwise
(EMF only if `symbol` is MaxiCode) */
static const char *getFileType(int symbol, const struct QZintXdimDpVars *vars, bool msg = false);
};
} /* namespace Zint */
/* vim: set ts=4 sw=4 et : */

View file

@ -115,6 +115,10 @@ private slots:
bc.setScale(scale);
QCOMPARE(bc.scale(), scale);
float dpmm = 11.811f;
bc.setDPMM(dpmm);
QCOMPARE(bc.dpmm(), dpmm);
bool dotty = true;
bc.setDotty(dotty);
QCOMPARE(bc.dotty(), dotty);
@ -260,6 +264,12 @@ private slots:
QCOMPARE(bc.encodedWidth(), 0); // Read-only
QCOMPARE(bc.encodedRows(), 0); // Read-only
QCOMPARE(bc.vectorWidth(), 0.0f); // Read-only
QCOMPARE(bc.vectorHeight(), 0.0f); // Read-only
QCOMPARE(bc.takesGS1AIData(BARCODE_CODE128), false);
QCOMPARE(bc.takesGS1AIData(BARCODE_GS1_128), true);
}
void setGetECIValueTest_data()
@ -370,10 +380,12 @@ private slots:
QTest::addColumn<QString>("error_message");
QTest::addColumn<int>("encodedWidth");
QTest::addColumn<int>("encodedRows");
QTest::addColumn<float>("vectorWidth");
QTest::addColumn<float>("vectorHeight");
QTest::newRow("BARCODE_QRCODE") << BARCODE_QRCODE << "1234" << 0 << "" << 21 << 21;
QTest::newRow("BARCODE_QRCODE") << BARCODE_QRCODE << "1234" << 0 << "" << 21 << 21 << 42.0f << 42.0f;
if (!m_skipIfFontUsed) {
QTest::newRow("BARCODE_QRCODE no text") << BARCODE_QRCODE << "" << ZINT_ERROR_INVALID_DATA << "Error 778: No input data (segment 0 empty)" << 0 << 0;
QTest::newRow("BARCODE_QRCODE no text") << BARCODE_QRCODE << "" << ZINT_ERROR_INVALID_DATA << "Error 778: No input data (segment 0 empty)" << 0 << 0 << 0.0f << 0.0f;
}
}
@ -398,6 +410,8 @@ private slots:
QFETCH(QString, error_message);
QFETCH(int, encodedWidth);
QFETCH(int, encodedRows);
QFETCH(float, vectorWidth);
QFETCH(float, vectorHeight);
bc.setSymbol(symbology);
bc.setText(text);
@ -416,6 +430,8 @@ private slots:
QCOMPARE(bc.hasErrors(), getError != 0);
QCOMPARE(bc.encodedWidth(), encodedWidth);
QCOMPARE(bc.encodedRows(), encodedRows);
QCOMPARE(bc.vectorWidth(), vectorWidth);
QCOMPARE(bc.vectorHeight(), vectorHeight);
if (getError) {
QCOMPARE(spyEncoded.count(), 0);
@ -476,6 +492,7 @@ private slots:
QTest::addColumn<int>("option2");
QTest::addColumn<int>("option3");
QTest::addColumn<float>("scale");
QTest::addColumn<float>("dpmm");
QTest::addColumn<bool>("dotty");
QTest::addColumn<float>("dotSize");
QTest::addColumn<float>("guardDescent");
@ -503,341 +520,403 @@ private slots:
QTest::addColumn<int>("warnLevel");
QTest::addColumn<bool>("debug");
QTest::addColumn<double>("xdimdp_xdim");
QTest::addColumn<int>("xdimdp_xdim_units");
QTest::addColumn<int>("xdimdp_resolution");
QTest::addColumn<int>("xdimdp_resolution_units");
QTest::addColumn<int>("xdimdp_filetype");
QTest::addColumn<int>("xdimdp_filetype_maxicode");
QTest::addColumn<QString>("expected_cmd");
QTest::addColumn<QString>("expected_win");
QTest::addColumn<QString>("expected_longOptOnly");
QTest::addColumn<QString>("expected_barcodeNames");
QTest::addColumn<QString>("expected_noexe");
QTest::addColumn<QString>("expected_xdimdp");
QTest::newRow("BARCODE_AUSPOST") << true << 0.0f << ""
<< BARCODE_AUSPOST << DATA_MODE // symbology-inputMode
<< "12345678" << "" // text-primary
<< 30.0f << -1 << 0 << 0 << 1.0f << false << 0.8f // height-dotSize
<< 30.0f << -1 << 0 << 0 << 1.0f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
<< "zint -b 63 --binary --compliantheight -d '12345678'"
<< "zint.exe -b 63 --binary --compliantheight -d \"12345678\""
<< "zint --barcode=63 --binary --compliantheight --data='12345678'"
<< "zint -b AUSPOST --binary --compliantheight -d '12345678'"
<< "zint -b 63 --binary --compliantheight -d \"12345678\"";
<< "zint -b 63 --binary --compliantheight -d \"12345678\""
<< "";
QTest::newRow("BARCODE_AZTEC") << false << 0.0f << ""
<< BARCODE_AZTEC << UNICODE_MODE // symbology-inputMode
<< "12345678Ж0%var%" << "" // text-primary
<< 0.0f << 1 << 0 << 0 << 4.0f << true << 0.9f // height-dotSize
<< 0.0f << 1 << 0 << 0 << 4.0f << 0.0f << true << 0.9f // height-dotSize
<< 5.0f << 2 << 1 << "as\"dfa'sdf" << QColor(Qt::blue) << QColor(Qt::white) // guardDescent-bgColor
<< true << 0 << 0 << 2 << 3 << 0 // cmyk-fontSetting
<< true << false << false << false << false << 0 // showText-rotateAngle
<< 7 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
<< "zint -b 92 --cmyk --eci=7 -d '12345678Ж0%var%' --dotsize=0.9 --dotty --fg=0000FF --scale=4"
" --secure=1 --structapp='1,2,as\"dfa'\\''sdf' --vwhitesp=3 -w 2"
<< "zint.exe -b 92 --cmyk --eci=7 -d \"12345678Ж0%var%\" --dotsize=0.9 --dotty --fg=0000FF --scale=4"
" --secure=1 --structapp=\"1,2,as\\\"dfa'sdf\" --vwhitesp=3 -w 2"
<< "" << "" << "";
<< "" << "" << "" << "";
QTest::newRow("BARCODE_C25INTER") << true << 0.0f << ""
<< BARCODE_C25INTER << UNICODE_MODE // symbology-inputMode
<< "12345" << "" // text-primary
<< 0.0f << -1 << 2 << 0 << 1.0f << false << 0.8f // height-dotSize
<< 0.0f << -1 << 2 << 0 << 1.0f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << SMALL_TEXT // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
<< "zint -b 3 --compliantheight -d '12345' --small --vers=2"
<< "zint.exe -b 3 --compliantheight -d \"12345\" --small --vers=2"
<< "" << "" << "";
<< "" << "" << "" << "";
QTest::newRow("BARCODE_CHANNEL") << false << 0.0f << ""
<< BARCODE_CHANNEL << UNICODE_MODE // symbology-inputMode
<< "453678" << "" // text-primary
<< 19.7f << -1 << 7 << 0 << 1.0f << false << 0.8f // height-dotSize
<< 19.7f << -1 << 7 << 0 << 1.0f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(255, 255, 255, 0) // guardDescent-bgColor
<< false << 1 << 2 << 0 << 0 << BOLD_TEXT // cmyk-fontSetting
<< true << false << true << false << false << 90 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << true // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
<< "zint -b 140 --bind --bold --border=2 -d '453678' --height=19.7 --nobackground --quietzones"
" --rotate=90 --verbose --vers=7"
<< "zint.exe -b 140 --bind --bold --border=2 -d \"453678\" --height=19.7 --nobackground --quietzones"
" --rotate=90 --verbose --vers=7"
<< "" << "" << "";
<< "" << "" << "" << "";
QTest::newRow("BARCODE_GS1_128_CC") << false << 0.0f << ""
<< BARCODE_GS1_128_CC << UNICODE_MODE // symbology-inputMode
<< "[01]12345678901231[15]121212" << "[11]901222[99]ABCDE" // text-primary
<< 71.142f << 3 << 0 << 0 << 3.5f << false << 0.8f // height-dotSize
<< 71.142f << 3 << 0 << 0 << 3.5f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< false << false << true << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
<< "zint -b 131 --compliantheight -d '[11]901222[99]ABCDE' --height=71.142 --mode=3 --notext"
" --primary='[01]12345678901231[15]121212' --quietzones --scale=3.5"
<< "zint.exe -b 131 --compliantheight -d \"[11]901222[99]ABCDE\" --height=71.142 --mode=3 --notext"
" --primary=\"[01]12345678901231[15]121212\" --quietzones --scale=3.5"
<< "" << "" << "";
<< "" << "" << "" << "";
QTest::newRow("BARCODE_CODE16K") << false << 11.7f << ""
<< BARCODE_CODE16K << (UNICODE_MODE | HEIGHTPERROW_MODE) // symbology-inputMode
<< "12345678901234567890123456789012" << "" // text-primary
<< 0.0f << 4 << 0 << 2 << 1.0f << false << 0.8f // height-dotSize
<< 0.0f << 4 << 0 << 2 << 1.0f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 1 << 1 << 0 << 0 << SMALL_TEXT // cmyk-fontSetting
<< true << false << false << true << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
<< "zint -b 23 --compliantheight -d '12345678901234567890123456789012'"
" --height=11.7 --heightperrow --noquietzones --rows=4 --separator=2 --small"
<< "zint.exe -b 23 --compliantheight -d \"12345678901234567890123456789012\""
" --height=11.7 --heightperrow --noquietzones --rows=4 --separator=2 --small"
<< "" << "" << "";
<< "" << "" << "" << "";
QTest::newRow("BARCODE_CODE49") << true << 0.0f << ""
<< BARCODE_CODE49 << UNICODE_MODE // symbology-inputMode
<< "12345678901234567890" << "" // text-primary
<< 30.0f << -1 << 0 << 0 << 1.0f << false << 0.8f // height-dotSize
<< 30.0f << -1 << 0 << 0 << 1.0f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
<< "zint -b 24 --compliantheight -d '12345678901234567890'"
<< "zint.exe -b 24 --compliantheight -d \"12345678901234567890\""
<< "" << "" << "";
<< "" << "" << "" << "";
QTest::newRow("BARCODE_CODABLOCKF") << true << 0.0f << ""
<< BARCODE_CODABLOCKF << (DATA_MODE | ESCAPE_MODE) // symbology-inputMode
<< "T\\n\\xA0t\\\"" << "" // text-primary
<< 0.0f << 2 << 5 << 3 << 3.0f << false << 0.8f // height-dotSize
<< 0.0f << 2 << 5 << 3 << 3.0f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 2 << 4 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << true << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
<< "zint -b 74 --binary --border=4 --box --cols=5 --compliantheight -d 'T\\n\\xA0t\\\"' --esc --init"
" --rows=2 --scale=3 --separator=3"
<< "zint.exe -b 74 --binary --border=4 --box --cols=5 --compliantheight -d \"T\\n\\xA0t\\\\\"\" --esc --init"
" --rows=2 --scale=3 --separator=3"
<< "" << "" << "";
<< "" << "" << "" << "";
QTest::newRow("BARCODE_DAFT") << false << 0.0f << ""
<< BARCODE_DAFT << UNICODE_MODE // symbology-inputMode
<< "daft" << "" // text-primary
<< 9.2f << -1 << 251 << 0 << 1.0f << false << 0.7f // height-dotSize
<< 9.2f << -1 << 251 << 0 << 1.0f << 0.0f << false << 0.7f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(0x30, 0x31, 0x32, 0x33) << QColor(0xBF, 0xBE, 0xBD, 0xBC) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
<< "zint -b 93 --bg=BFBEBDBC -d 'daft' --fg=30313233 --height=9.2 --vers=251"
<< "zint.exe -b 93 --bg=BFBEBDBC -d \"daft\" --fg=30313233 --height=9.2 --vers=251"
<< "" << "" << "";
<< "" << "" << "" << "";
QTest::newRow("BARCODE_DATAMATRIX") << true << 0.0f << ""
<< BARCODE_DATAMATRIX << GS1_MODE // symbology-inputMode
<< "[20]12" << "" // text-primary
<< 0.0f << -1 << 0 << DM_SQUARE << 1.0f << false << 0.7f // height-dotSize
<< 0.0f << -1 << 0 << DM_SQUARE << 1.0f << 0.0f << false << 0.7f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << true << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
<< "zint -b 71 -d '[20]12' --gs1 --gssep --square"
<< "zint.exe -b 71 -d \"[20]12\" --gs1 --gssep --square"
<< "" << "" << "";
<< "" << "" << "" << "";
QTest::newRow("BARCODE_DATAMATRIX") << false << 0.0f << ""
<< BARCODE_DATAMATRIX << (DATA_MODE | ESCAPE_MODE | FAST_MODE) // symbology-inputMode
<< "ABCDEFGH\\x01I" << "" // text-primary
<< 0.0f << -1 << 0 << 0 << 1.0f << false << 0.7f // height-dotSize
<< 0.0f << -1 << 0 << 0 << 1.0f << 0.0f << false << 0.7f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
<< "zint -b 71 --binary -d 'ABCDEFGH\\x01I' --esc --fast"
<< "zint.exe -b 71 --binary -d \"ABCDEFGH\\x01I\" --esc --fast"
<< "" << "" << "";
<< "" << "" << "" << "";
QTest::newRow("BARCODE_DBAR_EXPSTK_CC") << false << 40.8f << ""
<< BARCODE_DBAR_EXPSTK_CC << (DATA_MODE | HEIGHTPERROW_MODE) // symbology-inputMode
<< "[91]ABCDEFGHIJKL" << "[11]901222[99]ABCDE" // text-primary
<< 0.0f << -1 << 0 << 2 << 1.0f << true << 0.9f // height-dotSize
<< 0.0f << -1 << 0 << 2 << 1.0f << 0.0f << true << 0.9f // height-dotSize
<< 3.0f << 2 << 1 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
<< "zint -b 139 --binary --compliantheight -d '[11]901222[99]ABCDE' --height=40.8 --heightperrow"
" --primary='[91]ABCDEFGHIJKL' --rows=2"
<< "zint.exe -b 139 --binary --compliantheight -d \"[11]901222[99]ABCDE\" --height=40.8 --heightperrow"
" --primary=\"[91]ABCDEFGHIJKL\" --rows=2"
<< "" << "" << "";
<< "" << "" << "" << "";
QTest::newRow("BARCODE_DOTCODE") << false << 1.0f << ""
<< BARCODE_DOTCODE << GS1_MODE // symbology-inputMode
<< "[20]01" << "" // text-primary
<< 30.0f << -1 << 8 << ((0 + 1) << 8) << 1.0f << false << 0.7f // height-dotSize
<< 30.0f << -1 << 8 << ((0 + 1) << 8) << 1.0f << 0.0f << false << 0.7f // height-dotSize
<< 0.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
<< "zint -b 115 --cols=8 -d '[20]01' --dotsize=0.7 --gs1 --mask=0"
<< "zint.exe -b 115 --cols=8 -d \"[20]01\" --dotsize=0.7 --gs1 --mask=0"
<< "" << "" << "";
<< "" << "" << "" << "";
QTest::newRow("BARCODE_DOTCODE") << false << 1.0f << ""
<< BARCODE_DOTCODE << GS1_MODE // symbology-inputMode
<< "[20]01" << "" // text-primary
<< 30.0f << -1 << 8 << ((0 + 1) << 8) << 1.0f << 0.0f << false << 0.7f // height-dotSize
<< 0.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
<< "zint -b 115 --cols=8 -d '[20]01' --dotsize=0.7 --gs1 --mask=0"
<< "zint.exe -b 115 --cols=8 -d \"[20]01\" --dotsize=0.7 --gs1 --mask=0"
<< "" << "" << "" << "";
QTest::newRow("BARCODE_DPD") << true << 0.0f << ""
<< BARCODE_DPD << UNICODE_MODE // symbology-inputMode
<< "1234567890123456789012345678" << "" // text-primary
<< 0.0f << -1 << 0 << 0 << 4.5f << 24.0f << true << 0.8f // height-dotSize
<< 0.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.375 << 0 << 600 << 1 << 0 << 0 // xdimdp
<< "zint -b 96 --compliantheight -d '1234567890123456789012345678' --scalexdimdp=0.375,24"
<< "zint.exe -b 96 --compliantheight -d \"1234567890123456789012345678\" --scalexdimdp=0.375,24"
<< "" << "" << ""
<< "zint -b 96 --compliantheight -d '1234567890123456789012345678' --scalexdimdp=0.375mm,600dpi";
QTest::newRow("BARCODE_EANX") << true << 0.0f << ""
<< BARCODE_EANX << UNICODE_MODE // symbology-inputMode
<< "123456789012+12" << "" // text-primary
<< 0.0f << -1 << 8 << 0 << 1.0f << true << 0.8f // height-dotSize
<< 0.0f << -1 << 8 << 0 << 1.0f << 0.0f << true << 0.8f // height-dotSize
<< 0.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
<< "zint -b 13 --addongap=8 --compliantheight -d '123456789012+12' --guarddescent=0"
<< "zint.exe -b 13 --addongap=8 --compliantheight -d \"123456789012+12\" --guarddescent=0"
<< "" << "" << "";
<< "" << "" << "" << "";
QTest::newRow("BARCODE_GRIDMATRIX") << false << 0.0f << ""
<< BARCODE_GRIDMATRIX << UNICODE_MODE // symbology-inputMode
<< "Your Data Here!" << "" // text-primary
<< 0.0f << 1 << 5 << 0 << 0.5f << false << 0.8f // height-dotSize
<< 0.0f << 1 << 5 << 0 << 0.5f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << true << false << true << 270 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
<< "zint -b 142 -d 'Your Data Here!' --quietzones --rotate=270 --scale=0.5 --secure=1 --vers=5"
<< "zint.exe -b 142 -d \"Your Data Here!\" --quietzones --rotate=270 --scale=0.5 --secure=1 --vers=5"
<< "" << "" << "";
<< "" << "" << "" << "";
QTest::newRow("BARCODE_HANXIN") << false << 0.0f << ""
<< BARCODE_HANXIN << (UNICODE_MODE | ESCAPE_MODE) // symbology-inputMode
<< "éβÿ啊\\e\"'" << "" // text-primary
<< 30.0f << 2 << 5 << ((0 + 1) << 8) << 1.0f << false << 0.8f // height-dotSize
<< 30.0f << 2 << 5 << ((0 + 1) << 8) << 1.0f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 29 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
<< "zint -b 116 --eci=29 -d 'éβÿ啊\\e\"'\\''' --esc --mask=0 --secure=2 --vers=5"
<< "zint.exe -b 116 --eci=29 -d \"éβÿ啊\\e\\\"'\" --esc --mask=0 --secure=2 --vers=5"
<< "" << "" << "";
<< "" << "" << "" << "";
QTest::newRow("BARCODE_HIBC_DM") << false << 10.0f << ""
<< BARCODE_HIBC_DM << UNICODE_MODE // symbology-inputMode
<< "1234" << "" // text-primary
<< 0.0f << -1 << 8 << DM_DMRE << 1.0f << false << 0.7f // height-dotSize
<< 0.0f << -1 << 8 << DM_DMRE << 1.0f << 0.0f << false << 0.7f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << true << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
<< "zint -b 102 -d '1234' --dmre --vers=8"
<< "zint.exe -b 102 -d \"1234\" --dmre --vers=8"
<< "" << "" << "";
<< "" << "" << "" << "";
QTest::newRow("BARCODE_HIBC_PDF") << false << 0.0f << ""
<< BARCODE_HIBC_PDF << (DATA_MODE | HEIGHTPERROW_MODE) // symbology-inputMode
<< "TEXT" << "" // text-primary
<< 3.5f << 3 << 4 << 10 << 10.0f << false << 0.8f // height-dotSize
<< 3.5f << 3 << 4 << 10 << 10.0f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 2 << 1 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << true << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
<< "zint -b 106 --binary --cols=4 -d 'TEXT' --height=3.5 --heightperrow --quietzones"
" --rows=10 --scale=10 --secure=3 --structapp=1,2"
<< "zint.exe -b 106 --binary --cols=4 -d \"TEXT\" --height=3.5 --heightperrow --quietzones"
" --rows=10 --scale=10 --secure=3 --structapp=1,2"
<< "" << "" << "";
<< "" << "" << "" << "";
QTest::newRow("BARCODE_ITF14") << true << 0.0f << ""
<< BARCODE_ITF14 << UNICODE_MODE // symbology-inputMode
<< "9212320967145" << "" // text-primary
<< 30.0f << -1 << 0 << 0 << 1.0f << false << 0.8f // height-dotSize
<< 30.0f << -1 << 0 << 0 << 1.0f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
<< "zint -b 89 --compliantheight -d '9212320967145'"
<< "zint.exe -b 89 --compliantheight -d \"9212320967145\""
<< "" << "" << "";
<< "" << "" << "" << "";
QTest::newRow("BARCODE_ITF14") << true << 0.0f << ""
<< BARCODE_ITF14 << UNICODE_MODE // symbology-inputMode
<< "9212320967145" << "" // text-primary
<< 30.0f << -1 << 0 << 0 << 1.0f << false << 0.8f // height-dotSize
<< 30.0f << -1 << 0 << 0 << 1.0f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 1 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
<< "zint -b 89 --border=1 --compliantheight -d '9212320967145'"
<< "zint.exe -b 89 --border=1 --compliantheight -d \"9212320967145\""
<< "" << "" << "";
<< "" << "" << "" << "";
QTest::newRow("BARCODE_MAXICODE") << true << 0.0f << ""
<< BARCODE_MAXICODE << (UNICODE_MODE | ESCAPE_MODE) // symbology-inputMode
<< "152382802840001"
<< "1Z00004951\\GUPSN\\G06X610\\G159\\G1234567\\G1/1\\G\\GY\\G1 MAIN ST\\GTOWN\\GNY\\R\\E" // text-primary
<< 0.0f << -1 << (96 + 1) << 0 << 2.5f << false << 0.8f // height-dotSize
<< 0.0f << -1 << (96 + 1) << 0 << 2.5f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << true << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
<< "zint -b 57 -d '1Z00004951\\GUPSN\\G06X610\\G159\\G1234567\\G1/1\\G\\GY\\G1 MAIN ST\\GTOWN\\GNY\\R\\E'"
" --esc --primary='152382802840001' --quietzones --scale=2.5 --scmvv=96"
<< "zint.exe -b 57 -d \"1Z00004951\\GUPSN\\G06X610\\G159\\G1234567\\G1/1\\G\\GY\\G1 MAIN ST\\GTOWN\\GNY\\R\\E\""
" --esc --primary=\"152382802840001\" --quietzones --scale=2.5 --scmvv=96"
<< "" << "" << "";
<< "" << "" << "" << "";
QTest::newRow("BARCODE_MICROQR") << false << 0.0f << ""
<< BARCODE_MICROQR << UNICODE_MODE // symbology-inputMode
<< "1234" << "" // text-primary
<< 30.0f << 2 << 3 << (ZINT_FULL_MULTIBYTE | (3 + 1) << 8) << 1.0f << false << 0.8f // height-dotSize
<< 30.0f << 2 << 3 << (ZINT_FULL_MULTIBYTE | (3 + 1) << 8) << 1.0f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
<< "zint -b 97 -d '1234' --fullmultibyte --mask=3 --secure=2 --vers=3"
<< "zint.exe -b 97 -d \"1234\" --fullmultibyte --mask=3 --secure=2 --vers=3"
<< "" << "" << "";
<< "" << "" << "" << "";
QTest::newRow("BARCODE_QRCODE") << true << 0.0f << ""
<< BARCODE_QRCODE << GS1_MODE // symbology-inputMode
<< "(01)12" << "" // text-primary
<< 0.0f << 1 << 5 << (ZINT_FULL_MULTIBYTE | (0 + 1) << 8) << 1.0f << false << 0.8f // height-dotSize
<< 0.0f << 1 << 5 << (ZINT_FULL_MULTIBYTE | (0 + 1) << 8) << 1.0f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << true << false << true << 0 // showText-rotateAngle
<< 0 << true << true << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
<< "zint -b 58 -d '(01)12' --fullmultibyte --gs1 --gs1parens --gs1nocheck --mask=0 --quietzones"
" --secure=1 --vers=5"
<< "zint.exe -b 58 -d \"(01)12\" --fullmultibyte --gs1 --gs1parens --gs1nocheck --mask=0 --quietzones"
" --secure=1 --vers=5"
<< "" << "" << "";
<< "" << "" << "" << "";
QTest::newRow("BARCODE_RMQR") << true << 0.0f << ""
<< BARCODE_RMQR << UNICODE_MODE // symbology-inputMode
<< "" << "" // text-primary
<< 30.0f << -1 << 8 << 0 << 1.0f << false << 0.8f // height-dotSize
<< 30.0f << -1 << 8 << 0 << 1.0f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 180 // showText-rotateAngle
<< 20 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
<< "zint -b 145 --eci=20 -d 'テ' --rotate=180 --vers=8"
<< "zint.exe -b 145 --eci=20 -d \"\" --rotate=180 --vers=8"
<< "" << "" << "";
<< "" << "" << "" << "";
QTest::newRow("BARCODE_ULTRA") << false << 0.0f << ""
<< BARCODE_ULTRA << (GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE) // symbology-inputMode
<< "(01)1" << "" // text-primary
<< 0.0f << 6 << 2 << 0 << 1.0f << true << 0.8f // height-dotSize
<< 0.0f << 6 << 2 << 0 << 1.0f << 0.0f << true << 0.8f // height-dotSize
<< 5.0f << 2 << 1 << "4" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
<< "zint -b 144 -d '(01)1' --gs1 --gs1parens --gs1nocheck --secure=6 --structapp='1,2,4' --vers=2"
<< "zint.exe -b 144 -d \"(01)1\" --gs1 --gs1parens --gs1nocheck --secure=6 --structapp=\"1,2,4\" --vers=2"
<< "" << "" << "";
<< "" << "" << "" << "";
QTest::newRow("BARCODE_UPCE_CC") << true << 0.0f << "out.svg"
<< BARCODE_UPCE_CC << UNICODE_MODE // symbology-inputMode
<< "12345670+1234" << "[11]901222[99]ABCDE" // text-primary
<< 0.0f << -1 << 0 << 0 << 1.0f << false << 0.8f // height-dotSize
<< 0.0f << -1 << 0 << 0 << 1.0f << 0.0f << false << 0.8f // height-dotSize
<< 6.5f << 0 << 0 << "" << QColor(0xEF, 0x29, 0x29) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << (BOLD_TEXT | SMALL_TEXT) // cmyk-fontSetting
<< true << false << false << true << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_FAIL_ALL << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
<< "zint -b 136 --bold --compliantheight -d '[11]901222[99]ABCDE' --fg=EF2929 --guarddescent=6.5"
" --noquietzones -o 'out.svg' --primary='12345670+1234' --small --werror"
<< "zint.exe -b 136 --bold --compliantheight -d \"[11]901222[99]ABCDE\" --fg=EF2929 --guarddescent=6.5"
@ -847,19 +926,21 @@ private slots:
<< "zint -b UPCE_CC --bold --compliantheight -d '[11]901222[99]ABCDE' --fg=EF2929 --guarddescent=6.5"
" --noquietzones -o 'out.svg' --primary='12345670+1234' --small --werror"
<< "zint -b 136 --bold --compliantheight -d \"[11]901222[99]ABCDE\" --fg=EF2929 --guarddescent=6.5"
" --noquietzones -o \"out.svg\" --primary=\"12345670+1234\" --small --werror";
" --noquietzones -o \"out.svg\" --primary=\"12345670+1234\" --small --werror"
<< "";
QTest::newRow("BARCODE_VIN") << false << 2.0f << ""
<< BARCODE_VIN << UNICODE_MODE // symbology-inputMode
<< "12345678701234567" << "" // text-primary
<< 20.0f << -1 << 1 << 0 << 1.0f << false << 0.8f // height-dotSize
<< 20.0f << -1 << 1 << 0 << 1.0f << 0.0f << false << 0.8f // height-dotSize
<< 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor
<< false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting
<< true << false << false << false << true << 0 // showText-rotateAngle
<< 0 << false << false << false << WARN_DEFAULT << false // eci-debug
<< 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp
<< "zint -b 73 -d '12345678701234567' --height=20 --vers=1"
<< "zint.exe -b 73 -d \"12345678701234567\" --height=20 --vers=1"
<< "" << "" << "";
<< "" << "" << "" << "";
}
void getAsCLITest()
@ -881,6 +962,7 @@ private slots:
QFETCH(int, option2);
QFETCH(int, option3);
QFETCH(float, scale);
QFETCH(float, dpmm);
QFETCH(bool, dotty);
QFETCH(float, dotSize);
QFETCH(float, guardDescent);
@ -908,11 +990,19 @@ private slots:
QFETCH(int, warnLevel);
QFETCH(bool, debug);
QFETCH(double, xdimdp_xdim);
QFETCH(int, xdimdp_xdim_units);
QFETCH(int, xdimdp_resolution);
QFETCH(int, xdimdp_resolution_units);
QFETCH(int, xdimdp_filetype);
QFETCH(int, xdimdp_filetype_maxicode);
QFETCH(QString, expected_cmd);
QFETCH(QString, expected_win);
QFETCH(QString, expected_longOptOnly);
QFETCH(QString, expected_barcodeNames);
QFETCH(QString, expected_noexe);
QFETCH(QString, expected_xdimdp);
bc.setSymbol(symbology);
bc.setInputMode(inputMode);
@ -927,6 +1017,7 @@ private slots:
bc.setOption2(option2);
bc.setOption3(option3);
bc.setScale(scale);
bc.setDPMM(dpmm);
bc.setDotty(dotty);
bc.setDotSize(dotSize);
bc.setGuardDescent(guardDescent);
@ -977,6 +1068,16 @@ private slots:
autoHeight, heightPerRow, outfile);
QCOMPARE(cmd, expected_noexe);
}
if (xdimdp_xdim) {
struct Zint::QZintXdimDpVars vars = {
xdimdp_xdim, xdimdp_xdim_units, xdimdp_resolution, xdimdp_resolution_units, xdimdp_filetype,
xdimdp_filetype_maxicode, 1 /*set*/
};
cmd = bc.getAsCLI(false /*win*/, false /*longOptOnly*/, false /*barcodeNames*/, false /*noEXE*/,
autoHeight, heightPerRow, outfile, &vars);
QCOMPARE(cmd, expected_xdimdp);
}
}
void getAsCLISegsTest()
@ -1017,7 +1118,7 @@ private slots:
QCOMPARE(cmd, expected_win);
}
void qZintAndLibZintEqual_data()
void qZintAndLibZintEqualTest_data()
{
QTest::addColumn<int>("symbology");
QTest::addColumn<int>("rotateAngles");
@ -1030,7 +1131,7 @@ private slots:
QTest::newRow("symbology=BARCODE_QRCODE rotateAngles=270 text=Hello%20World") << BARCODE_QRCODE << 270 << "Hello%20World";
}
void qZintAndLibZintEqual()
void qZintAndLibZintEqualTest()
{
QFETCH(int, symbology);
QFETCH(int, rotateAngles);
@ -1064,6 +1165,25 @@ private slots:
QFile::remove(fileNameForLibZint);
QFile::remove(fileNameForQZint);
}
void barcodeNameTest_data()
{
QTest::addColumn<int>("symbology");
QTest::addColumn<QString>("expected_name");
QTest::newRow("BARCODE_MAXICODE") << BARCODE_MAXICODE << "BARCODE_MAXICODE";
QTest::newRow("BARCODE_CODE128AB") << BARCODE_CODE128AB << "BARCODE_CODE128AB";
QTest::newRow("BARCODE_CODE128B") << BARCODE_CODE128B << "BARCODE_CODE128AB";
}
void barcodeNameTest()
{
QFETCH(int, symbology);
QFETCH(QString, expected_name);
QString name = Zint::QZint::barcodeName(symbology);
QCOMPARE(name, expected_name);
}
};
QTEST_MAIN(TestQZint)