mirror of
https://git.code.sf.net/p/zint/code
synced 2026-01-26 05:15:57 +00:00
latin1_process function changed
This commit is contained in:
@@ -680,8 +680,11 @@ int aztec(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||||||
local_source[length] = '\0';
|
local_source[length] = '\0';
|
||||||
break;
|
break;
|
||||||
case UNICODE_MODE:
|
case UNICODE_MODE:
|
||||||
err_code = latin1_process(symbol, source, local_source, &length);
|
err_code = latin1_process(source, local_source, &length);
|
||||||
if(err_code != 0) { return err_code; }
|
if(err_code != 0) {
|
||||||
|
strcpy(symbol->errtxt, "error: Invalid character in input string (only Latin-1 characters supported)");
|
||||||
|
return err_code;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1317,7 +1320,7 @@ int aztec_runes(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||||||
rs_encode(2, data_codewords, ecc_codewords);
|
rs_encode(2, data_codewords, ecc_codewords);
|
||||||
rs_free();
|
rs_free();
|
||||||
|
|
||||||
strcpy(binary_string, "");
|
memset(binary_string, 0, 28);
|
||||||
|
|
||||||
for(i = 0; i < 5; i++) {
|
for(i = 0; i < 5; i++) {
|
||||||
if(ecc_codewords[4 - i] & 0x08) { binary_string[(i * 4) + 8] = '1'; } else { binary_string[(i * 4) + 8] = '0'; }
|
if(ecc_codewords[4 - i] & 0x08) { binary_string[(i * 4) + 8] = '1'; } else { binary_string[(i * 4) + 8] = '0'; }
|
||||||
|
|||||||
@@ -283,39 +283,40 @@ float froundup(float input)
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
int latin1_process(struct zint_symbol *symbol, unsigned char source[], unsigned char preprocessed[], int *length)
|
int latin1_process(unsigned char source[], unsigned char preprocessed[], int *length)
|
||||||
{
|
{
|
||||||
int j, i, next;
|
int j, i, next;
|
||||||
|
|
||||||
/* Convert Unicode to Latin-1 for those symbologies which only support Latin-1 */
|
/* Convert Unicode to Latin-1 for those symbologies which only support Latin-1 */
|
||||||
j = 0;
|
j = 0;
|
||||||
i = 0;
|
i = 0;
|
||||||
do {
|
if (length && *length) {
|
||||||
next = -1;
|
do {
|
||||||
if(source[i] < 128) {
|
next = -1;
|
||||||
preprocessed[j] = source[i];
|
if(source[i] < 128) {
|
||||||
j++;
|
preprocessed[j] = source[i];
|
||||||
next = i + 1;
|
|
||||||
} else {
|
|
||||||
if(source[i] == 0xC2) {
|
|
||||||
preprocessed[j] = source[i + 1];
|
|
||||||
j++;
|
j++;
|
||||||
next = i + 2;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(source[i] == 0xC3) {
|
if(next == -1) {
|
||||||
preprocessed[j] = source[i + 1] + 64;
|
return ZERROR_INVALID_DATA;
|
||||||
j++;
|
|
||||||
next = i + 2;
|
|
||||||
}
|
}
|
||||||
}
|
i = next;
|
||||||
if(next == -1) {
|
} while(i < *length);
|
||||||
strcpy(symbol->errtxt, "error: Invalid character in input string (only Latin-1 characters supported)");
|
preprocessed[j] = '\0';
|
||||||
return ZERROR_INVALID_DATA;
|
*length = j;
|
||||||
}
|
}
|
||||||
i = next;
|
|
||||||
} while(i < *length);
|
|
||||||
preprocessed[j] = '\0';
|
|
||||||
*length = j;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ extern void unset_module(struct zint_symbol *symbol, int y_coord, int x_coord);
|
|||||||
extern int istwodigits(unsigned char source[], int position);
|
extern int istwodigits(unsigned char source[], int position);
|
||||||
extern float froundup(float input);
|
extern float froundup(float input);
|
||||||
extern int parunmodd(unsigned char llyth);
|
extern int parunmodd(unsigned char llyth);
|
||||||
extern int latin1_process(struct zint_symbol *symbol, unsigned char source[], unsigned char preprocessed[], int *length);
|
extern int latin1_process(unsigned char source[], unsigned char preprocessed[], int *length);
|
||||||
extern int utf8toutf16(struct zint_symbol *symbol, unsigned char source[], int vals[], int *length);
|
extern int utf8toutf16(struct zint_symbol *symbol, unsigned char source[], int vals[], int *length);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -469,8 +469,11 @@ int reduced_charset(struct zint_symbol *symbol, unsigned char *source, int lengt
|
|||||||
preprocessed[length] = '\0';
|
preprocessed[length] = '\0';
|
||||||
break;
|
break;
|
||||||
case UNICODE_MODE:
|
case UNICODE_MODE:
|
||||||
error_number = latin1_process(symbol, source, preprocessed, &length);
|
error_number = latin1_process(source, preprocessed, &length);
|
||||||
if(error_number != 0) { return error_number; }
|
if(error_number != 0) {
|
||||||
|
strcpy(symbol->errtxt, "error: Invalid character in input string (only Latin-1 characters supported)");
|
||||||
|
return error_number;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -575,8 +575,11 @@ int maxicode(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||||||
local_source[length] = '\0';
|
local_source[length] = '\0';
|
||||||
break;
|
break;
|
||||||
case UNICODE_MODE:
|
case UNICODE_MODE:
|
||||||
error_number = latin1_process(symbol, source, local_source, &length);
|
error_number = latin1_process(source, local_source, &length);
|
||||||
if(error_number != 0) { return error_number; }
|
if(error_number != 0) {
|
||||||
|
strcpy(symbol->errtxt, "error: Invalid character in input string (only Latin-1 characters supported)");
|
||||||
|
return error_number;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
memset(maxi_codeword, 0, sizeof(maxi_codeword));
|
memset(maxi_codeword, 0, sizeof(maxi_codeword));
|
||||||
|
|||||||
@@ -680,62 +680,33 @@ int maxi_png_plot(struct zint_symbol *symbol, int rotate_angle, int data_type)
|
|||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
void to_latin1(unsigned char source[], unsigned char preprocessed[])
|
|
||||||
{
|
|
||||||
int j, i, input_length;
|
|
||||||
|
|
||||||
input_length = ustrlen(source);
|
|
||||||
|
|
||||||
j = 0;
|
|
||||||
i = 0;
|
|
||||||
do {
|
|
||||||
if(source[i] < 128) {
|
|
||||||
preprocessed[j] = source[i];
|
|
||||||
j++;
|
|
||||||
i++;
|
|
||||||
} else {
|
|
||||||
if(source[i] == 0xC2) {
|
|
||||||
preprocessed[j] = source[i + 1];
|
|
||||||
j++;
|
|
||||||
i += 2;
|
|
||||||
}
|
|
||||||
if(source[i] == 0xC3) {
|
|
||||||
preprocessed[j] = source[i + 1] + 64;
|
|
||||||
j++;
|
|
||||||
i += 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while (i < input_length);
|
|
||||||
preprocessed[j] = '\0';
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int png_plot(struct zint_symbol *symbol, int rotate_angle, int data_type)
|
int png_plot(struct zint_symbol *symbol, int rotate_angle, int data_type)
|
||||||
{
|
{
|
||||||
int textdone, main_width, comp_offset, large_bar_count;
|
int textdone, main_width, comp_offset, large_bar_count;
|
||||||
char textpart[10], addon[6];
|
char textpart[10], addon[6];
|
||||||
float addon_text_posn, preset_height, large_bar_height;
|
float addon_text_posn, preset_height, large_bar_height;
|
||||||
int i, r, textoffset, yoffset, xoffset, latch, image_width, image_height;
|
int i, r, textoffset, yoffset, xoffset, latch, image_width, image_height;
|
||||||
char *pixelbuf;
|
char *pixelbuf = NULL;
|
||||||
int addon_latch = 0, smalltext = 0;
|
int addon_latch = 0, smalltext = 0;
|
||||||
int this_row, block_width, plot_height, plot_yposn, textpos;
|
int this_row, block_width, plot_height, plot_yposn, textpos;
|
||||||
float row_height, row_posn;
|
float row_height, row_posn;
|
||||||
int error_number;
|
int error_number;
|
||||||
int default_text_posn;
|
int default_text_posn;
|
||||||
int next_yposn;
|
int next_yposn;
|
||||||
#ifndef _MSC_VER
|
unsigned char* local_text = NULL;
|
||||||
unsigned char local_text[ustrlen(symbol->text) + 1];
|
int tlen = ustrlen(symbol->text);
|
||||||
#else
|
|
||||||
unsigned char* local_text = (unsigned char*)_alloca(ustrlen(symbol->text) + 1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(symbol->show_hrt != 0) {
|
if (tlen) {
|
||||||
to_latin1(symbol->text, local_text);
|
local_text = (unsigned char*)calloc(tlen + 1, sizeof(char));
|
||||||
} else {
|
if (NULL == local_text) {
|
||||||
local_text[0] = '\0';
|
strcpy(symbol->errtxt, "Out of memory");
|
||||||
|
return ZERROR_MEMORY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(symbol->show_hrt != 0 && tlen)
|
||||||
|
latin1_process(symbol->text, local_text, &tlen);
|
||||||
|
|
||||||
textdone = 0;
|
textdone = 0;
|
||||||
main_width = symbol->width;
|
main_width = symbol->width;
|
||||||
strcpy(addon, "");
|
strcpy(addon, "");
|
||||||
@@ -773,7 +744,7 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle, int data_type)
|
|||||||
/* 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))
|
||||||
|| (symbol->symbology == BARCODE_ISBNX)) {
|
|| (symbol->symbology == BARCODE_ISBNX)) {
|
||||||
switch(ustrlen(local_text)) {
|
switch(tlen) {
|
||||||
case 13: /* EAN 13 */
|
case 13: /* EAN 13 */
|
||||||
case 16:
|
case 16:
|
||||||
case 19:
|
case 19:
|
||||||
@@ -805,7 +776,7 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle, int data_type)
|
|||||||
r = 0;
|
r = 0;
|
||||||
/* Isolate add-on text */
|
/* Isolate add-on text */
|
||||||
if(is_extendable(symbol->symbology)) {
|
if(is_extendable(symbol->symbology)) {
|
||||||
for(i = 0; i < ustrlen(local_text); i++) {
|
for(i = 0; i < tlen; i++) {
|
||||||
if (latch == 1) {
|
if (latch == 1) {
|
||||||
addon[r] = local_text[i];
|
addon[r] = local_text[i];
|
||||||
r++;
|
r++;
|
||||||
@@ -817,7 +788,7 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle, int data_type)
|
|||||||
}
|
}
|
||||||
addon[r] = '\0';
|
addon[r] = '\0';
|
||||||
|
|
||||||
if(ustrlen(local_text) != 0) {
|
if(tlen) {
|
||||||
textoffset = 9;
|
textoffset = 9;
|
||||||
} else {
|
} else {
|
||||||
textoffset = 0;
|
textoffset = 0;
|
||||||
@@ -829,6 +800,9 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle, int data_type)
|
|||||||
|
|
||||||
if (!(pixelbuf = (char *) malloc(image_width * image_height))) {
|
if (!(pixelbuf = (char *) malloc(image_width * image_height))) {
|
||||||
printf("Insufficient memory for pixel buffer");
|
printf("Insufficient memory for pixel buffer");
|
||||||
|
if(local_text)
|
||||||
|
free(local_text);
|
||||||
|
|
||||||
return ZERROR_ENCODING_PROBLEM;
|
return ZERROR_ENCODING_PROBLEM;
|
||||||
} else {
|
} else {
|
||||||
for(i = 0; i < (image_width * image_height); i++) {
|
for(i = 0; i < (image_width * image_height); i++) {
|
||||||
@@ -894,7 +868,7 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle, int data_type)
|
|||||||
|
|
||||||
if ((((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC)) || (symbol->symbology == BARCODE_ISBNX)) {
|
if ((((symbol->symbology == BARCODE_EANX) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_EANX_CC)) || (symbol->symbology == BARCODE_ISBNX)) {
|
||||||
/* guard bar extensions and text formatting for EAN8 and EAN13 */
|
/* guard bar extensions and text formatting for EAN8 and EAN13 */
|
||||||
switch(ustrlen(local_text)) {
|
switch(tlen) {
|
||||||
case 8: /* EAN-8 */
|
case 8: /* EAN-8 */
|
||||||
case 11:
|
case 11:
|
||||||
case 14:
|
case 14:
|
||||||
@@ -1105,13 +1079,17 @@ int png_plot(struct zint_symbol *symbol, int rotate_angle, int data_type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Put the human readable text at the bottom */
|
/* Put the human readable text at the bottom */
|
||||||
if((textdone == 0) && (ustrlen(local_text) != 0)) {
|
if((textdone == 0) && tlen) {
|
||||||
textpos = (image_width / 2);
|
textpos = (image_width / 2);
|
||||||
draw_string(pixelbuf, (char*)local_text, textpos, default_text_posn, smalltext, image_width, image_height);
|
draw_string(pixelbuf, (char*)local_text, textpos, default_text_posn, smalltext, image_width, image_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
error_number=png_to_file(symbol, image_height, image_width, pixelbuf, rotate_angle, data_type);
|
error_number=png_to_file(symbol, image_height, image_width, pixelbuf, rotate_angle, data_type);
|
||||||
free(pixelbuf);
|
free(pixelbuf);
|
||||||
|
|
||||||
|
if (local_text)
|
||||||
|
free(local_text);
|
||||||
|
|
||||||
return error_number;
|
return error_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
zint.nsi
2
zint.nsi
@@ -5,7 +5,7 @@
|
|||||||
;******************************************************************************
|
;******************************************************************************
|
||||||
!define PRODUCT_NAME "Zint"
|
!define PRODUCT_NAME "Zint"
|
||||||
!define PRODUCT_EXE "qtZint.exe"
|
!define PRODUCT_EXE "qtZint.exe"
|
||||||
!define PRODUCT_VERSION "2.4.2.0"
|
!define PRODUCT_VERSION "2.4.2.2"
|
||||||
!define PRODUCT_WEB_SITE "http://www.zint.org.uk"
|
!define PRODUCT_WEB_SITE "http://www.zint.org.uk"
|
||||||
!define PRODUCT_PUBLISHER "Robin Stuart & BogDan Vatra"
|
!define PRODUCT_PUBLISHER "Robin Stuart & BogDan Vatra"
|
||||||
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\${PRODUCT_EXE}"
|
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\${PRODUCT_EXE}"
|
||||||
|
|||||||
Reference in New Issue
Block a user