BC412: height calc, table typo fix, tests, manual

This commit is contained in:
gitlost 2022-07-21 12:29:53 +01:00
parent 4e2c467718
commit 2a55f15135
20 changed files with 501 additions and 376 deletions

View file

@ -52,7 +52,7 @@ static const char BC412Table[35][8] = {
{'1','1','1','2','1','4','1','1'}, {'1','1','1','5','1','1','1','1'},
{'1','5','1','1','1','1','1','1'}, {'1','1','1','1','1','5','1','1'},
{'1','2','1','3','1','2','1','1'}, {'1','3','1','2','1','1','1','2'},
{'1','3','1','1','1','2','1','2'}, {'1','1','1','1','1','2','1','4'},
{'1','3','1','1','1','3','1','1'}, {'1','1','1','1','1','2','1','4'},
{'1','2','1','2','1','1','1','3'}, {'1','1','1','1','1','3','1','3'},
{'1','3','1','1','1','1','1','3'}, {'1','1','1','2','1','2','1','3'},
{'1','1','1','4','1','1','1','2'}, {'1','1','1','2','1','3','1','2'},
@ -66,7 +66,7 @@ static const char BC412Table[35][8] = {
};
INTERNAL int bc412(struct zint_symbol *symbol, unsigned char source[], int length) { /* IBM BC412 */
unsigned char padded_source[19];
unsigned char padded_source[20];
int posns[35];
int i, counter_odd = 0, counter_even = 0, check_sum = 0;
char dest[293]; /* 2 + (36 * 8) + 3 */
@ -74,7 +74,7 @@ INTERNAL int bc412(struct zint_symbol *symbol, unsigned char source[], int lengt
int error_number = 0;
if ((length < 7) || (length > 18)) {
strcpy(symbol->errtxt, "nan: Input wrong length (should be between 7 and 18 characters)");
strcpy(symbol->errtxt, "790: Input wrong length (should be between 7 and 18 characters)");
return ZINT_ERROR_TOO_LONG;
}
to_upper(source, length);
@ -88,7 +88,7 @@ INTERNAL int bc412(struct zint_symbol *symbol, unsigned char source[], int lengt
padded_source[length + 1] = 0;
if (!is_sane_lookup(BROMINE, 35, padded_source, length + 1, posns)) {
strcpy(symbol->errtxt, "nan: Invalid character in data");
strcpy(symbol->errtxt, "791: Invalid character in data (alphanumerics only, excluding the letter \"O\")");
return ZINT_ERROR_INVALID_DATA;
}
@ -131,7 +131,15 @@ INTERNAL int bc412(struct zint_symbol *symbol, unsigned char source[], int lengt
expand(symbol, dest, d - dest);
ustrcpy(symbol->text, padded_source);
/* TODO: exact dimensions / whitespace required */
if (symbol->output_options & COMPLIANT_HEIGHT) {
/* SEMI T1-95 Table 1 "Module" (Character) Height 2mm ± 0.025mm, using Module Spacing 0.12mm ± 0.025mm as
X-dimension */
error_number = set_height(symbol, stripf(1.975f / 0.145f), stripf(2.0f / 0.12f), stripf(2.025f / 0.095f),
0 /*no_errtxt*/);
} else {
/* Using compliant height as default as no backwards compatibility to consider */
(void) set_height(symbol, 0.0f, stripf(2.0f / 0.12f), 0.0f, 1 /*no_errtxt*/);
}
return error_number;
}