Various minor bugfixes

This commit is contained in:
hooper114 2010-05-16 21:58:18 +00:00
parent f3e8505fd4
commit 93d65a910c
9 changed files with 833 additions and 774 deletions

View File

@ -53,6 +53,7 @@ struct zint_symbol *ZBarcode_Create()
symbol->option_1 = -1; symbol->option_1 = -1;
symbol->option_2 = 0; symbol->option_2 = 0;
symbol->option_3 = 928; // PDF_MAX symbol->option_3 = 928; // PDF_MAX
symbol->show_hrt = 1; // Show human readable text
symbol->input_mode = DATA_MODE; symbol->input_mode = DATA_MODE;
strcpy(symbol->primary, ""); strcpy(symbol->primary, "");
for(i = 0; i < 178; i++) { for(i = 0; i < 178; i++) {
@ -82,6 +83,7 @@ void ZBarcode_Clear(struct zint_symbol *symbol)
symbol->errtxt[0] = '\0'; symbol->errtxt[0] = '\0';
if (symbol->bitmap != NULL) if (symbol->bitmap != NULL)
free(symbol->bitmap); free(symbol->bitmap);
symbol->bitmap = NULL;
symbol->bitmap_width = 0; symbol->bitmap_width = 0;
symbol->bitmap_height = 0; symbol->bitmap_height = 0;
} }

View File

@ -714,7 +714,11 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle, int data_type)
unsigned char* local_text = (unsigned char*)_alloca(ustrlen(symbol->text) + 1); unsigned char* local_text = (unsigned char*)_alloca(ustrlen(symbol->text) + 1);
#endif #endif
to_latin1(symbol->text, local_text); if(symbol->show_hrt != 0) {
to_latin1(symbol->text, local_text);
} else {
local_text[0] = '\0';
}
textdone = 0; textdone = 0;
main_width = symbol->width; main_width = symbol->width;

View File

