Correctly format EAN and UPC without text

EAN and UPC should have a standard compliant format even without text
Fixes #27
This commit is contained in:
Robin Stuart 2016-06-19 11:59:09 +01:00
parent c709b08da5
commit d2774af120
3 changed files with 728 additions and 642 deletions

View File

@ -721,9 +721,34 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle, int data_type) {
#endif #endif
if (symbol->show_hrt != 0) { if (symbol->show_hrt != 0) {
/* Copy text from symbol */
to_latin1(symbol->text, local_text); to_latin1(symbol->text, local_text);
} else { } else {
local_text[0] = '\0'; /* No text needed */
switch (symbol->symbology) {
case BARCODE_EANX:
case BARCODE_EANX_CC:
case BARCODE_ISBNX:
case BARCODE_UPCA:
case BARCODE_UPCE:
case BARCODE_UPCA_CC:
case BARCODE_UPCE_CC:
/* For these symbols use dummy text to ensure formatting is done
* properly even if no text is required */
for (i = 0; i < ustrlen(symbol->text); i++) {
if (symbol->text[i] == '+') {
local_text[i] = '+';
} else {
local_text[i] = ' ';
}
local_text[ustrlen(symbol->text)] = '\0';
}
break;
default:
/* For everything else, just remove the text */
local_text[0] = '\0';
break;
}
} }
textdone = 0; textdone = 0;
@ -812,6 +837,7 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle, int data_type) {
} else { } else {
textoffset = 0; textoffset = 0;
} }
xoffset = symbol->border_width + symbol->whitespace_width; xoffset = symbol->border_width + symbol->whitespace_width;
yoffset = symbol->border_width; yoffset = symbol->border_width;
image_width = 2 * (symbol->width + xoffset + xoffset); image_width = 2 * (symbol->width + xoffset + xoffset);
@ -895,14 +921,14 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle, int data_type) {
draw_bar(pixelbuf, (64 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height); draw_bar(pixelbuf, (64 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height);
draw_bar(pixelbuf, (66 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height); draw_bar(pixelbuf, (66 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height);
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
textpart[i] = symbol->text[i]; textpart[i] = local_text[i];
} }
textpart[4] = '\0'; textpart[4] = '\0';
textpos = 2 * (17 + xoffset); textpos = 2 * (17 + xoffset);
draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height);
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
textpart[i] = symbol->text[i + 4]; textpart[i] = local_text[i + 4];
} }
textpart[4] = '\0'; textpart[4] = '\0';
textpos = 2 * (50 + xoffset); textpos = 2 * (50 + xoffset);
@ -930,18 +956,18 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle, int data_type) {
draw_bar(pixelbuf, (92 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height); draw_bar(pixelbuf, (92 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height);
draw_bar(pixelbuf, (94 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height); draw_bar(pixelbuf, (94 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height);
textpart[0] = symbol->text[0]; textpart[0] = local_text[0];
textpart[1] = '\0'; textpart[1] = '\0';
textpos = 2 * (-7 + xoffset); textpos = 2 * (-7 + xoffset);
draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height);
for (i = 0; i < 6; i++) { for (i = 0; i < 6; i++) {
textpart[i] = symbol->text[i + 1]; textpart[i] = local_text[i + 1];
} }
textpart[6] = '\0'; textpart[6] = '\0';
textpos = 2 * (24 + xoffset); textpos = 2 * (24 + xoffset);
draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height);
for (i = 0; i < 6; i++) { for (i = 0; i < 6; i++) {
textpart[i] = symbol->text[i + 7]; textpart[i] = local_text[i + 7];
} }
textpart[6] = '\0'; textpart[6] = '\0';
textpos = 2 * (71 + xoffset); textpos = 2 * (71 + xoffset);
@ -1001,23 +1027,23 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle, int data_type) {
} }
i += block_width; i += block_width;
} while (i < 96 + comp_offset); } while (i < 96 + comp_offset);
textpart[0] = symbol->text[0]; textpart[0] = local_text[0];
textpart[1] = '\0'; textpart[1] = '\0';
textpos = 2 * (-5 + xoffset); textpos = 2 * (-5 + xoffset);
draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height);
for (i = 0; i < 5; i++) { for (i = 0; i < 5; i++) {
textpart[i] = symbol->text[i + 1]; textpart[i] = local_text[i + 1];
} }
textpart[5] = '\0'; textpart[5] = '\0';
textpos = 2 * (27 + xoffset); textpos = 2 * (27 + xoffset);
draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height);
for (i = 0; i < 5; i++) { for (i = 0; i < 5; i++) {
textpart[i] = symbol->text[i + 6]; textpart[i] = local_text[i + 6];
} }
textpart[6] = '\0'; textpart[6] = '\0';
textpos = 2 * (68 + xoffset); textpos = 2 * (68 + xoffset);
draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height);
textpart[0] = symbol->text[11]; textpart[0] = local_text[11];
textpart[1] = '\0'; textpart[1] = '\0';
textpos = 2 * (100 + xoffset); textpos = 2 * (100 + xoffset);
draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height);
@ -1043,17 +1069,17 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle, int data_type) {
draw_bar(pixelbuf, (48 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height); draw_bar(pixelbuf, (48 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height);
draw_bar(pixelbuf, (50 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height); draw_bar(pixelbuf, (50 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height);
textpart[0] = symbol->text[0]; textpart[0] = local_text[0];
textpart[1] = '\0'; textpart[1] = '\0';
textpos = 2 * (-5 + xoffset); textpos = 2 * (-5 + xoffset);
draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height);
for (i = 0; i < 6; i++) { for (i = 0; i < 6; i++) {
textpart[i] = symbol->text[i + 1]; textpart[i] = local_text[i + 1];
} }
textpart[6] = '\0'; textpart[6] = '\0';
textpos = 2 * (24 + xoffset); textpos = 2 * (24 + xoffset);
draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height);
textpart[0] = symbol->text[7]; textpart[0] = local_text[7];
textpart[1] = '\0'; textpart[1] = '\0';
textpos = 2 * (55 + xoffset); textpos = 2 * (55 + xoffset);
draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height);

View File

@ -52,8 +52,12 @@ int ps_plot(struct zint_symbol *symbol) {
float addon_text_posn; float addon_text_posn;
float scaler = symbol->scale; float scaler = symbol->scale;
float default_text_posn; float default_text_posn;
int plot_text = 1;
const char *locale = NULL; const char *locale = NULL;
#ifndef _MSC_VER
unsigned char local_text[ustrlen(symbol->text) + 1];
#else
unsigned char* local_text = (unsigned char*) _alloca(ustrlen(symbol->text) + 1);
#endif
row_height = 0; row_height = 0;
textdone = 0; textdone = 0;
@ -62,6 +66,37 @@ int ps_plot(struct zint_symbol *symbol) {
comp_offset = 0; comp_offset = 0;
addon_text_posn = 0.0; addon_text_posn = 0.0;
if (symbol->show_hrt != 0) {
/* Copy text from symbol */
ustrcpy(local_text, symbol->text);
} else {
/* No text needed */
switch (symbol->symbology) {
case BARCODE_EANX:
case BARCODE_EANX_CC:
case BARCODE_ISBNX:
case BARCODE_UPCA:
case BARCODE_UPCE:
case BARCODE_UPCA_CC:
case BARCODE_UPCE_CC:
/* For these symbols use dummy text to ensure formatting is done
* properly even if no text is required */
for (i = 0; i < ustrlen(symbol->text); i++) {
if (symbol->text[i] == '+') {
local_text[i] = '+';
} else {
local_text[i] = ' ';
}
local_text[ustrlen(symbol->text)] = '\0';
}
break;
default:
/* For everything else, just remove the text */
local_text[0] = '\0';
break;
}
}
if ((symbol->output_options & BARCODE_STDOUT) != 0) { if ((symbol->output_options & BARCODE_STDOUT) != 0) {
feps = stdout; feps = stdout;
} else { } else {
@ -134,7 +169,7 @@ int ps_plot(struct zint_symbol *symbol) {
/* Certain symbols need whitespace otherwise characters get chopped off the sides */ /* Certain symbols need whitespace otherwise characters get chopped off the sides */
if ((((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC)) if ((((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC))
|| (symbol->symbology == BARCODE_ISBNX)) { || (symbol->symbology == BARCODE_ISBNX)) {
switch (ustrlen(symbol->text)) { switch (ustrlen(local_text)) {
case 13: /* EAN 13 */ case 13: /* EAN 13 */
case 16: case 16:
case 19: case 19:
@ -166,22 +201,19 @@ int ps_plot(struct zint_symbol *symbol) {
r = 0; r = 0;
/* Isolate add-on text */ /* Isolate add-on text */
if (is_extendable(symbol->symbology)) { if (is_extendable(symbol->symbology)) {
for (i = 0; i < ustrlen(symbol->text); i++) { for (i = 0; i < ustrlen(local_text); i++) {
if (latch == 1) { if (latch == 1) {
addon[r] = symbol->text[i]; addon[r] = local_text[i];
r++; r++;
} }
if (symbol->text[i] == '+') { if (local_text[i] == '+') {
latch = 1; latch = 1;
} }
} }
} }
addon[r] = '\0'; addon[r] = '\0';
if ((symbol->show_hrt == 0) || (ustrlen(symbol->text) == 0)) { if (ustrlen(local_text) != 0) {
plot_text = 0;
}
if (plot_text) {
textoffset = 9; textoffset = 9;
} else { } else {
textoffset = 0; textoffset = 0;
@ -192,8 +224,8 @@ int ps_plot(struct zint_symbol *symbol) {
/* Start writing the header */ /* Start writing the header */
fprintf(feps, "%%!PS-Adobe-3.0 EPSF-3.0\n"); fprintf(feps, "%%!PS-Adobe-3.0 EPSF-3.0\n");
fprintf(feps, "%%%%Creator: Zint %s\n", ZINT_VERSION); fprintf(feps, "%%%%Creator: Zint %s\n", ZINT_VERSION);
if (ustrlen(symbol->text) != 0) { if (ustrlen(local_text) != 0) {
fprintf(feps, "%%%%Title: %s\n", symbol->text); fprintf(feps, "%%%%Title: %s\n", local_text);
} else { } else {
fprintf(feps, "%%%%Title: Zint Generated Symbol\n"); fprintf(feps, "%%%%Title: Zint Generated Symbol\n");
} }
@ -339,374 +371,372 @@ int ps_plot(struct zint_symbol *symbol) {
xoffset += comp_offset; xoffset += comp_offset;
if (plot_text) { if ((((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC)) ||
if ((((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC)) || (symbol->symbology == BARCODE_ISBNX)) {
(symbol->symbology == BARCODE_ISBNX)) { /* guard bar extensions and text formatting for EAN8 and EAN13 */
/* guard bar extensions and text formatting for EAN8 and EAN13 */ switch (ustrlen(local_text)) {
switch (ustrlen(symbol->text)) { case 8: /* EAN-8 */
case 8: /* EAN-8 */ case 11:
case 11: case 14:
case 14: fprintf(feps, "TE\n");
fprintf(feps, "TE\n"); fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink); fprintf(feps, "%.2f %.2f ", 5.0 * scaler, (4.0 + yoffset) * scaler);
fprintf(feps, "%.2f %.2f ", 5.0 * scaler, (4.0 + yoffset) * scaler); fprintf(feps, "TB %.2f %.2f TR\n", (0 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (0 + xoffset) * scaler, 1 * scaler); fprintf(feps, "TB %.2f %.2f TR\n", (2 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (2 + xoffset) * scaler, 1 * scaler); fprintf(feps, "TB %.2f %.2f TR\n", (32 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (32 + xoffset) * scaler, 1 * scaler); fprintf(feps, "TB %.2f %.2f TR\n", (34 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (34 + xoffset) * scaler, 1 * scaler); fprintf(feps, "TB %.2f %.2f TR\n", (64 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (64 + xoffset) * scaler, 1 * scaler); fprintf(feps, "TB %.2f %.2f TR\n", (66 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (66 + xoffset) * scaler, 1 * scaler); for (i = 0; i < 4; i++) {
for (i = 0; i < 4; i++) { textpart[i] = local_text[i];
textpart[i] = symbol->text[i];
}
textpart[4] = '\0';
fprintf(feps, "TE\n");
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = 17;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, "setmatrix\n");
for (i = 0; i < 4; i++) {
textpart[i] = symbol->text[i + 4];
}
textpart[4] = '\0';
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = 50;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, "setmatrix\n");
textdone = 1;
switch (strlen(addon)) {
case 2:
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = xoffset + 86;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler);
fprintf(feps, " (%s) stringwidth\n", addon);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", addon);
fprintf(feps, "setmatrix\n");
break;
case 5:
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = xoffset + 100;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler);
fprintf(feps, " (%s) stringwidth\n", addon);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", addon);
fprintf(feps, "setmatrix\n");
break;
}
break;
case 13: /* EAN 13 */
case 16:
case 19:
fprintf(feps, "TE\n");
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
fprintf(feps, "%.2f %.2f ", 5.0 * scaler, (4.0 + yoffset) * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (0 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (2 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (46 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (48 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (92 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (94 + xoffset) * scaler, 1 * scaler);
textpart[0] = symbol->text[0];
textpart[1] = '\0';
fprintf(feps, "TE\n");
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = -7;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, "setmatrix\n");
for (i = 0; i < 6; i++) {
textpart[i] = symbol->text[i + 1];
}
textpart[6] = '\0';
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = 24;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, "setmatrix\n");
for (i = 0; i < 6; i++) {
textpart[i] = symbol->text[i + 7];
}
textpart[6] = '\0';
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = 71;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, "setmatrix\n");
textdone = 1;
switch (strlen(addon)) {
case 2:
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = xoffset + 114;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler);
fprintf(feps, " (%s) stringwidth\n", addon);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", addon);
fprintf(feps, "setmatrix\n");
break;
case 5:
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = xoffset + 128;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler);
fprintf(feps, " (%s) stringwidth\n", addon);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", addon);
fprintf(feps, "setmatrix\n");
break;
}
break;
}
}
if (((symbol->symbology == BARCODE_UPCA) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCA_CC)) {
/* guard bar extensions and text formatting for UPCA */
fprintf(feps, "TE\n");
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
fprintf(feps, "%.2f %.2f ", 5.0 * scaler, (4.0 + yoffset) * scaler);
latch = 1;
i = 0 + comp_offset;
do {
block_width = 0;
do {
block_width++;
} while (module_is_set(symbol, symbol->rows - 1, i + block_width) == module_is_set(symbol, symbol->rows - 1, i));
if (latch == 1) {
/* a bar */
fprintf(feps, "TB %.2f %.2f TR\n", (i + xoffset - comp_offset) * scaler, block_width * scaler);
latch = 0;
} else {
/* a space */
latch = 1;
} }
i += block_width; textpart[4] = '\0';
} while (i < 11 + comp_offset); fprintf(feps, "TE\n");
fprintf(feps, "TB %.2f %.2f TR\n", (46 + xoffset) * scaler, 1 * scaler); fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
fprintf(feps, "TB %.2f %.2f TR\n", (48 + xoffset) * scaler, 1 * scaler); fprintf(feps, "matrix currentmatrix\n");
latch = 1; fprintf(feps, "/Helvetica findfont\n");
i = 85 + comp_offset; fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
do { textpos = 17;
block_width = 0; fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
do { fprintf(feps, " (%s) stringwidth\n", textpart);
block_width++; fprintf(feps, "pop\n");
} while (module_is_set(symbol, symbol->rows - 1, i + block_width) == module_is_set(symbol, symbol->rows - 1, i)); fprintf(feps, "-2 div 0 rmoveto\n");
if (latch == 1) { fprintf(feps, " (%s) show\n", textpart);
/* a bar */ fprintf(feps, "setmatrix\n");
fprintf(feps, "TB %.2f %.2f TR\n", (i + xoffset - comp_offset) * scaler, block_width * scaler); for (i = 0; i < 4; i++) {
latch = 0; textpart[i] = local_text[i + 4];
} else {
/* a space */
latch = 1;
} }
i += block_width; textpart[4] = '\0';
} while (i < 96 + comp_offset); fprintf(feps, "matrix currentmatrix\n");
textpart[0] = symbol->text[0]; fprintf(feps, "/Helvetica findfont\n");
textpart[1] = '\0'; fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
fprintf(feps, "TE\n"); textpos = 50;
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink); fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, "pop\n");
fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler); fprintf(feps, "-2 div 0 rmoveto\n");
textpos = -5; fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn); fprintf(feps, "setmatrix\n");
fprintf(feps, " (%s) stringwidth\n", textpart); textdone = 1;
fprintf(feps, "pop\n"); switch (strlen(addon)) {
fprintf(feps, "-2 div 0 rmoveto\n"); case 2:
fprintf(feps, " (%s) show\n", textpart); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "setmatrix\n"); fprintf(feps, "/Helvetica findfont\n");
for (i = 0; i < 5; i++) { fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpart[i] = symbol->text[i + 1]; textpos = xoffset + 86;
} fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler);
textpart[5] = '\0'; fprintf(feps, " (%s) stringwidth\n", addon);
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "pop\n");
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler); fprintf(feps, " (%s) show\n", addon);
textpos = 27; fprintf(feps, "setmatrix\n");
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn); break;
fprintf(feps, " (%s) stringwidth\n", textpart); case 5:
fprintf(feps, "pop\n"); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, " (%s) show\n", textpart); fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
fprintf(feps, "setmatrix\n"); textpos = xoffset + 100;
for (i = 0; i < 5; i++) { fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler);
textpart[i] = symbol->text[i + 6]; fprintf(feps, " (%s) stringwidth\n", addon);
} fprintf(feps, "pop\n");
textpart[6] = '\0'; fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, " (%s) show\n", addon);
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, "setmatrix\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler); break;
textpos = 68; }
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, " (%s) stringwidth\n", textpart); break;
fprintf(feps, "pop\n"); case 13: /* EAN 13 */
fprintf(feps, "-2 div 0 rmoveto\n"); case 16:
fprintf(feps, " (%s) show\n", textpart); case 19:
fprintf(feps, "setmatrix\n"); fprintf(feps, "TE\n");
textpart[0] = symbol->text[11]; fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
textpart[1] = '\0'; fprintf(feps, "%.2f %.2f ", 5.0 * scaler, (4.0 + yoffset) * scaler);
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "TB %.2f %.2f TR\n", (0 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, "TB %.2f %.2f TR\n", (2 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler); fprintf(feps, "TB %.2f %.2f TR\n", (46 + xoffset) * scaler, 1 * scaler);
textpos = 100; fprintf(feps, "TB %.2f %.2f TR\n", (48 + xoffset) * scaler, 1 * scaler);
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn); fprintf(feps, "TB %.2f %.2f TR\n", (92 + xoffset) * scaler, 1 * scaler);
fprintf(feps, " (%s) stringwidth\n", textpart); fprintf(feps, "TB %.2f %.2f TR\n", (94 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "pop\n"); textpart[0] = local_text[0];
fprintf(feps, "-2 div 0 rmoveto\n"); textpart[1] = '\0';
fprintf(feps, " (%s) show\n", textpart); fprintf(feps, "TE\n");
fprintf(feps, "setmatrix\n"); fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
textdone = 1; fprintf(feps, "matrix currentmatrix\n");
switch (strlen(addon)) { fprintf(feps, "/Helvetica findfont\n");
case 2: fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
fprintf(feps, "matrix currentmatrix\n"); textpos = -7;
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler); fprintf(feps, " (%s) stringwidth\n", textpart);
textpos = xoffset + 116; fprintf(feps, "pop\n");
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler); fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) stringwidth\n", addon); fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, "pop\n"); fprintf(feps, "setmatrix\n");
fprintf(feps, "-2 div 0 rmoveto\n"); for (i = 0; i < 6; i++) {
fprintf(feps, " (%s) show\n", addon); textpart[i] = local_text[i + 1];
fprintf(feps, "setmatrix\n"); }
break; textpart[6] = '\0';
case 5: fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler); textpos = 24;
textpos = xoffset + 130; fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler); fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, " (%s) stringwidth\n", addon); fprintf(feps, "pop\n");
fprintf(feps, "pop\n"); fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, " (%s) show\n", addon); fprintf(feps, "setmatrix\n");
fprintf(feps, "setmatrix\n"); for (i = 0; i < 6; i++) {
break; textpart[i] = local_text[i + 7];
} }
textpart[6] = '\0';
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = 71;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, "setmatrix\n");
textdone = 1;
switch (strlen(addon)) {
case 2:
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = xoffset + 114;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler);
fprintf(feps, " (%s) stringwidth\n", addon);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", addon);
fprintf(feps, "setmatrix\n");
break;
case 5:
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = xoffset + 128;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler);
fprintf(feps, " (%s) stringwidth\n", addon);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", addon);
fprintf(feps, "setmatrix\n");
break;
}
break;
} }
}
if (((symbol->symbology == BARCODE_UPCE) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCE_CC)) { if (((symbol->symbology == BARCODE_UPCA) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCA_CC)) {
/* guard bar extensions and text formatting for UPCE */ /* guard bar extensions and text formatting for UPCA */
fprintf(feps, "TE\n"); fprintf(feps, "TE\n");
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink); fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
fprintf(feps, "%.2f %.2f ", 5.0 * scaler, (4.0 + yoffset) * scaler); fprintf(feps, "%.2f %.2f ", 5.0 * scaler, (4.0 + yoffset) * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (0 + xoffset) * scaler, 1 * scaler); latch = 1;
fprintf(feps, "TB %.2f %.2f TR\n", (2 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (46 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (48 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (50 + xoffset) * scaler, 1 * scaler);
textpart[0] = symbol->text[0];
textpart[1] = '\0';
fprintf(feps, "TE\n");
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler);
textpos = -5;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, "setmatrix\n");
for (i = 0; i < 6; i++) {
textpart[i] = symbol->text[i + 1];
}
textpart[6] = '\0';
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = 24;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, "setmatrix\n");
textpart[0] = symbol->text[7];
textpart[1] = '\0';
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler);
textpos = 55;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, "setmatrix\n");
textdone = 1;
switch (strlen(addon)) {
case 2:
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = xoffset + 70;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler);
fprintf(feps, " (%s) stringwidth\n", addon);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", addon);
fprintf(feps, "setmatrix\n");
break;
case 5:
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = xoffset + 84;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler);
fprintf(feps, " (%s) stringwidth\n", addon);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", addon);
fprintf(feps, "setmatrix\n");
break;
}
i = 0 + comp_offset;
do {
block_width = 0;
do {
block_width++;
} while (module_is_set(symbol, symbol->rows - 1, i + block_width) == module_is_set(symbol, symbol->rows - 1, i));
if (latch == 1) {
/* a bar */
fprintf(feps, "TB %.2f %.2f TR\n", (i + xoffset - comp_offset) * scaler, block_width * scaler);
latch = 0;
} else {
/* a space */
latch = 1;
}
i += block_width;
} while (i < 11 + comp_offset);
fprintf(feps, "TB %.2f %.2f TR\n", (46 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (48 + xoffset) * scaler, 1 * scaler);
latch = 1;
i = 85 + comp_offset;
do {
block_width = 0;
do {
block_width++;
} while (module_is_set(symbol, symbol->rows - 1, i + block_width) == module_is_set(symbol, symbol->rows - 1, i));
if (latch == 1) {
/* a bar */
fprintf(feps, "TB %.2f %.2f TR\n", (i + xoffset - comp_offset) * scaler, block_width * scaler);
latch = 0;
} else {
/* a space */
latch = 1;
}
i += block_width;
} while (i < 96 + comp_offset);
textpart[0] = local_text[0];
textpart[1] = '\0';
fprintf(feps, "TE\n");
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler);
textpos = -5;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, "setmatrix\n");
for (i = 0; i < 5; i++) {
textpart[i] = local_text[i + 1];
} }
} /* if (plot_text) */ textpart[5] = '\0';
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = 27;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, "setmatrix\n");
for (i = 0; i < 5; i++) {
textpart[i] = local_text[i + 6];
}
textpart[6] = '\0';
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = 68;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, "setmatrix\n");
textpart[0] = local_text[11];
textpart[1] = '\0';
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler);
textpos = 100;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, "setmatrix\n");
textdone = 1;
switch (strlen(addon)) {
case 2:
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = xoffset + 116;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler);
fprintf(feps, " (%s) stringwidth\n", addon);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", addon);
fprintf(feps, "setmatrix\n");
break;
case 5:
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = xoffset + 130;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler);
fprintf(feps, " (%s) stringwidth\n", addon);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", addon);
fprintf(feps, "setmatrix\n");
break;
}
}
if (((symbol->symbology == BARCODE_UPCE) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCE_CC)) {
/* guard bar extensions and text formatting for UPCE */
fprintf(feps, "TE\n");
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
fprintf(feps, "%.2f %.2f ", 5.0 * scaler, (4.0 + yoffset) * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (0 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (2 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (46 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (48 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (50 + xoffset) * scaler, 1 * scaler);
textpart[0] = local_text[0];
textpart[1] = '\0';
fprintf(feps, "TE\n");
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler);
textpos = -5;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, "setmatrix\n");
for (i = 0; i < 6; i++) {
textpart[i] = local_text[i + 1];
}
textpart[6] = '\0';
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = 24;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, "setmatrix\n");
textpart[0] = local_text[7];
textpart[1] = '\0';
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler);
textpos = 55;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, "setmatrix\n");
textdone = 1;
switch (strlen(addon)) {
case 2:
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = xoffset + 70;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler);
fprintf(feps, " (%s) stringwidth\n", addon);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", addon);
fprintf(feps, "setmatrix\n");
break;
case 5:
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = xoffset + 84;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler);
fprintf(feps, " (%s) stringwidth\n", addon);
fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", addon);
fprintf(feps, "setmatrix\n");
break;
}
}
xoffset -= comp_offset; xoffset -= comp_offset;
@ -742,7 +772,7 @@ int ps_plot(struct zint_symbol *symbol) {
} }
/* Put the human readable text at the bottom */ /* Put the human readable text at the bottom */
if (plot_text && (textdone == 0)) { if (textdone == 0) {
fprintf(feps, "TE\n"); fprintf(feps, "TE\n");
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink); fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "matrix currentmatrix\n");
@ -750,10 +780,10 @@ int ps_plot(struct zint_symbol *symbol) {
fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler); fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler);
textpos = symbol->width / 2.0; textpos = symbol->width / 2.0;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn); fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, " (%s) stringwidth\n", symbol->text); fprintf(feps, " (%s) stringwidth\n", local_text);
fprintf(feps, "pop\n"); fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", symbol->text); fprintf(feps, " (%s) show\n", local_text);
fprintf(feps, "setmatrix\n"); fprintf(feps, "setmatrix\n");
} }
fprintf(feps, "\nshowpage\n"); fprintf(feps, "\nshowpage\n");

