mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Enforce DataBar height restrictions
This commit is contained in:
parent
d6a1008ae7
commit
dd80371b17
@ -272,3 +272,25 @@ int utf8toutf16(struct zint_symbol *symbol, const unsigned char source[], int va
|
||||
return error_number;
|
||||
}
|
||||
|
||||
void set_minimum_height(struct zint_symbol *symbol, int min_height) {
|
||||
/* Enforce minimum permissable height of rows */
|
||||
int fixed_height = 0;
|
||||
int zero_count = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < symbol->rows; i++) {
|
||||
fixed_height += symbol->row_height[i];
|
||||
|
||||
if (symbol->row_height[i] == 0) {
|
||||
zero_count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (((symbol->height - fixed_height) / zero_count) < min_height) {
|
||||
for (i = 0; i < symbol->rows; i++) {
|
||||
if (symbol->row_height[i] == 0) {
|
||||
symbol->row_height[i] = min_height;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -72,6 +72,7 @@ extern "C" {
|
||||
extern double froundup(const double input);
|
||||
extern int parunmodd(const unsigned char llyth);
|
||||
extern int utf8toutf16(struct zint_symbol *symbol, const unsigned char source[], int vals[], int *length);
|
||||
extern void set_minimum_height(struct zint_symbol *symbol, int min_height);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
@ -514,6 +514,8 @@ int rss14(struct zint_symbol *symbol, unsigned char source[], int src_len) {
|
||||
hrt[13] = itoc(check_digit);
|
||||
|
||||
strcat((char*) symbol->text, hrt);
|
||||
|
||||
set_minimum_height(symbol, 14); // Minimum height is 14X for truncated symbol
|
||||
}
|
||||
|
||||
if ((symbol->symbology == BARCODE_RSS14STACK) || (symbol->symbology == BARCODE_RSS14STACK_CC)) {
|
||||
@ -716,6 +718,8 @@ int rss14(struct zint_symbol *symbol, unsigned char source[], int src_len) {
|
||||
}
|
||||
}
|
||||
symbol->rows = symbol->rows + 1;
|
||||
|
||||
set_minimum_height(symbol, 33);
|
||||
}
|
||||
|
||||
|
||||
@ -1043,6 +1047,8 @@ int rsslimited(struct zint_symbol *symbol, unsigned char source[], int src_len)
|
||||
|
||||
strcat((char*) symbol->text, hrt);
|
||||
|
||||
set_minimum_height(symbol, 10);
|
||||
|
||||
return error_number;
|
||||
}
|
||||
|
||||
@ -2502,5 +2508,11 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[], int src_len)
|
||||
|
||||
}
|
||||
|
||||
for (i = 0; i < symbol->rows; i++) {
|
||||
if (symbol->row_height[i] == 0) {
|
||||
symbol->row_height[i] = 34;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user