Allow Unicode in SVG output text

This commit is contained in:
hooper114 2009-02-19 19:09:57 +00:00
parent aa9edfb320
commit 636a18c74f
17 changed files with 208 additions and 155 deletions

View File

@ -65,7 +65,7 @@ int matrix_two_of_five(struct zint_symbol *symbol, unsigned char source[])
concat (dest, "41111"); concat (dest, "41111");
expand(symbol, dest); expand(symbol, dest);
strcpy(symbol->text, (char*)source); ustrcpy(symbol->text, source);
return error_number; return error_number;
} }
@ -99,7 +99,7 @@ int industrial_two_of_five(struct zint_symbol *symbol, unsigned char source[])
concat (dest, "31113"); concat (dest, "31113");
expand(symbol, dest); expand(symbol, dest);
strcpy(symbol->text, (char*)source); ustrcpy(symbol->text, source);
return error_number; return error_number;
} }
@ -132,7 +132,7 @@ int iata_two_of_five(struct zint_symbol *symbol, unsigned char source[])
concat (dest, "311"); concat (dest, "311");
expand(symbol, dest); expand(symbol, dest);
strcpy(symbol->text, (char*)source); ustrcpy(symbol->text, source);
return error_number; return error_number;
} }
@ -166,7 +166,7 @@ int logic_two_of_five(struct zint_symbol *symbol, unsigned char source[])
concat (dest, "311"); concat (dest, "311");
expand(symbol, dest); expand(symbol, dest);
strcpy(symbol->text, (char*)source); ustrcpy(symbol->text, source);
return error_number; return error_number;
} }
@ -234,7 +234,7 @@ int interleaved_two_of_five(struct zint_symbol *symbol, unsigned char source[])
concat (dest, "311"); concat (dest, "311");
expand(symbol, dest); expand(symbol, dest);
strcpy(symbol->text, (char*)source); ustrcpy(symbol->text, source);
return error_number; return error_number;
} }
@ -287,7 +287,7 @@ int itf14(struct zint_symbol *symbol, unsigned char source[])
checkstr[1] = '\0'; checkstr[1] = '\0';
concat(localstr, checkstr); concat(localstr, checkstr);
error_number = interleaved_two_of_five(symbol, (unsigned char *)localstr); error_number = interleaved_two_of_five(symbol, (unsigned char *)localstr);
strcpy(symbol->text, localstr); ustrcpy(symbol->text, (unsigned char*)localstr);
return error_number; return error_number;
} }
@ -332,7 +332,7 @@ int dpleit(struct zint_symbol *symbol, unsigned char source[])
checkstr[1] = '\0'; checkstr[1] = '\0';
concat(localstr, checkstr); concat(localstr, checkstr);
error_number = interleaved_two_of_five(symbol, (unsigned char *)localstr); error_number = interleaved_two_of_five(symbol, (unsigned char *)localstr);
strcpy(symbol->text, localstr); ustrcpy(symbol->text, (unsigned char*)localstr);
return error_number; return error_number;
} }
@ -375,6 +375,6 @@ int dpident(struct zint_symbol *symbol, unsigned char source[])
checkstr[1] = '\0'; checkstr[1] = '\0';
concat(localstr, checkstr); concat(localstr, checkstr);
error_number = interleaved_two_of_five(symbol, (unsigned char *)localstr); error_number = interleaved_two_of_five(symbol, (unsigned char *)localstr);
strcpy(symbol->text, localstr); ustrcpy(symbol->text, (unsigned char*)localstr);
return error_number; return error_number;
} }

View File