@ -44,6 +44,7 @@ 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;
row_height=0; row_height=0;
textdone = 0; textdone = 0;
@ -167,7 +168,10 @@ int ps_plot(struct zint_symbol *symbol)
} }
addon[r] = '\0'; addon[r] = '\0';
if(ustrlen(symbol->text) != 0) { if((symbol->show_hrt == 0) || (ustrlen(symbol->text) == 0)) {
plot_text = 0;
}
if(plot_text) {
textoffset = 9; textoffset = 9;
} else { } else {
textoffset = 0; textoffset = 0;
@ -327,372 +331,374 @@ int ps_plot(struct zint_symbol *symbol)
xoffset += comp_offset; xoffset += comp_offset;
if ((((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC)) || if (plot_text) {
(symbol->symbology == BARCODE_ISBNX)) { if ((((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC)) ||
/* guard bar extensions and text formatting for EAN8 and EAN13 */ (symbol->symbology == BARCODE_ISBNX)) {
switch(ustrlen(symbol->text)) { /* guard bar extensions and text formatting for EAN8 and EAN13 */
case 8: /* EAN-8 */ switch(ustrlen(symbol->text)) {
case 11: case 8: /* EAN-8 */
case 14: case 11:
fprintf(feps, "TE\n"); case 14:
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink); fprintf(feps, "TE\n");
fprintf(feps, "%.2f %.2f ", 5.0 * scaler, (4.0 + yoffset) * scaler); fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
fprintf(feps, "TB %.2f %.2f TR\n", (0 + xoffset) * scaler, 1 * scaler); fprintf(feps, "%.2f %.2f ", 5.0 * scaler, (4.0 + yoffset) * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (2 + xoffset) * scaler, 1 * scaler); fprintf(feps, "TB %.2f %.2f TR\n", (0 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (32 + xoffset) * scaler, 1 * scaler); fprintf(feps, "TB %.2f %.2f TR\n", (2 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (34 + xoffset) * scaler, 1 * scaler); fprintf(feps, "TB %.2f %.2f TR\n", (32 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (64 + xoffset) * scaler, 1 * scaler); fprintf(feps, "TB %.2f %.2f TR\n", (34 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (66 + xoffset) * scaler, 1 * scaler); fprintf(feps, "TB %.2f %.2f TR\n", (64 + xoffset) * scaler, 1 * scaler);
for(i = 0; i < 4; i++) { fprintf(feps, "TB %.2f %.2f TR\n", (66 + xoffset) * scaler, 1 * scaler);
textpart[i] = symbol->text[i]; for(i = 0; i < 4; i++) {
} textpart[i] = symbol->text[i];
textpart[4] = '\0'; }
fprintf(feps, "TE\n"); textpart[4] = '\0';
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink); fprintf(feps, "TE\n");
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler); fprintf(feps, "/Helvetica findfont\n");
textpos = 17; fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn); textpos = 17;
fprintf(feps, " (%s) stringwidth\n", textpart); fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, "pop\n"); fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, "pop\n");
fprintf(feps, " (%s) show\n", textpart); fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, "setmatrix\n"); fprintf(feps, " (%s) show\n", textpart);
for(i = 0; i < 4; i++) { fprintf(feps, "setmatrix\n");
textpart[i] = symbol->text[i + 4]; for(i = 0; i < 4; i++) {
} textpart[i] = symbol->text[i + 4];
textpart[4] = '\0'; }
fprintf(feps, "matrix currentmatrix\n"); textpart[4] = '\0';
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler); fprintf(feps, "/Helvetica findfont\n");
textpos = 50; fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn); textpos = 50;
fprintf(feps, " (%s) stringwidth\n", textpart); fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, "pop\n"); fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, "pop\n");
fprintf(feps, " (%s) show\n", textpart); fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, "setmatrix\n"); fprintf(feps, " (%s) show\n", textpart);
textdone = 1; fprintf(feps, "setmatrix\n");
switch(strlen(addon)) { textdone = 1;
case 2: switch(strlen(addon)) {
fprintf(feps, "matrix currentmatrix\n"); case 2:
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler); fprintf(feps, "/Helvetica findfont\n");
textpos = xoffset + 86; fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler); textpos = xoffset + 86;
fprintf(feps, " (%s) stringwidth\n", addon); fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler);
fprintf(feps, "pop\n"); fprintf(feps, " (%s) stringwidth\n", addon);
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, "pop\n");
fprintf(feps, " (%s) show\n", addon); fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, "setmatrix\n"); fprintf(feps, " (%s) show\n", addon);
break; fprintf(feps, "setmatrix\n");
case 5: break;
fprintf(feps, "matrix currentmatrix\n"); case 5:
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler); fprintf(feps, "/Helvetica findfont\n");
textpos = xoffset + 100; fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler); textpos = xoffset + 100;
fprintf(feps, " (%s) stringwidth\n", addon); fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler);
fprintf(feps, "pop\n"); fprintf(feps, " (%s) stringwidth\n", addon);
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, "pop\n");
fprintf(feps, " (%s) show\n", addon); fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, "setmatrix\n"); fprintf(feps, " (%s) show\n", addon);
break; fprintf(feps, "setmatrix\n");
} break;
}
break; break;
case 13: /* EAN 13 */ case 13: /* EAN 13 */
case 16: case 16:
case 19: case 19:
fprintf(feps, "TE\n"); fprintf(feps, "TE\n");
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink); fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
fprintf(feps, "%.2f %.2f ", 5.0 * scaler, (4.0 + yoffset) * scaler); fprintf(feps, "%.2f %.2f ", 5.0 * scaler, (4.0 + yoffset) * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (0 + xoffset) * scaler, 1 * scaler); fprintf(feps, "TB %.2f %.2f TR\n", (0 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (2 + xoffset) * scaler, 1 * scaler); fprintf(feps, "TB %.2f %.2f TR\n", (2 + xoffset) * scaler, 1 * scaler);
fprintf(feps, "TB %.2f %.2f TR\n", (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", (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] = symbol->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);
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler); fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = -7; 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, " 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, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n"); fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", textpart); fprintf(feps, " (%s) show\n", 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] = symbol->text[i + 1];
} }
textpart[6] = '\0'; textpart[6] = '\0';
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler); fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = 24; textpos = 24;
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", textpart); fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n"); fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", textpart); fprintf(feps, " (%s) show\n", 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] = symbol->text[i + 7];
} }
textpart[6] = '\0'; textpart[6] = '\0';
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler); fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = 71; 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, " 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, " (%s) stringwidth\n", textpart);
fprintf(feps, "pop\n"); fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", textpart); fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, "setmatrix\n"); fprintf(feps, "setmatrix\n");
textdone = 1; textdone = 1;
switch(strlen(addon)) { switch(strlen(addon)) {
case 2: case 2:
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler); fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = xoffset + 114; 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, " 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, " (%s) stringwidth\n", addon);
fprintf(feps, "pop\n"); fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", addon); fprintf(feps, " (%s) show\n", addon);
fprintf(feps, "setmatrix\n"); fprintf(feps, "setmatrix\n");
break; break;
case 5: case 5:
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler); fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
textpos = xoffset + 128; 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, " 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, " (%s) stringwidth\n", addon);
fprintf(feps, "pop\n"); fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, " (%s) show\n", addon); fprintf(feps, " (%s) show\n", addon);
fprintf(feps, "setmatrix\n"); fprintf(feps, "setmatrix\n");
break; break;
} }
break; break;
}
}
if (((symbol->symbology == BARCODE_UPCA) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCA_CC)) {
/* guard bar extensions and text formatting for UPCA */
fprintf(feps, "TE\n");
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
fprintf(feps, "%.2f %.2f ", 5.0 * scaler, (4.0 + yoffset) * scaler);
latch = 1;
i = 0 + comp_offset;
do {
block_width = 0;
do {
block_width++;
} while (module_is_set(symbol, symbol->rows - 1, i + block_width) == module_is_set(symbol, symbol->rows - 1, i));
if(latch == 1) {
/* a bar */
fprintf(feps, "TB %.2f %.2f TR\n", (i + xoffset - comp_offset) * scaler, block_width * scaler);
latch = 0;
} else {
/* a space */
latch = 1;
} }
i += block_width; }
} while (i < 11 + comp_offset);
fprintf(feps, "TB %.2f %.2f TR\n", (46 + xoffset) * scaler, 1 * scaler); if (((symbol->symbology == BARCODE_UPCA) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCA_CC)) {
fprintf(feps, "TB %.2f %.2f TR\n", (48 + xoffset) * scaler, 1 * scaler); /* guard bar extensions and text formatting for UPCA */
latch = 1; fprintf(feps, "TE\n");
i = 85 + comp_offset; fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
do { fprintf(feps, "%.2f %.2f ", 5.0 * scaler, (4.0 + yoffset) * scaler);
block_width = 0; latch = 1;
i = 0 + comp_offset;
do { do {
block_width++; block_width = 0;
} while (module_is_set(symbol, symbol->rows - 1, i + block_width) == module_is_set(symbol, symbol->rows - 1, i)); do {
if(latch == 1) { block_width++;
/* a bar */ } while (module_is_set(symbol, symbol->rows - 1, i + block_width) == module_is_set(symbol, symbol->rows - 1, i));
fprintf(feps, "TB %.2f %.2f TR\n", (i + xoffset - comp_offset) * scaler, block_width * scaler); if(latch == 1) {
latch = 0; /* a bar */
} else { fprintf(feps, "TB %.2f %.2f TR\n", (i + xoffset - comp_offset) * scaler, block_width * scaler);
/* a space */ latch = 0;
latch = 1; } 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] = 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];
} }
i += block_width; textpart[5] = '\0';
} while (i < 96 + comp_offset); fprintf(feps, "matrix currentmatrix\n");
textpart[0] = symbol->text[0]; fprintf(feps, "/Helvetica findfont\n");
textpart[1] = '\0'; fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
fprintf(feps, "TE\n"); textpos = 27;
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink); fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, "pop\n");
fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler); fprintf(feps, "-2 div 0 rmoveto\n");
textpos = -5; fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn); fprintf(feps, "setmatrix\n");
fprintf(feps, " (%s) stringwidth\n", textpart); for(i = 0; i < 5; i++) {
fprintf(feps, "pop\n"); textpart[i] = symbol->text[i + 6];
fprintf(feps, "-2 div 0 rmoveto\n"); }
fprintf(feps, " (%s) show\n", textpart); textpart[6] = '\0';
fprintf(feps, "setmatrix\n"); fprintf(feps, "matrix currentmatrix\n");
for(i = 0; i < 5; i++) { fprintf(feps, "/Helvetica findfont\n");
textpart[i] = symbol->text[i + 1]; fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
} textpos = 68;
textpart[5] = '\0'; fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, " (%s) stringwidth\n", textpart);
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, "pop\n");
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler); fprintf(feps, "-2 div 0 rmoveto\n");
textpos = 27; fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn); fprintf(feps, "setmatrix\n");
fprintf(feps, " (%s) stringwidth\n", textpart); textpart[0] = symbol->text[11];
fprintf(feps, "pop\n"); textpart[1] = '\0';
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, " (%s) show\n", textpart); fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "setmatrix\n"); fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler);
for(i = 0; i < 5; i++) { textpos = 100;
textpart[i] = symbol->text[i + 6]; 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);
textpart[6] = '\0'; fprintf(feps, "pop\n");
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, " (%s) show\n", textpart);
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler); fprintf(feps, "setmatrix\n");
textpos = 68; textdone = 1;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn); switch(strlen(addon)) {
fprintf(feps, " (%s) stringwidth\n", textpart); case 2:
fprintf(feps, "pop\n"); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, " (%s) show\n", textpart); fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
fprintf(feps, "setmatrix\n"); textpos = xoffset + 116;
textpart[0] = symbol->text[11]; fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler);
textpart[1] = '\0'; fprintf(feps, " (%s) stringwidth\n", addon);
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "pop\n");
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler); fprintf(feps, " (%s) show\n", addon);
textpos = 100; fprintf(feps, "setmatrix\n");
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn); break;
fprintf(feps, " (%s) stringwidth\n", textpart); case 5:
fprintf(feps, "pop\n"); fprintf(feps, "matrix currentmatrix\n");
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, " (%s) show\n", textpart); fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler);
fprintf(feps, "setmatrix\n"); textpos = xoffset + 130;
textdone = 1; fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", textpos * scaler, addon_text_posn * scaler);
switch(strlen(addon)) { fprintf(feps, " (%s) stringwidth\n", addon);
case 2: fprintf(feps, "pop\n");
fprintf(feps, "matrix currentmatrix\n"); fprintf(feps, "-2 div 0 rmoveto\n");
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, " (%s) show\n", addon);
fprintf(feps, "%.2f scalefont setfont\n", 11.0 * scaler); fprintf(feps, "setmatrix\n");
textpos = xoffset + 116; break;
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] = 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_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'; } /* if (plot_text) */
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;
}
}
xoffset -= comp_offset; xoffset -= comp_offset;
@ -743,7 +749,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((textdone == 0) && (ustrlen(symbol->text) != 0)) { if(plot_text && (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");

View File

@ -1077,7 +1077,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
char* general_field_type = (char*)_alloca(strlen(source)); char* general_field_type = (char*)_alloca(strlen(source));
#endif #endif
int remainder, d1, d2, value; int remainder, d1, d2, value;
char padstring[14]; char padstring[40];
read_posn=0; read_posn=0;
value=0; value=0;
@ -1643,19 +1643,34 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
} }
latch = general_rules(general_field, general_field_type); latch = general_rules(general_field, general_field_type);
if(debug) printf("General field type: %s\n", general_field_type);
last_mode = NUMERIC;
/* Set initial mode if not NUMERIC */
if(general_field_type[0] == ALPHA) {
concat(binary_string, "0000"); /* Alphanumeric latch */
last_mode = ALPHA;
}
if(general_field_type[0] == ISOIEC) {
concat(binary_string, "0000"); /* Alphanumeric latch */
concat(binary_string, "00100"); /* ISO/IEC 646 latch */
last_mode = ISOIEC;
}
i = 0; i = 0;
do { do {
if(debug) printf("Processing character %d ", i); if(debug) printf("Processing character %d ", i);
switch(general_field_type[i]) { switch(general_field_type[i]) {
case NUMERIC: case NUMERIC:
if(debug) printf("as NUMERIC\n"); if(debug) printf("as NUMERIC:");
if(i != 0) {
if((general_field_type[i - 1] != NUMERIC) && (general_field[i - 1] != '[')) { if(last_mode != NUMERIC) {
concat(binary_string, "000"); /* Numeric latch */ concat(binary_string, "000"); /* Numeric latch */
} if(debug) printf("<NUMERIC LATCH>\n");
} }
if(debug) printf(" %c%c > ", general_field[i], general_field[i + 1]);
if(general_field[i] != '[') { if(general_field[i] != '[') {
d1 = ctoi(general_field[i]); d1 = ctoi(general_field[i]);
} else { } else {
@ -1674,24 +1689,27 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
for(j = 0; j < 7; j++) { for(j = 0; j < 7; j++) {
if((value & mask) == 0x00) { if((value & mask) == 0x00) {
concat(binary_string, "0"); concat(binary_string, "0");
if(debug) printf("0");
} else { } else {
concat(binary_string, "1"); concat(binary_string, "1");
if(debug) printf("1");
} }
mask = mask >> 1; mask = mask >> 1;
} }
i += 2; i += 2;
if(debug) printf("\n");
last_mode = NUMERIC; last_mode = NUMERIC;
break; break;
case ALPHA: case ALPHA:
if(debug) printf("as ALPHA\n"); if(debug) printf("as ALPHA\n");
if(i != 0) { if(i != 0) {
if((general_field_type[i - 1] == NUMERIC) || (general_field[i - 1] == '[')) { if(last_mode == NUMERIC) {
concat(binary_string, "0000"); /* Alphanumeric latch */ concat(binary_string, "0000"); /* Alphanumeric latch */
} }
if(general_field_type[i - 1] == ISOIEC) { if(last_mode == ISOIEC) {
concat(binary_string, "00100"); /* ISO/IEC 646 latch */ concat(binary_string, "00100"); /* Alphanumeric latch */
} }
} }
@ -1725,7 +1743,8 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
} }
} }
if(general_field[i] == '[') concat(binary_string, "01111"); /* FNC1/Numeric latch */ last_mode = ALPHA;
if(general_field[i] == '[') { concat(binary_string, "01111"); last_mode = NUMERIC; } /* FNC1/Numeric latch */
if(general_field[i] == '*') concat(binary_string, "111010"); /* asterisk */ if(general_field[i] == '*') concat(binary_string, "111010"); /* asterisk */
if(general_field[i] == ',') concat(binary_string, "111011"); /* comma */ if(general_field[i] == ',') concat(binary_string, "111011"); /* comma */
if(general_field[i] == '-') concat(binary_string, "111100"); /* minus or hyphen */ if(general_field[i] == '-') concat(binary_string, "111100"); /* minus or hyphen */
@ -1733,17 +1752,16 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
if(general_field[i] == '/') concat(binary_string, "111110"); /* slash or solidus */ if(general_field[i] == '/') concat(binary_string, "111110"); /* slash or solidus */
i++; i++;
last_mode = ALPHA;
break; break;
case ISOIEC: case ISOIEC:
if(debug) printf("as ISOIEC\n"); if(debug) printf("as ISOIEC\n");
if(i != 0) { if(i != 0) {
if((general_field_type[i - 1] == NUMERIC) || (general_field[i - 1] == '[')) { if(last_mode == NUMERIC) {
concat(binary_string, "0000"); /* Alphanumeric latch */ concat(binary_string, "0000"); /* Alphanumeric latch */
concat(binary_string, "00100"); /* ISO/IEC 646 latch */ concat(binary_string, "00100"); /* ISO/IEC 646 latch */
} }
if(general_field_type[i - 1] == ALPHA) { if(last_mode == ALPHA) {
concat(binary_string, "00100"); /* ISO/IEC 646 latch */ concat(binary_string, "00100"); /* ISO/IEC 646 latch */
} }
} }
@ -1793,7 +1811,8 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
} }
} }
if(general_field[i] == '[') concat(binary_string, "01111"); /* FNC1/Numeric latch */ last_mode = ISOIEC;
if(general_field[i] == '[') { concat(binary_string, "01111"); last_mode = NUMERIC; } /* FNC1/Numeric latch */
if(general_field[i] == '!') concat(binary_string, "11101000"); /* exclamation mark */ if(general_field[i] == '!') concat(binary_string, "11101000"); /* exclamation mark */
if(general_field[i] == 34) concat(binary_string, "11101001"); /* quotation mark */ if(general_field[i] == 34) concat(binary_string, "11101001"); /* quotation mark */
if(general_field[i] == 37) concat(binary_string, "11101010"); /* percent sign */ if(general_field[i] == 37) concat(binary_string, "11101010"); /* percent sign */
@ -1817,41 +1836,55 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
if(general_field[i] == ' ') concat(binary_string, "11111100"); /* space */ if(general_field[i] == ' ') concat(binary_string, "11111100"); /* space */
i++; i++;
last_mode = ISOIEC;
break; break;
} }
} while (i + latch < strlen(general_field)); } while (i + latch < strlen(general_field));
if(debug) printf("Resultant binary = %s\n", binary_string); if(debug) printf("Resultant binary = %s\n", binary_string);
if(debug) printf("\tLength: %d\n", strlen(binary_string)); if(debug) printf("\tLength: %d\n", (int)strlen(binary_string));
remainder = strlen(binary_string) % 12; remainder = 12 - (strlen(binary_string) % 12);
if(remainder == 12) { remainder = 0; }
if(strlen(binary_string) < 36) { remainder = 36 - strlen(binary_string); } if(strlen(binary_string) < 36) { remainder = 36 - strlen(binary_string); }
if(latch == 1) { if(latch == 1) {
/* There is still one more numeric digit to encode */ /* There is still one more numeric digit to encode */
if(debug) printf("Adding extra (odd) numeric digit\n"); if(debug) printf("Adding extra (odd) numeric digit\n");
if((remainder >= 4) && (remainder <= 6)) { if(last_mode == NUMERIC) {
value = ctoi(general_field[i]); if((remainder >= 4) && (remainder <= 6)) {
value++; value = ctoi(general_field[i]);
value++;
mask = 0x08; mask = 0x08;
for(j = 0; j < 4; j++) { for(j = 0; j < 4; j++) {
if((value & mask) == 0x00) { if((value & mask) == 0x00) {
concat(binary_string, "0"); concat(binary_string, "0");
} else { } else {
concat(binary_string, "1"); concat(binary_string, "1");
}
mask = mask >> 1;
}
} else {
d1 = ctoi(general_field[i]);
d2 = 10;
value = (11 * d1) + d2 + 8;
mask = 0x40;
for(j = 0; j < 7; j++) {
if((value & mask) == 0x00) {
concat(binary_string, "0");
} else {
concat(binary_string, "1");
}
mask = mask >> 1;
} }
mask = mask >> 1;
} }
} else { } else {
d1 = ctoi(general_field[i]); value = general_field[i] - 43;
d2 = 10;
value = (11 * d1) + d2 + 8; mask = 0x10;
for(j = 0; j < 5; j++) {
mask = 0x40;
for(j = 0; j < 7; j++) {
if((value & mask) == 0x00) { if((value & mask) == 0x00) {
concat(binary_string, "0"); concat(binary_string, "0");
} else { } else {
@ -1860,11 +1893,12 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
mask = mask >> 1; mask = mask >> 1;
} }
} }
remainder = strlen(binary_string) % 12;
remainder = 12 - (strlen(binary_string) % 12);
if(remainder == 12) { remainder = 0; }
if(strlen(binary_string) < 36) { remainder = 36 - strlen(binary_string); } if(strlen(binary_string) < 36) { remainder = 36 - strlen(binary_string); }
last_mode = NUMERIC;
if(debug) printf("Resultant binary = %s\n", binary_string); if(debug) printf("Resultant binary = %s\n", binary_string);
if(debug) printf("\tLength: %d\n", strlen(binary_string)); if(debug) printf("\tLength: %d\n", (int)strlen(binary_string));
} }
if(strlen(binary_string) > 252) { if(strlen(binary_string) > 252) {
@ -1872,18 +1906,18 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
/* Now add padding to binary string */ /* Now add padding to binary string (7.2.5.5.4) */
if(strlen(general_field) != 0) { i = remainder;
if (last_mode == NUMERIC) { if((strlen(general_field) != 0) && (last_mode == NUMERIC)) {
strcpy(padstring, "000000100001"); strcpy(padstring, "0000");
} else { i -= 4;
strcpy(padstring, "001000010000");
}
} else { } else {
strcpy(padstring, "001000010000"); strcpy(padstring, "");
} }
remainder = 12 - remainder; for(;i > 0;i -= 5) {
if(remainder == 12) { remainder = 0; } concat(padstring, "00100");
}
padstring[remainder] = '\0'; padstring[remainder] = '\0';
concat(binary_string, padstring); concat(binary_string, padstring);
@ -1904,7 +1938,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
if(d2 == 0) { binary_string[7] = '0'; } else { binary_string[7] = '1'; } if(d2 == 0) { binary_string[7] = '0'; } else { binary_string[7] = '1'; }
} }
if(debug) printf("Resultant binary = %s\n", binary_string); if(debug) printf("Resultant binary = %s\n", binary_string);
if(debug) printf("\tLength: %d\n", strlen(binary_string)); if(debug) printf("\tLength: %d\n", (int)strlen(binary_string));
return 0; return 0;
} }

