Convert text and colour information to SVG format

This commit is contained in:
hooper114 2009-02-18 19:14:56 +00:00
parent 1df2fff8a9
commit aa9edfb320

View File

@ -183,7 +183,13 @@ int svg_plot(struct zint_symbol *symbol)
fprintf(fsvg, " <desc>Zint Generated Symbol\n"); fprintf(fsvg, " <desc>Zint Generated Symbol\n");
} }
fprintf(fsvg, " </desc>\n"); fprintf(fsvg, " </desc>\n");
fprintf(fsvg, "\n <g id=\"barcode\" fill=\"black\">\n"); fprintf(fsvg, "\n <g id=\"barcode\" fill=\"#%s\">\n", symbol->fgcolour);
if(symbol->symbology != BARCODE_MAXICODE) {
fprintf(fsvg, " <rect x=\"0\" y=\"0\" width=\"%d\" height=\"%d\" fill=\"#%s\" />\n", roundup((symbol->width + xoffset + xoffset) * scaler), roundup((symbol->height + textoffset + yoffset + yoffset) * scaler), symbol->bgcolour);
} else {
fprintf(fsvg, " <rect x=\"0\" y=\"0\" width=\"%d\" height=\"%d\" fill=\"#%s\" />\n", roundup((74.0 + xoffset + xoffset) * scaler), roundup((72.0 + yoffset + yoffset) * scaler), symbol->bgcolour);
}
if(symbol->symbology == BARCODE_MAXICODE) { if(symbol->symbology == BARCODE_MAXICODE) {
/* Maxicode uses hexagons */ /* Maxicode uses hexagons */
@ -200,12 +206,12 @@ int svg_plot(struct zint_symbol *symbol)
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", 0.0, 0.0, symbol->border_width * scaler, (72.0 + (2 * symbol->border_width)) * scaler); fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", 0.0, 0.0, symbol->border_width * scaler, (72.0 + (2 * symbol->border_width)) * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (74.0 + xoffset + xoffset - symbol->border_width) * scaler, 0.0, symbol->border_width * scaler, (72.0 + (2 * symbol->border_width)) * scaler); fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (74.0 + xoffset + xoffset - symbol->border_width) * scaler, 0.0, symbol->border_width * scaler, (72.0 + (2 * symbol->border_width)) * scaler);
} }
fprintf(fsvg, " <circle cx=\"%.2f\" cy=\"%.2f\" r=\"%.2f\" fill=\"black\" />\n", (35.76 + xoffset) * scaler, (35.60 + yoffset) * scaler, 10.85 * scaler); fprintf(fsvg, " <circle cx=\"%.2f\" cy=\"%.2f\" r=\"%.2f\" fill=\"#%s\" />\n", (35.76 + xoffset) * scaler, (35.60 + yoffset) * scaler, 10.85 * scaler, symbol->fgcolour);
fprintf(fsvg, " <circle cx=\"%.2f\" cy=\"%.2f\" r=\"%.2f\" fill=\"white\" />\n", (35.76 + xoffset) * scaler, (35.60 + yoffset) * scaler, 8.97 * scaler); fprintf(fsvg, " <circle cx=\"%.2f\" cy=\"%.2f\" r=\"%.2f\" fill=\"#%s\" />\n", (35.76 + xoffset) * scaler, (35.60 + yoffset) * scaler, 8.97 * scaler, symbol->bgcolour);
fprintf(fsvg, " <circle cx=\"%.2f\" cy=\"%.2f\" r=\"%.2f\" fill=\"black\" />\n", (35.76 + xoffset) * scaler, (35.60 + yoffset) * scaler, 7.10 * scaler); fprintf(fsvg, " <circle cx=\"%.2f\" cy=\"%.2f\" r=\"%.2f\" fill=\"#%s\" />\n", (35.76 + xoffset) * scaler, (35.60 + yoffset) * scaler, 7.10 * scaler, symbol->fgcolour);
fprintf(fsvg, " <circle cx=\"%.2f\" cy=\"%.2f\" r=\"%.2f\" fill=\"white\" />\n", (35.76 + xoffset) * scaler, (35.60 + yoffset) * scaler, 5.22 * scaler); fprintf(fsvg, " <circle cx=\"%.2f\" cy=\"%.2f\" r=\"%.2f\" fill=\"#%s\" />\n", (35.76 + xoffset) * scaler, (35.60 + yoffset) * scaler, 5.22 * scaler, symbol->bgcolour);
fprintf(fsvg, " <circle cx=\"%.2f\" cy=\"%.2f\" r=\"%.2f\" fill=\"black\" />\n", (35.76 + xoffset) * scaler, (35.60 + yoffset) * scaler, 3.31 * scaler); fprintf(fsvg, " <circle cx=\"%.2f\" cy=\"%.2f\" r=\"%.2f\" fill=\"#%s\" />\n", (35.76 + xoffset) * scaler, (35.60 + yoffset) * scaler, 3.31 * scaler, symbol->fgcolour);
fprintf(fsvg, " <circle cx=\"%.2f\" cy=\"%.2f\" r=\"%.2f\" fill=\"white\" />\n", (35.76 + xoffset) * scaler, (35.60 + yoffset) * scaler, 1.43 * scaler); fprintf(fsvg, " <circle cx=\"%.2f\" cy=\"%.2f\" r=\"%.2f\" fill=\"#%s\" />\n", (35.76 + xoffset) * scaler, (35.60 + yoffset) * scaler, 1.43 * scaler, symbol->bgcolour);
for(r = 0; r < symbol->rows; r++) { for(r = 0; r < symbol->rows; r++) {
for(i = 0; i < symbol->width; i++) { for(i = 0; i < symbol->width; i++) {
if(symbol->encoded_data[r][i] == '1') { if(symbol->encoded_data[r][i] == '1') {
@ -269,7 +275,7 @@ int svg_plot(struct zint_symbol *symbol)
block_width++; block_width++;
} while (symbol->encoded_data[this_row][i + block_width] == symbol->encoded_data[this_row][i]); } while (symbol->encoded_data[this_row][i + block_width] == symbol->encoded_data[this_row][i]);
if((addon_latch == 0) && (r == 0) && (i > main_width)) { if((addon_latch == 0) && (r == 0) && (i > main_width)) {
addon_text_posn = row_posn + row_height - 8.0; addon_text_posn = 9.0;
addon_latch = 1; addon_latch = 1;
} }
if(latch == 1) { if(latch == 1) {
@ -309,60 +315,38 @@ int svg_plot(struct zint_symbol *symbol)
for(i = 0; i < 4; i++) { for(i = 0; i < 4; i++) {
textpart[i] = symbol->text[i]; textpart[i] = symbol->text[i];
} }
/* textpart[4] = '\0'; textpart[4] = '\0';
fprintf(fsvg, "TE\n");
fprintf(fsvg, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
fprintf(fsvg, "matrix currentmatrix\n");
fprintf(fsvg, "/Helvetica findfont\n");
fprintf(fsvg, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = 17; textpos = 17;
fprintf(fsvg, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 0.50 * scaler); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, (symbol->height + textoffset) * scaler);
fprintf(fsvg, " (%s) stringwidth\n", textpart); fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, "pop\n"); fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, "-2 div 0 rmoveto\n"); fprintf(fsvg, " </text>\n");
fprintf(fsvg, " (%s) show\n", textpart);
fprintf(fsvg, "setmatrix\n");
for(i = 0; i < 4; i++) { for(i = 0; i < 4; i++) {
textpart[i] = symbol->text[i + 4]; textpart[i] = symbol->text[i + 4];
} }
textpart[4] = '\0'; textpart[4] = '\0';
fprintf(fsvg, "matrix currentmatrix\n");
fprintf(fsvg, "/Helvetica findfont\n");
fprintf(fsvg, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = 50; textpos = 50;
fprintf(fsvg, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 0.5 * scaler); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, (symbol->height + textoffset) * scaler);
fprintf(fsvg, " (%s) stringwidth\n", textpart); fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, "pop\n"); fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, "-2 div 0 rmoveto\n"); fprintf(fsvg, " </text>\n");
fprintf(fsvg, " (%s) show\n", textpart);
fprintf(fsvg, "setmatrix\n");
textdone = 1; textdone = 1;
switch(strlen(addon)) { switch(strlen(addon)) {
case 2: case 2:
fprintf(fsvg, "matrix currentmatrix\n");
fprintf(fsvg, "/Helvetica findfont\n");
fprintf(fsvg, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = symbol->width + xoffset - 10; textpos = symbol->width + xoffset - 10;
fprintf(fsvg, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " (%s) stringwidth\n", addon); fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, "pop\n"); fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, "-2 div 0 rmoveto\n"); fprintf(fsvg, " </text>\n");
fprintf(fsvg, " (%s) show\n", addon);
fprintf(fsvg, "setmatrix\n");
break; break;
case 5: case 5:
fprintf(fsvg, "matrix currentmatrix\n");
fprintf(fsvg, "/Helvetica findfont\n");
fprintf(fsvg, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = symbol->width + xoffset - 23; textpos = symbol->width + xoffset - 23;
fprintf(fsvg, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " (%s) stringwidth\n", addon); fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, "pop\n"); fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, "-2 div 0 rmoveto\n"); fprintf(fsvg, " </text>\n");
fprintf(fsvg, " (%s) show\n", addon);
fprintf(fsvg, "setmatrix\n");
break; break;
} */ }
break; break;
case 13: /* EAN 13 */ case 13: /* EAN 13 */
@ -376,74 +360,47 @@ int svg_plot(struct zint_symbol *symbol)
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] = symbol->text[0];
textpart[1] = '\0'; textpart[1] = '\0';
/*fprintf(fsvg, "TE\n");
fprintf(fsvg, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
fprintf(fsvg, "matrix currentmatrix\n");
fprintf(fsvg, "/Helvetica findfont\n");
fprintf(fsvg, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = -7; textpos = -7;
fprintf(fsvg, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 0.50 * scaler); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, (symbol->height + textoffset) * scaler);
fprintf(fsvg, " (%s) stringwidth\n", textpart); fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, "pop\n"); fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, "-2 div 0 rmoveto\n"); fprintf(fsvg, " </text>\n");
fprintf(fsvg, " (%s) show\n", textpart);
fprintf(fsvg, "setmatrix\n");
for(i = 0; i < 6; i++) { for(i = 0; i < 6; i++) {
textpart[i] = symbol->text[i + 1]; textpart[i] = symbol->text[i + 1];
} }
textpart[6] = '\0'; textpart[6] = '\0';
fprintf(fsvg, "matrix currentmatrix\n");
fprintf(fsvg, "/Helvetica findfont\n");
fprintf(fsvg, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = 24; textpos = 24;
fprintf(fsvg, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 0.50 * scaler); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, (symbol->height + textoffset) * scaler);
fprintf(fsvg, " (%s) stringwidth\n", textpart); fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, "pop\n"); fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, "-2 div 0 rmoveto\n"); fprintf(fsvg, " </text>\n");
fprintf(fsvg, " (%s) show\n", textpart);
fprintf(fsvg, "setmatrix\n");
for(i = 0; i < 6; i++) { for(i = 0; i < 6; i++) {
textpart[i] = symbol->text[i + 7]; textpart[i] = symbol->text[i + 7];
} }
textpart[6] = '\0'; textpart[6] = '\0';
fprintf(fsvg, "matrix currentmatrix\n");
fprintf(fsvg, "/Helvetica findfont\n");
fprintf(fsvg, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = 71; textpos = 71;
fprintf(fsvg, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 0.5 * scaler); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, (symbol->height + textoffset) * scaler);
fprintf(fsvg, " (%s) stringwidth\n", textpart); fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, "pop\n"); fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, "-2 div 0 rmoveto\n"); fprintf(fsvg, " </text>\n");
fprintf(fsvg, " (%s) show\n", textpart);
fprintf(fsvg, "setmatrix\n");
textdone = 1; textdone = 1;
switch(strlen(addon)) { switch(strlen(addon)) {
case 2: case 2:
fprintf(fsvg, "matrix currentmatrix\n");
fprintf(fsvg, "/Helvetica findfont\n");
fprintf(fsvg, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = symbol->width + xoffset - 10; textpos = symbol->width + xoffset - 10;
fprintf(fsvg, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " (%s) stringwidth\n", addon); fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, "pop\n"); fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, "-2 div 0 rmoveto\n"); fprintf(fsvg, " </text>\n");
fprintf(fsvg, " (%s) show\n", addon);
fprintf(fsvg, "setmatrix\n");
break; break;
case 5: case 5:
fprintf(fsvg, "matrix currentmatrix\n");
fprintf(fsvg, "/Helvetica findfont\n");
fprintf(fsvg, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = symbol->width + xoffset - 23; textpos = symbol->width + xoffset - 23;
fprintf(fsvg, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " (%s) stringwidth\n", addon); fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, "pop\n"); fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, "-2 div 0 rmoveto\n"); fprintf(fsvg, " </text>\n");
fprintf(fsvg, " (%s) show\n", addon);
fprintf(fsvg, "setmatrix\n");
break; break;
} }
break; */ break;
} }
} }
@ -489,85 +446,53 @@ int svg_plot(struct zint_symbol *symbol)
} while (i < 96 + comp_offset); } while (i < 96 + comp_offset);
textpart[0] = symbol->text[0]; textpart[0] = symbol->text[0];
textpart[1] = '\0'; textpart[1] = '\0';
/*fprintf(fsvg, "TE\n");
fprintf(fsvg, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
fprintf(fsvg, "matrix currentmatrix\n");
fprintf(fsvg, "/Helvetica findfont\n");
fprintf(fsvg, "%.2f scalefont setfont\n", 8.0 * scaler);
textpos = -5; textpos = -5;
fprintf(fsvg, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 0.5 * scaler); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, (symbol->height + textoffset) * scaler);
fprintf(fsvg, " (%s) stringwidth\n", textpart); fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour);
fprintf(fsvg, "pop\n"); fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, "-2 div 0 rmoveto\n"); fprintf(fsvg, " </text>\n");
fprintf(fsvg, " (%s) show\n", textpart);
fprintf(fsvg, "setmatrix\n");
for(i = 0; i < 5; i++) { for(i = 0; i < 5; i++) {
textpart[i] = symbol->text[i + 1]; textpart[i] = symbol->text[i + 1];
} }
textpart[5] = '\0'; textpart[5] = '\0';
fprintf(fsvg, "matrix currentmatrix\n");
fprintf(fsvg, "/Helvetica findfont\n");
fprintf(fsvg, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = 27; textpos = 27;
fprintf(fsvg, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 0.5 * scaler); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, (symbol->height + textoffset) * scaler);
fprintf(fsvg, " (%s) stringwidth\n", textpart); fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, "pop\n"); fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, "-2 div 0 rmoveto\n"); fprintf(fsvg, " </text>\n");
fprintf(fsvg, " (%s) show\n", textpart);
fprintf(fsvg, "setmatrix\n");
for(i = 0; i < 5; i++) { for(i = 0; i < 5; i++) {
textpart[i] = symbol->text[i + 6]; textpart[i] = symbol->text[i + 6];
} }
textpart[6] = '\0'; textpart[6] = '\0';
fprintf(fsvg, "matrix currentmatrix\n");
fprintf(fsvg, "/Helvetica findfont\n");
fprintf(fsvg, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = 68; textpos = 68;
fprintf(fsvg, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 0.5 * scaler); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, (symbol->height + textoffset) * scaler);
fprintf(fsvg, " (%s) stringwidth\n", textpart); fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, "pop\n"); fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, "-2 div 0 rmoveto\n"); fprintf(fsvg, " </text>\n");
fprintf(fsvg, " (%s) show\n", textpart);
fprintf(fsvg, "setmatrix\n");
textpart[0] = symbol->text[11]; textpart[0] = symbol->text[11];
textpart[1] = '\0'; textpart[1] = '\0';
fprintf(fsvg, "matrix currentmatrix\n");
fprintf(fsvg, "/Helvetica findfont\n");
fprintf(fsvg, "%.2f scalefont setfont\n", 8.0 * scaler);
textpos = 100; textpos = 100;
fprintf(fsvg, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 0.5 * scaler); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, (symbol->height + textoffset) * scaler);
fprintf(fsvg, " (%s) stringwidth\n", textpart); fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour);
fprintf(fsvg, "pop\n"); fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, "-2 div 0 rmoveto\n"); fprintf(fsvg, " </text>\n");
fprintf(fsvg, " (%s) show\n", textpart);
fprintf(fsvg, "setmatrix\n");
textdone = 1; textdone = 1;
switch(strlen(addon)) { switch(strlen(addon)) {
case 2: case 2:
fprintf(fsvg, "matrix currentmatrix\n");
fprintf(fsvg, "/Helvetica findfont\n");
fprintf(fsvg, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = symbol->width + xoffset - 10; textpos = symbol->width + xoffset - 10;
fprintf(fsvg, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " (%s) stringwidth\n", addon); fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, "pop\n"); fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, "-2 div 0 rmoveto\n"); fprintf(fsvg, " </text>\n");
fprintf(fsvg, " (%s) show\n", addon);
fprintf(fsvg, "setmatrix\n");
break; break;
case 5: case 5:
fprintf(fsvg, "matrix currentmatrix\n");
fprintf(fsvg, "/Helvetica findfont\n");
fprintf(fsvg, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = symbol->width + xoffset - 23; textpos = symbol->width + xoffset - 23;
fprintf(fsvg, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " (%s) stringwidth\n", addon); fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, "pop\n"); fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, "-2 div 0 rmoveto\n"); fprintf(fsvg, " </text>\n");
fprintf(fsvg, " (%s) show\n", addon);
fprintf(fsvg, "setmatrix\n");
break; break;
} */ }
} }
@ -580,71 +505,44 @@ int svg_plot(struct zint_symbol *symbol)
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] = symbol->text[0];
textpart[1] = '\0'; textpart[1] = '\0';
/* fprintf(fsvg, "TE\n");
fprintf(fsvg, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
fprintf(fsvg, "matrix currentmatrix\n");
fprintf(fsvg, "/Helvetica findfont\n");
fprintf(fsvg, "%.2f scalefont setfont\n", 8.0 * scaler);
textpos = -5; textpos = -5;
fprintf(fsvg, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 0.5 * scaler); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, (symbol->height + textoffset) * scaler);
fprintf(fsvg, " (%s) stringwidth\n", textpart); fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour);
fprintf(fsvg, "pop\n"); fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, "-2 div 0 rmoveto\n"); fprintf(fsvg, " </text>\n");
fprintf(fsvg, " (%s) show\n", textpart);
fprintf(fsvg, "setmatrix\n");
for(i = 0; i < 6; i++) { for(i = 0; i < 6; i++) {
textpart[i] = symbol->text[i + 1]; textpart[i] = symbol->text[i + 1];
} }
textpart[6] = '\0'; textpart[6] = '\0';
fprintf(fsvg, "matrix currentmatrix\n");
fprintf(fsvg, "/Helvetica findfont\n");
fprintf(fsvg, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = 24; textpos = 24;
fprintf(fsvg, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 0.5 * scaler); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, (symbol->height + textoffset) * scaler);
fprintf(fsvg, " (%s) stringwidth\n", textpart); fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, "pop\n"); fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, "-2 div 0 rmoveto\n"); fprintf(fsvg, " </text>\n");
fprintf(fsvg, " (%s) show\n", textpart);
fprintf(fsvg, "setmatrix\n");
textpart[0] = symbol->text[7]; textpart[0] = symbol->text[7];
textpart[1] = '\0'; textpart[1] = '\0';
fprintf(fsvg, "matrix currentmatrix\n");
fprintf(fsvg, "/Helvetica findfont\n");
fprintf(fsvg, "%.2f scalefont setfont\n", 8.0 * scaler);
textpos = 55; textpos = 55;
fprintf(fsvg, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 0.5 * scaler); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, (symbol->height + textoffset) * scaler);
fprintf(fsvg, " (%s) stringwidth\n", textpart); fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour);
fprintf(fsvg, "pop\n"); fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, "-2 div 0 rmoveto\n"); fprintf(fsvg, " </text>\n");
fprintf(fsvg, " (%s) show\n", textpart);
fprintf(fsvg, "setmatrix\n");
textdone = 1; textdone = 1;
switch(strlen(addon)) { switch(strlen(addon)) {
case 2: case 2:
fprintf(fsvg, "matrix currentmatrix\n");
fprintf(fsvg, "/Helvetica findfont\n");
fprintf(fsvg, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = symbol->width + xoffset - 10; textpos = symbol->width + xoffset - 10;
fprintf(fsvg, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " (%s) stringwidth\n", addon); fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, "pop\n"); fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, "-2 div 0 rmoveto\n"); fprintf(fsvg, " </text>\n");
fprintf(fsvg, " (%s) show\n", addon);
fprintf(fsvg, "setmatrix\n");
break; break;
case 5: case 5:
fprintf(fsvg, "matrix currentmatrix\n");
fprintf(fsvg, "/Helvetica findfont\n");
fprintf(fsvg, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = symbol->width + xoffset - 23; textpos = symbol->width + xoffset - 23;
fprintf(fsvg, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " (%s) stringwidth\n", addon); fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, "pop\n"); fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, "-2 div 0 rmoveto\n"); fprintf(fsvg, " </text>\n");
fprintf(fsvg, " (%s) show\n", addon);
fprintf(fsvg, "setmatrix\n");
break; break;
} */ }
} }
@ -687,20 +585,13 @@ int svg_plot(struct zint_symbol *symbol)
} }
/* Put the human readable text at the bottom */ /* Put the human readable text at the bottom */
/* if((textdone == 0) && (strlen(symbol->text) != 0)) { if((textdone == 0) && (strlen(symbol->text) != 0)) {
fprintf(fsvg, "TE\n");
fprintf(fsvg, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
fprintf(fsvg, "matrix currentmatrix\n");
fprintf(fsvg, "/Helvetica findfont\n");
fprintf(fsvg, "%.2f scalefont setfont\n", 8.0 * scaler);
textpos = symbol->width / 2.0; textpos = symbol->width / 2.0;
fprintf(fsvg, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 1.67 * scaler); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, (symbol->height + textoffset) * scaler);
fprintf(fsvg, " (%s) stringwidth\n", symbol->text); fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour);
fprintf(fsvg, "pop\n"); fprintf(fsvg, " %s\n", symbol->text);
fprintf(fsvg, "-2 div 0 rmoveto\n"); fprintf(fsvg, " </text>\n");
fprintf(fsvg, " (%s) show\n", symbol->text); }
fprintf(fsvg, "setmatrix\n");
} */
fprintf(fsvg, " </g>\n"); fprintf(fsvg, " </g>\n");
fprintf(fsvg, "</svg>\n"); fprintf(fsvg, "</svg>\n");