@ -147,8 +147,8 @@ int code_11(struct zint_symbol *symbol, unsigned char source[])
expand(symbol, dest); expand(symbol, dest);
strcpy(symbol->text, (char*)source); ustrcpy(symbol->text, source);
concat(symbol->text, checkstr); uconcat(symbol->text, (unsigned char*)checkstr);
return error_number; return error_number;
} }
@ -235,11 +235,11 @@ int c39(struct zint_symbol *symbol, unsigned char source[])
expand(symbol, dest); expand(symbol, dest);
if(symbol->symbology == BARCODE_CODE39) { if(symbol->symbology == BARCODE_CODE39) {
strcpy(symbol->text, "*"); ustrcpy(symbol->text, (unsigned char*)"*");
concat(symbol->text, (char*)source); uconcat(symbol->text, source);
concat(symbol->text, "*"); uconcat(symbol->text, (unsigned char*)"*");
} else { } else {
strcpy(symbol->text, (char*)source); ustrcpy(symbol->text, source);
} }
return error_number; return error_number;
} }
@ -287,8 +287,8 @@ int pharmazentral(struct zint_symbol *symbol, unsigned char source[])
} }
concat(localstr, checkstr); concat(localstr, checkstr);
error_number = c39(symbol, (unsigned char *)localstr); error_number = c39(symbol, (unsigned char *)localstr);
strcpy(symbol->text, "PZN"); ustrcpy(symbol->text, (unsigned char *)"PZN");
concat(symbol->text, localstr); uconcat(symbol->text, (unsigned char *)localstr);
return error_number; return error_number;
} }
@ -336,8 +336,8 @@ int ec39(struct zint_symbol *symbol, unsigned char source[])
/* Then sends the buffer to the C39 function */ /* Then sends the buffer to the C39 function */
error_number = c39(symbol, buffer); error_number = c39(symbol, buffer);
strcpy(symbol->text, (char*)source); ustrcpy(symbol->text, source);
for(i = 0; i < strlen(symbol->text); i++) { for(i = 0; i < ustrlen(symbol->text); i++) {
if(symbol->text[i] == symbol->nullchar) { if(symbol->text[i] == symbol->nullchar) {
symbol->text[i] = ' '; symbol->text[i] = ' ';
} }
@ -458,8 +458,8 @@ int c93(struct zint_symbol *symbol, unsigned char source[])
source[h + 1] = set_copy[k]; source[h + 1] = set_copy[k];
source[h + 2] = '\0'; source[h + 2] = '\0';
expand(symbol, dest); expand(symbol, dest);
strcpy(symbol->text, (char*)source); ustrcpy(symbol->text, source);
for(i = 0; i < strlen(symbol->text); i++) { for(i = 0; i < ustrlen(symbol->text); i++) {
if(symbol->text[i] == symbol->nullchar) { if(symbol->text[i] == symbol->nullchar) {
symbol->text[i] = ' '; symbol->text[i] = ' ';
} }

View File

@ -543,8 +543,8 @@ int code_128(struct zint_symbol *symbol, unsigned char source[])
/* Stop character */ /* Stop character */
concat(dest, C128Table[106]); concat(dest, C128Table[106]);
expand(symbol, dest); expand(symbol, dest);
strcpy(symbol->text, (char*)source); ustrcpy(symbol->text, source);
for(i = 0; i < strlen(symbol->text); i++) { for(i = 0; i < ustrlen(symbol->text); i++) {
if(symbol->text[i] == symbol->nullchar) { if(symbol->text[i] == symbol->nullchar) {
symbol->text[i] = ' '; symbol->text[i] = ' ';
} }

View File

@ -33,6 +33,17 @@ int ustrlen(unsigned char data[]) {
return i; return i;
} }
void ustrcpy(unsigned char target[], unsigned char source[]) {
/* Local replacement for strcpy() with unsigned char strings */
int i, len;
len = ustrlen(source);
for(i = 0; i < len; i++) {
target[i] = source[i];
}
target[i] = '\0';
}
void concat(char dest[], char source[]) void concat(char dest[], char source[])
{ /* Concatinates dest[] with the contents of source[], copying /0 as well */ { /* Concatinates dest[] with the contents of source[], copying /0 as well */
unsigned int i, j; unsigned int i, j;
@ -42,6 +53,16 @@ void concat(char dest[], char source[])
dest[i + j] = source[i]; } dest[i + j] = source[i]; }
} }
void uconcat(unsigned char dest[], unsigned char source[])
{ /* Concatinates dest[] with the contents of source[], copying /0 as well */
unsigned int i, j;
j = ustrlen(dest);
for(i = 0; i <= ustrlen(source); i++) {
dest[i + j] = source[i]; }
}
int ctoi(char source) int ctoi(char source)
{ /* Converts a character 0-9 to its equivalent integer value */ { /* Converts a character 0-9 to its equivalent integer value */
if((source >= '0') && (source <= '9')) if((source >= '0') && (source <= '9'))

View File

@ -29,7 +29,9 @@
#include "zint.h" #include "zint.h"
int ustrlen(unsigned char source[]); int ustrlen(unsigned char source[]);
void ustrcpy(unsigned char target[], unsigned char source[]);
void concat(char dest[], char source[]); void concat(char dest[], char source[]);
void uconcat(unsigned char dest[], unsigned char source[]);
int ctoi(char source); int ctoi(char source);
char itoc(int source); char itoc(int source);
void to_upper(unsigned char source[]); void to_upper(unsigned char source[]);
@ -39,3 +41,4 @@ int posn(char set_string[], char data);
void expand(struct zint_symbol *symbol, char data[]); void expand(struct zint_symbol *symbol, char data[]);
int is_stackable(int symbology); int is_stackable(int symbology);
int roundup(float input); int roundup(float input);

View File

@ -1866,7 +1866,7 @@ int composite(struct zint_symbol *symbol, unsigned char source[])
symbol->width += top_shift; symbol->width += top_shift;
} }
symbol->rows += linear->rows; symbol->rows += linear->rows;
strcpy(symbol->text, linear->text); ustrcpy(symbol->text, (unsigned char *)linear->text);
ZBarcode_Delete(linear); ZBarcode_Delete(linear);

View File

@ -197,16 +197,16 @@ int hibc(struct zint_symbol *symbol, unsigned char source[])
switch(symbol->symbology) { switch(symbol->symbology) {
case BARCODE_HIBC_128: case BARCODE_HIBC_128:
error_number = code_128(symbol, (unsigned char *)to_process); error_number = code_128(symbol, (unsigned char *)to_process);
strcpy(symbol->text, "*"); ustrcpy(symbol->text, (unsigned char*)"*");
concat(symbol->text, to_process); uconcat(symbol->text, (unsigned char*)to_process);
concat(symbol->text, "*"); uconcat(symbol->text, (unsigned char*)"*");
break; break;
case BARCODE_HIBC_39: case BARCODE_HIBC_39:
symbol->option_2 = 0; symbol->option_2 = 0;
error_number = c39(symbol, (unsigned char *)to_process); error_number = c39(symbol, (unsigned char *)to_process);
strcpy(symbol->text, "*"); ustrcpy(symbol->text, (unsigned char*)"*");
concat(symbol->text, to_process); uconcat(symbol->text, (unsigned char*)to_process);
concat(symbol->text, "*"); uconcat(symbol->text, (unsigned char*)"*");
break; break;
case BARCODE_HIBC_DM: case BARCODE_HIBC_DM:
error_number = dmatrix(symbol, (unsigned char *)to_process); error_number = dmatrix(symbol, (unsigned char *)to_process);
@ -300,16 +300,6 @@ int gs1_compliant(int symbology)
return result; return result;
} }
void ustrcpy(unsigned char dest[], unsigned char source[]) {
int i;
i = 0;
do {
dest[i] = source[i];
i++;
} while (source[i - 1] != '\0');
}
int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *source) int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *source)
{ {
int error_number, error_buffer; int error_number, error_buffer;
@ -489,6 +479,10 @@ int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *source)
case BARCODE_HIBC_MICPDF: error_number = hibc(symbol, preprocessed); break; case BARCODE_HIBC_MICPDF: error_number = hibc(symbol, preprocessed); break;
case BARCODE_HIBC_BLOCKF: error_number = hibc(symbol, preprocessed); break; case BARCODE_HIBC_BLOCKF: error_number = hibc(symbol, preprocessed); break;
} }
if((symbol->symbology == BARCODE_CODE128) || (symbol->symbology == BARCODE_CODE128B)) {
ustrcpy(symbol->text, source);
}
if(error_number == 0) { if(error_number == 0) {
error_number = error_buffer; error_number = error_buffer;
} }

View File

@ -96,7 +96,7 @@ int pharma_one(struct zint_symbol *symbol, unsigned char source[])
} }
expand(symbol, dest); expand(symbol, dest);
strcpy(symbol->text, "");
return error_number; return error_number;
} }
@ -190,7 +190,7 @@ int pharma_two(struct zint_symbol *symbol, unsigned char source[])
symbol->rows = 2; symbol->rows = 2;
symbol->width = writer - 1; symbol->width = writer - 1;
strcpy(symbol->text, "");
return error_number; return error_number;
} }
@ -235,7 +235,7 @@ int codabar(struct zint_symbol *symbol, unsigned char source[])
} }
expand(symbol, dest); expand(symbol, dest);
strcpy(symbol->text, (char*)source); ustrcpy(symbol->text, source);
return error_number; return error_number;
} }
@ -315,8 +315,8 @@ int code32(struct zint_symbol *symbol, unsigned char source[])
if(error_number != 0) { return error_number; } if(error_number != 0) { return error_number; }
/* Override the normal text output with the Pharmacode number */ /* Override the normal text output with the Pharmacode number */
strcpy(symbol->text, "A"); ustrcpy(symbol->text, (unsigned char*)"A");
concat(symbol->text, localstr); uconcat(symbol->text, (unsigned char*)localstr);
return error_number; return error_number;
} }

