diff --git a/backend/png.c b/backend/png.c index 62044fde..d702e316 100644 --- a/backend/png.c +++ b/backend/png.c @@ -721,9 +721,34 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle, int data_type) { #endif if (symbol->show_hrt != 0) { + /* Copy text from symbol */ to_latin1(symbol->text, local_text); } 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; @@ -812,6 +837,7 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle, int data_type) { } else { textoffset = 0; } + xoffset = symbol->border_width + symbol->whitespace_width; yoffset = symbol->border_width; 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, (66 + xoffset) * 2, 1 * 2, (4 + (int) yoffset) * 2, 5 * 2, image_width, image_height); for (i = 0; i < 4; i++) { - textpart[i] = symbol->text[i]; + textpart[i] = local_text[i]; } textpart[4] = '\0'; textpos = 2 * (17 + xoffset); draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); for (i = 0; i < 4; i++) { - textpart[i] = symbol->text[i + 4]; + textpart[i] = local_text[i + 4]; } textpart[4] = '\0'; 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, (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'; textpos = 2 * (-7 + xoffset); draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); for (i = 0; i < 6; i++) { - textpart[i] = symbol->text[i + 1]; + textpart[i] = local_text[i + 1]; } textpart[6] = '\0'; textpos = 2 * (24 + xoffset); draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); for (i = 0; i < 6; i++) { - textpart[i] = symbol->text[i + 7]; + textpart[i] = local_text[i + 7]; } textpart[6] = '\0'; textpos = 2 * (71 + xoffset); @@ -1001,23 +1027,23 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle, int data_type) { } i += block_width; } while (i < 96 + comp_offset); - textpart[0] = symbol->text[0]; + textpart[0] = local_text[0]; textpart[1] = '\0'; textpos = 2 * (-5 + xoffset); draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); for (i = 0; i < 5; i++) { - textpart[i] = symbol->text[i + 1]; + textpart[i] = local_text[i + 1]; } textpart[5] = '\0'; textpos = 2 * (27 + xoffset); draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); for (i = 0; i < 5; i++) { - textpart[i] = symbol->text[i + 6]; + textpart[i] = local_text[i + 6]; } textpart[6] = '\0'; textpos = 2 * (68 + xoffset); 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'; textpos = 2 * (100 + xoffset); 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, (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'; textpos = 2 * (-5 + xoffset); draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); for (i = 0; i < 6; i++) { - textpart[i] = symbol->text[i + 1]; + textpart[i] = local_text[i + 1]; } textpart[6] = '\0'; textpos = 2 * (24 + xoffset); 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'; textpos = 2 * (55 + xoffset); draw_string(pixelbuf, textpart, textpos, default_text_posn, smalltext, image_width, image_height); diff --git a/backend/ps.c b/backend/ps.c index dfc863f2..14065dde 100644 --- a/backend/ps.c +++ b/backend/ps.c @@ -52,8 +52,12 @@ int ps_plot(struct zint_symbol *symbol) { float addon_text_posn; float scaler = symbol->scale; float default_text_posn; - int plot_text = 1; 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; textdone = 0; @@ -61,6 +65,37 @@ int ps_plot(struct zint_symbol *symbol) { strcpy(addon, ""); comp_offset = 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) { feps = stdout; @@ -134,7 +169,7 @@ int ps_plot(struct zint_symbol *symbol) { /* Certain symbols need whitespace otherwise characters get chopped off the sides */ if ((((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC)) || (symbol->symbology == BARCODE_ISBNX)) { - switch (ustrlen(symbol->text)) { + switch (ustrlen(local_text)) { case 13: /* EAN 13 */ case 16: case 19: @@ -166,22 +201,19 @@ int ps_plot(struct zint_symbol *symbol) { r = 0; /* Isolate add-on text */ if (is_extendable(symbol->symbology)) { - for (i = 0; i < ustrlen(symbol->text); i++) { + for (i = 0; i < ustrlen(local_text); i++) { if (latch == 1) { - addon[r] = symbol->text[i]; + addon[r] = local_text[i]; r++; } - if (symbol->text[i] == '+') { + if (local_text[i] == '+') { latch = 1; } } } addon[r] = '\0'; - if ((symbol->show_hrt == 0) || (ustrlen(symbol->text) == 0)) { - plot_text = 0; - } - if (plot_text) { + if (ustrlen(local_text) != 0) { textoffset = 9; } else { textoffset = 0; @@ -192,8 +224,8 @@ int ps_plot(struct zint_symbol *symbol) { /* Start writing the header */ fprintf(feps, "%%!PS-Adobe-3.0 EPSF-3.0\n"); fprintf(feps, "%%%%Creator: Zint %s\n", ZINT_VERSION); - if (ustrlen(symbol->text) != 0) { - fprintf(feps, "%%%%Title: %s\n", symbol->text); + if (ustrlen(local_text) != 0) { + fprintf(feps, "%%%%Title: %s\n", local_text); } else { fprintf(feps, "%%%%Title: Zint Generated Symbol\n"); } @@ -339,374 +371,372 @@ int ps_plot(struct zint_symbol *symbol) { xoffset += comp_offset; - if (plot_text) { - if ((((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC)) || - (symbol->symbology == BARCODE_ISBNX)) { - /* guard bar extensions and text formatting for EAN8 and EAN13 */ - switch (ustrlen(symbol->text)) { - case 8: /* EAN-8 */ - case 11: - case 14: - 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", (32 + 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", (66 + xoffset) * scaler, 1 * scaler); - for (i = 0; i < 4; 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; + if ((((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC)) || + (symbol->symbology == BARCODE_ISBNX)) { + /* guard bar extensions and text formatting for EAN8 and EAN13 */ + switch (ustrlen(local_text)) { + case 8: /* EAN-8 */ + case 11: + case 14: + 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", (32 + 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", (66 + xoffset) * scaler, 1 * scaler); + for (i = 0; i < 4; i++) { + textpart[i] = local_text[i]; } - 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; + 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] = local_text[i + 4]; } - i += block_width; - } while (i < 96 + comp_offset); - 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 < 5; i++) { - textpart[i] = symbol->text[i + 1]; - } - 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] = symbol->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] = symbol->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; - } + 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] = 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", 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] = 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"); + for (i = 0; i < 6; i++) { + 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)) { - /* 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] = 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; - } + 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; + } 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; @@ -742,7 +772,7 @@ int ps_plot(struct zint_symbol *symbol) { } /* Put the human readable text at the bottom */ - if (plot_text && (textdone == 0)) { + if (textdone == 0) { fprintf(feps, "TE\n"); fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink); 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); 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, " (%s) stringwidth\n", symbol->text); + fprintf(feps, " (%s) stringwidth\n", local_text); fprintf(feps, "pop\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, "\nshowpage\n"); diff --git a/backend/svg.c b/backend/svg.c index 02af747d..61d0a216 100644 --- a/backend/svg.c +++ b/backend/svg.c @@ -50,8 +50,12 @@ int svg_plot(struct zint_symbol *symbol) { float addon_text_posn; float scaler = symbol->scale; float default_text_posn; - int plot_text = 1; 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; textdone = 0; @@ -59,6 +63,37 @@ int svg_plot(struct zint_symbol *symbol) { strcpy(addon, ""); comp_offset = 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) { fsvg = stdout; @@ -119,7 +154,7 @@ int svg_plot(struct zint_symbol *symbol) { /* Certain symbols need whitespace otherwise characters get chopped off the sides */ if ((((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC)) || (symbol->symbology == BARCODE_ISBNX)) { - switch (ustrlen(symbol->text)) { + switch (ustrlen(local_text)) { case 13: /* EAN 13 */ case 16: case 19: @@ -151,22 +186,19 @@ int svg_plot(struct zint_symbol *symbol) { r = 0; /* Isolate add-on text */ if (is_extendable(symbol->symbology)) { - for (i = 0; i < ustrlen(symbol->text); i++) { + for (i = 0; i < ustrlen(local_text); i++) { if (latch == 1) { - addon[r] = symbol->text[i]; + addon[r] = local_text[i]; r++; } - if (symbol->text[i] == '+') { + if (local_text[i] == '+') { latch = 1; } } } addon[r] = '\0'; - if ((symbol->show_hrt == 0) || (ustrlen(symbol->text) == 0)) { - plot_text = 0; - } - if (plot_text) { + if (ustrlen(local_text) != 0) { textoffset = 9; } else { textoffset = 0; @@ -184,8 +216,8 @@ int svg_plot(struct zint_symbol *symbol) { fprintf(fsvg, "\n"); - if (ustrlen(symbol->text) != 0) { - fprintf(fsvg, " %s\n", symbol->text); + if (ustrlen(local_text) != 0) { + fprintf(fsvg, " %s\n", local_text); } else { fprintf(fsvg, " Zint Generated Symbol\n"); } @@ -313,254 +345,252 @@ int svg_plot(struct zint_symbol *symbol) { xoffset += comp_offset; row_posn = (row_posn + large_bar_height) * scaler; - if (plot_text) { - if ((((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC)) || - (symbol->symbology == BARCODE_ISBNX)) { - /* guard bar extensions and text formatting for EAN8 and EAN13 */ - switch (ustrlen(symbol->text)) { - case 8: /* EAN-8 */ - case 11: - case 14: - fprintf(fsvg, " \n", (0 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); - fprintf(fsvg, " \n", (2 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); - fprintf(fsvg, " \n", (32 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); - fprintf(fsvg, " \n", (34 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); - fprintf(fsvg, " \n", (64 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); - fprintf(fsvg, " \n", (66 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); - for (i = 0; i < 4; i++) { - textpart[i] = symbol->text[i]; - } - textpart[4] = '\0'; - textpos = 17; - fprintf(fsvg, " \n", 11.0 * scaler, symbol->fgcolour); - fprintf(fsvg, " %s\n", textpart); - fprintf(fsvg, " \n"); - for (i = 0; i < 4; i++) { - textpart[i] = symbol->text[i + 4]; - } - textpart[4] = '\0'; - textpos = 50; - fprintf(fsvg, " \n", 11.0 * scaler, symbol->fgcolour); - fprintf(fsvg, " %s\n", textpart); - fprintf(fsvg, " \n"); - textdone = 1; - switch (strlen(addon)) { - case 2: - textpos = xoffset + 86; - fprintf(fsvg, " \n", 11.0 * scaler, symbol->fgcolour); - fprintf(fsvg, " %s\n", addon); - fprintf(fsvg, " \n"); - break; - case 5: - textpos = xoffset + 100; - fprintf(fsvg, " \n", 11.0 * scaler, symbol->fgcolour); - fprintf(fsvg, " %s\n", addon); - fprintf(fsvg, " \n"); - break; - } - - break; - case 13: /* EAN 13 */ - case 16: - case 19: - fprintf(fsvg, " \n", (0 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); - fprintf(fsvg, " \n", (2 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); - fprintf(fsvg, " \n", (46 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); - fprintf(fsvg, " \n", (48 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); - fprintf(fsvg, " \n", (92 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); - fprintf(fsvg, " \n", (94 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); - textpart[0] = symbol->text[0]; - textpart[1] = '\0'; - textpos = -7; - fprintf(fsvg, " \n", 11.0 * scaler, symbol->fgcolour); - fprintf(fsvg, " %s\n", textpart); - fprintf(fsvg, " \n"); - for (i = 0; i < 6; i++) { - textpart[i] = symbol->text[i + 1]; - } - textpart[6] = '\0'; - textpos = 24; - fprintf(fsvg, " \n", 11.0 * scaler, symbol->fgcolour); - fprintf(fsvg, " %s\n", textpart); - fprintf(fsvg, " \n"); - for (i = 0; i < 6; i++) { - textpart[i] = symbol->text[i + 7]; - } - textpart[6] = '\0'; - textpos = 71; - fprintf(fsvg, " \n", 11.0 * scaler, symbol->fgcolour); - fprintf(fsvg, " %s\n", textpart); - fprintf(fsvg, " \n"); - textdone = 1; - switch (strlen(addon)) { - case 2: - textpos = xoffset + 114; - fprintf(fsvg, " \n", 11.0 * scaler, symbol->fgcolour); - fprintf(fsvg, " %s\n", addon); - fprintf(fsvg, " \n"); - break; - case 5: - textpos = xoffset + 128; - fprintf(fsvg, " \n", 11.0 * scaler, symbol->fgcolour); - fprintf(fsvg, " %s\n", addon); - fprintf(fsvg, " \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, " \n", (i + xoffset - comp_offset) * scaler, row_posn, block_width * scaler, 5.0 * scaler); - latch = 0; - } else { - /* a space */ - latch = 1; + if ((((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC)) || + (symbol->symbology == BARCODE_ISBNX)) { + /* guard bar extensions and text formatting for EAN8 and EAN13 */ + switch (ustrlen(local_text)) { + case 8: /* EAN-8 */ + case 11: + case 14: + fprintf(fsvg, " \n", (0 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); + fprintf(fsvg, " \n", (2 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); + fprintf(fsvg, " \n", (32 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); + fprintf(fsvg, " \n", (34 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); + fprintf(fsvg, " \n", (64 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); + fprintf(fsvg, " \n", (66 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); + for (i = 0; i < 4; i++) { + textpart[i] = local_text[i]; } - i += block_width; - } while (i < 11 + comp_offset); - fprintf(fsvg, " \n", (46 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); - fprintf(fsvg, " \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, " \n", (i + xoffset - comp_offset) * scaler, row_posn, block_width * scaler, 5.0 * scaler); - latch = 0; - } else { - /* a space */ - latch = 1; + textpart[4] = '\0'; + textpos = 17; + fprintf(fsvg, " \n", 11.0 * scaler, symbol->fgcolour); + fprintf(fsvg, " %s\n", textpart); + fprintf(fsvg, " \n"); + for (i = 0; i < 4; i++) { + textpart[i] = local_text[i + 4]; } - i += block_width; - } while (i < 96 + comp_offset); - textpart[0] = symbol->text[0]; - textpart[1] = '\0'; - textpos = -5; - fprintf(fsvg, " \n", 8.0 * scaler, symbol->fgcolour); - fprintf(fsvg, " %s\n", textpart); - fprintf(fsvg, " \n"); - for (i = 0; i < 5; i++) { - textpart[i] = symbol->text[i + 1]; - } - textpart[5] = '\0'; - textpos = 27; - fprintf(fsvg, " \n", 11.0 * scaler, symbol->fgcolour); - fprintf(fsvg, " %s\n", textpart); - fprintf(fsvg, " \n"); - for (i = 0; i < 5; i++) { - textpart[i] = symbol->text[i + 6]; - } - textpart[6] = '\0'; - textpos = 68; - fprintf(fsvg, " \n", 11.0 * scaler, symbol->fgcolour); - fprintf(fsvg, " %s\n", textpart); - fprintf(fsvg, " \n"); - textpart[0] = symbol->text[11]; - textpart[1] = '\0'; - textpos = 100; - fprintf(fsvg, " \n", 8.0 * scaler, symbol->fgcolour); - fprintf(fsvg, " %s\n", textpart); - fprintf(fsvg, " \n"); - textdone = 1; - switch (strlen(addon)) { - case 2: - textpos = xoffset + 116; - fprintf(fsvg, " \n", 11.0 * scaler, symbol->fgcolour); - fprintf(fsvg, " %s\n", addon); - fprintf(fsvg, " \n"); - break; - case 5: - textpos = xoffset + 130; - fprintf(fsvg, " \n", 11.0 * scaler, symbol->fgcolour); - fprintf(fsvg, " %s\n", addon); - fprintf(fsvg, " \n"); - break; - } + textpart[4] = '\0'; + textpos = 50; + fprintf(fsvg, " \n", 11.0 * scaler, symbol->fgcolour); + fprintf(fsvg, " %s\n", textpart); + fprintf(fsvg, " \n"); + textdone = 1; + switch (strlen(addon)) { + case 2: + textpos = xoffset + 86; + fprintf(fsvg, " \n", 11.0 * scaler, symbol->fgcolour); + fprintf(fsvg, " %s\n", addon); + fprintf(fsvg, " \n"); + break; + case 5: + textpos = xoffset + 100; + fprintf(fsvg, " \n", 11.0 * scaler, symbol->fgcolour); + fprintf(fsvg, " %s\n", addon); + fprintf(fsvg, " \n"); + break; + } + + break; + case 13: /* EAN 13 */ + case 16: + case 19: + fprintf(fsvg, " \n", (0 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); + fprintf(fsvg, " \n", (2 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); + fprintf(fsvg, " \n", (46 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); + fprintf(fsvg, " \n", (48 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); + fprintf(fsvg, " \n", (92 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); + fprintf(fsvg, " \n", (94 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); + textpart[0] = local_text[0]; + textpart[1] = '\0'; + textpos = -7; + fprintf(fsvg, " \n", 11.0 * scaler, symbol->fgcolour); + fprintf(fsvg, " %s\n", textpart); + fprintf(fsvg, " \n"); + for (i = 0; i < 6; i++) { + textpart[i] = local_text[i + 1]; + } + textpart[6] = '\0'; + textpos = 24; + fprintf(fsvg, " \n", 11.0 * scaler, symbol->fgcolour); + fprintf(fsvg, " %s\n", textpart); + fprintf(fsvg, " \n"); + for (i = 0; i < 6; i++) { + textpart[i] = local_text[i + 7]; + } + textpart[6] = '\0'; + textpos = 71; + fprintf(fsvg, " \n", 11.0 * scaler, symbol->fgcolour); + fprintf(fsvg, " %s\n", textpart); + fprintf(fsvg, " \n"); + textdone = 1; + switch (strlen(addon)) { + case 2: + textpos = xoffset + 114; + fprintf(fsvg, " \n", 11.0 * scaler, symbol->fgcolour); + fprintf(fsvg, " %s\n", addon); + fprintf(fsvg, " \n"); + break; + case 5: + textpos = xoffset + 128; + fprintf(fsvg, " \n", 11.0 * scaler, symbol->fgcolour); + fprintf(fsvg, " %s\n", addon); + fprintf(fsvg, " \n"); + break; + } + break; } + } - if (((symbol->symbology == BARCODE_UPCE) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCE_CC)) { - /* guard bar extensions and text formatting for UPCE */ - fprintf(fsvg, " \n", (0 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); - fprintf(fsvg, " \n", (2 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); - fprintf(fsvg, " \n", (46 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); - fprintf(fsvg, " \n", (48 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); - fprintf(fsvg, " \n", (50 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); - textpart[0] = symbol->text[0]; - textpart[1] = '\0'; - textpos = -5; - fprintf(fsvg, " \n", 8.0 * scaler, symbol->fgcolour); - fprintf(fsvg, " %s\n", textpart); - fprintf(fsvg, " \n"); - for (i = 0; i < 6; i++) { - textpart[i] = symbol->text[i + 1]; - } - textpart[6] = '\0'; - textpos = 24; - fprintf(fsvg, " \n", 11.0 * scaler, symbol->fgcolour); - fprintf(fsvg, " %s\n", textpart); - fprintf(fsvg, " \n"); - textpart[0] = symbol->text[7]; - textpart[1] = '\0'; - textpos = 55; - fprintf(fsvg, " \n", 8.0 * scaler, symbol->fgcolour); - fprintf(fsvg, " %s\n", textpart); - fprintf(fsvg, " \n"); - textdone = 1; - switch (strlen(addon)) { - case 2: - textpos = xoffset + 70; - fprintf(fsvg, " \n", 11.0 * scaler, symbol->fgcolour); - fprintf(fsvg, " %s\n", addon); - fprintf(fsvg, " \n"); - break; - case 5: - textpos = xoffset + 84; - fprintf(fsvg, " \n", 11.0 * scaler, symbol->fgcolour); - fprintf(fsvg, " %s\n", addon); - fprintf(fsvg, " \n"); - 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, " \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, " \n", (46 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); + fprintf(fsvg, " \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, " \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, " \n", 8.0 * scaler, symbol->fgcolour); + fprintf(fsvg, " %s\n", textpart); + fprintf(fsvg, " \n"); + for (i = 0; i < 5; i++) { + textpart[i] = local_text[i + 1]; } - } /* if (plot_text) */ + textpart[5] = '\0'; + textpos = 27; + fprintf(fsvg, " \n", 11.0 * scaler, symbol->fgcolour); + fprintf(fsvg, " %s\n", textpart); + fprintf(fsvg, " \n"); + for (i = 0; i < 5; i++) { + textpart[i] = local_text[i + 6]; + } + textpart[6] = '\0'; + textpos = 68; + fprintf(fsvg, " \n", 11.0 * scaler, symbol->fgcolour); + fprintf(fsvg, " %s\n", textpart); + fprintf(fsvg, " \n"); + textpart[0] = local_text[11]; + textpart[1] = '\0'; + textpos = 100; + fprintf(fsvg, " \n", 8.0 * scaler, symbol->fgcolour); + fprintf(fsvg, " %s\n", textpart); + fprintf(fsvg, " \n"); + textdone = 1; + switch (strlen(addon)) { + case 2: + textpos = xoffset + 116; + fprintf(fsvg, " \n", 11.0 * scaler, symbol->fgcolour); + fprintf(fsvg, " %s\n", addon); + fprintf(fsvg, " \n"); + break; + case 5: + textpos = xoffset + 130; + fprintf(fsvg, " \n", 11.0 * scaler, symbol->fgcolour); + fprintf(fsvg, " %s\n", addon); + fprintf(fsvg, " \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, " \n", (0 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); + fprintf(fsvg, " \n", (2 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); + fprintf(fsvg, " \n", (46 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); + fprintf(fsvg, " \n", (48 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); + fprintf(fsvg, " \n", (50 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); + textpart[0] = local_text[0]; + textpart[1] = '\0'; + textpos = -5; + fprintf(fsvg, " \n", 8.0 * scaler, symbol->fgcolour); + fprintf(fsvg, " %s\n", textpart); + fprintf(fsvg, " \n"); + for (i = 0; i < 6; i++) { + textpart[i] = local_text[i + 1]; + } + textpart[6] = '\0'; + textpos = 24; + fprintf(fsvg, " \n", 11.0 * scaler, symbol->fgcolour); + fprintf(fsvg, " %s\n", textpart); + fprintf(fsvg, " \n"); + textpart[0] = local_text[7]; + textpart[1] = '\0'; + textpos = 55; + fprintf(fsvg, " \n", 8.0 * scaler, symbol->fgcolour); + fprintf(fsvg, " %s\n", textpart); + fprintf(fsvg, " \n"); + textdone = 1; + switch (strlen(addon)) { + case 2: + textpos = xoffset + 70; + fprintf(fsvg, " \n", 11.0 * scaler, symbol->fgcolour); + fprintf(fsvg, " %s\n", addon); + fprintf(fsvg, " \n"); + break; + case 5: + textpos = xoffset + 84; + fprintf(fsvg, " \n", 11.0 * scaler, symbol->fgcolour); + fprintf(fsvg, " %s\n", addon); + fprintf(fsvg, " \n"); + break; + } + + } xoffset -= comp_offset; @@ -590,11 +620,11 @@ int svg_plot(struct zint_symbol *symbol) { } /* Put the human readable text at the bottom */ - if (plot_text && (textdone == 0)) { + if (textdone == 0) { textpos = symbol->width / 2.0; fprintf(fsvg, " \n", 8.0 * scaler, symbol->fgcolour); - fprintf(fsvg, " %s\n", symbol->text); + fprintf(fsvg, " %s\n", local_text); fprintf(fsvg, " \n"); } fprintf(fsvg, " \n");