Add font size option for SVG and EPS

This commit is contained in:
Robin Stuart 2018-02-11 09:55:28 +00:00
parent 8bb4d2ce86
commit 78d85bd72e
5 changed files with 55 additions and 42 deletions

View File

@ -63,6 +63,7 @@ struct zint_symbol *ZBarcode_Create() {
symbol->option_2 = 0;
symbol->option_3 = 928; // PDF_MAX
symbol->show_hrt = 1; // Show human readable text
symbol->fontsize = 8;
symbol->input_mode = DATA_MODE;
strcpy(symbol->primary, "");
memset(&(symbol->encoded_data[0][0]), 0, sizeof (symbol->encoded_data));

View File

@ -55,6 +55,7 @@ int ps_plot(struct zint_symbol *symbol) {
float scaler = symbol->scale;
float default_text_posn;
const char *locale = NULL;
float fontsize = symbol->fontsize * scaler;
#ifndef _MSC_VER
unsigned char local_text[ustrlen(symbol->text) + 1];
#else
@ -518,7 +519,7 @@ int ps_plot(struct zint_symbol *symbol) {
}
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
fprintf(feps, "%.2f scalefont setfont\n", (11.0 / 8.0) * fontsize);
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);
@ -532,7 +533,7 @@ int ps_plot(struct zint_symbol *symbol) {
textpart[4] = '\0';
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
fprintf(feps, "%.2f scalefont setfont\n", (11.0 / 8.0) * fontsize);
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);
@ -545,7 +546,7 @@ int ps_plot(struct zint_symbol *symbol) {
case 2:
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
fprintf(feps, "%.2f scalefont setfont\n", (11.0 / 8.0) * fontsize);
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);
@ -557,7 +558,7 @@ int ps_plot(struct zint_symbol *symbol) {
case 5:
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
fprintf(feps, "%.2f scalefont setfont\n", (11.0 / 8.0) * fontsize);
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);
@ -595,7 +596,7 @@ int ps_plot(struct zint_symbol *symbol) {
}
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
fprintf(feps, "%.2f scalefont setfont\n", (11.0 / 8.0) * fontsize);
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);
@ -609,7 +610,7 @@ int ps_plot(struct zint_symbol *symbol) {
textpart[6] = '\0';
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
fprintf(feps, "%.2f scalefont setfont\n", (11.0 / 8.0) * fontsize);
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);
@ -623,7 +624,7 @@ int ps_plot(struct zint_symbol *symbol) {
textpart[6] = '\0';
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
fprintf(feps, "%.2f scalefont setfont\n", (11.0 / 8.0) * fontsize);
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);
@ -636,7 +637,7 @@ int ps_plot(struct zint_symbol *symbol) {
case 2:
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
fprintf(feps, "%.2f scalefont setfont\n", (11.0 / 8.0) * fontsize);
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);
@ -648,7 +649,7 @@ int ps_plot(struct zint_symbol *symbol) {
case 5:
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
fprintf(feps, "%.2f scalefont setfont\n", (11.0 / 8.0) * fontsize);
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);
@ -719,7 +720,7 @@ int ps_plot(struct zint_symbol *symbol) {
}
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler);
fprintf(feps, "%.2f scalefont setfont\n", fontsize);
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);
@ -733,7 +734,7 @@ int ps_plot(struct zint_symbol *symbol) {
textpart[5] = '\0';
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
fprintf(feps, "%.2f scalefont setfont\n", (11.0 / 8.0) * fontsize);
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);
@ -747,7 +748,7 @@ int ps_plot(struct zint_symbol *symbol) {
textpart[6] = '\0';
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
fprintf(feps, "%.2f scalefont setfont\n", (11.0 / 8.0) * fontsize);
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);
@ -759,7 +760,7 @@ int ps_plot(struct zint_symbol *symbol) {
textpart[1] = '\0';
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler);
fprintf(feps, "%.2f scalefont setfont\n", fontsize);
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);
@ -772,7 +773,7 @@ int ps_plot(struct zint_symbol *symbol) {
case 2:
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
fprintf(feps, "%.2f scalefont setfont\n", (11.0 / 8.0) * fontsize);
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);
@ -784,7 +785,7 @@ int ps_plot(struct zint_symbol *symbol) {
case 5:
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
fprintf(feps, "%.2f scalefont setfont\n", (11.0 / 8.0) * fontsize);
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);
@ -817,7 +818,7 @@ int ps_plot(struct zint_symbol *symbol) {
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);
fprintf(feps, "%.2f scalefont setfont\n", fontsize);
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);
@ -831,7 +832,7 @@ int ps_plot(struct zint_symbol *symbol) {
textpart[6] = '\0';
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
fprintf(feps, "%.2f scalefont setfont\n", (11.0 / 8.0) * fontsize);
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);
@ -843,7 +844,7 @@ int ps_plot(struct zint_symbol *symbol) {
textpart[1] = '\0';
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler);
fprintf(feps, "%.2f scalefont setfont\n", fontsize);
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);
@ -856,7 +857,7 @@ int ps_plot(struct zint_symbol *symbol) {
case 2:
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
fprintf(feps, "%.2f scalefont setfont\n", (11.0 / 8.0) * fontsize);
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);
@ -868,7 +869,7 @@ int ps_plot(struct zint_symbol *symbol) {
case 5:
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
fprintf(feps, "%.2f scalefont setfont\n", (11.0 / 8.0) * fontsize);
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);
@ -947,7 +948,7 @@ int ps_plot(struct zint_symbol *symbol) {
}
fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler);
fprintf(feps, "%.2f scalefont setfont\n", fontsize);
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", local_text);

