diff --git a/backend/common.c b/backend/common.c index 2c04b59f..5cd39a64 100644 --- a/backend/common.c +++ b/backend/common.c @@ -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; + } + } + } +} diff --git a/backend/common.h b/backend/common.h index 03554ad4..9d3ec7fd 100644 --- a/backend/common.h +++ b/backend/common.h @@ -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 */ diff --git a/backend/rss.c b/backend/rss.c index 7a83a966..4b362f20 100644 --- a/backend/rss.c +++ b/backend/rss.c @@ -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); } @@ -1042,6 +1046,8 @@ int rsslimited(struct zint_symbol *symbol, unsigned char source[], int src_len) hrt[14] = '\0'; strcat((char*) symbol->text, hrt); + + set_minimum_height(symbol, 10); return error_number; } @@ -2501,6 +2507,12 @@ 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; }