View File

@ -93,7 +93,7 @@ int plessey(struct zint_symbol *symbol, unsigned char source[])
concat(dest, "331311313"); concat(dest, "331311313");
expand(symbol, dest); expand(symbol, dest);
strcpy(symbol->text, (char*)source); ustrcpy(symbol->text, source);
free(checkptr); free(checkptr);
return error_number; return error_number;
} }
@ -130,7 +130,7 @@ int msi_plessey(struct zint_symbol *symbol, unsigned char source[])
concat (dest, "121"); concat (dest, "121");
expand(symbol, dest); expand(symbol, dest);
strcpy(symbol->text, (char*)source); ustrcpy(symbol->text, source);
return error_number; return error_number;
} }
@ -228,7 +228,7 @@ int msi_plessey_mod10(struct zint_symbol *symbol, unsigned char source[])
source[h] = itoc(pump); source[h] = itoc(pump);
source[h + 1] = '\0'; source[h + 1] = '\0';
expand(symbol, dest); expand(symbol, dest);
strcpy(symbol->text, (char*)source); ustrcpy(symbol->text, source);
return error_number; return error_number;
} }
@ -383,7 +383,7 @@ int msi_plessey_mod1010(struct zint_symbol *symbol, unsigned char source[])
source[h + 1] = itoc(chwech); source[h + 1] = itoc(chwech);
source[h + 2] = '\0'; source[h + 2] = '\0';
expand(symbol, dest); expand(symbol, dest);
strcpy(symbol->text, (char*)source); ustrcpy(symbol->text, source);
return error_number; return error_number;
} }
@ -453,7 +453,7 @@ int msi_plessey_mod11(struct zint_symbol *symbol, unsigned char source[])
concat (dest, "121"); concat (dest, "121");
expand(symbol, dest); expand(symbol, dest);
strcpy(symbol->text, (char*)source); ustrcpy(symbol->text, source);
return error_number; return error_number;
} }
@ -579,7 +579,7 @@ int msi_plessey_mod1110(struct zint_symbol *symbol, unsigned char source[])
source[h + 1] = '\0'; source[h + 1] = '\0';
expand(symbol, dest); expand(symbol, dest);
strcpy(symbol->text, (char*)source); ustrcpy(symbol->text, source);
return error_number; return error_number;
} }

View File