View File

@ -55,6 +55,7 @@ int svg_plot(struct zint_symbol *symbol) {
float scaler = symbol->scale;
float default_text_posn;
const char *locale = NULL;
float fontsize = symbol->fontsize * scaler;
#ifndef _MSC_VER
unsigned char local_text[ustrlen(symbol->text) + 1];
#else
@ -389,7 +390,7 @@ int svg_plot(struct zint_symbol *symbol) {
textpart[4] = '\0';
textpos = 17;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", (11.0 / 8.0) * fontsize, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
for (i = 0; i < 4; i++) {
@ -398,7 +399,7 @@ int svg_plot(struct zint_symbol *symbol) {
textpart[4] = '\0';
textpos = 50;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", (11.0 / 8.0) * fontsize, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
textdone = 1;
@ -406,14 +407,14 @@ int svg_plot(struct zint_symbol *symbol) {
case 2:
textpos = xoffset + 86;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", (11.0 / 8.0) * fontsize, symbol->fgcolour);
fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n");
break;
case 5:
textpos = xoffset + 100;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", (11.0 / 8.0) * fontsize, symbol->fgcolour);
fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n");
break;
@ -433,7 +434,7 @@ int svg_plot(struct zint_symbol *symbol) {
textpart[1] = '\0';
textpos = -7;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", (11.0 / 8.0) * fontsize, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
for (i = 0; i < 6; i++) {
@ -442,7 +443,7 @@ int svg_plot(struct zint_symbol *symbol) {
textpart[6] = '\0';
textpos = 24;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", (11.0 / 8.0) * fontsize, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
for (i = 0; i < 6; i++) {
@ -451,7 +452,7 @@ int svg_plot(struct zint_symbol *symbol) {
textpart[6] = '\0';
textpos = 71;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", (11.0 / 8.0) * fontsize, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
textdone = 1;
@ -459,14 +460,14 @@ int svg_plot(struct zint_symbol *symbol) {
case 2:
textpos = xoffset + 114;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", (11.0 / 8.0) * fontsize, symbol->fgcolour);
fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n");
break;
case 5:
textpos = xoffset + 128;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", (11.0 / 8.0) * fontsize, symbol->fgcolour);
fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n");
break;
@ -519,7 +520,7 @@ int svg_plot(struct zint_symbol *symbol) {
textpart[1] = '\0';
textpos = -5;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", fontsize, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
for (i = 0; i < 5; i++) {
@ -528,7 +529,7 @@ int svg_plot(struct zint_symbol *symbol) {
textpart[5] = '\0';
textpos = 27;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", (11.0 / 8.0) * fontsize, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
for (i = 0; i < 5; i++) {
@ -537,14 +538,14 @@ int svg_plot(struct zint_symbol *symbol) {
textpart[6] = '\0';
textpos = 68;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", (11.0 / 8.0) * fontsize, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
textpart[0] = local_text[11];
textpart[1] = '\0';
textpos = 100;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", fontsize, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
textdone = 1;
@ -552,14 +553,14 @@ int svg_plot(struct zint_symbol *symbol) {
case 2:
textpos = xoffset + 116;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", (11.0 / 8.0) * fontsize, symbol->fgcolour);
fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n");
break;
case 5:
textpos = xoffset + 130;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", (11.0 / 8.0) * fontsize, symbol->fgcolour);
fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n");
break;
@ -578,7 +579,7 @@ int svg_plot(struct zint_symbol *symbol) {
textpart[1] = '\0';
textpos = -5;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", fontsize, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
for (i = 0; i < 6; i++) {
@ -587,14 +588,14 @@ int svg_plot(struct zint_symbol *symbol) {
textpart[6] = '\0';
textpos = 24;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", (11.0 / 8.0) * fontsize, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
textpart[0] = local_text[7];
textpart[1] = '\0';
textpos = 55;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", fontsize, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
textdone = 1;
@ -602,14 +603,14 @@ int svg_plot(struct zint_symbol *symbol) {
case 2:
textpos = xoffset + 70;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", (8.0 / 11.0) * fontsize, symbol->fgcolour);
fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n");
break;
case 5:
textpos = xoffset + 84;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", (8.0 / 11.0) * fontsize, symbol->fgcolour);
fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n");
break;
@ -659,7 +660,7 @@ int svg_plot(struct zint_symbol *symbol) {
if ((textdone == 0) && ustrlen(local_text)) {
textpos = symbol->width / 2.0;
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", fontsize, symbol->fgcolour);
fprintf(fsvg, " %s\n", local_text);
fprintf(fsvg, " </text>\n");
}

View File

@ -81,6 +81,7 @@ extern "C" {
int option_2;
int option_3;
int show_hrt;
int fontsize;
int input_mode;
int eci;
unsigned char text[128];

View File

@ -435,6 +435,7 @@ int main(int argc, char **argv) {
{"eci", 1, 0, 0},
{"filetype", 1, 0, 0},
{"esc", 0, 0, 0},
{"fontsize", 1, 0, 0},
{"verbose", 0, 0, 0}, // Currently undocumented, output some debug info
{0, 0, 0, 0}
};
@ -639,6 +640,14 @@ int main(int argc, char **argv) {
if (!strcmp(long_options[option_index].name, "verbose")) {
my_symbol->debug = 1;
}
if (!strcmp(long_options[option_index].name, "fontsize")) {
if ((atoi(optarg) >= 0) && (atoi(optarg) <= 100)) {
my_symbol->fontsize = atoi(optarg);
} else {
fprintf(stderr, "Warning 125: Invalid font size\n");
fflush(stderr);
}
}
break;
case 'h':