mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Add size restrictions for some barcode types
No longer allows symbols of size less than 2mm high or 2mm wide Enforces correct sizing for Australia Post, Intelligent Mail, Royal Mail 4-State and KIX Code Adjusts ascender/tracker/descender proportions on all 4-state codes to revised 3/2/3 standards Enforces normative sizing for UPC and EAN Enforces minimum sizing for Codabar and Code 49 Tidies up the code a bit so that all of the above makes some sense
This commit is contained in:
parent
0f81737e2a
commit
2300a76a07
@ -236,9 +236,9 @@ int australia_post(struct zint_symbol *symbol, unsigned char source[], int lengt
|
|||||||
writer += 2;
|
writer += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
symbol->row_height[0] = 4;
|
symbol->row_height[0] = 3;
|
||||||
symbol->row_height[1] = 2;
|
symbol->row_height[1] = 2;
|
||||||
symbol->row_height[2] = 4;
|
symbol->row_height[2] = 3;
|
||||||
|
|
||||||
symbol->rows = 3;
|
symbol->rows = 3;
|
||||||
symbol->width = writer - 1;
|
symbol->width = writer - 1;
|
||||||
|
@ -690,9 +690,9 @@ int imail(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||||||
read += 2;
|
read += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
symbol->row_height[0] = 2;
|
symbol->row_height[0] = 3;
|
||||||
symbol->row_height[1] = 2;
|
symbol->row_height[1] = 2;
|
||||||
symbol->row_height[2] = 2;
|
symbol->row_height[2] = 3;
|
||||||
|
|
||||||
symbol->rows = 3;
|
symbol->rows = 3;
|
||||||
symbol->width = read - 1;
|
symbol->width = read - 1;
|
||||||
|
@ -349,9 +349,9 @@ int royal_plot(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||||||
writer += 2;
|
writer += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
symbol->row_height[0] = 4;
|
symbol->row_height[0] = 3;
|
||||||
symbol->row_height[1] = 2;
|
symbol->row_height[1] = 2;
|
||||||
symbol->row_height[2] = 4;
|
symbol->row_height[2] = 3;
|
||||||
symbol->rows = 3;
|
symbol->rows = 3;
|
||||||
symbol->width = writer - 1;
|
symbol->width = writer - 1;
|
||||||
|
|
||||||
@ -409,9 +409,9 @@ int kix_code(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||||||
writer += 2;
|
writer += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
symbol->row_height[0] = 4;
|
symbol->row_height[0] = 3;
|
||||||
symbol->row_height[1] = 2;
|
symbol->row_height[1] = 2;
|
||||||
symbol->row_height[2] = 4;
|
symbol->row_height[2] = 3;
|
||||||
symbol->rows = 3;
|
symbol->rows = 3;
|
||||||
symbol->width = writer - 1;
|
symbol->width = writer - 1;
|
||||||
|
|
||||||
@ -463,9 +463,9 @@ int daft_code(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||||||
writer += 2;
|
writer += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
symbol->row_height[0] = 4;
|
symbol->row_height[0] = 3;
|
||||||
symbol->row_height[1] = 2;
|
symbol->row_height[1] = 2;
|
||||||
symbol->row_height[2] = 4;
|
symbol->row_height[2] = 3;
|
||||||
symbol->rows = 3;
|
symbol->rows = 3;
|
||||||
symbol->width = writer - 1;
|
symbol->width = writer - 1;
|
||||||
|
|
||||||
@ -593,9 +593,9 @@ int japan_post(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||||||
writer += 2;
|
writer += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
symbol->row_height[0] = 2;
|
symbol->row_height[0] = 3;
|
||||||
symbol->row_height[1] = 2;
|
symbol->row_height[1] = 2;
|
||||||
symbol->row_height[2] = 2;
|
symbol->row_height[2] = 3;
|
||||||
symbol->rows = 3;
|
symbol->rows = 3;
|
||||||
symbol->width = writer - 1;
|
symbol->width = writer - 1;
|
||||||
|
|
||||||
|
380
backend/render.c
380
backend/render.c
@ -31,6 +31,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
#define GL_CONST 2.8346
|
||||||
|
|
||||||
struct zint_render_line *render_plot_create_line(float x, float y, float width, float length);
|
struct zint_render_line *render_plot_create_line(float x, float y, float width, float length);
|
||||||
int render_plot_add_line(struct zint_symbol *symbol, struct zint_render_line *line, struct zint_render_line **last_line);
|
int render_plot_add_line(struct zint_symbol *symbol, struct zint_render_line *line, struct zint_render_line **last_line);
|
||||||
struct zint_render_ring *render_plot_create_ring(float x, float y, float radius, float line_width);
|
struct zint_render_ring *render_plot_create_ring(float x, float y, float radius, float line_width);
|
||||||
@ -51,17 +53,18 @@ int render_plot(struct zint_symbol *symbol, float width, float height)
|
|||||||
int i, r, block_width, latch, this_row;
|
int i, r, block_width, latch, this_row;
|
||||||
float textpos, textwidth, large_bar_height, preset_height, row_height, row_posn = 0.0;
|
float textpos, textwidth, large_bar_height, preset_height, row_height, row_posn = 0.0;
|
||||||
// int error_number = 0;
|
// int error_number = 0;
|
||||||
int textoffset, textheight, xoffset, yoffset, textdone, main_width, addon_width;
|
int text_offset, text_height, xoffset, yoffset, textdone, main_symbol_width_x, addon_width_x;
|
||||||
char addon[6], textpart[10];
|
char addon[6], textpart[10];
|
||||||
int large_bar_count, comp_offset;
|
int large_bar_count, symbol_lead_in, total_symbol_width_x, total_area_width_x;
|
||||||
float addon_text_posn;
|
float addon_text_posn;
|
||||||
float default_text_posn;
|
float default_text_posn;
|
||||||
float scaler;
|
float scaler;
|
||||||
const char *locale = NULL;
|
const char *locale = NULL;
|
||||||
int hide_text = 0;
|
int hide_text = 0;
|
||||||
float required_aspect;
|
float required_aspect;
|
||||||
float symbol_aspect;
|
float symbol_aspect = 1;
|
||||||
float x_spacer, y_spacer;
|
float x_dimension;
|
||||||
|
int upceanflag = 0;
|
||||||
|
|
||||||
// Allocate memory for the rendered version
|
// Allocate memory for the rendered version
|
||||||
render = symbol->rendered = malloc(sizeof(struct zint_render));
|
render = symbol->rendered = malloc(sizeof(struct zint_render));
|
||||||
@ -75,11 +78,11 @@ int render_plot(struct zint_symbol *symbol, float width, float height)
|
|||||||
row_height = 0;
|
row_height = 0;
|
||||||
textdone = 0;
|
textdone = 0;
|
||||||
textpos = 0.0;
|
textpos = 0.0;
|
||||||
main_width = symbol->width;
|
main_symbol_width_x = symbol->width;
|
||||||
strcpy(addon, "");
|
strcpy(addon, "");
|
||||||
comp_offset = 0;
|
symbol_lead_in = 0;
|
||||||
addon_text_posn = 0.0;
|
addon_text_posn = 0.0;
|
||||||
addon_width = 0;
|
addon_width_x = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Determine if there will be any addon texts and text height
|
* Determine if there will be any addon texts and text height
|
||||||
@ -102,10 +105,10 @@ int render_plot(struct zint_symbol *symbol, float width, float height)
|
|||||||
|
|
||||||
if((!symbol->show_hrt) || (ustrlen(symbol->text) == 0)) {
|
if((!symbol->show_hrt) || (ustrlen(symbol->text) == 0)) {
|
||||||
hide_text = 1;
|
hide_text = 1;
|
||||||
textheight = textoffset = 0.0;
|
text_height = text_offset = 0.0;
|
||||||
} else {
|
} else {
|
||||||
textheight = 9.0;
|
text_height = 9.0;
|
||||||
textoffset = 2.0;
|
text_offset = 2.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -114,8 +117,8 @@ int render_plot(struct zint_symbol *symbol, float width, float height)
|
|||||||
* borders or white space to add.
|
* borders or white space to add.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
while(!(module_is_set(symbol, symbol->rows - 1, comp_offset))) {
|
while(!(module_is_set(symbol, symbol->rows - 1, symbol_lead_in))) {
|
||||||
comp_offset++;
|
symbol_lead_in++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Certain symbols need whitespace otherwise characters get chopped off the sides */
|
/* Certain symbols need whitespace otherwise characters get chopped off the sides */
|
||||||
@ -128,65 +131,74 @@ int render_plot(struct zint_symbol *symbol, float width, float height)
|
|||||||
if(symbol->whitespace_width == 0) {
|
if(symbol->whitespace_width == 0) {
|
||||||
symbol->whitespace_width = 10;
|
symbol->whitespace_width = 10;
|
||||||
}
|
}
|
||||||
main_width = 96 + comp_offset;
|
main_symbol_width_x = 96 + symbol_lead_in;
|
||||||
|
upceanflag = 13;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
main_width = 22 + comp_offset;
|
main_symbol_width_x = 22 + symbol_lead_in;
|
||||||
|
upceanflag = 2;
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
main_width = 49 + comp_offset;
|
main_symbol_width_x = 49 + symbol_lead_in;
|
||||||
|
upceanflag = 5;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
main_width = 68 + comp_offset;
|
main_symbol_width_x = 68 + symbol_lead_in;
|
||||||
|
upceanflag = 8;
|
||||||
}
|
}
|
||||||
switch(ustrlen(symbol->text)) {
|
switch(ustrlen(symbol->text)) {
|
||||||
case 11:
|
case 11:
|
||||||
case 16:
|
case 16:
|
||||||
/* EAN-2 add-on */
|
/* EAN-2 add-on */
|
||||||
addon_width = 31;
|
addon_width_x = 31;
|
||||||
break;
|
break;
|
||||||
case 14:
|
case 14:
|
||||||
case 19:
|
case 19:
|
||||||
/* EAN-5 add-on */
|
/* EAN-5 add-on */
|
||||||
addon_width = 58;
|
addon_width_x = 58;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((symbol->symbology == BARCODE_UPCA) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCA_CC)) {
|
if (((symbol->symbology == BARCODE_UPCA) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCA_CC)) {
|
||||||
if(symbol->whitespace_width == 0) {
|
upceanflag = 12;
|
||||||
|
if(symbol->whitespace_width < 10) {
|
||||||
symbol->whitespace_width = 10;
|
symbol->whitespace_width = 10;
|
||||||
main_width = 96 + comp_offset;
|
main_symbol_width_x = 96 + symbol_lead_in;
|
||||||
}
|
}
|
||||||
switch(ustrlen(symbol->text)) {
|
switch(ustrlen(symbol->text)) {
|
||||||
case 15:
|
case 15:
|
||||||
/* EAN-2 add-on */
|
/* EAN-2 add-on */
|
||||||
addon_width = 31;
|
addon_width_x = 31;
|
||||||
break;
|
break;
|
||||||
case 18:
|
case 18:
|
||||||
/* EAN-5 add-on */
|
/* EAN-5 add-on */
|
||||||
addon_width = 58;
|
addon_width_x = 58;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((symbol->symbology == BARCODE_UPCE) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCE_CC)) {
|
if (((symbol->symbology == BARCODE_UPCE) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCE_CC)) {
|
||||||
|
upceanflag = 6;
|
||||||
if(symbol->whitespace_width == 0) {
|
if(symbol->whitespace_width == 0) {
|
||||||
symbol->whitespace_width = 10;
|
symbol->whitespace_width = 10;
|
||||||
main_width = 51 + comp_offset;
|
main_symbol_width_x = 51 + symbol_lead_in;
|
||||||
}
|
}
|
||||||
switch(ustrlen(symbol->text)) {
|
switch(ustrlen(symbol->text)) {
|
||||||
case 11:
|
case 11:
|
||||||
/* EAN-2 add-on */
|
/* EAN-2 add-on */
|
||||||
addon_width = 31;
|
addon_width_x = 31;
|
||||||
break;
|
break;
|
||||||
case 14:
|
case 14:
|
||||||
/* EAN-5 add-on */
|
/* EAN-5 add-on */
|
||||||
addon_width = 58;
|
addon_width_x = 58;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
total_symbol_width_x = main_symbol_width_x + addon_width_x;
|
||||||
|
total_area_width_x = total_symbol_width_x + (2 * (symbol->border_width + symbol->whitespace_width));
|
||||||
|
|
||||||
xoffset = symbol->border_width + symbol->whitespace_width;
|
xoffset = symbol->border_width + symbol->whitespace_width;
|
||||||
yoffset = symbol->border_width;
|
yoffset = symbol->border_width;
|
||||||
|
|
||||||
@ -202,42 +214,111 @@ int render_plot(struct zint_symbol *symbol, float width, float height)
|
|||||||
|
|
||||||
if (large_bar_count == 0) {
|
if (large_bar_count == 0) {
|
||||||
required_aspect = width / height;
|
required_aspect = width / height;
|
||||||
symbol_aspect = (main_width + addon_width + (2 * xoffset)) / (preset_height + (2 * yoffset) + textoffset + textheight);
|
symbol_aspect = (total_symbol_width_x + (2 * xoffset)) / (preset_height + (2 * yoffset) + text_offset + text_height);
|
||||||
symbol->height = preset_height;
|
symbol->height = preset_height;
|
||||||
if (required_aspect > symbol_aspect) {
|
if (required_aspect > symbol_aspect) {
|
||||||
/* horizontal padding is required */
|
/* the area is too wide */
|
||||||
scaler = height / (preset_height + (2 * yoffset) + textoffset + textheight);
|
scaler = height / (preset_height + (2 * yoffset) + text_offset + text_height);
|
||||||
x_spacer = ((width / scaler) - (main_width + addon_width + (2 * xoffset))) / 2;
|
render->width = symbol_aspect * height;
|
||||||
y_spacer = 0.0;
|
render->height = height;
|
||||||
} else {
|
} else {
|
||||||
/* vertical padding is required */
|
/* the area is too high */
|
||||||
scaler = width / (main_width + addon_width + (2 * xoffset));
|
scaler = width / (total_symbol_width_x + (2 * xoffset));
|
||||||
y_spacer = ((height / scaler) - (preset_height + (2 * yoffset) + textoffset + textheight)) / 2;
|
render->width = width;
|
||||||
x_spacer = 0.0;
|
render->height = width / symbol_aspect;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
scaler = width / (main_width + addon_width + (2 * xoffset));
|
scaler = width / (total_symbol_width_x + (2 * xoffset));
|
||||||
symbol->height = (height / scaler) - ((2 * yoffset) + textoffset + textheight);
|
symbol->height = (height / scaler) - ((2 * yoffset) + text_offset + text_height);
|
||||||
|
|
||||||
x_spacer = 0.0;
|
render->width = width;
|
||||||
y_spacer = 0.0;
|
render->height = height;
|
||||||
}
|
}
|
||||||
large_bar_height = (symbol->height - preset_height) / large_bar_count;
|
large_bar_height = (symbol->height - preset_height) / large_bar_count;
|
||||||
|
|
||||||
// Set initial render dimensions
|
|
||||||
render->width = width;
|
|
||||||
render->height = height;
|
|
||||||
|
|
||||||
if(((symbol->output_options & BARCODE_BOX) != 0) || ((symbol->output_options & BARCODE_BIND) != 0)) {
|
if(((symbol->output_options & BARCODE_BOX) != 0) || ((symbol->output_options & BARCODE_BIND) != 0)) {
|
||||||
default_text_posn = (symbol->height + textoffset + symbol->border_width + symbol->border_width) * scaler;
|
default_text_posn = (symbol->height + text_offset + symbol->border_width + symbol->border_width) * scaler;
|
||||||
} else {
|
} else {
|
||||||
default_text_posn = (symbol->height + textoffset + symbol->border_width) * scaler;
|
default_text_posn = (symbol->height + text_offset + symbol->border_width) * scaler;
|
||||||
|
}
|
||||||
|
|
||||||
|
x_dimension = render->width / total_area_width_x;
|
||||||
|
x_dimension /= GL_CONST;
|
||||||
|
|
||||||
|
/* Set minimum size of symbol */
|
||||||
|
/* Barcode must be at least 2mm high by 2mm across */
|
||||||
|
if(render->height < ((x_dimension * ((2 * symbol->border_width) + text_offset + text_height)) + 2.0) * GL_CONST) {
|
||||||
|
render->height = ((x_dimension * ((2 * symbol->border_width) + text_offset + text_height)) + 2.0) * GL_CONST;
|
||||||
|
}
|
||||||
|
if(render->width < (2.0 * GL_CONST)) {
|
||||||
|
render->width = (2.0 * GL_CONST);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(symbol->symbology == BARCODE_CODABAR) {
|
||||||
|
/* The minimum X-dimension of Codabar is 0.191mm. The minimum bar height is 5mm */
|
||||||
|
if(x_dimension < 0.191) {
|
||||||
|
render->width = 0.191 * GL_CONST * total_area_width_x;
|
||||||
|
}
|
||||||
|
if(render->height < ((x_dimension * ((2 * symbol->border_width) + text_offset + text_height)) + 5.0) * GL_CONST) {
|
||||||
|
render->height = ((x_dimension * ((2 * symbol->border_width) + text_offset + text_height)) + 5.0) * GL_CONST;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(symbol->symbology == BARCODE_CODE49) {
|
||||||
|
/* The minimum X-dimension of Code 49 is 0.191mm */
|
||||||
|
if(x_dimension < 0.191) {
|
||||||
|
render->width = 0.191 * GL_CONST * total_area_width_x;
|
||||||
|
render->height = render->width / symbol_aspect;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(upceanflag != 0) {
|
||||||
|
/* The X-dimension of UPC/EAN symbols is fixed at 0.330mm */
|
||||||
|
/* NOTE: This code will need adjustment before it correctly deals with composite symbols */
|
||||||
|
render->width = 0.330 * GL_CONST * total_area_width_x;
|
||||||
|
/* The height is also fixed */
|
||||||
|
switch (upceanflag) {
|
||||||
|
case 6:
|
||||||
|
case 12:
|
||||||
|
case 13:
|
||||||
|
/* UPC-A, UPC-E and EAN-13 */
|
||||||
|
/* Height of bars should be 22.85mm */
|
||||||
|
render->height = ((0.330 * ((2 * symbol->border_width) + text_offset + text_height)) + 22.85) * GL_CONST;
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
/* EAN-8 */
|
||||||
|
/* Height of bars should be 18.23mm */
|
||||||
|
render->height = ((0.330 * ((2 * symbol->border_width) + text_offset + text_height)) + 18.23) * GL_CONST;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* EAN-2 and EAN-5 */
|
||||||
|
/* Height of bars should be 21.10mm */
|
||||||
|
render->height = ((0.330 * ((2 * symbol->border_width) + text_offset + text_height)) + 21.10) * GL_CONST;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(symbol->symbology == BARCODE_ONECODE) {
|
||||||
|
/* The size of USPS Intelligent Mail barcode is fixed */
|
||||||
|
render->width = 0.508 * GL_CONST * total_area_width_x;
|
||||||
|
render->height = 4.064 * GL_CONST;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(((symbol->symbology == BARCODE_AUSPOST) || (symbol->symbology == BARCODE_AUSREPLY)) ||
|
||||||
|
((symbol->symbology == BARCODE_AUSROUTE) || (symbol->symbology == BARCODE_AUSREDIRECT))) {
|
||||||
|
/* Australia Post use the same sizes as USPS */
|
||||||
|
render->width = 0.508 * GL_CONST * total_area_width_x;
|
||||||
|
render->height = 4.064 * GL_CONST;
|
||||||
|
}
|
||||||
|
|
||||||
|
if((symbol->symbology == BARCODE_RM4SCC) || (symbol->symbology == BARCODE_KIX)) {
|
||||||
|
/* Royal Mail and KIX Code uses 22 bars per inch */
|
||||||
|
render->width = 0.577 * GL_CONST * total_area_width_x;
|
||||||
|
render->height = 5.22 * GL_CONST;
|
||||||
}
|
}
|
||||||
// SAMS ORIGINAL // default_text_posn = (symbol->height + textoffset + symbol->border_width) * scaler;
|
|
||||||
|
|
||||||
if(symbol->symbology == BARCODE_MAXICODE) {
|
if(symbol->symbology == BARCODE_MAXICODE) {
|
||||||
/* Maxicode is a fixed size */
|
/* Maxicode is a fixed size */
|
||||||
scaler = 2.8346; /* Converts from millimeters to the scale used by glabels */
|
scaler = GL_CONST; /* Converts from millimeters to the scale used by glabels */
|
||||||
render->width = 28.16 * scaler;
|
render->width = 28.16 * scaler;
|
||||||
render->height = 26.86 * scaler;
|
render->height = 26.86 * scaler;
|
||||||
|
|
||||||
@ -297,16 +378,16 @@ int render_plot(struct zint_symbol *symbol, float width, float height)
|
|||||||
do {
|
do {
|
||||||
block_width++;
|
block_width++;
|
||||||
} while (module_is_set(symbol, this_row, i + block_width) == module_is_set(symbol, this_row, i));
|
} while (module_is_set(symbol, this_row, i + block_width) == module_is_set(symbol, this_row, i));
|
||||||
if((addon_latch == 0) && (r == (symbol->rows - 1)) && (i > main_width)) {
|
if((addon_latch == 0) && (r == (symbol->rows - 1)) && (i > main_symbol_width_x)) {
|
||||||
addon_text_posn = row_posn * scaler;
|
addon_text_posn = row_posn * scaler;
|
||||||
addon_latch = 1;
|
addon_latch = 1;
|
||||||
}
|
}
|
||||||
if(latch == 1) {
|
if(latch == 1) {
|
||||||
/* a bar */
|
/* a bar */
|
||||||
if(addon_latch == 0) {
|
if(addon_latch == 0) {
|
||||||
line = render_plot_create_line((i + xoffset + x_spacer) * scaler, (row_posn + y_spacer) * scaler, block_width * scaler, row_height * scaler);
|
line = render_plot_create_line((i + xoffset) * scaler, (row_posn) * scaler, block_width * scaler, row_height * scaler);
|
||||||
} else {
|
} else {
|
||||||
line = render_plot_create_line((i + xoffset + x_spacer) * scaler, (row_posn + 10.0 + y_spacer) * scaler, block_width * scaler, (row_height - 5.0) * scaler);
|
line = render_plot_create_line((i + xoffset) * scaler, (row_posn + 10.0) * scaler, block_width * scaler, (row_height - 5.0) * scaler);
|
||||||
}
|
}
|
||||||
latch = 0;
|
latch = 0;
|
||||||
|
|
||||||
@ -324,115 +405,108 @@ int render_plot(struct zint_symbol *symbol, float width, float height)
|
|||||||
|
|
||||||
|
|
||||||
/* Add the text */
|
/* Add the text */
|
||||||
xoffset -= comp_offset;
|
xoffset -= symbol_lead_in;
|
||||||
row_posn = (row_posn + large_bar_height) * scaler;
|
row_posn = (row_posn + large_bar_height) * scaler;
|
||||||
|
|
||||||
if (!hide_text) {
|
if (!hide_text) {
|
||||||
if ((((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC)) ||
|
if(upceanflag == 8) {
|
||||||
(symbol->symbology == BARCODE_ISBNX)) {
|
/* guard bar extensions and text formatting for EAN-8 */
|
||||||
/* guard bar extensions and text formatting for EAN8 and EAN13 */
|
i = 0;
|
||||||
switch(ustrlen(symbol->text)) {
|
for (line = symbol->rendered->lines; line != NULL; line = line->next) {
|
||||||
case 8: /* EAN-8 */
|
switch(i) {
|
||||||
case 11:
|
case 0:
|
||||||
case 14:
|
case 1:
|
||||||
i = 0;
|
case 10:
|
||||||
for (line = symbol->rendered->lines; line != NULL; line = line->next) {
|
case 11:
|
||||||
switch(i) {
|
case 20:
|
||||||
case 0:
|
case 21:
|
||||||
case 1:
|
line->length += (5.0 * scaler);
|
||||||
case 10:
|
break;
|
||||||
case 11:
|
}
|
||||||
case 20:
|
i++;
|
||||||
case 21:
|
}
|
||||||
line->length += (5.0 * scaler);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(i = 0; i < 4; i++) {
|
|
||||||
textpart[i] = symbol->text[i];
|
|
||||||
}
|
|
||||||
textpart[4] = '\0';
|
|
||||||
textpos = 17;
|
|
||||||
textwidth = 4.0 * 8.5;
|
|
||||||
render_plot_add_string(symbol, (unsigned char *) textpart, (textpos + xoffset) * scaler, default_text_posn, 11.0 * scaler, textwidth * scaler, &last_string);
|
|
||||||
for(i = 0; i < 4; i++) {
|
|
||||||
textpart[i] = symbol->text[i + 4];
|
|
||||||
}
|
|
||||||
textpart[4] = '\0';
|
|
||||||
textpos = 50;
|
|
||||||
render_plot_add_string(symbol, (unsigned char *) textpart, (textpos + xoffset) * scaler, default_text_posn, 11.0 * scaler, textwidth * scaler, &last_string);
|
|
||||||
textdone = 1;
|
|
||||||
switch(strlen(addon)) {
|
|
||||||
case 2:
|
|
||||||
textpos = xoffset + 86;
|
|
||||||
textwidth = 2.0 * 8.5;
|
|
||||||
render_plot_add_string(symbol, (unsigned char *) addon, textpos * scaler, addon_text_posn * scaler, 11.0 * scaler, textwidth * scaler, &last_string);
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
textpos = xoffset + 100;
|
|
||||||
textwidth = 5.0 * 8.5;
|
|
||||||
render_plot_add_string(symbol, (unsigned char *) addon, textpos * scaler, addon_text_posn * scaler, 11.0 * scaler, textwidth * scaler, &last_string);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
for(i = 0; i < 4; i++) {
|
||||||
|
textpart[i] = symbol->text[i];
|
||||||
|
}
|
||||||
|
textpart[4] = '\0';
|
||||||
|
textpos = 17;
|
||||||
|
textwidth = 4.0 * 8.5;
|
||||||
|
render_plot_add_string(symbol, (unsigned char *) textpart, (textpos + xoffset) * scaler, default_text_posn, 11.0 * scaler, textwidth * scaler, &last_string);
|
||||||
|
for(i = 0; i < 4; i++) {
|
||||||
|
textpart[i] = symbol->text[i + 4];
|
||||||
|
}
|
||||||
|
textpart[4] = '\0';
|
||||||
|
textpos = 50;
|
||||||
|
render_plot_add_string(symbol, (unsigned char *) textpart, (textpos + xoffset) * scaler, default_text_posn, 11.0 * scaler, textwidth * scaler, &last_string);
|
||||||
|
textdone = 1;
|
||||||
|
switch(strlen(addon)) {
|
||||||
|
case 2:
|
||||||
|
textpos = xoffset + 86;
|
||||||
|
textwidth = 2.0 * 8.5;
|
||||||
|
render_plot_add_string(symbol, (unsigned char *) addon, textpos * scaler, addon_text_posn * scaler, 11.0 * scaler, textwidth * scaler, &last_string);
|
||||||
break;
|
break;
|
||||||
case 13: /* EAN 13 */
|
case 5:
|
||||||
case 16:
|
textpos = xoffset + 100;
|
||||||
case 19:
|
textwidth = 5.0 * 8.5;
|
||||||
i = 0;
|
render_plot_add_string(symbol, (unsigned char *) addon, textpos * scaler, addon_text_posn * scaler, 11.0 * scaler, textwidth * scaler, &last_string);
|
||||||
for (line = symbol->rendered->lines; line != NULL; line = line->next) {
|
break;
|
||||||
switch(i) {
|
}
|
||||||
case 0:
|
|
||||||
case 1:
|
|
||||||
case 14:
|
|
||||||
case 15:
|
|
||||||
case 28:
|
|
||||||
case 29:
|
|
||||||
line->length += (5.0 * scaler);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
textpart[0] = symbol->text[0];
|
}
|
||||||
textpart[1] = '\0';
|
|
||||||
textpos = -5; // 7
|
|
||||||
textwidth = 8.5;
|
|
||||||
render_plot_add_string(symbol, (unsigned char *) textpart, (textpos + xoffset) * scaler, default_text_posn, 11.0 * scaler, textwidth * scaler, &last_string);
|
|
||||||
|
|
||||||
for(i = 0; i < 6; i++) {
|
if(upceanflag == 13) {
|
||||||
textpart[i] = symbol->text[i + 1];
|
/* guard bar extensions and text formatting for EAN-13 */
|
||||||
}
|
i = 0;
|
||||||
textpart[6] = '\0';
|
for (line = symbol->rendered->lines; line != NULL; line = line->next) {
|
||||||
textpos = 25;
|
switch(i) {
|
||||||
textwidth = 6.0 * 8.5;
|
case 0:
|
||||||
render_plot_add_string(symbol, (unsigned char *) textpart, (textpos + xoffset) * scaler, default_text_posn, 11.0 * scaler, textwidth * scaler, &last_string);
|
case 1:
|
||||||
for(i = 0; i < 6; i++) {
|
case 14:
|
||||||
textpart[i] = symbol->text[i + 7];
|
case 15:
|
||||||
}
|
case 28:
|
||||||
textpart[6] = '\0';
|
case 29:
|
||||||
textpos = 72;
|
line->length += (5.0 * scaler);
|
||||||
render_plot_add_string(symbol, (unsigned char *) textpart, (textpos + xoffset) * scaler, default_text_posn, 11.0 * scaler, textwidth * scaler, &last_string);
|
break;
|
||||||
textdone = 1;
|
}
|
||||||
switch(strlen(addon)) {
|
i++;
|
||||||
case 2:
|
}
|
||||||
textpos = xoffset + 114;
|
|
||||||
textwidth = 2.0 * 8.5;
|
textpart[0] = symbol->text[0];
|
||||||
render_plot_add_string(symbol, (unsigned char *) addon, textpos * scaler, addon_text_posn * scaler, 11.0 * scaler, textwidth * scaler, &last_string);
|
textpart[1] = '\0';
|
||||||
break;
|
textpos = -5; // 7
|
||||||
case 5:
|
textwidth = 8.5;
|
||||||
textpos = xoffset + 128;
|
render_plot_add_string(symbol, (unsigned char *) textpart, (textpos + xoffset) * scaler, default_text_posn, 11.0 * scaler, textwidth * scaler, &last_string);
|
||||||
textwidth = 5.0 * 8.5;
|
|
||||||
render_plot_add_string(symbol, (unsigned char *) addon, textpos * scaler, addon_text_posn * scaler, 11.0 * scaler, textwidth * scaler, &last_string);
|
for(i = 0; i < 6; i++) {
|
||||||
break;
|
textpart[i] = symbol->text[i + 1];
|
||||||
}
|
}
|
||||||
|
textpart[6] = '\0';
|
||||||
|
textpos = 25;
|
||||||
|
textwidth = 6.0 * 8.5;
|
||||||
|
render_plot_add_string(symbol, (unsigned char *) textpart, (textpos + xoffset) * scaler, default_text_posn, 11.0 * scaler, textwidth * scaler, &last_string);
|
||||||
|
for(i = 0; i < 6; i++) {
|
||||||
|
textpart[i] = symbol->text[i + 7];
|
||||||
|
}
|
||||||
|
textpart[6] = '\0';
|
||||||
|
textpos = 72;
|
||||||
|
render_plot_add_string(symbol, (unsigned char *) textpart, (textpos + xoffset) * scaler, default_text_posn, 11.0 * scaler, textwidth * scaler, &last_string);
|
||||||
|
textdone = 1;
|
||||||
|
switch(strlen(addon)) {
|
||||||
|
case 2:
|
||||||
|
textpos = xoffset + 114;
|
||||||
|
textwidth = 2.0 * 8.5;
|
||||||
|
render_plot_add_string(symbol, (unsigned char *) addon, textpos * scaler, addon_text_posn * scaler, 11.0 * scaler, textwidth * scaler, &last_string);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
textpos = xoffset + 128;
|
||||||
|
textwidth = 5.0 * 8.5;
|
||||||
|
render_plot_add_string(symbol, (unsigned char *) addon, textpos * scaler, addon_text_posn * scaler, 11.0 * scaler, textwidth * scaler, &last_string);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((symbol->symbology == BARCODE_UPCA) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCA_CC)) {
|
if (upceanflag == 12) {
|
||||||
/* guard bar extensions and text formatting for UPCA */
|
/* guard bar extensions and text formatting for UPCA */
|
||||||
i = 0;
|
i = 0;
|
||||||
for (line = symbol->rendered->lines; line != NULL; line = line->next) {
|
for (line = symbol->rendered->lines; line != NULL; line = line->next) {
|
||||||
@ -490,7 +564,7 @@ int render_plot(struct zint_symbol *symbol, float width, float height)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((symbol->symbology == BARCODE_UPCE) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCE_CC)) {
|
if (upceanflag == 6) {
|
||||||
/* guard bar extensions and text formatting for UPCE */
|
/* guard bar extensions and text formatting for UPCE */
|
||||||
i = 0;
|
i = 0;
|
||||||
for (line = symbol->rendered->lines; line != NULL; line = line->next) {
|
for (line = symbol->rendered->lines; line != NULL; line = line->next) {
|
||||||
@ -554,22 +628,22 @@ int render_plot(struct zint_symbol *symbol, float width, float height)
|
|||||||
if((symbol->rows > 1) && (is_stackable(symbol->symbology) == 1)) {
|
if((symbol->rows > 1) && (is_stackable(symbol->symbology) == 1)) {
|
||||||
/* row binding */
|
/* row binding */
|
||||||
for(r = 1; r < symbol->rows; r++) {
|
for(r = 1; r < symbol->rows; r++) {
|
||||||
line = render_plot_create_line((xoffset + x_spacer) * scaler, ((r * row_height) + yoffset - 1 + y_spacer) * scaler, symbol->width * scaler, 2.0 * scaler);
|
line = render_plot_create_line(xoffset * scaler, ((r * row_height) + yoffset - 1) * scaler, symbol->width * scaler, 2.0 * scaler);
|
||||||
render_plot_add_line(symbol, line, &last_line);
|
render_plot_add_line(symbol, line, &last_line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (((symbol->output_options & BARCODE_BOX) != 0) || ((symbol->output_options & BARCODE_BIND) != 0)) {
|
if (((symbol->output_options & BARCODE_BOX) != 0) || ((symbol->output_options & BARCODE_BIND) != 0)) {
|
||||||
line = render_plot_create_line((x_spacer * scaler), (y_spacer * scaler), (symbol->width + xoffset + xoffset) * scaler, symbol->border_width * scaler);
|
line = render_plot_create_line(0, 0, (symbol->width + xoffset + xoffset) * scaler, symbol->border_width * scaler);
|
||||||
render_plot_add_line(symbol, line, &last_line);
|
render_plot_add_line(symbol, line, &last_line);
|
||||||
line = render_plot_create_line((x_spacer * scaler), (symbol->height + symbol->border_width + y_spacer) * scaler, (symbol->width + xoffset + xoffset) * scaler, symbol->border_width * scaler);
|
line = render_plot_create_line(0, (symbol->height + symbol->border_width) * scaler, (symbol->width + xoffset + xoffset) * scaler, symbol->border_width * scaler);
|
||||||
render_plot_add_line(symbol, line, &last_line);
|
render_plot_add_line(symbol, line, &last_line);
|
||||||
}
|
}
|
||||||
if((symbol->output_options & BARCODE_BOX) != 0) {
|
if((symbol->output_options & BARCODE_BOX) != 0) {
|
||||||
/* side bars */
|
/* side bars */
|
||||||
line = render_plot_create_line((x_spacer * scaler), (y_spacer * scaler), symbol->border_width * scaler, (symbol->height + (2 * symbol->border_width)) * scaler);
|
line = render_plot_create_line(0, 0, symbol->border_width * scaler, (symbol->height + (2 * symbol->border_width)) * scaler);
|
||||||
render_plot_add_line(symbol, line, &last_line);
|
render_plot_add_line(symbol, line, &last_line);
|
||||||
line = render_plot_create_line((symbol->width + xoffset + xoffset - symbol->border_width + x_spacer) * scaler, (y_spacer * scaler), symbol->border_width * scaler, (symbol->height + (2 * symbol->border_width)) * scaler);
|
line = render_plot_create_line((symbol->width + xoffset + xoffset - symbol->border_width) * scaler, 0, symbol->border_width * scaler, (symbol->height + (2 * symbol->border_width)) * scaler);
|
||||||
render_plot_add_line(symbol, line, &last_line);
|
render_plot_add_line(symbol, line, &last_line);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user