mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Adjust vector border to place bottom border above text
This commit is contained in:
parent
ff332335ea
commit
3ed1b5692f
@ -826,7 +826,7 @@ int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_type) {
|
||||
}
|
||||
vector_plot_add_rect(symbol, rectangle, &last_rectangle);
|
||||
// Bottom
|
||||
rectangle = vector_plot_create_rect(0.0, vector->height - symbol->border_width, vector->width, symbol->border_width);
|
||||
rectangle = vector_plot_create_rect(0.0, vector->height - symbol->border_width - text_offset, vector->width, symbol->border_width);
|
||||
if (symbol->symbology == BARCODE_CODABLOCKF) {
|
||||
rectangle->x = xoffset;
|
||||
rectangle->width -= (2.0 * xoffset);
|
||||
@ -835,10 +835,10 @@ int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_type) {
|
||||
}
|
||||
if (symbol->output_options & BARCODE_BOX) {
|
||||
// Left
|
||||
rectangle = vector_plot_create_rect(0.0, 0.0, symbol->border_width, vector->height);
|
||||
rectangle = vector_plot_create_rect(0.0, 0.0, symbol->border_width, vector->height - text_offset);
|
||||
vector_plot_add_rect(symbol, rectangle, &last_rectangle);
|
||||
// Right
|
||||
rectangle = vector_plot_create_rect(vector->width - symbol->border_width, 0.0, symbol->border_width, vector->height);
|
||||
rectangle = vector_plot_create_rect(vector->width - symbol->border_width, 0.0, symbol->border_width, vector->height - text_offset);
|
||||
vector_plot_add_rect(symbol, rectangle, &last_rectangle);
|
||||
}
|
||||
|
||||
|
@ -17,12 +17,13 @@
|
||||
|
||||
#include "qzint.h"
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <QFontMetrics>
|
||||
|
||||
namespace Zint {
|
||||
static const char* fontstyle = "Arial";
|
||||
static const int fontPixelSizeSmall = 6;
|
||||
static const int fontPixelSizeLarge = 8;
|
||||
static const int fontPixelSizeSmall = 8;
|
||||
static const int fontPixelSizeLarge = 12;
|
||||
|
||||
QZint::QZint() {
|
||||
m_symbol = BARCODE_CODE128;
|
||||
@ -277,7 +278,6 @@ namespace Zint {
|
||||
struct zint_vector_hexagon *hex;
|
||||
struct zint_vector_circle *circle;
|
||||
struct zint_vector_string *string;
|
||||
qreal ax, ay, bx, by, cx, cy, dx, dy, ex, ey, fx, fy;
|
||||
qreal radius;
|
||||
|
||||
encode();
|
||||
@ -306,12 +306,13 @@ namespace Zint {
|
||||
qreal gheight = m_zintSymbol->vector->height;
|
||||
|
||||
if (paintRect.width() / gwidth < paintRect.height() / gheight) {
|
||||
scale = (qreal) paintRect.width() / gwidth;
|
||||
ytr += (qreal) (paintRect.height() - gheight * scale) / 2;
|
||||
scale = (qreal) floor(paintRect.width() / gwidth);
|
||||
} else {
|
||||
scale = (qreal) paintRect.height() / gheight;
|
||||
xtr += (qreal) (paintRect.width() - gwidth * scale) / 2;
|
||||
scale = (qreal) floor(paintRect.height() / gheight);
|
||||
}
|
||||
|
||||
xtr += (qreal) (paintRect.width() - gwidth * scale) / 2.0;
|
||||
ytr += (qreal) (paintRect.height() - gheight * scale) / 2.0;
|
||||
|
||||
painter.setBackground(QBrush(m_bgColor));
|
||||
painter.fillRect(paintRect, QBrush(m_bgColor));
|
||||
@ -325,6 +326,7 @@ namespace Zint {
|
||||
QPen p;
|
||||
|
||||
p.setWidth(1);
|
||||
p.setColor(m_fgColor);
|
||||
painter.setPen(p);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
@ -340,27 +342,14 @@ namespace Zint {
|
||||
while (hex) {
|
||||
radius = hex->diameter / 2.0;
|
||||
|
||||
ay = hex->y + (1.0 * radius);
|
||||
by = hex->y + (0.5 * radius);
|
||||
cy = hex->y - (0.5 * radius);
|
||||
dy = hex->y - (1.0 * radius);
|
||||
ey = hex->y - (0.5 * radius);
|
||||
fy = hex->y + (0.5 * radius);
|
||||
ax = hex->x;
|
||||
bx = hex->x + (0.86 * radius);
|
||||
cx = hex->x + (0.86 * radius);
|
||||
dx = hex->x;
|
||||
ex = hex->x - (0.86 * radius);
|
||||
fx = hex->x - (0.86 * radius);
|
||||
|
||||
QPainterPath pt;
|
||||
pt.moveTo(ax, ay);
|
||||
pt.lineTo(bx, by);
|
||||
pt.lineTo(cx, cy);
|
||||
pt.lineTo(dx, dy);
|
||||
pt.lineTo(ex, ey);
|
||||
pt.lineTo(fx, fy);
|
||||
pt.lineTo(ax, ay);
|
||||
pt.moveTo(hex->x, hex->y + (1.0 * radius));
|
||||
pt.lineTo(hex->x + (0.86 * radius), hex->y + (0.5 * radius));
|
||||
pt.lineTo(hex->x + (0.86 * radius), hex->y - (0.5 * radius));
|
||||
pt.lineTo(hex->x, hex->y - (1.0 * radius));
|
||||
pt.lineTo(hex->x - (0.86 * radius), hex->y - (0.5 * radius));
|
||||
pt.lineTo(hex->x - (0.86 * radius), hex->y + (0.5 * radius));
|
||||
pt.lineTo(hex->x, hex->y + (1.0 * radius));
|
||||
painter.fillPath(pt, QBrush(m_fgColor));
|
||||
|
||||
hex = hex->next;
|
||||
|
Loading…
Reference in New Issue
Block a user