Allow DotCode output in EPS

This commit is contained in:
Robin Stuart 2016-08-28 16:38:02 +01:00
parent d7c60cf422
commit 8ccde8ad67

View File

@ -289,6 +289,7 @@ int ps_plot(struct zint_symbol *symbol) {
/* Definitions */ /* Definitions */
fprintf(feps, "/TL { setlinewidth moveto lineto stroke } bind def\n"); fprintf(feps, "/TL { setlinewidth moveto lineto stroke } bind def\n");
fprintf(feps, "/TC { moveto 0 360 arc 360 0 arcn fill } bind def\n"); fprintf(feps, "/TC { moveto 0 360 arc 360 0 arcn fill } bind def\n");
fprintf(feps, "/TD { newpath 0 360 arc fill } bind def\n");
fprintf(feps, "/TH { 0 setlinewidth moveto lineto lineto lineto lineto lineto closepath fill } bind def\n"); fprintf(feps, "/TH { 0 setlinewidth moveto lineto lineto lineto lineto lineto closepath fill } bind def\n");
fprintf(feps, "/TB { 2 copy } bind def\n"); fprintf(feps, "/TB { 2 copy } bind def\n");
fprintf(feps, "/TR { newpath 4 1 roll exch moveto 1 index 0 rlineto 0 exch rlineto neg 0 rlineto closepath fill } bind def\n"); fprintf(feps, "/TR { newpath 4 1 roll exch moveto 1 index 0 rlineto 0 exch rlineto neg 0 rlineto closepath fill } bind def\n");
@ -380,6 +381,7 @@ int ps_plot(struct zint_symbol *symbol) {
if (symbol->symbology != BARCODE_MAXICODE) { if (symbol->symbology != BARCODE_MAXICODE) {
/* everything else uses rectangles (or squares) */ /* everything else uses rectangles (or squares) */
/* Works from the bottom of the symbol up */ /* Works from the bottom of the symbol up */
int addon_latch = 0; int addon_latch = 0;
for (r = 0; r < symbol->rows; r++) { for (r = 0; r < symbol->rows; r++) {
@ -399,12 +401,29 @@ int ps_plot(struct zint_symbol *symbol) {
} }
row_posn += (textoffset + yoffset); row_posn += (textoffset + yoffset);
if ((symbol->output_options & BARCODE_DOTTY_MODE) != 0) {
if ((symbol->output_options & CMYK_COLOUR) == 0) {
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
} else {
fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n", cyan_ink, magenta_ink, yellow_ink, black_ink);
}
/* Use dots instead of squares */
for (i = 0; i < symbol->width; i++) {
if (module_is_set(symbol, this_row, i)) {
fprintf(feps, "%.2f %.2f %.2f TD\n", ((i + xoffset) * scaler) + (scaler / 2.0), (row_posn * scaler) + (scaler / 2.0), (2.0 / 5.0) * scaler);
}
}
} else {
/* Normal mode, with rectangles */
fprintf(feps, "TE\n"); fprintf(feps, "TE\n");
if ((symbol->output_options & CMYK_COLOUR) == 0) { if ((symbol->output_options & CMYK_COLOUR) == 0) {
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);
} else { } else {
fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n", cyan_ink, magenta_ink, yellow_ink, black_ink); fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n", cyan_ink, magenta_ink, yellow_ink, black_ink);
} }
fprintf(feps, "%.2f %.2f ", row_height * scaler, row_posn * scaler); fprintf(feps, "%.2f %.2f ", row_height * scaler, row_posn * scaler);
i = 0; i = 0;
if (module_is_set(symbol, this_row, 0)) { if (module_is_set(symbol, this_row, 0)) {
@ -442,6 +461,7 @@ int ps_plot(struct zint_symbol *symbol) {
} while (i < symbol->width); } while (i < symbol->width);
} }
} }
}
/* That's done the actual data area, everything else is human-friendly */ /* That's done the actual data area, everything else is human-friendly */
xoffset += comp_offset; xoffset += comp_offset;
@ -887,7 +907,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) { if ((textdone == 0) && (ustrlen(local_text))) {
fprintf(feps, "TE\n"); fprintf(feps, "TE\n");
if ((symbol->output_options & CMYK_COLOUR) == 0) { if ((symbol->output_options & CMYK_COLOUR) == 0) {
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);