mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding certain trailing bytes libzint: fix some confusing error messages introduced by segment stuff general: new escape chars \U, \d and \o backend_qt: fudge rendering of border rectangles due to scaling/translation rounding errors TODO: better fudge GUI: foreground/background colours -> text boxes and icon buttons, add swap button, independently movable picker (NULL parent), preview colour changes, preview Data Window changes, add clear data (del) buttons, add zap button and Factory Reset menu option, various other fixes libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers CMake: add find package QtSvg, remove QtXml manual: split symbology and general specs and sort, move DAFT to 4-state, UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info, various other fiddlings man page: options or -> |, expand MSI Plessey check digit options README.linux: add packages info license: add SPDX-License-Identifier to touched files
This commit is contained in:
@ -14,6 +14,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/>. *
|
||||
***************************************************************************/
|
||||
/* SPDX-License-Identifier: GPL-3.0-or-later */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if _MSC_VER >= 1900 /* MSVC 2015 */
|
||||
@ -60,6 +61,43 @@ namespace Zint {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Helper to calculate max right and bottom of elements for fudging render() */
|
||||
static void getMaxRectsRightBottom(struct zint_vector *vector, int &maxRight, int &maxBottom) {
|
||||
struct zint_vector_rect *rect;
|
||||
struct zint_vector_hexagon *hex;
|
||||
struct zint_vector_circle *circle;
|
||||
|
||||
maxRight = maxBottom = -1;
|
||||
|
||||
for (rect = vector->rectangles; rect; rect = rect->next) {
|
||||
if (rect->x + rect->width > maxRight) {
|
||||
maxRight = rect->x + rect->width;
|
||||
}
|
||||
if (rect->y + rect->height > maxBottom) {
|
||||
maxBottom = rect->y + rect->height;
|
||||
}
|
||||
}
|
||||
|
||||
for (hex = vector->hexagons; hex; hex = hex->next) {
|
||||
if (hex->x + hex->diameter > maxRight) {
|
||||
maxRight = hex->x + hex->diameter;
|
||||
}
|
||||
if (hex->y + hex->diameter > maxBottom) {
|
||||
maxBottom = hex->y + hex->diameter;
|
||||
}
|
||||
}
|
||||
|
||||
for (circle = vector->circles; circle; circle = circle->next) {
|
||||
if (circle->x + circle->diameter + circle->width > maxRight) {
|
||||
maxRight = circle->x + circle->diameter + circle->width;
|
||||
}
|
||||
if (circle->y + circle->diameter + circle->width > maxBottom) {
|
||||
maxBottom = circle->y + circle->diameter + circle->width;
|
||||
}
|
||||
}
|
||||
// TODO: Strings?
|
||||
}
|
||||
|
||||
/* Segment constructors */
|
||||
QZintSeg::QZintSeg() : m_eci(0) {}
|
||||
QZintSeg::QZintSeg(const QString& text, const int ECIIndex) : m_text(text), m_eci(ECIIndexToECI(ECIIndex)) {}
|
||||
@ -773,6 +811,10 @@ namespace Zint {
|
||||
// Plot rectangles
|
||||
rect = m_zintSymbol->vector->rectangles;
|
||||
if (rect) {
|
||||
int maxRight = -1, maxBottom = -1; // Used for fudging below
|
||||
if (borderWidth() && (borderType() & (BARCODE_BIND | BARCODE_BOX))) {
|
||||
getMaxRectsRightBottom(m_zintSymbol->vector, maxRight, maxBottom);
|
||||
}
|
||||
QBrush brush(Qt::SolidPattern);
|
||||
while (rect) {
|
||||
if (rect->colour == -1) {
|
||||
@ -780,7 +822,10 @@ namespace Zint {
|
||||
} else {
|
||||
brush.setColor(colourToQtColor(rect->colour));
|
||||
}
|
||||
painter.fillRect(QRectF(rect->x, rect->y, rect->width, rect->height), brush);
|
||||
// Allow for rounding errors on translation/scaling TODO: proper calc
|
||||
float fudgeW = rect->x + rect->width == maxRight ? 0.1f : 0.0f;
|
||||
float fudgeH = rect->y + rect->height == maxBottom ? 0.1f : 0.0f;
|
||||
painter.fillRect(QRectF(rect->x, rect->y, rect->width + fudgeW, rect->height + fudgeH), brush);
|
||||
rect = rect->next;
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,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/>. *
|
||||
***************************************************************************/
|
||||
/* SPDX-License-Identifier: GPL-3.0-or-later */
|
||||
|
||||
#ifndef QZINT_H
|
||||
#define QZINT_H
|
||||
|
@ -12,6 +12,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/>. *
|
||||
***************************************************************************/
|
||||
/* SPDX-License-Identifier: GPL-3.0-or-later */
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
#include "../qzint.h" /* Don't use <qzint.h> in case it's been changed */
|
||||
@ -372,7 +373,7 @@ private slots:
|
||||
|
||||
QTest::newRow("BARCODE_QRCODE") << BARCODE_QRCODE << "1234" << 0 << "" << 21 << 21;
|
||||
if (!m_skipIfFontUsed) {
|
||||
QTest::newRow("BARCODE_QRCODE no text") << BARCODE_QRCODE << "" << ZINT_ERROR_INVALID_DATA << "Error 773: Input segment 0 length zero" << 0 << 0;
|
||||
QTest::newRow("BARCODE_QRCODE no text") << BARCODE_QRCODE << "" << ZINT_ERROR_INVALID_DATA << "Error 778: No input data (segment 0 empty)" << 0 << 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user