View File

@ -50,8 +50,12 @@ int svg_plot(struct zint_symbol *symbol) {
float addon_text_posn; float addon_text_posn;
float scaler = symbol->scale; float scaler = symbol->scale;
float default_text_posn; float default_text_posn;
int plot_text = 1;
const char *locale = NULL; const char *locale = NULL;
#ifndef _MSC_VER
unsigned char local_text[ustrlen(symbol->text) + 1];
#else
unsigned char* local_text = (unsigned char*) _alloca(ustrlen(symbol->text) + 1);
#endif
row_height = 0; row_height = 0;
textdone = 0; textdone = 0;
@ -60,6 +64,37 @@ int svg_plot(struct zint_symbol *symbol) {
comp_offset = 0; comp_offset = 0;
addon_text_posn = 0.0; addon_text_posn = 0.0;
if (symbol->show_hrt != 0) {
/* Copy text from symbol */
ustrcpy(local_text, symbol->text);
} else {
/* No text needed */
switch (symbol->symbology) {
case BARCODE_EANX:
case BARCODE_EANX_CC:
case BARCODE_ISBNX:
case BARCODE_UPCA:
case BARCODE_UPCE:
case BARCODE_UPCA_CC:
case BARCODE_UPCE_CC:
/* For these symbols use dummy text to ensure formatting is done
* properly even if no text is required */
for (i = 0; i < ustrlen(symbol->text); i++) {
if (symbol->text[i] == '+') {
local_text[i] = '+';
} else {
local_text[i] = ' ';
}
local_text[ustrlen(symbol->text)] = '\0';
}
break;
default:
/* For everything else, just remove the text */
local_text[0] = '\0';
break;
}
}
if ((symbol->output_options & BARCODE_STDOUT) != 0) { if ((symbol->output_options & BARCODE_STDOUT) != 0) {
fsvg = stdout; fsvg = stdout;
} else { } else {
@ -119,7 +154,7 @@ int svg_plot(struct zint_symbol *symbol) {
/* Certain symbols need whitespace otherwise characters get chopped off the sides */ /* Certain symbols need whitespace otherwise characters get chopped off the sides */
if ((((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC)) if ((((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC))
|| (symbol->symbology == BARCODE_ISBNX)) { || (symbol->symbology == BARCODE_ISBNX)) {
switch (ustrlen(symbol->text)) { switch (ustrlen(local_text)) {
case 13: /* EAN 13 */ case 13: /* EAN 13 */
case 16: case 16:
case 19: case 19:
@ -151,22 +186,19 @@ int svg_plot(struct zint_symbol *symbol) {
r = 0; r = 0;
/* Isolate add-on text */ /* Isolate add-on text */
if (is_extendable(symbol->symbology)) { if (is_extendable(symbol->symbology)) {
for (i = 0; i < ustrlen(symbol->text); i++) { for (i = 0; i < ustrlen(local_text); i++) {
if (latch == 1) { if (latch == 1) {
addon[r] = symbol->text[i]; addon[r] = local_text[i];
r++; r++;
} }
if (symbol->text[i] == '+') { if (local_text[i] == '+') {
latch = 1; latch = 1;
} }
} }
} }
addon[r] = '\0'; addon[r] = '\0';
if ((symbol->show_hrt == 0) || (ustrlen(symbol->text) == 0)) { if (ustrlen(local_text) != 0) {
plot_text = 0;
}
if (plot_text) {
textoffset = 9; textoffset = 9;
} else { } else {
textoffset = 0; textoffset = 0;
@ -184,8 +216,8 @@ int svg_plot(struct zint_symbol *symbol) {
fprintf(fsvg, "<svg width=\"%d\" height=\"%d\" version=\"1.1\"\n", (int)ceil((74.0F + xoffset + xoffset) * scaler), (int)ceil((72.0F + yoffset + yoffset) * scaler)); fprintf(fsvg, "<svg width=\"%d\" height=\"%d\" version=\"1.1\"\n", (int)ceil((74.0F + xoffset + xoffset) * scaler), (int)ceil((72.0F + yoffset + yoffset) * scaler));
} }
fprintf(fsvg, " xmlns=\"http://www.w3.org/2000/svg\">\n"); fprintf(fsvg, " xmlns=\"http://www.w3.org/2000/svg\">\n");
if (ustrlen(symbol->text) != 0) { if (ustrlen(local_text) != 0) {
fprintf(fsvg, " <desc>%s\n", symbol->text); fprintf(fsvg, " <desc>%s\n", local_text);
} else { } else {
fprintf(fsvg, " <desc>Zint Generated Symbol\n"); fprintf(fsvg, " <desc>Zint Generated Symbol\n");
} }
@ -313,254 +345,252 @@ int svg_plot(struct zint_symbol *symbol) {
xoffset += comp_offset; xoffset += comp_offset;
row_posn = (row_posn + large_bar_height) * scaler; row_posn = (row_posn + large_bar_height) * scaler;
if (plot_text) { if ((((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC)) ||
if ((((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC)) || (symbol->symbology == BARCODE_ISBNX)) {
(symbol->symbology == BARCODE_ISBNX)) { /* guard bar extensions and text formatting for EAN8 and EAN13 */
/* guard bar extensions and text formatting for EAN8 and EAN13 */ switch (ustrlen(local_text)) {
switch (ustrlen(symbol->text)) { case 8: /* EAN-8 */
case 8: /* EAN-8 */ case 11:
case 11: case 14:
case 14: fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (0 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (0 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (2 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (2 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (32 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (32 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (34 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (34 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (64 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (64 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (66 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (66 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); for (i = 0; i < 4; i++) {
for (i = 0; i < 4; i++) { textpart[i] = local_text[i];
textpart[i] = symbol->text[i];
}
textpart[4] = '\0';
textpos = 17;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
for (i = 0; i < 4; i++) {
textpart[i] = symbol->text[i + 4];
}
textpart[4] = '\0';
textpos = 50;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
textdone = 1;
switch (strlen(addon)) {
case 2:
textpos = xoffset + 86;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n");
break;
case 5:
textpos = xoffset + 100;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n");
break;
}
break;
case 13: /* EAN 13 */
case 16:
case 19:
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (0 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (2 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (46 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (48 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (92 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (94 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
textpart[0] = symbol->text[0];
textpart[1] = '\0';
textpos = -7;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
for (i = 0; i < 6; i++) {
textpart[i] = symbol->text[i + 1];
}
textpart[6] = '\0';
textpos = 24;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
for (i = 0; i < 6; i++) {
textpart[i] = symbol->text[i + 7];
}
textpart[6] = '\0';
textpos = 71;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
textdone = 1;
switch (strlen(addon)) {
case 2:
textpos = xoffset + 114;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n");
break;
case 5:
textpos = xoffset + 128;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n");
break;
}
break;
}
}
if (((symbol->symbology == BARCODE_UPCA) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCA_CC)) {
/* guard bar extensions and text formatting for UPCA */
latch = 1;
i = 0 + comp_offset;
do {
block_width = 0;
do {
block_width++;
} while (module_is_set(symbol, symbol->rows - 1, i + block_width) == module_is_set(symbol, symbol->rows - 1, i));
if (latch == 1) {
/* a bar */
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (i + xoffset - comp_offset) * scaler, row_posn, block_width * scaler, 5.0 * scaler);
latch = 0;
} else {
/* a space */
latch = 1;
} }
i += block_width; textpart[4] = '\0';
} while (i < 11 + comp_offset); textpos = 17;
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (46 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (48 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
latch = 1; fprintf(fsvg, " %s\n", textpart);
i = 85 + comp_offset; fprintf(fsvg, " </text>\n");
do { for (i = 0; i < 4; i++) {
block_width = 0; textpart[i] = local_text[i + 4];
do {
block_width++;
} while (module_is_set(symbol, symbol->rows - 1, i + block_width) == module_is_set(symbol, symbol->rows - 1, i));
if (latch == 1) {
/* a bar */
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (i + xoffset - comp_offset) * scaler, row_posn, block_width * scaler, 5.0 * scaler);
latch = 0;
} else {
/* a space */
latch = 1;
} }
i += block_width; textpart[4] = '\0';
} while (i < 96 + comp_offset); textpos = 50;
textpart[0] = symbol->text[0]; fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
textpart[1] = '\0'; fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
textpos = -5; fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn); fprintf(fsvg, " </text>\n");
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour); textdone = 1;
fprintf(fsvg, " %s\n", textpart); switch (strlen(addon)) {
fprintf(fsvg, " </text>\n"); case 2:
for (i = 0; i < 5; i++) { textpos = xoffset + 86;
textpart[i] = symbol->text[i + 1]; fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
} fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
textpart[5] = '\0'; fprintf(fsvg, " %s\n", addon);
textpos = 27; fprintf(fsvg, " </text>\n");
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn); break;
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour); case 5:
fprintf(fsvg, " %s\n", textpart); textpos = xoffset + 100;
fprintf(fsvg, " </text>\n"); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
for (i = 0; i < 5; i++) { fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
textpart[i] = symbol->text[i + 6]; fprintf(fsvg, " %s\n", addon);
} fprintf(fsvg, " </text>\n");
textpart[6] = '\0'; break;
textpos = 68; }
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour); break;
fprintf(fsvg, " %s\n", textpart); case 13: /* EAN 13 */
fprintf(fsvg, " </text>\n"); case 16:
textpart[0] = symbol->text[11]; case 19:
textpart[1] = '\0'; fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (0 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
textpos = 100; fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (2 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn); fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (46 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour); fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (48 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " %s\n", textpart); fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (92 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " </text>\n"); fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (94 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
textdone = 1; textpart[0] = local_text[0];
switch (strlen(addon)) { textpart[1] = '\0';
case 2: textpos = -7;
textpos = xoffset + 116; fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler); fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour); fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " %s\n", addon); fprintf(fsvg, " </text>\n");
fprintf(fsvg, " </text>\n"); for (i = 0; i < 6; i++) {
break; textpart[i] = local_text[i + 1];
case 5: }
textpos = xoffset + 130; textpart[6] = '\0';
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler); textpos = 24;
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " %s\n", addon); fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " </text>\n"); fprintf(fsvg, " %s\n", textpart);
break; fprintf(fsvg, " </text>\n");
} for (i = 0; i < 6; i++) {
textpart[i] = local_text[i + 7];
}
textpart[6] = '\0';
textpos = 71;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
textdone = 1;
switch (strlen(addon)) {
case 2:
textpos = xoffset + 114;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n");
break;
case 5:
textpos = xoffset + 128;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n");
break;
}
break;
} }
}
if (((symbol->symbology == BARCODE_UPCE) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCE_CC)) { if (((symbol->symbology == BARCODE_UPCA) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCA_CC)) {
/* guard bar extensions and text formatting for UPCE */ /* guard bar extensions and text formatting for UPCA */
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (0 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); latch = 1;
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (2 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (46 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (48 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (50 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
textpart[0] = symbol->text[0];
textpart[1] = '\0';
textpos = -5;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
for (i = 0; i < 6; i++) {
textpart[i] = symbol->text[i + 1];
}
textpart[6] = '\0';
textpos = 24;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
textpart[0] = symbol->text[7];
textpart[1] = '\0';
textpos = 55;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
textdone = 1;
switch (strlen(addon)) {
case 2:
textpos = xoffset + 70;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n");
break;
case 5:
textpos = xoffset + 84;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n");
break;
}
i = 0 + comp_offset;
do {
block_width = 0;
do {
block_width++;
} while (module_is_set(symbol, symbol->rows - 1, i + block_width) == module_is_set(symbol, symbol->rows - 1, i));
if (latch == 1) {
/* a bar */
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (i + xoffset - comp_offset) * scaler, row_posn, block_width * scaler, 5.0 * scaler);
latch = 0;
} else {
/* a space */
latch = 1;
}
i += block_width;
} while (i < 11 + comp_offset);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (46 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (48 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
latch = 1;
i = 85 + comp_offset;
do {
block_width = 0;
do {
block_width++;
} while (module_is_set(symbol, symbol->rows - 1, i + block_width) == module_is_set(symbol, symbol->rows - 1, i));
if (latch == 1) {
/* a bar */
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (i + xoffset - comp_offset) * scaler, row_posn, block_width * scaler, 5.0 * scaler);
latch = 0;
} else {
/* a space */
latch = 1;
}
i += block_width;
} while (i < 96 + comp_offset);
textpart[0] = local_text[0];
textpart[1] = '\0';
textpos = -5;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
for (i = 0; i < 5; i++) {
textpart[i] = local_text[i + 1];
} }
} /* if (plot_text) */ textpart[5] = '\0';
textpos = 27;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
for (i = 0; i < 5; i++) {
textpart[i] = local_text[i + 6];
}
textpart[6] = '\0';
textpos = 68;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
textpart[0] = local_text[11];
textpart[1] = '\0';
textpos = 100;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
textdone = 1;
switch (strlen(addon)) {
case 2:
textpos = xoffset + 116;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n");
break;
case 5:
textpos = xoffset + 130;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n");
break;
}
}
if (((symbol->symbology == BARCODE_UPCE) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCE_CC)) {
/* guard bar extensions and text formatting for UPCE */
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (0 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (2 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (46 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (48 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (50 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
textpart[0] = local_text[0];
textpart[1] = '\0';
textpos = -5;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
for (i = 0; i < 6; i++) {
textpart[i] = local_text[i + 1];
}
textpart[6] = '\0';
textpos = 24;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
textpart[0] = local_text[7];
textpart[1] = '\0';
textpos = 55;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
textdone = 1;
switch (strlen(addon)) {
case 2:
textpos = xoffset + 70;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n");
break;
case 5:
textpos = xoffset + 84;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n");
break;
}
}
xoffset -= comp_offset; xoffset -= comp_offset;
@ -590,11 +620,11 @@ int svg_plot(struct zint_symbol *symbol) {
} }
/* Put the human readable text at the bottom */ /* Put the human readable text at the bottom */
if (plot_text && (textdone == 0)) { if (textdone == 0) {
textpos = symbol->width / 2.0; textpos = symbol->width / 2.0;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour); fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", symbol->text); fprintf(fsvg, " %s\n", local_text);
fprintf(fsvg, " </text>\n"); fprintf(fsvg, " </text>\n");
} }
fprintf(fsvg, " </g>\n"); fprintf(fsvg, " </g>\n");