- Add new symbology BARCODE_UPU_S10

- PZN: allow check digit to be given; add space after hyphen in
  HRT; PZN7 option
- backend_qt: add `encodedHeight()` read-only
This commit is contained in:
gitlost
2022-12-09 14:51:26 +00:00
parent 25dacb2949
commit 53769c6ed1
35 changed files with 1314 additions and 852 deletions

View File

@ -122,7 +122,7 @@ namespace Zint {
m_gs1parens(false), m_gs1nocheck(false),
m_reader_init(false),
m_warn_level(WARN_DEFAULT), m_debug(false),
m_encodedWidth(0), m_encodedRows(0),
m_encodedWidth(0), m_encodedRows(0), m_encodedHeight(0.0f),
m_vectorWidth(0.0f), m_vectorHeight(0.0f),
m_error(0),
target_size_horiz(0), target_size_vert(0) // Legacy
@ -231,12 +231,13 @@ namespace Zint {
m_vwhitespace = m_zintSymbol->whitespace_height;
m_encodedWidth = m_zintSymbol->width;
m_encodedRows = m_zintSymbol->rows;
m_encodedHeight = m_zintSymbol->height;
m_vectorWidth = m_zintSymbol->vector->width;
m_vectorHeight = m_zintSymbol->vector->height;
emit encoded();
} else {
m_encodedWidth = m_encodedRows = 0;
m_vectorWidth = m_vectorHeight = 0.0f;
m_encodedHeight = m_vectorWidth = m_vectorHeight = 0.0f;
emit errored();
}
}
@ -655,6 +656,13 @@ namespace Zint {
return m_encodedRows;
}
float QZint::encodedHeight() const { // Read-only, in X-dimensions
if (m_symbol == BARCODE_MAXICODE) { // Maxicode encoded height is meaningless, so return fixed value
return 33 * 0.866f; // √3 / 2
}
return m_encodedHeight;
}
float QZint::vectorWidth() const { // Read-only, scaled width
return m_vectorWidth;
}
@ -783,7 +791,7 @@ namespace Zint {
if (m_error >= ZINT_ERROR) {
m_lastError = m_zintSymbol->errtxt;
m_encodedWidth = m_encodedRows = 0;
m_vectorWidth = m_vectorHeight = 0.0f;
m_encodedHeight = m_vectorWidth = m_vectorHeight = 0.0f;
emit errored();
return false;
}

View File

@ -212,6 +212,7 @@ public:
/* 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 encodedHeight() const; // Read-only, in X-dimensions
float vectorWidth() const; // Read-only, scaled width
float vectorHeight() const; // Read-only, scaled height
@ -370,6 +371,7 @@ private:
bool m_debug;
int m_encodedWidth;
int m_encodedRows;
float m_encodedHeight;
float m_vectorWidth;
float m_vectorHeight;
QString m_lastError;

View File

@ -264,6 +264,7 @@ private slots:
QCOMPARE(bc.encodedWidth(), 0); // Read-only
QCOMPARE(bc.encodedRows(), 0); // Read-only
QCOMPARE(bc.encodedHeight(), 0.0f); // Read-only
QCOMPARE(bc.vectorWidth(), 0.0f); // Read-only
QCOMPARE(bc.vectorHeight(), 0.0f); // Read-only
@ -376,17 +377,24 @@ private slots:
{
QTest::addColumn<int>("symbology");
QTest::addColumn<QString>("text");
QTest::addColumn<float>("scale");
QTest::addColumn<int>("getError");
QTest::addColumn<QString>("error_message");
QTest::addColumn<int>("encodedWidth");
QTest::addColumn<int>("encodedRows");
QTest::addColumn<float>("encodedHeight");
QTest::addColumn<float>("vectorWidth");
QTest::addColumn<float>("vectorHeight");
QTest::newRow("BARCODE_QRCODE") << BARCODE_QRCODE << "1234" << 0 << "" << 21 << 21 << 42.0f << 42.0f;
QTest::newRow("BARCODE_CODE128") << BARCODE_CODE128 << "1234" << 0.0f << 0 << "" << 57 << 1 << 50.0f << 114.0f << 100.0f;
QTest::newRow("BARCODE_CODE128") << BARCODE_CODE128 << "1234" << 2.0f << 0 << "" << 57 << 1 << 50.0f << 228.0f << 200.0f;
QTest::newRow("BARCODE_QRCODE") << BARCODE_QRCODE << "1234" << 0.0f << 0 << "" << 21 << 21 << 21.0f << 42.0f << 42.0f;
QTest::newRow("BARCODE_QRCODE") << BARCODE_QRCODE << "1234" << 1.5f << 0 << "" << 21 << 21 << 21.0f << 63.0f << 63.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 << 0.0f << 0.0f;
QTest::newRow("BARCODE_QRCODE no text") << BARCODE_QRCODE << "" << 0.0f << ZINT_ERROR_INVALID_DATA << "Error 778: No input data (segment 0 empty)" << 0 << 0 << 0.0f << 0.0f << 0.0f;
}
QTest::newRow("BARCODE_MAXICODE") << BARCODE_MAXICODE << "1234" << 0.0f << 0 << "" << 30 << 33 << 28.578f << 60.0f << 57.7334f;
QTest::newRow("BARCODE_MAXICODE") << BARCODE_MAXICODE << "1234" << 2.0f << 0 << "" << 30 << 33 << 28.578f << 120.0f << 115.467f;
}
void renderTest()
@ -406,15 +414,21 @@ private slots:
QFETCH(int, symbology);
QFETCH(QString, text);
QFETCH(float, scale);
QFETCH(int, getError);
QFETCH(QString, error_message);
QFETCH(int, encodedWidth);
QFETCH(int, encodedRows);
QFETCH(float, encodedHeight);
QFETCH(float, vectorWidth);
QFETCH(float, vectorHeight);
bc.setSymbol(symbology);
bc.setText(text);
bc.setShowText(false);
if (scale) {
bc.setScale(scale);
}
bRet = painter.begin(&paintDevice);
QCOMPARE(bRet, true);
@ -430,6 +444,7 @@ private slots:
QCOMPARE(bc.hasErrors(), getError != 0);
QCOMPARE(bc.encodedWidth(), encodedWidth);
QCOMPARE(bc.encodedRows(), encodedRows);
QCOMPARE(bc.encodedHeight(), encodedHeight);
QCOMPARE(bc.vectorWidth(), vectorWidth);
QCOMPARE(bc.vectorHeight(), vectorHeight);