@ -426,6 +426,38 @@ int maxi_png_plot(struct zint_symbol *symbol, int rotate_angle)
return error_number; return error_number;
} }
void to_latin1(unsigned char source[], unsigned char preprocessed[])
{
int j, i, next, input_length;
input_length = ustrlen(source);
j = 0;
i = 0;
do {
if(source[i] < 128) {
preprocessed[j] = source[i];
j++;
next = i + 1;
} else {
if(source[i] == 0xC2) {
preprocessed[j] = source[i + 1];
j++;
next = i + 2;
}
if(source[i] == 0xC3) {
preprocessed[j] = source[i + 1] + 64;
j++;
next = i + 2;
}
}
i = next;
} while(i < input_length);
preprocessed[j] = '\0';
return;
}
int png_plot(struct zint_symbol *symbol, int rotate_angle) int png_plot(struct zint_symbol *symbol, int rotate_angle)
{ {
int textdone, main_width, comp_offset, large_bar_count; int textdone, main_width, comp_offset, large_bar_count;
@ -438,6 +470,10 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle)
float row_height, row_posn; float row_height, row_posn;
int error_number; int error_number;
int scaler = (int)(2 * symbol->scale); int scaler = (int)(2 * symbol->scale);
int default_text_posn;
unsigned char local_text[ustrlen(symbol->text)];
to_latin1(symbol->text, local_text);
textdone = 0; textdone = 0;
main_width = symbol->width; main_width = symbol->width;
@ -470,7 +506,7 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle)
/* Certain symbols need whitespace otherwise characters get chopped off the sides */ /* Certain symbols need whitespace otherwise characters get chopped off the sides */
if (((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC)) { if (((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC)) {
switch(strlen(symbol->text)) { switch(ustrlen(local_text)) {
case 13: /* EAN 13 */ case 13: /* EAN 13 */
case 16: case 16:
case 19: case 19:
@ -501,9 +537,9 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle)
latch = 0; latch = 0;
r = 0; r = 0;
/* Isolate add-on text */ /* Isolate add-on text */
for(i = 0; i < strlen(symbol->text); i++) { for(i = 0; i < ustrlen(local_text); i++) {
if (latch == 1) { if (latch == 1) {
addon[r] = symbol->text[i]; addon[r] = local_text[i];
r++; r++;
} }
if (symbol->text[i] == '+') { if (symbol->text[i] == '+') {
@ -512,7 +548,7 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle)
} }
addon[r] = '\0'; addon[r] = '\0';
if(strcmp(symbol->text, "")) { if(ustrlen(local_text) != 0) {
textoffset = 9; textoffset = 9;
} else { } else {
textoffset = 0; textoffset = 0;
@ -531,6 +567,12 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle)
} }
} }
if(((symbol->output_options & BARCODE_BOX) != 0) || ((symbol->output_options & BARCODE_BIND) != 0)) {
default_text_posn = image_height - 17;
} else {
default_text_posn = image_height - 17 - symbol->border_width - symbol->border_width;
}
/* Plot the body of the symbol to the pixel buffer */ /* Plot the body of the symbol to the pixel buffer */
for(r = 0; r < symbol->rows; r++) { for(r = 0; r < symbol->rows; r++) {
this_row = symbol->rows - r - 1; /* invert r otherwise plots upside down */ this_row = symbol->rows - r - 1; /* invert r otherwise plots upside down */
@ -587,7 +629,7 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle)
if (((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC)) { if (((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC)) {
/* guard bar extensions and text formatting for EAN8 and EAN13 */ /* guard bar extensions and text formatting for EAN8 and EAN13 */
switch(strlen(symbol->text)) { switch(ustrlen(local_text)) {
case 8: /* EAN-8 */ case 8: /* EAN-8 */
case 11: case 11:
case 14: case 14:
@ -602,13 +644,14 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle)
} }
textpart[4] = '\0'; textpart[4] = '\0';
textpos = scaler * (17 + xoffset); textpos = scaler * (17 + xoffset);
draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height);
draw_string(pixelbuf, textpart, textpos, default_text_posn, image_width, image_height);
for(i = 0; i < 4; i++) { for(i = 0; i < 4; i++) {
textpart[i] = symbol->text[i + 4]; textpart[i] = symbol->text[i + 4];
} }
textpart[4] = '\0'; textpart[4] = '\0';
textpos = scaler * (50 + xoffset); textpos = scaler * (50 + xoffset);
draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); draw_string(pixelbuf, textpart, textpos, default_text_posn, image_width, image_height);
textdone = 1; textdone = 1;
switch(strlen(addon)) { switch(strlen(addon)) {
case 2: case 2:
@ -635,19 +678,19 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle)
textpart[0] = symbol->text[0]; textpart[0] = symbol->text[0];
textpart[1] = '\0'; textpart[1] = '\0';
textpos = scaler * (-7 + xoffset); textpos = scaler * (-7 + xoffset);
draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); draw_string(pixelbuf, textpart, textpos, default_text_posn, image_width, image_height);
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 = scaler * (24 + xoffset); textpos = scaler * (24 + xoffset);
draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); draw_string(pixelbuf, textpart, textpos, default_text_posn, image_width, image_height);
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 = scaler * (71 + xoffset); textpos = scaler * (71 + xoffset);
draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); draw_string(pixelbuf, textpart, textpos, default_text_posn, image_width, image_height);
textdone = 1; textdone = 1;
switch(strlen(addon)) { switch(strlen(addon)) {
case 2: case 2:
@ -706,23 +749,23 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle)
textpart[0] = symbol->text[0]; textpart[0] = symbol->text[0];
textpart[1] = '\0'; textpart[1] = '\0';
textpos = scaler * (-5 + xoffset); textpos = scaler * (-5 + xoffset);
draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); draw_string(pixelbuf, textpart, textpos, default_text_posn, image_width, image_height);
for(i = 0; i < 5; i++) { for(i = 0; i < 5; i++) {
textpart[i] = symbol->text[i + 1]; textpart[i] = symbol->text[i + 1];
} }
textpart[5] = '\0'; textpart[5] = '\0';
textpos = scaler * (27 + xoffset); textpos = scaler * (27 + xoffset);
draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); draw_string(pixelbuf, textpart, textpos, default_text_posn, image_width, image_height);
for(i = 0; i < 5; i++) { for(i = 0; i < 5; i++) {
textpart[i] = symbol->text[i + 6]; textpart[i] = symbol->text[i + 6];
} }
textpart[6] = '\0'; textpart[6] = '\0';
textpos = scaler * (68 + xoffset); textpos = scaler * (68 + xoffset);
draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); draw_string(pixelbuf, textpart, textpos, default_text_posn, image_width, image_height);
textpart[0] = symbol->text[11]; textpart[0] = symbol->text[11];
textpart[1] = '\0'; textpart[1] = '\0';
textpos = scaler * (100 + xoffset); textpos = scaler * (100 + xoffset);
draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); draw_string(pixelbuf, textpart, textpos, default_text_posn, image_width, image_height);
textdone = 1; textdone = 1;
switch(strlen(addon)) { switch(strlen(addon)) {
case 2: case 2:
@ -748,17 +791,17 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle)
textpart[0] = symbol->text[0]; textpart[0] = symbol->text[0];
textpart[1] = '\0'; textpart[1] = '\0';
textpos = scaler * (-5 + xoffset); textpos = scaler * (-5 + xoffset);
draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); draw_string(pixelbuf, textpart, textpos, default_text_posn, image_width, image_height);
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 = scaler * (24 + xoffset); textpos = scaler * (24 + xoffset);
draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); draw_string(pixelbuf, textpart, textpos, default_text_posn, image_width, image_height);
textpart[0] = symbol->text[7]; textpart[0] = symbol->text[7];
textpart[1] = '\0'; textpart[1] = '\0';
textpos = scaler * (55 + xoffset); textpos = scaler * (55 + xoffset);
draw_string(pixelbuf, textpart, textpos, (image_height - 17), image_width, image_height); draw_string(pixelbuf, textpart, textpos, default_text_posn, image_width, image_height);
textdone = 1; textdone = 1;
switch(strlen(addon)) { switch(strlen(addon)) {
case 2: case 2:
@ -809,9 +852,9 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle)
} }
/* Put the human readable text at the bottom */ /* Put the human readable text at the bottom */
if((textdone == 0) && (strlen(symbol->text) != 0)) { if((textdone == 0) && (ustrlen(local_text) != 0)) {
textpos = (image_width / 2); textpos = (image_width / 2);
draw_string(pixelbuf, symbol->text, textpos, (image_height - 17), image_width, image_height); draw_string(pixelbuf, (char*)local_text, textpos, default_text_posn, image_width, image_height);
} }
error_number=png_to_file(symbol, image_height, image_width, pixelbuf, rotate_angle); error_number=png_to_file(symbol, image_height, image_width, pixelbuf, rotate_angle);

View File

