mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
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:
parent
c709b08da5
commit
d2774af120
@ -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 {
|
||||||
|
/* 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';
|
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);
|
||||||
|
88
backend/ps.c
88
backend/ps.c
@ -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,11 +371,10 @@ 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(symbol->text)) {
|
switch (ustrlen(local_text)) {
|
||||||
case 8: /* EAN-8 */
|
case 8: /* EAN-8 */
|
||||||
case 11:
|
case 11:
|
||||||
case 14:
|
case 14:
|
||||||
@ -357,7 +388,7 @@ int ps_plot(struct zint_symbol *symbol) {
|
|||||||
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] = symbol->text[i];
|
textpart[i] = local_text[i];
|
||||||
}
|
}
|
||||||
textpart[4] = '\0';
|
textpart[4] = '\0';
|
||||||
fprintf(feps, "TE\n");
|
fprintf(feps, "TE\n");
|
||||||
@ -373,7 +404,7 @@ int ps_plot(struct zint_symbol *symbol) {
|
|||||||
fprintf(feps, " (%s) show\n", textpart);
|
fprintf(feps, " (%s) show\n", textpart);
|
||||||
fprintf(feps, "setmatrix\n");
|
fprintf(feps, "setmatrix\n");
|
||||||
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';
|
||||||
fprintf(feps, "matrix currentmatrix\n");
|
fprintf(feps, "matrix currentmatrix\n");
|
||||||
@ -427,7 +458,7 @@ int ps_plot(struct zint_symbol *symbol) {
|
|||||||
fprintf(feps, "TB %.2f %.2f TR\n", (48 + 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", (92 + xoffset) * scaler, 1 * scaler);
|
||||||
fprintf(feps, "TB %.2f %.2f TR\n", (94 + xoffset) * scaler, 1 * scaler);
|
fprintf(feps, "TB %.2f %.2f TR\n", (94 + xoffset) * scaler, 1 * scaler);
|
||||||
textpart[0] = symbol->text[0];
|
textpart[0] = local_text[0];
|
||||||
textpart[1] = '\0';
|
textpart[1] = '\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);
|
||||||
@ -442,7 +473,7 @@ int ps_plot(struct zint_symbol *symbol) {
|
|||||||
fprintf(feps, " (%s) show\n", textpart);
|
fprintf(feps, " (%s) show\n", textpart);
|
||||||
fprintf(feps, "setmatrix\n");
|
fprintf(feps, "setmatrix\n");
|
||||||
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';
|
||||||
fprintf(feps, "matrix currentmatrix\n");
|
fprintf(feps, "matrix currentmatrix\n");
|
||||||
@ -456,7 +487,7 @@ int ps_plot(struct zint_symbol *symbol) {
|
|||||||
fprintf(feps, " (%s) show\n", textpart);
|
fprintf(feps, " (%s) show\n", textpart);
|
||||||
fprintf(feps, "setmatrix\n");
|
fprintf(feps, "setmatrix\n");
|
||||||
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';
|
||||||
fprintf(feps, "matrix currentmatrix\n");
|
fprintf(feps, "matrix currentmatrix\n");
|
||||||
@ -543,7 +574,7 @@ int ps_plot(struct zint_symbol *symbol) {
|
|||||||
}
|
}
|
||||||
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';
|
||||||
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);
|
||||||
@ -558,7 +589,7 @@ int ps_plot(struct zint_symbol *symbol) {
|
|||||||
fprintf(feps, " (%s) show\n", textpart);
|
fprintf(feps, " (%s) show\n", textpart);
|
||||||
fprintf(feps, "setmatrix\n");
|
fprintf(feps, "setmatrix\n");
|
||||||
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';
|
||||||
fprintf(feps, "matrix currentmatrix\n");
|
fprintf(feps, "matrix currentmatrix\n");
|
||||||
@ -572,7 +603,7 @@ int ps_plot(struct zint_symbol *symbol) {
|
|||||||
fprintf(feps, " (%s) show\n", textpart);
|
fprintf(feps, " (%s) show\n", textpart);
|
||||||
fprintf(feps, "setmatrix\n");
|
fprintf(feps, "setmatrix\n");
|
||||||
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';
|
||||||
fprintf(feps, "matrix currentmatrix\n");
|
fprintf(feps, "matrix currentmatrix\n");
|
||||||
@ -585,7 +616,7 @@ int ps_plot(struct zint_symbol *symbol) {
|
|||||||
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", textpart);
|
||||||
fprintf(feps, "setmatrix\n");
|
fprintf(feps, "setmatrix\n");
|
||||||
textpart[0] = symbol->text[11];
|
textpart[0] = local_text[11];
|
||||||
textpart[1] = '\0';
|
textpart[1] = '\0';
|
||||||
fprintf(feps, "matrix currentmatrix\n");
|
fprintf(feps, "matrix currentmatrix\n");
|
||||||
fprintf(feps, "/Helvetica findfont\n");
|
fprintf(feps, "/Helvetica findfont\n");
|
||||||
@ -637,7 +668,7 @@ int ps_plot(struct zint_symbol *symbol) {
|
|||||||
fprintf(feps, "TB %.2f %.2f TR\n", (46 + 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", (48 + xoffset) * scaler, 1 * scaler);
|
||||||
fprintf(feps, "TB %.2f %.2f TR\n", (50 + xoffset) * scaler, 1 * scaler);
|
fprintf(feps, "TB %.2f %.2f TR\n", (50 + xoffset) * scaler, 1 * scaler);
|
||||||
textpart[0] = symbol->text[0];
|
textpart[0] = local_text[0];
|
||||||
textpart[1] = '\0';
|
textpart[1] = '\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);
|
||||||
@ -652,7 +683,7 @@ int ps_plot(struct zint_symbol *symbol) {
|
|||||||
fprintf(feps, " (%s) show\n", textpart);
|
fprintf(feps, " (%s) show\n", textpart);
|
||||||
fprintf(feps, "setmatrix\n");
|
fprintf(feps, "setmatrix\n");
|
||||||
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';
|
||||||
fprintf(feps, "matrix currentmatrix\n");
|
fprintf(feps, "matrix currentmatrix\n");
|
||||||
@ -665,7 +696,7 @@ int ps_plot(struct zint_symbol *symbol) {
|
|||||||
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", textpart);
|
||||||
fprintf(feps, "setmatrix\n");
|
fprintf(feps, "setmatrix\n");
|
||||||
textpart[0] = symbol->text[7];
|
textpart[0] = local_text[7];
|
||||||
textpart[1] = '\0';
|
textpart[1] = '\0';
|
||||||
fprintf(feps, "matrix currentmatrix\n");
|
fprintf(feps, "matrix currentmatrix\n");
|
||||||
fprintf(feps, "/Helvetica findfont\n");
|
fprintf(feps, "/Helvetica findfont\n");
|
||||||
@ -706,7 +737,6 @@ int ps_plot(struct zint_symbol *symbol) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} /* if (plot_text) */
|
|
||||||
|
|
||||||
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");
|
||||||
|
@ -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,11 +345,10 @@ 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(symbol->text)) {
|
switch (ustrlen(local_text)) {
|
||||||
case 8: /* EAN-8 */
|
case 8: /* EAN-8 */
|
||||||
case 11:
|
case 11:
|
||||||
case 14:
|
case 14:
|
||||||
@ -328,7 +359,7 @@ int svg_plot(struct zint_symbol *symbol) {
|
|||||||
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] = symbol->text[i];
|
textpart[i] = local_text[i];
|
||||||
}
|
}
|
||||||
textpart[4] = '\0';
|
textpart[4] = '\0';
|
||||||
textpos = 17;
|
textpos = 17;
|
||||||
@ -337,7 +368,7 @@ int svg_plot(struct zint_symbol *symbol) {
|
|||||||
fprintf(fsvg, " %s\n", textpart);
|
fprintf(fsvg, " %s\n", textpart);
|
||||||
fprintf(fsvg, " </text>\n");
|
fprintf(fsvg, " </text>\n");
|
||||||
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 = 50;
|
textpos = 50;
|
||||||
@ -373,7 +404,7 @@ int svg_plot(struct zint_symbol *symbol) {
|
|||||||
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", (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", (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);
|
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[0] = local_text[0];
|
||||||
textpart[1] = '\0';
|
textpart[1] = '\0';
|
||||||
textpos = -7;
|
textpos = -7;
|
||||||
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);
|
||||||
@ -381,7 +412,7 @@ int svg_plot(struct zint_symbol *symbol) {
|
|||||||
fprintf(fsvg, " %s\n", textpart);
|
fprintf(fsvg, " %s\n", textpart);
|
||||||
fprintf(fsvg, " </text>\n");
|
fprintf(fsvg, " </text>\n");
|
||||||
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 = 24;
|
textpos = 24;
|
||||||
@ -390,7 +421,7 @@ int svg_plot(struct zint_symbol *symbol) {
|
|||||||
fprintf(fsvg, " %s\n", textpart);
|
fprintf(fsvg, " %s\n", textpart);
|
||||||
fprintf(fsvg, " </text>\n");
|
fprintf(fsvg, " </text>\n");
|
||||||
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 = 71;
|
textpos = 71;
|
||||||
@ -459,7 +490,7 @@ int svg_plot(struct zint_symbol *symbol) {
|
|||||||
}
|
}
|
||||||
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 = -5;
|
textpos = -5;
|
||||||
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);
|
||||||
@ -467,7 +498,7 @@ int svg_plot(struct zint_symbol *symbol) {
|
|||||||
fprintf(fsvg, " %s\n", textpart);
|
fprintf(fsvg, " %s\n", textpart);
|
||||||
fprintf(fsvg, " </text>\n");
|
fprintf(fsvg, " </text>\n");
|
||||||
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 = 27;
|
textpos = 27;
|
||||||
@ -476,7 +507,7 @@ int svg_plot(struct zint_symbol *symbol) {
|
|||||||
fprintf(fsvg, " %s\n", textpart);
|
fprintf(fsvg, " %s\n", textpart);
|
||||||
fprintf(fsvg, " </text>\n");
|
fprintf(fsvg, " </text>\n");
|
||||||
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 = 68;
|
textpos = 68;
|
||||||
@ -484,7 +515,7 @@ int svg_plot(struct zint_symbol *symbol) {
|
|||||||
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", textpart);
|
||||||
fprintf(fsvg, " </text>\n");
|
fprintf(fsvg, " </text>\n");
|
||||||
textpart[0] = symbol->text[11];
|
textpart[0] = local_text[11];
|
||||||
textpart[1] = '\0';
|
textpart[1] = '\0';
|
||||||
textpos = 100;
|
textpos = 100;
|
||||||
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);
|
||||||
@ -518,7 +549,7 @@ int svg_plot(struct zint_symbol *symbol) {
|
|||||||
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", (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", (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);
|
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[0] = local_text[0];
|
||||||
textpart[1] = '\0';
|
textpart[1] = '\0';
|
||||||
textpos = -5;
|
textpos = -5;
|
||||||
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);
|
||||||
@ -526,7 +557,7 @@ int svg_plot(struct zint_symbol *symbol) {
|
|||||||
fprintf(fsvg, " %s\n", textpart);
|
fprintf(fsvg, " %s\n", textpart);
|
||||||
fprintf(fsvg, " </text>\n");
|
fprintf(fsvg, " </text>\n");
|
||||||
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 = 24;
|
textpos = 24;
|
||||||
@ -534,7 +565,7 @@ int svg_plot(struct zint_symbol *symbol) {
|
|||||||
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", textpart);
|
||||||
fprintf(fsvg, " </text>\n");
|
fprintf(fsvg, " </text>\n");
|
||||||
textpart[0] = symbol->text[7];
|
textpart[0] = local_text[7];
|
||||||
textpart[1] = '\0';
|
textpart[1] = '\0';
|
||||||
textpos = 55;
|
textpos = 55;
|
||||||
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);
|
||||||
@ -560,7 +591,6 @@ int svg_plot(struct zint_symbol *symbol) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} /* if (plot_text) */
|
|
||||||
|
|
||||||
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");
|
||||||
|
Loading…
Reference in New Issue
Block a user