View File

@ -40,6 +40,7 @@ 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;
row_height=0; row_height=0;
textdone = 0; textdone = 0;
@ -163,7 +164,10 @@ int svg_plot(struct zint_symbol *symbol)
} }
addon[r] = '\0'; addon[r] = '\0';
if(ustrlen(symbol->text) != 0) { if((symbol->show_hrt == 0) || (ustrlen(symbol->text) != 0)) {
plot_text = 0;
}
if(plot_text) {
textoffset = 9; textoffset = 9;
} else { } else {
textoffset = 0; textoffset = 0;
@ -310,252 +314,254 @@ 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 ((((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC)) || if(plot_text) {
(symbol->symbology == BARCODE_ISBNX)) { if ((((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC)) ||
/* guard bar extensions and text formatting for EAN8 and EAN13 */ (symbol->symbology == BARCODE_ISBNX)) {
switch(ustrlen(symbol->text)) { /* guard bar extensions and text formatting for EAN8 and EAN13 */
case 8: /* EAN-8 */ switch(ustrlen(symbol->text)) {
case 11: case 8: /* EAN-8 */
case 14: case 11:
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (0 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); case 14:
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (2 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (0 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (32 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (2 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (34 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (32 + 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", (34 + 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", (64 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
for(i = 0; i < 4; i++) { fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (66 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
textpart[i] = symbol->text[i]; for(i = 0; i < 4; i++) {
} textpart[i] = symbol->text[i];
textpart[4] = '\0'; }
textpos = 17; textpart[4] = '\0';
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn); textpos = 17;
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " %s\n", textpart); fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " </text>\n"); fprintf(fsvg, " %s\n", textpart);
for(i = 0; i < 4; i++) { fprintf(fsvg, " </text>\n");
textpart[i] = symbol->text[i + 4]; for(i = 0; i < 4; i++) {
} textpart[i] = symbol->text[i + 4];
textpart[4] = '\0'; }
textpos = 50; textpart[4] = '\0';
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn); textpos = 50;
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " %s\n", textpart); fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " </text>\n"); fprintf(fsvg, " %s\n", textpart);
textdone = 1; fprintf(fsvg, " </text>\n");
switch(strlen(addon)) { textdone = 1;
case 2: switch(strlen(addon)) {
textpos = xoffset + 86; case 2:
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler); textpos = xoffset + 86;
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " %s\n", addon); fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " </text>\n"); fprintf(fsvg, " %s\n", addon);
break; fprintf(fsvg, " </text>\n");
case 5: break;
textpos = xoffset + 100; case 5:
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler); textpos = xoffset + 100;
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " %s\n", addon); fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " </text>\n"); fprintf(fsvg, " %s\n", addon);
break; fprintf(fsvg, " </text>\n");
} break;
}
break; break;
case 13: /* EAN 13 */ case 13: /* EAN 13 */
case 16: case 16:
case 19: case 19:
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (0 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (0 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (2 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (2 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (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", (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] = symbol->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);
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");
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';
textpos = 24; textpos = 24;
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", 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");
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';
textpos = 71; textpos = 71;
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", 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");
textdone = 1; textdone = 1;
switch(strlen(addon)) { switch(strlen(addon)) {
case 2: case 2:
textpos = xoffset + 114; textpos = xoffset + 114;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\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, " 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", addon); fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n"); fprintf(fsvg, " </text>\n");
break; break;
case 5: case 5:
textpos = xoffset + 128; textpos = xoffset + 128;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\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, " 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", addon); fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n"); fprintf(fsvg, " </text>\n");
break; break;
} }
break; break;
}
}
if (((symbol->symbology == BARCODE_UPCA) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCA_CC)) {
/* guard bar extensions and text formatting for UPCA */
latch = 1;
i = 0 + comp_offset;
do {
block_width = 0;
do {
block_width++;
} while (module_is_set(symbol, symbol->rows - 1, i + block_width) == module_is_set(symbol, symbol->rows - 1, i));
if(latch == 1) {
/* a bar */
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (i + xoffset - comp_offset) * scaler, row_posn, block_width * scaler, 5.0 * scaler);
latch = 0;
} else {
/* a space */
latch = 1;
} }
i += block_width; }
} while (i < 11 + comp_offset);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (46 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); if (((symbol->symbology == BARCODE_UPCA) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCA_CC)) {
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (48 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler); /* guard bar extensions and text formatting for UPCA */
latch = 1; latch = 1;
i = 85 + comp_offset;
do { i = 0 + comp_offset;
block_width = 0;
do { do {
block_width++; block_width = 0;
} while (module_is_set(symbol, symbol->rows - 1, i + block_width) == module_is_set(symbol, symbol->rows - 1, i)); do {
if(latch == 1) { block_width++;
/* a bar */ } while (module_is_set(symbol, symbol->rows - 1, i + block_width) == module_is_set(symbol, symbol->rows - 1, i));
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (i + xoffset - comp_offset) * scaler, row_posn, block_width * scaler, 5.0 * scaler); if(latch == 1) {
latch = 0; /* a bar */
} else { fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (i + xoffset - comp_offset) * scaler, row_posn, block_width * scaler, 5.0 * scaler);
/* a space */ latch = 0;
latch = 1; } else {
/* a space */
latch = 1;
}
i += block_width;
} while (i < 11 + comp_offset);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (46 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (48 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
latch = 1;
i = 85 + comp_offset;
do {
block_width = 0;
do {
block_width++;
} while (module_is_set(symbol, symbol->rows - 1, i + block_width) == module_is_set(symbol, symbol->rows - 1, i));
if(latch == 1) {
/* a bar */
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (i + xoffset - comp_offset) * scaler, row_posn, block_width * scaler, 5.0 * scaler);
latch = 0;
} else {
/* a space */
latch = 1;
}
i += block_width;
} while (i < 96 + comp_offset);
textpart[0] = symbol->text[0];
textpart[1] = '\0';
textpos = -5;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
for(i = 0; i < 5; i++) {
textpart[i] = symbol->text[i + 1];
} }
i += block_width; textpart[5] = '\0';
} while (i < 96 + comp_offset); textpos = 27;
textpart[0] = symbol->text[0]; fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
textpart[1] = '\0'; fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
textpos = -5; fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn); fprintf(fsvg, " </text>\n");
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour); for(i = 0; i < 5; i++) {
fprintf(fsvg, " %s\n", textpart); textpart[i] = symbol->text[i + 6];
fprintf(fsvg, " </text>\n"); }
for(i = 0; i < 5; i++) { textpart[6] = '\0';
textpart[i] = symbol->text[i + 1]; textpos = 68;
} fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
textpart[5] = '\0'; fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
textpos = 27; fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn); fprintf(fsvg, " </text>\n");
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour); textpart[0] = symbol->text[11];
fprintf(fsvg, " %s\n", textpart); textpart[1] = '\0';
fprintf(fsvg, " </text>\n"); textpos = 100;
for(i = 0; i < 5; i++) { fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
textpart[i] = symbol->text[i + 6]; fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour);
} fprintf(fsvg, " %s\n", textpart);
textpart[6] = '\0'; fprintf(fsvg, " </text>\n");
textpos = 68; textdone = 1;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn); switch(strlen(addon)) {
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour); case 2:
fprintf(fsvg, " %s\n", textpart); textpos = xoffset + 116;
fprintf(fsvg, " </text>\n"); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
textpart[0] = symbol->text[11]; fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
textpart[1] = '\0'; fprintf(fsvg, " %s\n", addon);
textpos = 100; fprintf(fsvg, " </text>\n");
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn); break;
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour); case 5:
fprintf(fsvg, " %s\n", textpart); textpos = xoffset + 130;
fprintf(fsvg, " </text>\n"); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
textdone = 1; fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
switch(strlen(addon)) { fprintf(fsvg, " %s\n", addon);
case 2: fprintf(fsvg, " </text>\n");
textpos = xoffset + 116; break;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler); }
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n");
break;
case 5:
textpos = xoffset + 130;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n");
break;
} }
} if (((symbol->symbology == BARCODE_UPCE) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCE_CC)) {
/* guard bar extensions and text formatting for UPCE */
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (0 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (2 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (46 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (48 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (50 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
textpart[0] = symbol->text[0];
textpart[1] = '\0';
textpos = -5;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
for(i = 0; i < 6; i++) {
textpart[i] = symbol->text[i + 1];
}
textpart[6] = '\0';
textpos = 24;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
textpart[0] = symbol->text[7];
textpart[1] = '\0';
textpos = 55;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
textdone = 1;
switch(strlen(addon)) {
case 2:
textpos = xoffset + 70;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n");
break;
case 5:
textpos = xoffset + 84;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n");
break;
}
if (((symbol->symbology == BARCODE_UPCE) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCE_CC)) {
/* guard bar extensions and text formatting for UPCE */
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (0 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (2 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (46 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (48 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
fprintf(fsvg, " <rect x=\"%.2f\" y=\"%.2f\" width=\"%.2f\" height=\"%.2f\" />\n", (50 + xoffset) * scaler, row_posn, scaler, 5.0 * scaler);
textpart[0] = symbol->text[0];
textpart[1] = '\0';
textpos = -5;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
for(i = 0; i < 6; i++) {
textpart[i] = symbol->text[i + 1];
} }
textpart[6] = '\0'; } /* if (plot_text) */
textpos = 24;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
textpart[0] = symbol->text[7];
textpart[1] = '\0';
textpos = 55;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n");
textdone = 1;
switch(strlen(addon)) {
case 2:
textpos = xoffset + 70;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n");
break;
case 5:
textpos = xoffset + 84;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", textpos * scaler, addon_text_posn * scaler);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 11.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", addon);
fprintf(fsvg, " </text>\n");
break;
}
}
xoffset -= comp_offset; xoffset -= comp_offset;
@ -596,7 +602,7 @@ 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) && (ustrlen(symbol->text) != 0)) { if(plot_text && (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);

View File

@ -388,6 +388,7 @@ char isbn13_check(unsigned char source[]) /* For ISBN(13) only */
char isbn_check(unsigned char source[]) /* For ISBN(10) and SBN only */ char isbn_check(unsigned char source[]) /* For ISBN(10) and SBN only */
{ {
unsigned int i, weight, sum, check, h; unsigned int i, weight, sum, check, h;
char check_char;
sum = 0; sum = 0;
weight = 1; weight = 1;
@ -400,7 +401,9 @@ char isbn_check(unsigned char source[]) /* For ISBN(10) and SBN only */
} }
check = sum % 11; check = sum % 11;
return itoc(check); check_char = itoc(check);
if(check == 10) { check_char = 'X'; }
return check_char;
} }
int isbn(struct zint_symbol *symbol, unsigned char source[], const unsigned int src_len, char dest[]) /* Make an EAN-13 barcode from an SBN or ISBN */ int isbn(struct zint_symbol *symbol, unsigned char source[], const unsigned int src_len, char dest[]) /* Make an EAN-13 barcode from an SBN or ISBN */

View File

@ -38,6 +38,7 @@ struct zint_symbol {
int option_1; int option_1;
int option_2; int option_2;
int option_3; int option_3;
int show_hrt;
int input_mode; int input_mode;
unsigned char text[128]; unsigned char text[128];
int rows; int rows;

View File

@ -65,6 +65,11 @@ void QZint::encode()
m_zintSymbol->option_1=m_securityLevel; m_zintSymbol->option_1=m_securityLevel;
m_zintSymbol->input_mode = m_input_mode; m_zintSymbol->input_mode = m_input_mode;
m_zintSymbol->option_2=m_width; m_zintSymbol->option_2=m_width;
if(m_hidetext) {
m_zintSymbol->show_hrt = 0;
} else {
m_zintSymbol->show_hrt = 1;
}
if(m_symbol == BARCODE_PDF417) { if(m_symbol == BARCODE_PDF417) {
m_zintSymbol->option_3=m_pdf417CodeWords; m_zintSymbol->option_3=m_pdf417CodeWords;
} else { } else {
@ -76,9 +81,6 @@ void QZint::encode()
int error = ZBarcode_Encode(m_zintSymbol, (unsigned char*)bstr.data(), bstr.length()); int error = ZBarcode_Encode(m_zintSymbol, (unsigned char*)bstr.data(), bstr.length());
if (error > WARN_INVALID_OPTION) if (error > WARN_INVALID_OPTION)
m_lastError=m_zintSymbol->errtxt; m_lastError=m_zintSymbol->errtxt;
if(m_hidetext) {
m_zintSymbol->text[0] = (unsigned char) '\0';
}
if (m_zintSymbol->symbology == BARCODE_MAXICODE) if (m_zintSymbol->symbology == BARCODE_MAXICODE)
m_zintSymbol->height = 33; m_zintSymbol->height = 33;
@ -259,6 +261,11 @@ bool QZint::save_to_file(QString filename)
m_zintSymbol->option_1=m_securityLevel; m_zintSymbol->option_1=m_securityLevel;
m_zintSymbol->input_mode = m_input_mode; m_zintSymbol->input_mode = m_input_mode;
m_zintSymbol->option_2=m_width; m_zintSymbol->option_2=m_width;
if(m_hidetext) {
m_zintSymbol->show_hrt = 0;
} else {
m_zintSymbol->show_hrt = 1;
}
if(m_symbol == BARCODE_PDF417) { if(m_symbol == BARCODE_PDF417) {
m_zintSymbol->option_3=m_pdf417CodeWords; m_zintSymbol->option_3=m_pdf417CodeWords;
} else { } else {
@ -277,9 +284,6 @@ bool QZint::save_to_file(QString filename)
int error = ZBarcode_Encode(m_zintSymbol, (unsigned char*)bstr.data(), bstr.length()); int error = ZBarcode_Encode(m_zintSymbol, (unsigned char*)bstr.data(), bstr.length());
if (error > WARN_INVALID_OPTION) if (error > WARN_INVALID_OPTION)
m_lastError=m_zintSymbol->errtxt; m_lastError=m_zintSymbol->errtxt;
if(m_hidetext) {
m_zintSymbol->text[0] = (unsigned char) '\0';
}
error = ZBarcode_Print(m_zintSymbol, 0); error = ZBarcode_Print(m_zintSymbol, 0);
if (error > WARN_INVALID_OPTION) if (error > WARN_INVALID_OPTION)
m_lastError=m_zintSymbol->errtxt; m_lastError=m_zintSymbol->errtxt;
@ -573,124 +577,126 @@ void QZint::render(QPainter & painter, const QRectF & paintRect, AspectRatioMode
textdone = false; textdone = false;
painter.setFont(fontSmall); if(m_hidetext == false) {
if(((m_zintSymbol->symbology == BARCODE_EANX) || (m_zintSymbol->symbology == BARCODE_EANX_CC)) || painter.setFont(fontSmall);
(m_zintSymbol->symbology == BARCODE_ISBNX)) { if(((m_zintSymbol->symbology == BARCODE_EANX) || (m_zintSymbol->symbology == BARCODE_EANX_CC)) ||
/* Add bridge and format text for EAN */ (m_zintSymbol->symbology == BARCODE_ISBNX)) {
switch(caption.size()) { /* Add bridge and format text for EAN */
case 8: switch(caption.size()) {
case 11: case 8:
case 14: case 11:
painter.fillRect(0 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor)); case 14:
painter.fillRect(2 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor)); painter.fillRect(0 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
painter.fillRect(32 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor)); painter.fillRect(2 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
painter.fillRect(34 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor)); painter.fillRect(32 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
painter.fillRect(64 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor)); painter.fillRect(34 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
painter.fillRect(66 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor)); painter.fillRect(64 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
painter.fillRect(66 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
painter.setFont(fontLarge);
painter.drawText(3 + xoffset, m_zintSymbol->height + yoffset, 29, 9,Qt::AlignCenter, caption.mid(0,4));
painter.drawText(35 + xoffset, m_zintSymbol->height + yoffset, 29, 9,Qt::AlignCenter, caption.mid(4,4));
if(caption.size() == 11) { /* EAN-2 */ painter.drawText(76 + xoffset, addon_text_height, 20, 9,Qt::AlignCenter, caption.mid(9,2)); };
if(caption.size() == 14) { /* EAN-5 */ painter.drawText(76 + xoffset, addon_text_height, 47, 9,Qt::AlignCenter, caption.mid(9,5)); };
painter.setFont(fontSmall);
textdone = true;
break;
case 13:
case 16:
case 19:
painter.fillRect(0 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
painter.fillRect(2 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
painter.fillRect(46 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
painter.fillRect(48 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
painter.fillRect(92 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
painter.fillRect(94 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
painter.setFont(fontLarge);
painter.drawText(xoffset - 7, m_zintSymbol->height + yoffset, 7, 9,Qt::AlignCenter, caption.mid(0,1));
painter.drawText(3 + xoffset, m_zintSymbol->height + yoffset, 43, 9,Qt::AlignCenter, caption.mid(1,6));
painter.drawText(49 + xoffset, m_zintSymbol->height + yoffset, 43, 9,Qt::AlignCenter, caption.mid(7,6));
if(caption.size() == 16) { /* EAN-2 */ painter.drawText(104 + xoffset, addon_text_height, 20, 9,Qt::AlignCenter, caption.mid(14,2)); };
if(caption.size() == 19) { /* EAN-5 */ painter.drawText(104 + xoffset, addon_text_height, 47, 9,Qt::AlignCenter, caption.mid(14,5)); };
painter.setFont(fontSmall);
textdone = true;
break;
}
if(textdone == false) {
painter.setFont(fontLarge); painter.setFont(fontLarge);
painter.drawText(3 + xoffset, m_zintSymbol->height + yoffset, 29, 9,Qt::AlignCenter, caption.mid(0,4)); painter.drawText(0, m_zintSymbol->height, m_zintSymbol->width, 9,Qt::AlignCenter, caption);
painter.drawText(35 + xoffset, m_zintSymbol->height + yoffset, 29, 9,Qt::AlignCenter, caption.mid(4,4));
if(caption.size() == 11) { /* EAN-2 */ painter.drawText(76 + xoffset, addon_text_height, 20, 9,Qt::AlignCenter, caption.mid(9,2)); };
if(caption.size() == 14) { /* EAN-5 */ painter.drawText(76 + xoffset, addon_text_height, 47, 9,Qt::AlignCenter, caption.mid(9,5)); };
painter.setFont(fontSmall); painter.setFont(fontSmall);
textdone = true; textdone = true;
break; }
case 13:
case 16:
case 19:
painter.fillRect(0 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
painter.fillRect(2 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
painter.fillRect(46 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
painter.fillRect(48 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
painter.fillRect(92 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
painter.fillRect(94 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
painter.setFont(fontLarge);
painter.drawText(xoffset - 7, m_zintSymbol->height + yoffset, 7, 9,Qt::AlignCenter, caption.mid(0,1));
painter.drawText(3 + xoffset, m_zintSymbol->height + yoffset, 43, 9,Qt::AlignCenter, caption.mid(1,6));
painter.drawText(49 + xoffset, m_zintSymbol->height + yoffset, 43, 9,Qt::AlignCenter, caption.mid(7,6));
if(caption.size() == 16) { /* EAN-2 */ painter.drawText(104 + xoffset, addon_text_height, 20, 9,Qt::AlignCenter, caption.mid(14,2)); };
if(caption.size() == 19) { /* EAN-5 */ painter.drawText(104 + xoffset, addon_text_height, 47, 9,Qt::AlignCenter, caption.mid(14,5)); };
painter.setFont(fontSmall);
textdone = true;
break;
} }
if(textdone == false) {
if((m_zintSymbol->symbology == BARCODE_UPCA) || (m_zintSymbol->symbology == BARCODE_UPCA_CC)) {
/* Add bridge and format text for UPC-A */
int block_width;
bool latch = true;
j = 0 + comp_offset;
do {
block_width = 0;
do {
block_width++;
} while (module_set(m_zintSymbol->rows - 1, j + block_width) == module_set(m_zintSymbol->rows - 1, j));
if(latch == true) {
/* a bar */
painter.fillRect(j + xoffset - comp_offset,m_zintSymbol->height,block_width,5,QBrush(m_fgColor));
latch = false;
} else {
/* a space */
latch = true;
}
j += block_width;
} while (j < 11 + comp_offset);
painter.fillRect(46 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
painter.fillRect(48 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
latch = true;
j = 85 + comp_offset;
do {
block_width = 0;
do {
block_width++;
} while (module_set(m_zintSymbol->rows - 1, j + block_width) == module_set(m_zintSymbol->rows - 1, j));
if(latch == true) {
/* a bar */
painter.fillRect(j + xoffset - comp_offset,m_zintSymbol->height,block_width,5,QBrush(m_fgColor));
latch = false;
} else {
/* a space */
latch = true;
}
j += block_width;
} while (j < 96 + comp_offset);
painter.drawText(xoffset - 7, m_zintSymbol->height + yoffset, 7, 7,Qt::AlignCenter, caption.mid(0,1));
painter.drawText(96 + xoffset, m_zintSymbol->height + yoffset, 7, 7,Qt::AlignCenter, caption.mid(11,1));
painter.setFont(fontLarge); painter.setFont(fontLarge);
painter.drawText(0, m_zintSymbol->height, m_zintSymbol->width, 9,Qt::AlignCenter, caption); painter.drawText(11 + xoffset, m_zintSymbol->height + yoffset, 35, 9,Qt::AlignCenter, caption.mid(1,5));
painter.drawText(49 + xoffset, m_zintSymbol->height + yoffset, 35, 9,Qt::AlignCenter, caption.mid(6,5));
if(caption.size() == 15) { /* EAN-2 */ painter.drawText(104 + xoffset, addon_text_height, 20, 9,Qt::AlignCenter, caption.mid(13,2)); };
if(caption.size() == 18) { /* EAN-5 */ painter.drawText(104 + xoffset, addon_text_height, 47, 9,Qt::AlignCenter, caption.mid(13,5)); };
painter.setFont(fontSmall); painter.setFont(fontSmall);
textdone = true; textdone = true;
} }
}
if((m_zintSymbol->symbology == BARCODE_UPCA) || (m_zintSymbol->symbology == BARCODE_UPCA_CC)) { if((m_zintSymbol->symbology == BARCODE_UPCE) || (m_zintSymbol->symbology == BARCODE_UPCE_CC)) {
/* Add bridge and format text for UPC-A */ /* Add bridge and format text for UPC-E */
int block_width; painter.fillRect(0 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
bool latch = true; painter.fillRect(2 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
painter.fillRect(46 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
painter.fillRect(48 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
painter.fillRect(50 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
painter.drawText(xoffset - 7, m_zintSymbol->height + yoffset, 7, 7,Qt::AlignCenter, caption.mid(0,1));
painter.drawText(51 + xoffset, m_zintSymbol->height + yoffset, 7, 7,Qt::AlignCenter, caption.mid(7,1));
painter.setFont(fontLarge);
painter.drawText(3 + xoffset, m_zintSymbol->height + yoffset, 43, 9,Qt::AlignCenter, caption.mid(1,6));
if(caption.size() == 11) { /* EAN-2 */ painter.drawText(60 + xoffset, addon_text_height, 20, 9,Qt::AlignCenter, caption.mid(9,2)); };
if(caption.size() == 14) { /* EAN-2 */ painter.drawText(60 + xoffset, addon_text_height, 47, 9,Qt::AlignCenter, caption.mid(9,5)); };
painter.setFont(fontSmall);
textdone = true;
}
} /* if (m_hidetext == false) */
j = 0 + comp_offset; if((m_hidetext == false) && (textdone == false)) {
do {
block_width = 0;
do {
block_width++;
} while (module_set(m_zintSymbol->rows - 1, j + block_width) == module_set(m_zintSymbol->rows - 1, j));
if(latch == true) {
/* a bar */
painter.fillRect(j + xoffset - comp_offset,m_zintSymbol->height,block_width,5,QBrush(m_fgColor));
latch = false;
} else {
/* a space */
latch = true;
}
j += block_width;
} while (j < 11 + comp_offset);
painter.fillRect(46 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
painter.fillRect(48 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
latch = true;
j = 85 + comp_offset;
do {
block_width = 0;
do {
block_width++;
} while (module_set(m_zintSymbol->rows - 1, j + block_width) == module_set(m_zintSymbol->rows - 1, j));
if(latch == true) {
/* a bar */
painter.fillRect(j + xoffset - comp_offset,m_zintSymbol->height,block_width,5,QBrush(m_fgColor));
latch = false;
} else {
/* a space */
latch = true;
}
j += block_width;
} while (j < 96 + comp_offset);
painter.drawText(xoffset - 7, m_zintSymbol->height + yoffset, 7, 7,Qt::AlignCenter, caption.mid(0,1));
painter.drawText(96 + xoffset, m_zintSymbol->height + yoffset, 7, 7,Qt::AlignCenter, caption.mid(11,1));
painter.setFont(fontLarge);
painter.drawText(11 + xoffset, m_zintSymbol->height + yoffset, 35, 9,Qt::AlignCenter, caption.mid(1,5));
painter.drawText(49 + xoffset, m_zintSymbol->height + yoffset, 35, 9,Qt::AlignCenter, caption.mid(6,5));
if(caption.size() == 15) { /* EAN-2 */ painter.drawText(104 + xoffset, addon_text_height, 20, 9,Qt::AlignCenter, caption.mid(13,2)); };
if(caption.size() == 18) { /* EAN-5 */ painter.drawText(104 + xoffset, addon_text_height, 47, 9,Qt::AlignCenter, caption.mid(13,5)); };
painter.setFont(fontSmall);
textdone = true;
}
if((m_zintSymbol->symbology == BARCODE_UPCE) || (m_zintSymbol->symbology == BARCODE_UPCE_CC)) {
/* Add bridge and format text for UPC-E */
painter.fillRect(0 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
painter.fillRect(2 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
painter.fillRect(46 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
painter.fillRect(48 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
painter.fillRect(50 + xoffset,m_zintSymbol->height,1,5,QBrush(m_fgColor));
painter.drawText(xoffset - 7, m_zintSymbol->height + yoffset, 7, 7,Qt::AlignCenter, caption.mid(0,1));
painter.drawText(51 + xoffset, m_zintSymbol->height + yoffset, 7, 7,Qt::AlignCenter, caption.mid(7,1));
painter.setFont(fontLarge);
painter.drawText(3 + xoffset, m_zintSymbol->height + yoffset, 43, 9,Qt::AlignCenter, caption.mid(1,6));
if(caption.size() == 11) { /* EAN-2 */ painter.drawText(60 + xoffset, addon_text_height, 20, 9,Qt::AlignCenter, caption.mid(9,2)); };
if(caption.size() == 14) { /* EAN-2 */ painter.drawText(60 + xoffset, addon_text_height, 47, 9,Qt::AlignCenter, caption.mid(9,5)); };
painter.setFont(fontSmall);
textdone = true;
}
if((caption.isEmpty() == false) && (textdone == false)) {
/* Add text to any other symbol */ /* Add text to any other symbol */
painter.drawText(0, m_zintSymbol->height + yoffset, m_zintSymbol->width, 7, Qt::AlignCenter, caption); painter.drawText(0, m_zintSymbol->height + yoffset, m_zintSymbol->width, 7, Qt::AlignCenter, caption);
} }

View File

@ -95,6 +95,7 @@ void usage(void)
" --gs1 Treat input as GS1 data\n" " --gs1 Treat input as GS1 data\n"
" --binary Treat input as Binary data\n" " --binary Treat input as Binary data\n"
" --notext Remove human readable text\n" " --notext Remove human readable text\n"
" --square Force Data Matrix symbols to be square\n"
, ZINT_VERSION); , ZINT_VERSION);
} }
@ -120,14 +121,12 @@ int main(int argc, char **argv)
int error_number; int error_number;
int rotate_angle; int rotate_angle;
int generated; int generated;
int suppress_human_readable;
error_number = 0; error_number = 0;
rotate_angle = 0; rotate_angle = 0;
generated = 0; generated = 0;
my_symbol = ZBarcode_Create(); my_symbol = ZBarcode_Create();
my_symbol->input_mode = UNICODE_MODE; my_symbol->input_mode = UNICODE_MODE;
suppress_human_readable = 0;
if(argc == 1) { if(argc == 1) {
usage(); usage();
@ -166,6 +165,7 @@ int main(int argc, char **argv)
{"sjis", 0, 0, 0}, {"sjis", 0, 0, 0},
{"binary", 0, 0, 0}, {"binary", 0, 0, 0},
{"notext", 0, 0, 0}, {"notext", 0, 0, 0},
{"square", 0, 0, 0},
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
c = getopt_long(argc, argv, "htb:w:d:o:i:rcmp", long_options, &option_index); c = getopt_long(argc, argv, "htb:w:d:o:i:rcmp", long_options, &option_index);
@ -210,7 +210,10 @@ int main(int argc, char **argv)
strncpy(my_symbol->bgcolour, optarg, 7); strncpy(my_symbol->bgcolour, optarg, 7);
} }
if(!strcmp(long_options[option_index].name, "notext")) { if(!strcmp(long_options[option_index].name, "notext")) {
suppress_human_readable = 1; my_symbol->show_hrt = 0;
}
if(!strcmp(long_options[option_index].name, "square")) {
my_symbol->option_3 = DM_SQUARE;
} }
if(!strcmp(long_options[option_index].name, "scale")) { if(!strcmp(long_options[option_index].name, "scale")) {
my_symbol->scale = (float)(atof(optarg)); my_symbol->scale = (float)(atof(optarg));
@ -331,9 +334,6 @@ int main(int argc, char **argv)
case 'd': /* we have some data! */ case 'd': /* we have some data! */
error_number = ZBarcode_Encode(my_symbol, (unsigned char*)optarg, strlen(optarg)); error_number = ZBarcode_Encode(my_symbol, (unsigned char*)optarg, strlen(optarg));
if(error_number == 0) { if(error_number == 0) {
if(suppress_human_readable) {
my_symbol->text[0] = (unsigned char)'\0';
}
error_number = ZBarcode_Print(my_symbol, rotate_angle); error_number = ZBarcode_Print(my_symbol, rotate_angle);
} }
generated = 1; generated = 1;
@ -347,9 +347,6 @@ int main(int argc, char **argv)
case 'i': /* Take data from file */ case 'i': /* Take data from file */
error_number = ZBarcode_Encode_File(my_symbol, optarg); error_number = ZBarcode_Encode_File(my_symbol, optarg);
if(error_number == 0) { if(error_number == 0) {
if(suppress_human_readable) {
my_symbol->text[0] = (unsigned char)'\0';
}
error_number = ZBarcode_Print(my_symbol, rotate_angle); error_number = ZBarcode_Print(my_symbol, rotate_angle);
} }
generated = 1; generated = 1;