@ -55,7 +55,7 @@ int postnet(struct zint_symbol *symbol, unsigned char source[], char dest[])
{ {
/* Handles the PostNet system used for Zip codes in the US */ /* Handles the PostNet system used for Zip codes in the US */
unsigned int i, sum, check_digit; unsigned int i, sum, check_digit;
int error_number, h; int error_number;
error_number = 0; error_number = 0;
@ -85,11 +85,6 @@ int postnet(struct zint_symbol *symbol, unsigned char source[], char dest[])
/* stop character */ /* stop character */
concat (dest, "L"); concat (dest, "L");
h = ustrlen(source);
source[h] = itoc(check_digit);
source[h + 1] = '\0';
strcpy(symbol->text, "");
return error_number; return error_number;
} }
@ -131,7 +126,7 @@ int planet(struct zint_symbol *symbol, unsigned char source[], char dest[])
{ {
/* Handles the PLANET system used for item tracking in the US */ /* Handles the PLANET system used for item tracking in the US */
unsigned int i, sum, check_digit; unsigned int i, sum, check_digit;
int error_number, h; int error_number;
error_number = 0; error_number = 0;
@ -161,11 +156,6 @@ int planet(struct zint_symbol *symbol, unsigned char source[], char dest[])
/* stop character */ /* stop character */
concat (dest, "L"); concat (dest, "L");
h = ustrlen(source);
source[h] = itoc(check_digit);
source[h + 1] = '\0';
strcpy(symbol->text, "");
return error_number; return error_number;
} }
@ -241,7 +231,7 @@ int korea_post(struct zint_symbol *symbol, unsigned char source[])
} }
lookup(NESET, KoreaTable, localstr[6], dest); lookup(NESET, KoreaTable, localstr[6], dest);
expand(symbol, dest); expand(symbol, dest);
strcpy(symbol->text, localstr); ustrcpy(symbol->text, (unsigned char*)localstr);
return error_number; return error_number;
} }
@ -269,7 +259,6 @@ int fim(struct zint_symbol *symbol, unsigned char source[])
lookup(BESET, FIMTable, source[0], dest); lookup(BESET, FIMTable, source[0], dest);
expand(symbol, dest); expand(symbol, dest);
strcpy(symbol->text, "");
return error_number; return error_number;
} }
@ -314,7 +303,7 @@ int royal_plot(struct zint_symbol *symbol, unsigned char source[])
char height_pattern[200], check; char height_pattern[200], check;
unsigned int loopey; unsigned int loopey;
int writer; int writer;
int error_number, h; int error_number;
strcpy(height_pattern, ""); strcpy(height_pattern, "");
error_number = 0; error_number = 0;
@ -352,11 +341,6 @@ int royal_plot(struct zint_symbol *symbol, unsigned char source[])
symbol->rows = 3; symbol->rows = 3;
symbol->width = writer - 1; symbol->width = writer - 1;
h = ustrlen(source);
source[h] = check;
source[h + 1] = '\0';
strcpy(symbol->text, "");
return error_number; return error_number;
} }
@ -417,8 +401,6 @@ int kix_code(struct zint_symbol *symbol, unsigned char source[])
symbol->rows = 3; symbol->rows = 3;
symbol->width = writer - 1; symbol->width = writer - 1;
strcpy(symbol->text, "");
return error_number; return error_number;
} }
@ -468,8 +450,6 @@ int daft_code(struct zint_symbol *symbol, unsigned char source[])
symbol->rows = 3; symbol->rows = 3;
symbol->width = writer - 1; symbol->width = writer - 1;
strcpy(symbol->text, "");
return 0; return 0;
} }
@ -497,6 +477,5 @@ int flattermarken(struct zint_symbol *symbol, unsigned char source[])
} }
expand(symbol, dest); expand(symbol, dest);
strcpy(symbol->text, "");
return error_number; return error_number;
} }

View File

