Set latching problems with Code 128.

This commit is contained in:
hooper114 2009-05-13 08:01:30 +00:00
parent d6d88b6bc1
commit 2170302bf5
2 changed files with 45 additions and 20 deletions

View File

@ -198,7 +198,7 @@ int code_128(struct zint_symbol *symbol, unsigned char source[])
{ /* Handle Code 128 and NVE-18 */
int i, j, k, e_count, values[170], bar_characters, read, total_sum, nve_check;
int error_number, indexchaine, indexliste, sourcelen;
char set[170], fset[170], mode, last_set, last_fset;
char set[170], fset[170], mode, last_set, last_fset, current_set = ' ';
float glyph_count;
char dest[1000];
@ -391,20 +391,24 @@ int code_128(struct zint_symbol *symbol, unsigned char source[])
case 'A': /* Start A */
concat(dest, C128Table[103]);
values[0] = 103;
current_set = 'A';
break;
case 'B': /* Start B */
concat(dest, C128Table[104]);
values[0] = 104;
current_set = 'B';
break;
case 'C': /* Start C */
concat(dest, C128Table[105]);
values[0] = 105;
current_set = 'C';
break;
}
bar_characters++;
last_set = set[0];
if(fset[0] == 'F') {
switch(set[0]) {
switch(current_set) {
case 'A':
concat(dest, C128Table[101]);
concat(dest, C128Table[101]);
@ -425,21 +429,24 @@ int code_128(struct zint_symbol *symbol, unsigned char source[])
read = 0;
do {
if((read != 0) && (set[read] != set[read - 1]))
if((read != 0) && (set[read] != current_set))
{ /* Latch different code set */
switch(set[read])
{
case 'A': concat(dest, C128Table[101]);
values[bar_characters] = 101;
bar_characters++;
current_set = 'A';
break;
case 'B': concat(dest, C128Table[100]);
values[bar_characters] = 100;
bar_characters++;
current_set = 'B';
break;
case 'C': concat(dest, C128Table[99]);
values[bar_characters] = 99;
bar_characters++;
current_set = 'C';
break;
}
}
@ -447,7 +454,7 @@ int code_128(struct zint_symbol *symbol, unsigned char source[])
if((read != 0) && (fset[read] != fset[read - 1])) {
if(fset[read] == 'F') {
/* Latch beginning of extended mode */
switch(set[0]) {
switch(current_set) {
case 'A':
concat(dest, C128Table[101]);
concat(dest, C128Table[101]);
@ -465,7 +472,7 @@ int code_128(struct zint_symbol *symbol, unsigned char source[])
}
if(fset[read - 1] == 'F') {
/* Latch end of extended mode */
switch(set[0]) {
switch(current_set) {
case 'A':
concat(dest, C128Table[101]);
concat(dest, C128Table[101]);
@ -485,13 +492,11 @@ int code_128(struct zint_symbol *symbol, unsigned char source[])
if(fset[read] == 'f') {
/* Shift extended mode */
switch(set[read]) {
case 'a':
switch(current_set) {
case 'A':
concat(dest, C128Table[101]);
values[bar_characters] = 101;
break;
case 'b':
case 'B':
concat(dest, C128Table[100]);
values[bar_characters] = 100;

View File

@ -117,7 +117,7 @@ int code16k(struct zint_symbol *symbol, unsigned char source[])
char width_pattern[100];
int current_row, rows_needed, flip_flop, looper, first_check, second_check;
int indexliste, indexchaine, pads_needed;
char set[160], fset[160], mode, last_set, last_fset;
char set[160], fset[160], mode, last_set, last_fset, current_set;
unsigned int i, j, k, m, e_count, read, mx_reader, writer;
unsigned int values[160];
unsigned int bar_characters;
@ -228,6 +228,23 @@ int code16k(struct zint_symbol *symbol, unsigned char source[])
}
}
/* Adjust for strings which start with shift characters - make them latch instead */
if(set[0] == 'a') {
i = 0;
do {
set[i] = 'A';
i++;
} while (set[i] == 'a');
}
if(set[0] == 'b') {
i = 0;
do {
set[i] = 'B';
i++;
} while (set[i] == 'b');
}
/* We have a problem with FNC1 in Code Set C to resolve */
for(i = 0; i < input_length; i++) {
if((set[i] == 'C') && (source[i] == '[')) {
@ -332,8 +349,9 @@ int code16k(struct zint_symbol *symbol, unsigned char source[])
values[bar_characters] = (7 * (rows_needed - 2)) + m; /* see 4.3.4.2 */
bar_characters++;
current_set = set[0];
if(fset[0] == 'F') {
switch(set[0]) {
switch(current_set) {
case 'A':
values[bar_characters] = 101;
values[bar_characters + 1] = 101;
@ -346,11 +364,6 @@ int code16k(struct zint_symbol *symbol, unsigned char source[])
bar_characters += 2;
}
for(j = 0; j < ustrlen(source); j++) {
if(set[j] == 'a') { set[j] = 'A'; }
if(set[j] == 'b') { set[j] = 'B'; }
}
read = 0;
/* Encode the data */
do {
@ -362,10 +375,12 @@ int code16k(struct zint_symbol *symbol, unsigned char source[])
case 'A':
values[bar_characters] = 101;
bar_characters++;
current_set = 'A';
break;
case 'B':
values[bar_characters] = 100;
bar_characters++;
current_set = 'B';
break;
case 'C':
if(!((read == 1) && (set[0] == 'B'))) { /* Not Mode C/Shift B */
@ -375,6 +390,7 @@ int code16k(struct zint_symbol *symbol, unsigned char source[])
bar_characters++;
}
}
current_set = 'C';
break;
}
}
@ -382,7 +398,7 @@ int code16k(struct zint_symbol *symbol, unsigned char source[])
if((read != 0) && (fset[read] != fset[read - 1])) {
if(fset[read] == 'F') {
/* Latch beginning of extended mode */
switch(set[0]) {
switch(current_set) {
case 'A':
values[bar_characters] = 101;
values[bar_characters + 1] = 101;
@ -396,7 +412,7 @@ int code16k(struct zint_symbol *symbol, unsigned char source[])
}
if(fset[read - 1] == 'F') {
/* Latch end of extended mode */
switch(set[0]) {
switch(current_set) {
case 'A':
values[bar_characters] = 101;
values[bar_characters + 1] = 101;
@ -412,7 +428,7 @@ int code16k(struct zint_symbol *symbol, unsigned char source[])
if(fset[i] == 'f') {
/* Shift extended mode */
switch(set[i]) {
switch(current_set) {
case 'A':
values[bar_characters] = 101;
break;
@ -432,10 +448,14 @@ int code16k(struct zint_symbol *symbol, unsigned char source[])
if(!((gs1) && (source[read] == '['))) {
switch(set[read])
{ /* Encode data characters */
case 'A': c16k_set_a(source[read], values, &bar_characters, symbol->nullchar);
case 'A':
case 'a':
c16k_set_a(source[read], values, &bar_characters, symbol->nullchar);
read++;
break;
case 'B': c16k_set_b(source[read], values, &bar_characters);
case 'B':
case 'b':
c16k_set_b(source[read], values, &bar_characters);
read++;
break;
case 'C': c16k_set_c(source[read], source[read + 1], values, &bar_characters);