1
0
mirror of https://git.code.sf.net/p/zint/code synced 2025-12-18 02:17:06 +00:00

UPC/EAN, ITF14: quiet zones, addongap; raster/vector: sync code, use double

This commit is contained in:
gitlost
2020-07-15 19:00:12 +01:00
parent e90c273165
commit 2a19b883a5
55 changed files with 2917 additions and 1351 deletions

View File

@@ -31,7 +31,6 @@
/* vim: set ts=4 sw=4 et : */
#include <stdio.h>
#include <string.h>
#include <math.h>
#ifdef _MSC_VER
@@ -45,7 +44,7 @@ INTERNAL int ps_plot(struct zint_symbol *symbol);
INTERNAL int svg_plot(struct zint_symbol *symbol);
INTERNAL int emf_plot(struct zint_symbol *symbol);
static struct zint_vector_rect *vector_plot_create_rect(float x, float y, float width, float height) {
static struct zint_vector_rect *vector_plot_create_rect(double x, double y, double width, double height) {
struct zint_vector_rect *rect;
rect = (struct zint_vector_rect*) malloc(sizeof (struct zint_vector_rect));
@@ -72,7 +71,7 @@ static int vector_plot_add_rect(struct zint_symbol *symbol, struct zint_vector_r
return 1;
}
static struct zint_vector_hexagon *vector_plot_create_hexagon(float x, float y, float diameter) {
static struct zint_vector_hexagon *vector_plot_create_hexagon(double x, double y, double diameter) {
struct zint_vector_hexagon *hexagon;
hexagon = (struct zint_vector_hexagon*) malloc(sizeof (struct zint_vector_hexagon));
@@ -80,7 +79,7 @@ static struct zint_vector_hexagon *vector_plot_create_hexagon(float x, float y,
hexagon->next = NULL;
hexagon->x = x;
hexagon->y = y;
hexagon->diameter = (float)((diameter * 5.0) / 4.0); // Ugly kludge for legacy support
hexagon->diameter = (diameter * 5.0) / 4.0; // Ugly kludge for legacy support
return hexagon;
}
@@ -96,7 +95,7 @@ static int vector_plot_add_hexagon(struct zint_symbol *symbol, struct zint_vecto
return 1;
}
static struct zint_vector_circle *vector_plot_create_circle(float x, float y, float diameter, int colour) {
static struct zint_vector_circle *vector_plot_create_circle(double x, double y, double diameter, int colour) {
struct zint_vector_circle *circle;
circle = (struct zint_vector_circle *) malloc(sizeof (struct zint_vector_circle));
@@ -122,7 +121,7 @@ static int vector_plot_add_circle(struct zint_symbol *symbol, struct zint_vector
}
static int vector_plot_add_string(struct zint_symbol *symbol,
unsigned char *text, float x, float y, float fsize, float width,
unsigned char *text, double x, double y, double fsize, double width,
struct zint_vector_string **last_string) {
struct zint_vector_string *string;
@@ -196,7 +195,7 @@ static void vector_scale(struct zint_symbol *symbol, int file_type) {
struct zint_vector_hexagon *hex;
struct zint_vector_circle *circle;
struct zint_vector_string *string;
float scale = symbol->scale * 2.0f;
double scale = symbol->scale * 2.0;
if ((file_type == OUT_EMF_FILE) && (symbol->symbology == BARCODE_MAXICODE)) {
// Increase size to overcome limitations in EMF file format
@@ -270,39 +269,44 @@ static void vector_reduce_rectangles(struct zint_symbol *symbol) {
INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_type) {
int error_number;
double large_bar_height;
int textdone;
int main_width, comp_offset, addon_gap;
unsigned char addon[6];
int xoffset, yoffset, roffset, boffset;
double addon_text_posn;
int textoffset;
int default_text_posn;
double row_height, row_posn;
int upceanflag = 0;
int addon_latch = 0;
unsigned char textpart1[5], textpart2[7], textpart3[7], textpart4[2];
int textpos;
int hide_text = 0;
int i, r;
double text_height;
int rect_count, last_row_start;
int this_row;
struct zint_vector *vector;
struct zint_vector_rect *rectangle, *rect, *last_rectangle = NULL;
struct zint_vector_hexagon *last_hexagon = NULL;
struct zint_vector_string *last_string = NULL;
struct zint_vector_circle *last_circle = NULL;
int i, r, latch;
float textpos, large_bar_height, preset_height, row_height, row_posn = 0.0;
float text_offset, text_height;
int xoffset, yoffset, textdone, main_symbol_width_x;
int roffset, boffset;
char addon[6];
int large_bar_count, symbol_lead_in;
float addon_text_posn;
float default_text_posn;
int hide_text = 0;
int upceanflag = 0;
int rect_count, last_row_start;
int this_row;
int addon_latch = 0;
struct zint_vector_string *string;
(void)rotate_angle; /* Not currently implemented */
// Free any previous rendering structures
vector_free(symbol);
// Sanity check colours
error_number = check_colour_options(symbol);
error_number = output_check_colour_options(symbol);
if (error_number != 0) {
return error_number;
}
// Free any previous rendering structures
vector_free(symbol);
// Allocate memory
vector = symbol->vector = (struct zint_vector *) malloc(sizeof (struct zint_vector));
if (!vector) return ZINT_ERROR_MEMORY;
@@ -311,121 +315,44 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
vector->circles = NULL;
vector->strings = NULL;
row_height = 0;
large_bar_height = output_large_bar_height(symbol);
textdone = 0;
main_symbol_width_x = symbol->width;
strcpy(addon, "");
symbol_lead_in = 0;
addon_text_posn = 0.0;
rect_count = 0;
last_row_start = 0;
/*
* Determine if there will be any addon texts and text height
*/
latch = 0;
r = 0;
/* Isolate add-on text */
main_width = symbol->width;
comp_offset = 0;
if (is_extendable(symbol->symbology)) {
for (i = 0; i < (int) ustrlen(symbol->text); i++) {
if (latch == 1) {
addon[r] = symbol->text[i];
r++;
}
if (symbol->text[i] == '+') {
latch = 1;
}
}
}
addon[r] = '\0';
/*
* Calculate the width of the barcode, especially if there are any extra
* borders or white space to add.
*/
if (is_composite(symbol->symbology)) {
while (!(module_is_set(symbol, symbol->rows - 1, symbol_lead_in))) {
symbol_lead_in++;
}
upceanflag = output_process_upcean(symbol, &main_width, &comp_offset, addon, &addon_gap);
}
/* Certain symbols need whitespace otherwise characters get chopped off the sides */
if ((symbol->symbology == BARCODE_EANX) || (symbol->symbology == BARCODE_EANX_CHK)
|| (symbol->symbology == BARCODE_EANX_CC) || (symbol->symbology == BARCODE_ISBNX)) {
switch (ustrlen(symbol->text)) {
case 13: /* EAN 13 */
case 16:
case 19:
if (symbol->whitespace_width == 0) {
symbol->whitespace_width = 10;
}
main_symbol_width_x = 96 + symbol_lead_in;
upceanflag = 13;
break;
case 2:
main_symbol_width_x = 22 + symbol_lead_in;
upceanflag = 2;
break;
case 5:
main_symbol_width_x = 49 + symbol_lead_in;
upceanflag = 5;
break;
default:
main_symbol_width_x = 68 + symbol_lead_in;
upceanflag = 8;
}
} else if ((symbol->symbology == BARCODE_UPCA) || (symbol->symbology == BARCODE_UPCA_CHK)
|| (symbol->symbology == BARCODE_UPCA_CC)) {
upceanflag = 12;
if (symbol->whitespace_width == 0) {
symbol->whitespace_width = 10;
}
main_symbol_width_x = 96 + symbol_lead_in;
} else if ((symbol->symbology == BARCODE_UPCE) || (symbol->symbology == BARCODE_UPCE_CHK)
|| (symbol->symbology == BARCODE_UPCE_CC)) {
upceanflag = 6;
if (symbol->whitespace_width == 0) {
symbol->whitespace_width = 10;
}
main_symbol_width_x = 51 + symbol_lead_in;
}
output_set_whitespace_offsets(symbol, &xoffset, &yoffset, &roffset, &boffset);
if ((!symbol->show_hrt) || (ustrlen(symbol->text) == 0)) {
hide_text = 1;
addon_text_posn = 0.0;
hide_text = ((!symbol->show_hrt) || (ustrlen(symbol->text) == 0));
if (hide_text) {
text_height = 0.0;
text_offset = upceanflag ? 9.0f : 0.0f;
textoffset = upceanflag ? 9.0 : 0.0;
} else {
text_height = upceanflag ? 11.0f : 9.0f;
text_offset = 9.0;
text_height = upceanflag ? 11.0 : 9.0;
textoffset = 9.0;
}
if (symbol->output_options & SMALL_TEXT)
text_height *= 0.8f;
text_height *= 0.8;
set_whitespace_offsets(symbol, &xoffset, &yoffset, &roffset, &boffset);
// Determine if height should be overridden
large_bar_count = 0;
preset_height = 0.0;
for (i = 0; i < symbol->rows; i++) {
preset_height += symbol->row_height[i];
if (symbol->row_height[i] == 0) {
large_bar_count++;
}
}
vector->width = (float)ceil(symbol->width + (xoffset + roffset));
vector->height = (float)ceil(symbol->height + text_offset + (yoffset + boffset));
large_bar_height = large_bar_count ? (symbol->height - preset_height) / large_bar_count : 0 /*Not used if large_bar_count zero*/;
vector->width = ceil(symbol->width + (xoffset + roffset));
vector->height = ceil(symbol->height + textoffset + (yoffset + boffset));
if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) {
default_text_posn = symbol->height + text_offset + symbol->border_width + symbol->border_width;
default_text_posn = symbol->height + textoffset + symbol->border_width + symbol->border_width;
} else {
default_text_posn = symbol->height + text_offset;
default_text_posn = symbol->height + textoffset;
}
row_height = 0.0;
rect_count = 0;
last_row_start = 0;
// Plot rectangles - most symbols created here
if ((symbol->symbology != BARCODE_MAXICODE) && ((symbol->output_options & BARCODE_DOTTY_MODE) == 0)) {
for (r = 0; r < symbol->rows; r++) {
@@ -434,7 +361,7 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
if (symbol->row_height[this_row] == 0) {
row_height = large_bar_height;
} else {
row_height = (float)symbol->row_height[this_row];
row_height = symbol->row_height[this_row];
}
row_posn = 0;
for (i = 0; i < r; i++) {
@@ -453,19 +380,23 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
do {
block_width++;
} while (i + block_width < symbol->width && 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_symbol_width_x)) {
addon_text_posn = row_posn + 8.0f;
if ((addon_latch == 0) && (r == (symbol->rows - 1)) && (i > main_width)) {
addon_text_posn = row_posn + 8.0;
addon_latch = 1;
}
if (module_is_set(symbol, this_row, i)) {
/* a bar or colour block */
if (addon_latch == 0) {
rectangle = vector_plot_create_rect((float)(i + xoffset), row_posn, (float)block_width, row_height);
rectangle = vector_plot_create_rect(i + xoffset, row_posn, block_width, row_height);
if (symbol->symbology == BARCODE_ULTRA) {
rectangle->colour = module_is_set(symbol, this_row, i);
}
} else {
rectangle = vector_plot_create_rect((float)(i + xoffset), row_posn + 10.0f, (float)block_width, row_height - 5.0f);
if (upceanflag == 12 || upceanflag == 6) { /* UPC-A/E don't descend */
rectangle = vector_plot_create_rect(i + xoffset, row_posn + 10.0, block_width, row_height > 10.0 ? row_height - 10.0 : 1.0);
} else {
rectangle = vector_plot_create_rect(i + xoffset, row_posn + 10.0, block_width, row_height > 5.0 ? row_height - 5.0 : 1.0);
}
}
vector_plot_add_rect(symbol, rectangle, &last_rectangle);
rect_count++;
@@ -479,21 +410,21 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
// Plot Maxicode symbols
if (symbol->symbology == BARCODE_MAXICODE) {
struct zint_vector_circle *circle;
vector->width = 37.0f + (xoffset + roffset);
vector->height = 36.0f + (yoffset + boffset);
vector->width = 37.0 + (xoffset + roffset);
vector->height = 36.0 + (yoffset + boffset);
// Bullseye
circle = vector_plot_create_circle(17.88f + xoffset, 17.8f + yoffset, 10.85f, 0);
circle = vector_plot_create_circle(17.88 + xoffset, 17.8 + yoffset, 10.85, 0);
vector_plot_add_circle(symbol, circle, &last_circle);
circle = vector_plot_create_circle(17.88f + xoffset, 17.8f + yoffset, 8.97f, 1);
circle = vector_plot_create_circle(17.88 + xoffset, 17.8 + yoffset, 8.97, 1);
vector_plot_add_circle(symbol, circle, &last_circle);
circle = vector_plot_create_circle(17.88f + xoffset, 17.8f + yoffset, 7.10f, 0);
circle = vector_plot_create_circle(17.88 + xoffset, 17.8 + yoffset, 7.10, 0);
vector_plot_add_circle(symbol, circle, &last_circle);
circle = vector_plot_create_circle(17.88f + xoffset, 17.8f + yoffset, 5.22f, 1);
circle = vector_plot_create_circle(17.88 + xoffset, 17.8 + yoffset, 5.22, 1);
vector_plot_add_circle(symbol, circle, &last_circle);
circle = vector_plot_create_circle(17.88f + xoffset, 17.8f + yoffset, 3.31f, 0);
circle = vector_plot_create_circle(17.88 + xoffset, 17.8 + yoffset, 3.31, 0);
vector_plot_add_circle(symbol, circle, &last_circle);
circle = vector_plot_create_circle(17.88f + xoffset, 17.8f + yoffset, 1.43f, 1);
circle = vector_plot_create_circle(17.88 + xoffset, 17.8 + yoffset, 1.43, 1);
vector_plot_add_circle(symbol, circle, &last_circle);
/* Hexagons */
@@ -501,8 +432,8 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
for (i = 0; i < symbol->width; i++) {
if (module_is_set(symbol, r, i)) {
//struct zint_vector_hexagon *hexagon = vector_plot_create_hexagon(((i * 0.88) + ((r & 1) ? 1.76 : 1.32)), ((r * 0.76) + 0.76), symbol->dot_size);
struct zint_vector_hexagon *hexagon = vector_plot_create_hexagon(((i * 1.23f) + 0.615f + ((r & 1) ? 0.615f : 0.0f)) + xoffset,
((r * 1.067f) + 0.715f) + yoffset, symbol->dot_size);
struct zint_vector_hexagon *hexagon = vector_plot_create_hexagon(((i * 1.23) + 0.615 + ((r & 1) ? 0.615 : 0.0)) + xoffset,
((r * 1.067) + 0.715) + yoffset, symbol->dot_size);
vector_plot_add_hexagon(symbol, hexagon, &last_hexagon);
}
}
@@ -514,247 +445,204 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
for (r = 0; r < symbol->rows; r++) {
for (i = 0; i < symbol->width; i++) {
if (module_is_set(symbol, r, i)) {
struct zint_vector_circle *circle = vector_plot_create_circle(i + 0.5f + xoffset, r + 0.5f + yoffset, 1.0f, 0);
struct zint_vector_circle *circle = vector_plot_create_circle(i + 0.5 + xoffset, r + 0.5 + yoffset, 1.0, 0);
vector_plot_add_circle(symbol, circle, &last_circle);
}
}
}
}
/* Guard bar extension */
if (upceanflag == 6) {
i = 0;
for (rect = symbol->vector->rectangles; rect != NULL; rect = rect->next) {
switch (i - last_row_start) {
case 0:
case 1:
case 14:
case 15:
case 16:
rect->height += 5.0;
break;
if (upceanflag) {
/* Guard bar extension */
if (upceanflag == 6) { /* UPC-E */
i = 0;
for (rect = symbol->vector->rectangles; rect != NULL; rect = rect->next) {
switch (i - last_row_start) {
case 0:
case 1:
case 14:
case 15:
case 16:
rect->height += 5.0;
break;
}
i++;
}
i++;
}
}
if (upceanflag == 8) {
i = 0;
for (rect = symbol->vector->rectangles; rect != NULL; rect = rect->next) {
switch (i - last_row_start) {
case 0:
case 1:
case 10:
case 11:
case 20:
case 21:
rect->height += 5.0;
break;
} else if (upceanflag == 8) { /* EAN-8 */
i = 0;
for (rect = symbol->vector->rectangles; rect != NULL; rect = rect->next) {
switch (i - last_row_start) {
case 0:
case 1:
case 10:
case 11:
case 20:
case 21:
rect->height += 5.0;
break;
}
i++;
}
i++;
}
}
if (upceanflag == 12) {
i = 0;
for (rect = symbol->vector->rectangles; rect != NULL; rect = rect->next) {
switch (i - last_row_start) {
case 0:
case 1:
case 2:
case 3:
case 14:
case 15:
case 26:
case 27:
case 28:
case 29:
rect->height += 5.0;
break;
} else if (upceanflag == 12) { /* UPC-A */
i = 0;
for (rect = symbol->vector->rectangles; rect != NULL; rect = rect->next) {
switch (i - last_row_start) {
case 0:
case 1:
case 2:
case 3:
case 14:
case 15:
case 26:
case 27:
case 28:
case 29:
rect->height += 5.0;
break;
}
i++;
}
i++;
}
}
if (upceanflag == 13) {
i = 0;
for (rect = symbol->vector->rectangles; rect != NULL; rect = rect->next) {
switch (i - last_row_start) {
case 0:
case 1:
case 14:
case 15:
case 28:
case 29:
rect->height += 5.0;
break;
} else if (upceanflag == 13) { /* EAN-13 */
i = 0;
for (rect = symbol->vector->rectangles; rect != NULL; rect = rect->next) {
switch (i - last_row_start) {
case 0:
case 1:
case 14:
case 15:
case 28:
case 29:
rect->height += 5.0;
break;
}
i++;
}
i++;
}
}
/* Add the text */
if (!hide_text) {
char textpart[10];
float textwidth;
xoffset += symbol_lead_in;
xoffset += comp_offset;
if (upceanflag == 8) {
for (i = 0; i < 4; i++) {
textpart[i] = symbol->text[i];
}
textpart[4] = '\0';
textpos = 17;
textwidth = 4.0 * 8.5;
vector_plot_add_string(symbol, (unsigned char *) textpart, textpos + xoffset, default_text_posn, text_height, textwidth, &last_string);
for (i = 0; i < 4; i++) {
textpart[i] = symbol->text[i + 4];
}
textpart[4] = '\0';
textpos = 50;
vector_plot_add_string(symbol, (unsigned char *) textpart, (textpos + xoffset), default_text_posn, text_height, textwidth, &last_string);
textdone = 1;
switch (strlen(addon)) {
case 2:
textpos = (float)(xoffset + 86);
textwidth = 2.0f * 8.5f;
vector_plot_add_string(symbol, (unsigned char *) addon, textpos, addon_text_posn, text_height, textwidth, &last_string);
break;
case 5:
textpos = (float)(xoffset + 100);
textwidth = 5.0f * 8.5f;
vector_plot_add_string(symbol, (unsigned char *) addon, textpos, addon_text_posn, text_height, textwidth, &last_string);
break;
}
if (upceanflag) {
double textwidth;
output_upcean_split_text(upceanflag, symbol->text, textpart1, textpart2, textpart3, textpart4);
}
if (upceanflag == 6) { /* UPC-E */
textpos = -5 + xoffset;
textwidth = 6.2;
vector_plot_add_string(symbol, textpart1, textpos, default_text_posn - 2.0, text_height * (8.0 / 11.0), textwidth, &last_string);
textpos = 24 + xoffset;
textwidth = 6.0 * 8.5;
vector_plot_add_string(symbol, textpart2, textpos, default_text_posn, text_height, textwidth, &last_string);
textpos = 55 + xoffset;
textwidth = 6.2;
vector_plot_add_string(symbol, textpart3, textpos, default_text_posn - 2.0, text_height * (8.0 / 11.0), textwidth, &last_string);
textdone = 1;
switch (ustrlen(addon)) {
case 2:
textpos = 61 + xoffset + addon_gap;
textwidth = 2.0 * 8.5;
vector_plot_add_string(symbol, addon, textpos, addon_text_posn, text_height, textwidth, &last_string);
break;
case 5:
textpos = 75 + xoffset + addon_gap;
textwidth = 5.0 * 8.5;
vector_plot_add_string(symbol, addon, textpos, addon_text_posn, text_height, textwidth, &last_string);
break;
}
if (upceanflag == 13) {
textpart[0] = symbol->text[0];
textpart[1] = '\0';
textpos = -5; // 7
textwidth = 8.5;
vector_plot_add_string(symbol, (unsigned char *) textpart, textpos + xoffset, default_text_posn, text_height, textwidth, &last_string);
} else if (upceanflag == 8) { /* EAN-8 */
textpos = 17 + xoffset;
textwidth = 4.0 * 8.5;
vector_plot_add_string(symbol, textpart1, textpos, default_text_posn, text_height, textwidth, &last_string);
textpos = 50 + xoffset;
vector_plot_add_string(symbol, textpart2, textpos, default_text_posn, text_height, textwidth, &last_string);
textdone = 1;
switch (ustrlen(addon)) {
case 2:
textpos = 77 + xoffset + addon_gap;
textwidth = 2.0 * 8.5;
vector_plot_add_string(symbol, addon, textpos, addon_text_posn, text_height, textwidth, &last_string);
break;
case 5:
textpos = 91 + xoffset + addon_gap;
textwidth = 5.0 * 8.5;
vector_plot_add_string(symbol, addon, textpos, addon_text_posn, text_height, textwidth, &last_string);
break;
}
for (i = 0; i < 6; i++) {
textpart[i] = symbol->text[i + 1];
}
textpart[6] = '\0';
textpos = 25;
textwidth = 6.0 * 8.5;
vector_plot_add_string(symbol, (unsigned char *) textpart, textpos + xoffset, default_text_posn, text_height, textwidth, &last_string);
for (i = 0; i < 6; i++) {
textpart[i] = symbol->text[i + 7];
}
textpart[6] = '\0';
textpos = 72;
vector_plot_add_string(symbol, (unsigned char *) textpart, textpos + xoffset, default_text_posn, text_height, textwidth, &last_string);
textdone = 1;
switch (strlen(addon)) {
case 2:
textpos = (float)(xoffset + 114);
textwidth = 2.0f * 8.5f;
vector_plot_add_string(symbol, (unsigned char *) addon, textpos, addon_text_posn, text_height, textwidth, &last_string);
break;
case 5:
textpos = (float)(xoffset + 128);
textwidth = 5.0f * 8.5f;
vector_plot_add_string(symbol, (unsigned char *) addon, textpos, addon_text_posn, text_height, textwidth, &last_string);
break;
} else if (upceanflag == 12) { /* UPC-A */
textpos = -5 + xoffset;
textwidth = 6.2;
vector_plot_add_string(symbol, textpart1, textpos, default_text_posn - 2.0, text_height * (8.0 / 11.0), textwidth, &last_string);
textpos = 27 + xoffset;
textwidth = 5.0 * 8.5;
vector_plot_add_string(symbol, textpart2, textpos, default_text_posn, text_height, textwidth, &last_string);
textpos = 68 + xoffset;
vector_plot_add_string(symbol, textpart3, textpos, default_text_posn, text_height, textwidth, &last_string);
textpos = 100 + xoffset;
textwidth = 6.2;
vector_plot_add_string(symbol, textpart4, textpos, default_text_posn - 2.0, text_height * (8.0 / 11.0), textwidth, &last_string);
textdone = 1;
switch (ustrlen(addon)) {
case 2:
textpos = 107 + xoffset + addon_gap;
textwidth = 2.0 * 8.5;
vector_plot_add_string(symbol, addon, textpos, addon_text_posn, text_height, textwidth, &last_string);
break;
case 5:
textpos = 121 + xoffset + addon_gap;
textwidth = 5.0 * 8.5;
vector_plot_add_string(symbol, addon, textpos, addon_text_posn, text_height, textwidth, &last_string);
break;
}
} else if (upceanflag == 13) { /* EAN-13 */
textpos = -7 + xoffset;
textwidth = 8.5;
vector_plot_add_string(symbol, textpart1, textpos, default_text_posn, text_height, textwidth, &last_string);
textpos = 24 + xoffset;
textwidth = 6.0 * 8.5;
vector_plot_add_string(symbol, textpart2, textpos, default_text_posn, text_height, textwidth, &last_string);
textpos = 71 + xoffset;
vector_plot_add_string(symbol, textpart3, textpos, default_text_posn, text_height, textwidth, &last_string);
textdone = 1;
switch (ustrlen(addon)) {
case 2:
textpos = 105 + xoffset + addon_gap;
textwidth = 2.0 * 8.5;
vector_plot_add_string(symbol, addon, textpos, addon_text_posn, text_height, textwidth, &last_string);
break;
case 5:
textpos = 119 + xoffset + addon_gap;
textwidth = 5.0 * 8.5;
vector_plot_add_string(symbol, addon, textpos, addon_text_posn, text_height, textwidth, &last_string);
break;
}
}
}
if (upceanflag == 12) {
textpart[0] = symbol->text[0];
textpart[1] = '\0';
textpos = -5;
textwidth = 6.2f;
vector_plot_add_string(symbol, (unsigned char *) textpart, textpos + xoffset, default_text_posn - 2.0f, text_height * (8.0f / 11.0f), textwidth, &last_string);
for (i = 0; i < 5; i++) {
textpart[i] = symbol->text[i + 1];
}
textpart[5] = '\0';
textpos = 27;
textwidth = 5.0f * 8.5f;
vector_plot_add_string(symbol, (unsigned char *) textpart, textpos + xoffset, default_text_posn, text_height, textwidth, &last_string);
for (i = 0; i < 5; i++) {
textpart[i] = symbol->text[i + 6];
}
textpos = 68;
vector_plot_add_string(symbol, (unsigned char *) textpart, textpos + xoffset, default_text_posn, text_height, textwidth, &last_string);
textpart[0] = symbol->text[11];
textpart[1] = '\0';
textpos = 100;
textwidth = 6.2f;
vector_plot_add_string(symbol, (unsigned char *) textpart, textpos + xoffset, default_text_posn - 2.0f, text_height * (8.0f / 11.0f), textwidth, &last_string);
textdone = 1;
switch (strlen(addon)) {
case 2:
textpos = (float)(xoffset + 116);
textwidth = 2.0f * 8.5f;
vector_plot_add_string(symbol, (unsigned char *) addon, textpos, addon_text_posn, text_height, textwidth, &last_string);
break;
case 5:
textpos = (float)(xoffset + 130);
textwidth = 5.0f * 8.5f;
vector_plot_add_string(symbol, (unsigned char *) addon, textpos, addon_text_posn, text_height, textwidth, &last_string);
break;
if (!textdone) {
/* Put normal human readable text at the bottom (and centered) */
// calculate start xoffset to center text
vector_plot_add_string(symbol, symbol->text, main_width / 2.0 + xoffset, default_text_posn, text_height, symbol->width, &last_string);
// Remove control characters from readable text
// This only applies to Code 128
string = symbol->vector->strings;
if (string) {
for (i = 0; i < string->length; i++) {
if (string->text[i] < ' ') {
string->text[i] = ' ';
}
}
}
}
if (upceanflag == 6) {
textpart[0] = symbol->text[0];
textpart[1] = '\0';
textpos = -5;
textwidth = 6.2f;
vector_plot_add_string(symbol, (unsigned char *) textpart, textpos + xoffset, default_text_posn - 2.0f, text_height * (8.0f / 11.0f), textwidth, &last_string);
for (i = 0; i < 6; i++) {
textpart[i] = symbol->text[i + 1];
}
textpart[6] = '\0';
textpos = 24;
textwidth = 6.0 * 8.5;
vector_plot_add_string(symbol, (unsigned char *) textpart, textpos + xoffset, default_text_posn, text_height, textwidth, &last_string);
textpart[0] = symbol->text[7];
textpart[1] = '\0';
textpos = 55;
textwidth = 6.2f;
vector_plot_add_string(symbol, (unsigned char *) textpart, textpos + xoffset, default_text_posn - 2.0f, text_height * (8.0f / 11.0f), textwidth, &last_string);
textdone = 1;
switch (strlen(addon)) {
case 2:
textpos = (float)(xoffset + 70);
textwidth = 2.0f * 8.5f;
vector_plot_add_string(symbol, (unsigned char *) addon, textpos, addon_text_posn, text_height, textwidth, &last_string);
break;
case 5:
textpos = (float)(xoffset + 84);
textwidth = 5.0f * 8.5f;
vector_plot_add_string(symbol, (unsigned char *) addon, textpos, addon_text_posn, text_height, textwidth, &last_string);
break;
}
}
/* Put normal human readable text at the bottom (and centered) */
if (textdone == 0) {
// caculate start xoffset to center text
vector_plot_add_string(symbol, symbol->text, (symbol->width / 2.0f) + xoffset, default_text_posn, text_height, (float)symbol->width, &last_string);
}
xoffset -= symbol_lead_in; // Restore xoffset
}
//Remove control characters from readable text
// This only applies to Code 128
string = symbol->vector->strings;
if (string) {
for (i = 0; i < string->length; i++) {
if (string->text[i] < ' ') {
string->text[i] = ' ';
}
}
xoffset -= comp_offset; // Restore xoffset
}
// Binding and boxes
@@ -767,7 +655,7 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
/* row binding */
for (r = 1; r < symbol->rows; r++) {
if (symbol->symbology != BARCODE_CODABLOCKF && symbol->symbology != BARCODE_HIBC_BLOCKF) {
rectangle = vector_plot_create_rect((float)xoffset, (r * row_height) + yoffset - sep_height / 2, (float)symbol->width, sep_height);
rectangle = vector_plot_create_rect(xoffset, (r * row_height) + yoffset - sep_height / 2, symbol->width, sep_height);
vector_plot_add_rect(symbol, rectangle, &last_rectangle);
} else {
/* Avoid 11-module start and 13-module stop chars */
@@ -779,26 +667,26 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
}
if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) {
// Top
rectangle = vector_plot_create_rect(0.0f, 0.0f, vector->width, (float)symbol->border_width);
rectangle = vector_plot_create_rect(0.0, 0.0, vector->width, symbol->border_width);
if (!(symbol->output_options & BARCODE_BOX) && (symbol->symbology == BARCODE_CODABLOCKF || symbol->symbology == BARCODE_HIBC_BLOCKF)) {
rectangle->x = (float)xoffset;
rectangle->width -= (2.0f * xoffset);
rectangle->x = xoffset;
rectangle->width -= (2.0 * xoffset);
}
vector_plot_add_rect(symbol, rectangle, &last_rectangle);
// Bottom
rectangle = vector_plot_create_rect(0.0f, vector->height - symbol->border_width - text_offset, vector->width, (float)symbol->border_width);
rectangle = vector_plot_create_rect(0.0, vector->height - symbol->border_width - textoffset, vector->width, symbol->border_width);
if (!(symbol->output_options & BARCODE_BOX) && (symbol->symbology == BARCODE_CODABLOCKF || symbol->symbology == BARCODE_HIBC_BLOCKF)) {
rectangle->x = (float)xoffset;
rectangle->width -= (2.0f * xoffset);
rectangle->x = xoffset;
rectangle->width -= (2.0 * xoffset);
}
vector_plot_add_rect(symbol, rectangle, &last_rectangle);
}
if (symbol->output_options & BARCODE_BOX) {
// Left
rectangle = vector_plot_create_rect(0.0f, 0.0f, (float)symbol->border_width, vector->height - text_offset);
rectangle = vector_plot_create_rect(0.0, 0.0, symbol->border_width, vector->height - textoffset);
vector_plot_add_rect(symbol, rectangle, &last_rectangle);
// Right
rectangle = vector_plot_create_rect(vector->width - symbol->border_width, 0.0f, (float)symbol->border_width, vector->height - text_offset);
rectangle = vector_plot_create_rect(vector->width - symbol->border_width, 0.0, symbol->border_width, vector->height - textoffset);
vector_plot_add_rect(symbol, rectangle, &last_rectangle);
}