@ -43,6 +43,7 @@ int ps_plot(struct zint_symbol *symbol)
int large_bar_count, comp_offset; int large_bar_count, comp_offset;
float addon_text_posn; float addon_text_posn;
float scaler = symbol->scale; float scaler = symbol->scale;
float default_text_posn;
row_height=0; row_height=0;
textdone = 0; textdone = 0;
@ -121,7 +122,7 @@ int ps_plot(struct zint_symbol *symbol)
/* Certain symbols need whitespace otherwise characters get chopped off the sides */ /* Certain symbols need whitespace otherwise characters get chopped off the sides */
if (((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC)) { if (((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC)) {
switch(strlen(symbol->text)) { switch(ustrlen(symbol->text)) {
case 13: /* EAN 13 */ case 13: /* EAN 13 */
case 16: case 16:
case 19: case 19:
@ -152,7 +153,7 @@ int ps_plot(struct zint_symbol *symbol)
latch = 0; latch = 0;
r = 0; r = 0;
/* Isolate add-on text */ /* Isolate add-on text */
for(i = 0; i < strlen(symbol->text); i++) { for(i = 0; i < ustrlen(symbol->text); i++) {
if (latch == 1) { if (latch == 1) {
addon[r] = symbol->text[i]; addon[r] = symbol->text[i];
r++; r++;
@ -163,7 +164,7 @@ int ps_plot(struct zint_symbol *symbol)
} }
addon[r] = '\0'; addon[r] = '\0';
if(strcmp(symbol->text, "")) { if(ustrlen(symbol->text) != 0) {
textoffset = 9; textoffset = 9;
} else { } else {
textoffset = 0; textoffset = 0;
@ -174,7 +175,7 @@ int ps_plot(struct zint_symbol *symbol)
/* Start writing the header */ /* Start writing the header */
fprintf(feps, "%%!PS-Adobe-3.0 EPSF-3.0\n"); fprintf(feps, "%%!PS-Adobe-3.0 EPSF-3.0\n");
fprintf(feps, "%%%%Creator: Zint %s\n", ZINT_VERSION); fprintf(feps, "%%%%Creator: Zint %s\n", ZINT_VERSION);
if(strlen(symbol->text) != 0) { if(ustrlen(symbol->text) != 0) {
fprintf(feps, "%%%%Title: %s\n",symbol->text); fprintf(feps, "%%%%Title: %s\n",symbol->text);
} else { } else {
fprintf(feps, "%%%%Title: Zint Generated Symbol\n"); fprintf(feps, "%%%%Title: Zint Generated Symbol\n");
@ -202,6 +203,11 @@ int ps_plot(struct zint_symbol *symbol)
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_paper, green_paper, blue_paper); fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_paper, green_paper, blue_paper);
fprintf(feps, "%.2f 0.00 TB 0.00 %.2f TR\n", (symbol->height + textoffset + yoffset + yoffset) * scaler, (symbol->width + xoffset + xoffset) * scaler); fprintf(feps, "%.2f 0.00 TB 0.00 %.2f TR\n", (symbol->height + textoffset + yoffset + yoffset) * scaler, (symbol->width + xoffset + xoffset) * scaler);
if(((symbol->output_options & BARCODE_BOX) != 0) || ((symbol->output_options & BARCODE_BIND) != 0)) {
default_text_posn = 0.5 * scaler;
} else {
default_text_posn = (symbol->border_width + 0.5) * scaler;
}
if(symbol->symbology == BARCODE_MAXICODE) { if(symbol->symbology == BARCODE_MAXICODE) {
/* Maxicode uses hexagons */ /* Maxicode uses hexagons */
@ -320,7 +326,7 @@ int ps_plot(struct zint_symbol *symbol)
if (((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC)) { if (((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC)) {
/* guard bar extensions and text formatting for EAN8 and EAN13 */ /* guard bar extensions and text formatting for EAN8 and EAN13 */
switch(strlen(symbol->text)) { switch(ustrlen(symbol->text)) {
case 8: /* EAN-8 */ case 8: /* EAN-8 */
case 11: case 11:
case 14: case 14:
@ -343,7 +349,7 @@ int ps_plot(struct zint_symbol *symbol)
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 = 17; textpos = 17;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 0.50 * scaler); 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");
@ -357,7 +363,7 @@ int ps_plot(struct zint_symbol *symbol)
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 = 50; textpos = 50;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 0.5 * scaler); 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");
@ -412,7 +418,7 @@ int ps_plot(struct zint_symbol *symbol)
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, 0.50 * scaler); 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");
@ -426,7 +432,7 @@ int ps_plot(struct zint_symbol *symbol)
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, 0.50 * scaler); 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");
@ -440,7 +446,7 @@ int ps_plot(struct zint_symbol *symbol)
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, 0.5 * scaler); 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");
@ -528,7 +534,7 @@ int ps_plot(struct zint_symbol *symbol)
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler); fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler);
textpos = -5; textpos = -5;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 0.5 * scaler); 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");
@ -542,7 +548,7 @@ int ps_plot(struct zint_symbol *symbol)
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 = 27; textpos = 27;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 0.5 * scaler); 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");
@ -556,7 +562,7 @@ int ps_plot(struct zint_symbol *symbol)
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 = 68; textpos = 68;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 0.5 * scaler); 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");
@ -568,7 +574,7 @@ int ps_plot(struct zint_symbol *symbol)
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler); fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler);
textpos = 100; textpos = 100;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 0.5 * scaler); 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");
@ -622,7 +628,7 @@ int ps_plot(struct zint_symbol *symbol)
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler); fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler);
textpos = -5; textpos = -5;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 0.5 * scaler); 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");
@ -636,7 +642,7 @@ int ps_plot(struct zint_symbol *symbol)
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, 0.5 * scaler); 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");
@ -648,7 +654,7 @@ int ps_plot(struct zint_symbol *symbol)
fprintf(feps, "/Helvetica findfont\n"); fprintf(feps, "/Helvetica findfont\n");
fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler); fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler);
textpos = 55; textpos = 55;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 0.5 * scaler); 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");
@ -733,14 +739,14 @@ 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) && (strlen(symbol->text) != 0)) { if((textdone == 0) && (ustrlen(symbol->text) != 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", 8.0 * scaler); fprintf(feps, "%.2f scalefont setfont\n", 8.0 * scaler);
textpos = symbol->width / 2.0; textpos = symbol->width / 2.0;
fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, 1.67 * scaler); fprintf(feps, " 0 0 moveto %.2f %.2f translate 0.00 rotate 0 0 moveto\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(feps, " (%s) stringwidth\n", symbol->text); fprintf(feps, " (%s) stringwidth\n", symbol->text);
fprintf(feps, "pop\n"); fprintf(feps, "pop\n");
fprintf(feps, "-2 div 0 rmoveto\n"); fprintf(feps, "-2 div 0 rmoveto\n");

View File

@ -423,7 +423,7 @@ int rss14(struct zint_symbol *symbol, unsigned char source[])
check_digit = 0; check_digit = 0;
/* Calculate check digit from Annex A and place human readable text */ /* Calculate check digit from Annex A and place human readable text */
strcpy(symbol->text, "(01)"); ustrcpy(symbol->text, (unsigned char*)"(01)");
for(i = 0; i < 14; i++) { for(i = 0; i < 14; i++) {
hrt[i] = '0'; hrt[i] = '0';
} }
@ -446,7 +446,7 @@ int rss14(struct zint_symbol *symbol, unsigned char source[])
if (check_digit == 10) { check_digit = 0; } if (check_digit == 10) { check_digit = 0; }
hrt[13] = itoc(check_digit); hrt[13] = itoc(check_digit);
concat(symbol->text, hrt); uconcat(symbol->text, (unsigned char*)hrt);
} }
if((symbol->symbology == BARCODE_RSS14STACK) || (symbol->symbology == BARCODE_RSS14STACK_CC)) { if((symbol->symbology == BARCODE_RSS14STACK) || (symbol->symbology == BARCODE_RSS14STACK_CC)) {
@ -872,7 +872,7 @@ int rsslimited(struct zint_symbol *symbol, unsigned char source[])
check_digit = 0; check_digit = 0;
count = 0; count = 0;
strcpy(symbol->text, "(01)"); ustrcpy(symbol->text, (unsigned char*)"(01)");
for(i = 0; i < 14; i++) { for(i = 0; i < 14; i++) {
hrt[i] = '0'; hrt[i] = '0';
} }
@ -896,7 +896,7 @@ int rsslimited(struct zint_symbol *symbol, unsigned char source[])
hrt[13] = itoc(check_digit); hrt[13] = itoc(check_digit);
hrt[14] = '\0'; hrt[14] = '\0';
concat(symbol->text, hrt); uconcat(symbol->text, (unsigned char*)hrt);
return error_number; return error_number;
} }

View File

@ -39,6 +39,7 @@ int svg_plot(struct zint_symbol *symbol)
int large_bar_count, comp_offset; int large_bar_count, comp_offset;
float addon_text_posn; float addon_text_posn;
float scaler = symbol->scale; float scaler = symbol->scale;
float default_text_posn;
row_height=0; row_height=0;
textdone = 0; textdone = 0;
@ -117,7 +118,7 @@ int svg_plot(struct zint_symbol *symbol)
/* Certain symbols need whitespace otherwise characters get chopped off the sides */ /* Certain symbols need whitespace otherwise characters get chopped off the sides */
if (((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC)) { if (((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC)) {
switch(strlen(symbol->text)) { switch(ustrlen(symbol->text)) {
case 13: /* EAN 13 */ case 13: /* EAN 13 */
case 16: case 16:
case 19: case 19:
@ -148,7 +149,7 @@ int svg_plot(struct zint_symbol *symbol)
latch = 0; latch = 0;
r = 0; r = 0;
/* Isolate add-on text */ /* Isolate add-on text */
for(i = 0; i < strlen(symbol->text); i++) { for(i = 0; i < ustrlen(symbol->text); i++) {
if (latch == 1) { if (latch == 1) {
addon[r] = symbol->text[i]; addon[r] = symbol->text[i];
r++; r++;
@ -159,7 +160,7 @@ int svg_plot(struct zint_symbol *symbol)
} }
addon[r] = '\0'; addon[r] = '\0';
if(strcmp(symbol->text, "")) { if(ustrlen(symbol->text) != 0) {
textoffset = 9; textoffset = 9;
} else { } else {
textoffset = 0; textoffset = 0;
@ -177,7 +178,7 @@ int svg_plot(struct zint_symbol *symbol)
fprintf(fsvg, "<svg width=\"%d\" height=\"%d\" version=\"1.1\"\n", roundup((74.0 + xoffset + xoffset) * scaler), roundup((72.0 + yoffset + yoffset) * scaler)); fprintf(fsvg, "<svg width=\"%d\" height=\"%d\" version=\"1.1\"\n", roundup((74.0 + xoffset + xoffset) * scaler), roundup((72.0 + yoffset + yoffset) * scaler));
} }
fprintf(fsvg, " xmlns=\"http://www.w3.org/2000/svg\">\n"); fprintf(fsvg, " xmlns=\"http://www.w3.org/2000/svg\">\n");
if(strlen(symbol->text) != 0) { if(ustrlen(symbol->text) != 0) {
fprintf(fsvg, " <desc>%s\n", symbol->text); fprintf(fsvg, " <desc>%s\n", symbol->text);
} else { } else {
fprintf(fsvg, " <desc>Zint Generated Symbol\n"); fprintf(fsvg, " <desc>Zint Generated Symbol\n");
@ -191,6 +192,12 @@ int svg_plot(struct zint_symbol *symbol)
fprintf(fsvg, " <rect x=\"0\" y=\"0\" width=\"%d\" height=\"%d\" fill=\"#%s\" />\n", roundup((74.0 + xoffset + xoffset) * scaler), roundup((72.0 + yoffset + yoffset) * scaler), symbol->bgcolour); fprintf(fsvg, " <rect x=\"0\" y=\"0\" width=\"%d\" height=\"%d\" fill=\"#%s\" />\n", roundup((74.0 + xoffset + xoffset) * scaler), roundup((72.0 + yoffset + yoffset) * scaler), symbol->bgcolour);
} }
if(((symbol->output_options & BARCODE_BOX) != 0) || ((symbol->output_options & BARCODE_BIND) != 0)) {
default_text_posn = (symbol->height + textoffset + symbol->border_width + symbol->border_width) * scaler;
} else {
default_text_posn = (symbol->height + textoffset + symbol->border_width) * scaler;
}
if(symbol->symbology == BARCODE_MAXICODE) { if(symbol->symbology == BARCODE_MAXICODE) {
/* Maxicode uses hexagons */ /* Maxicode uses hexagons */
float ax, ay, bx, by, cx, cy, dx, dy, ex, ey, fx, fy, mx, my; float ax, ay, bx, by, cx, cy, dx, dy, ex, ey, fx, fy, mx, my;
@ -275,7 +282,7 @@ int svg_plot(struct zint_symbol *symbol)
block_width++; block_width++;
} while (symbol->encoded_data[this_row][i + block_width] == symbol->encoded_data[this_row][i]); } while (symbol->encoded_data[this_row][i + block_width] == symbol->encoded_data[this_row][i]);
if((addon_latch == 0) && (r == 0) && (i > main_width)) { if((addon_latch == 0) && (r == 0) && (i > main_width)) {
addon_text_posn = 9.0; addon_text_posn = 9.0 + symbol->border_width;
addon_latch = 1; addon_latch = 1;
} }
if(latch == 1) { if(latch == 1) {
@ -298,11 +305,11 @@ int svg_plot(struct zint_symbol *symbol)
/* 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;
row_posn = (yoffset + 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 (((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC)) {
/* guard bar extensions and text formatting for EAN8 and EAN13 */ /* guard bar extensions and text formatting for EAN8 and EAN13 */
switch(strlen(symbol->text)) { switch(ustrlen(symbol->text)) {
case 8: /* EAN-8 */ case 8: /* EAN-8 */
case 11: case 11:
case 14: case 14:
@ -317,7 +324,7 @@ int svg_plot(struct zint_symbol *symbol)
} }
textpart[4] = '\0'; textpart[4] = '\0';
textpos = 17; textpos = 17;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, (symbol->height + textoffset) * scaler); 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");
@ -326,7 +333,7 @@ int svg_plot(struct zint_symbol *symbol)
} }
textpart[4] = '\0'; textpart[4] = '\0';
textpos = 50; textpos = 50;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, (symbol->height + textoffset) * scaler); 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");
@ -361,7 +368,7 @@ int svg_plot(struct zint_symbol *symbol)
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, (symbol->height + textoffset) * scaler); 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");
@ -370,7 +377,7 @@ int svg_plot(struct zint_symbol *symbol)
} }
textpart[6] = '\0'; textpart[6] = '\0';
textpos = 24; textpos = 24;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, (symbol->height + textoffset) * scaler); 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");
@ -379,7 +386,7 @@ int svg_plot(struct zint_symbol *symbol)
} }
textpart[6] = '\0'; textpart[6] = '\0';
textpos = 71; textpos = 71;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, (symbol->height + textoffset) * scaler); 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");
@ -447,16 +454,16 @@ int svg_plot(struct zint_symbol *symbol)
textpart[0] = symbol->text[0]; textpart[0] = symbol->text[0];
textpart[1] = '\0'; textpart[1] = '\0';
textpos = -5; textpos = -5;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, (symbol->height + textoffset) * scaler); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour); fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart); fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n"); fprintf(fsvg, " </text>\n");
for(i = 0; i < 5; i++) { for(i = 0; i < 5; i++) {
textpart[i] = symbol->text[i + 1]; textpart[i] = symbol->text[i + 1];
} }
textpart[5] = '\0'; textpart[5] = '\0';
textpos = 27; textpos = 27;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, (symbol->height + textoffset) * scaler); 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");
@ -465,14 +472,14 @@ int svg_plot(struct zint_symbol *symbol)
} }
textpart[6] = '\0'; textpart[6] = '\0';
textpos = 68; textpos = 68;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, (symbol->height + textoffset) * scaler); 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");
textpart[0] = symbol->text[11]; textpart[0] = symbol->text[11];
textpart[1] = '\0'; textpart[1] = '\0';
textpos = 100; textpos = 100;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, (symbol->height + textoffset) * scaler); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour); fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart); fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n"); fprintf(fsvg, " </text>\n");
@ -506,7 +513,7 @@ int svg_plot(struct zint_symbol *symbol)
textpart[0] = symbol->text[0]; textpart[0] = symbol->text[0];
textpart[1] = '\0'; textpart[1] = '\0';
textpos = -5; textpos = -5;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, (symbol->height + textoffset) * scaler); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour); fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart); fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n"); fprintf(fsvg, " </text>\n");
@ -515,14 +522,14 @@ int svg_plot(struct zint_symbol *symbol)
} }
textpart[6] = '\0'; textpart[6] = '\0';
textpos = 24; textpos = 24;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, (symbol->height + textoffset) * scaler); 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");
textpart[0] = symbol->text[7]; textpart[0] = symbol->text[7];
textpart[1] = '\0'; textpart[1] = '\0';
textpos = 55; textpos = 55;
fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, (symbol->height + textoffset) * scaler); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour); fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", textpart); fprintf(fsvg, " %s\n", textpart);
fprintf(fsvg, " </text>\n"); fprintf(fsvg, " </text>\n");
@ -585,9 +592,9 @@ int svg_plot(struct zint_symbol *symbol)
} }
/* Put the human readable text at the bottom */ /* Put the human readable text at the bottom */
if((textdone == 0) && (strlen(symbol->text) != 0)) { if((textdone == 0) && (ustrlen(symbol->text) != 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, (symbol->height + textoffset) * scaler); fprintf(fsvg, " <text x=\"%.2f\" y=\"%.2f\" text-anchor=\"middle\"\n", (textpos + xoffset) * scaler, default_text_posn);
fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour); fprintf(fsvg, " font-family=\"Helvetica\" font-size=\"%.1f\" fill=\"#%s\" >\n", 8.0 * scaler, symbol->fgcolour);
fprintf(fsvg, " %s\n", symbol->text); fprintf(fsvg, " %s\n", symbol->text);
fprintf(fsvg, " </text>\n"); fprintf(fsvg, " </text>\n");

View File

@ -95,7 +95,7 @@ int telepen(struct zint_symbol *symbol, unsigned char source[])
concat(dest, TeleTable['z']); concat(dest, TeleTable['z']);
expand(symbol, dest); expand(symbol, dest);
strcpy(symbol->text, (char*)source); ustrcpy(symbol->text, source);
return error_number; return error_number;
} }
@ -168,7 +168,7 @@ int telepen_num(struct zint_symbol *symbol, unsigned char source[])
concat((char*)dest, TeleTable['z']); concat((char*)dest, TeleTable['z']);
expand(symbol, (char*)dest); expand(symbol, (char*)dest);
strcpy(symbol->text, (char*)local_source); ustrcpy(symbol->text, local_source);
return error_number; return error_number;
} }

View File

@ -99,7 +99,7 @@ void upca(struct zint_symbol *symbol, unsigned char source[], char dest[])
gtin[length] = upc_check(gtin); gtin[length] = upc_check(gtin);
gtin[length + 1] = '\0'; gtin[length + 1] = '\0';
upca_draw(gtin, dest); upca_draw(gtin, dest);
strcpy(symbol->text, gtin); ustrcpy(symbol->text, (unsigned char*)gtin);
} }
void upce(struct zint_symbol *symbol, unsigned char source[], char dest[]) void upce(struct zint_symbol *symbol, unsigned char source[], char dest[])
@ -209,7 +209,7 @@ void upce(struct zint_symbol *symbol, unsigned char source[], char dest[])
hrt[7] = check_digit; hrt[7] = check_digit;
hrt[8] = '\0'; hrt[8] = '\0';
strcpy(symbol->text, hrt); ustrcpy(symbol->text, (unsigned char*)hrt);
} }
@ -348,7 +348,7 @@ void ean13(struct zint_symbol *symbol, unsigned char source[], char dest[])
/* stop character */ /* stop character */
concat (dest, "111"); concat (dest, "111");
strcpy(symbol->text, gtin); ustrcpy(symbol->text, (unsigned char*)gtin);
} }
void ean8(struct zint_symbol *symbol, unsigned char source[], char dest[]) void ean8(struct zint_symbol *symbol, unsigned char source[], char dest[])
@ -362,7 +362,7 @@ void ean8(struct zint_symbol *symbol, unsigned char source[], char dest[])
gtin[length] = upc_check(gtin); gtin[length] = upc_check(gtin);
gtin[length + 1] = '\0'; gtin[length + 1] = '\0';
upca_draw(gtin, dest); upca_draw(gtin, dest);
strcpy(symbol->text, gtin); ustrcpy(symbol->text, (unsigned char*)gtin);
} }
char isbn13_check(unsigned char source[]) /* For ISBN(13) only */ char isbn13_check(unsigned char source[]) /* For ISBN(13) only */
@ -557,8 +557,8 @@ int eanx(struct zint_symbol *symbol, unsigned char source[])
case BARCODE_EANX: case BARCODE_EANX:
switch(ustrlen(first_part)) switch(ustrlen(first_part))
{ {
case 2: add_on(first_part, (char*)dest, 0); strcpy(symbol->text, (char*)first_part); break; case 2: add_on(first_part, (char*)dest, 0); ustrcpy(symbol->text, first_part); break;
case 5: add_on(first_part, (char*)dest, 0); strcpy(symbol->text, (char*)first_part); break; case 5: add_on(first_part, (char*)dest, 0); ustrcpy(symbol->text, first_part); break;
case 7: ean8(symbol, first_part, (char*)dest); break; case 7: ean8(symbol, first_part, (char*)dest); break;
case 12: ean13(symbol, first_part, (char*)dest); break; case 12: ean13(symbol, first_part, (char*)dest); break;
default: strcpy(symbol->errtxt, "Invalid length input [133]"); return ERROR_TOO_LONG; break; default: strcpy(symbol->errtxt, "Invalid length input [133]"); return ERROR_TOO_LONG; break;
@ -656,13 +656,13 @@ int eanx(struct zint_symbol *symbol, unsigned char source[])
case 0: break; case 0: break;
case 2: case 2:
add_on(second_part, (char*)dest, 1); add_on(second_part, (char*)dest, 1);
concat(symbol->text, "+"); uconcat(symbol->text, (unsigned char*)"+");
concat(symbol->text, (char*)second_part); uconcat(symbol->text, second_part);
break; break;
case 5: case 5:
add_on(second_part, (char*)dest, 1); add_on(second_part, (char*)dest, 1);
concat(symbol->text, "+"); uconcat(symbol->text, (unsigned char*)"+");
concat(symbol->text, (char*)second_part); uconcat(symbol->text, second_part);
break; break;
default: default:
strcpy(symbol->errtxt, "Invalid length input [139]"); strcpy(symbol->errtxt, "Invalid length input [139]");

View File

@ -40,7 +40,7 @@ struct zint_symbol {
int option_2; int option_2;
int option_3; int option_3;
int input_mode; int input_mode;
char text[100]; unsigned char text[100];
int rows; int rows;
int width; int width;
char primary[100]; char primary[100];