diff --git a/ChangeLog b/ChangeLog
index 943b50fe..74b1a673 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,7 @@ Version 2.13.0.9 (dev) not released yet
- New `memfile` & `memfile_size` fields in `symbol` for use with new output
option `BARCODE_MEMORY_FILE`
- Invalid `input_mode` now returns warning
+- New CODE128-only special extra escape `\^1` for manually inserting FNC1s
Changes
-------
@@ -21,6 +22,8 @@ Changes
iso4217: new ISO 4217 currency code 924
- AZTEC: workaround MSVC 2022 optimizer bug in `az_populate_map()` loops,
ticket #317, props Andre Maute
+- CODE128: Add new extra escape `\^1` for manual insertion of FNC1s, ticket
+ #324, props Jim Shank
Bugs
----
diff --git a/README.clang-tidy b/README.clang-tidy
index 1d16ecec..55be6fc9 100644
--- a/README.clang-tidy
+++ b/README.clang-tidy
@@ -1,16 +1,16 @@
-% README.clang-tidy 2024-03-03
-% Current as of latest clang-tidy-19 from Ubuntu 22.04 apt package
+% README.clang-tidy 2024-09-03
+% Current as of latest clang-tidy-20 from Ubuntu 22.04 apt package
Requires cmake in "build" sub-directory with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON (for "build/compile_commands.json")
and -DCMAKE_BUILD_TYPE=Debug (so `assert()`s defined), and then make (for Qt generated includes).
In project root directory (warning, slow):
-clang-tidy-19 backend/*.c frontend/*.c backend_qt/*.cpp frontend_qt/*.cpp -p build/compile_commands.json
+clang-tidy-20 backend/*.c frontend/*.c backend_qt/*.cpp frontend_qt/*.cpp -p build/compile_commands.json
For "backend_tcl", which has no "compile_commands.json", specify the tcl include directory, e.g.
-clang-tidy-19 backend_tcl/*.c -- -I/usr/include/tcl8.6
+clang-tidy-20 backend_tcl/*.c -- -I/usr/include/tcl8.6
Options are in ".clang-tidy" (in the project root directory). The excluded checks are
`clang-analyzer-security.insecureAPI.strcpy` (for `strcpy()`, `strcat()` etc), and
@@ -18,5 +18,5 @@ Options are in ".clang-tidy" (in the project root directory). The excluded check
The test suite (cmake given -DZINT_TEST=ON) can also be analysed with an additional check disabled:
-clang-tidy-19 backend/tests/*.c frontend/tests/*.c backend_qt/tests/*.cpp \
+clang-tidy-20 backend/tests/*.c frontend/tests/*.c backend_qt/tests/*.cpp \
-checks='-clang-analyzer-optin.performance.Padding' -p build/compile_commands.json
diff --git a/backend/code128.c b/backend/code128.c
index f2c9027d..1a18249f 100644
--- a/backend/code128.c
+++ b/backend/code128.c
@@ -76,11 +76,11 @@ INTERNAL_DATA const char C128Table[107][6] = { /* Used by CODABLOCKF and CODE16K
};
/* Determine appropriate mode for a given character */
-INTERNAL int c128_parunmodd(const unsigned char llyth) {
+INTERNAL int c128_parunmodd(const unsigned char llyth, const int check_fnc1) {
int modd;
if (llyth <= 31) {
- modd = C128_SHIFTA;
+ modd = check_fnc1 && llyth == '\x1D' ? C128_ABORC : C128_SHIFTA;
} else if ((llyth >= 48) && (llyth <= 57)) {
modd = C128_ABORC;
} else if (llyth <= 95) {
@@ -244,7 +244,7 @@ INTERNAL void c128_dxsmooth(int list[2][C128_MAX], int *p_indexliste, const char
*/
INTERNAL void c128_set_a(const unsigned char source, int values[], int *bar_chars) {
- if (source > 127) {
+ if (source >= 128) {
if (source < 160) {
values[(*bar_chars)] = (source - 128) + 64;
} else {
@@ -290,7 +290,7 @@ INTERNAL void c128_set_c(const unsigned char source_a, const unsigned char sourc
(*bar_chars)++;
}
-/* Put set data into set[]. If source given (GS1_MODE) then resolves odd C blocks */
+/* Put set data into set[]. If source given (GS1_MODE or manual FNC1s) then resolves odd C blocks */
INTERNAL void c128_put_in_set(int list[2][C128_MAX], const int indexliste, char set[C128_MAX],
const unsigned char *source) {
int read = 0;
@@ -303,12 +303,13 @@ INTERNAL void c128_put_in_set(int list[2][C128_MAX], const int indexliste, char
}
if (source) {
/* Watch out for odd-length Mode C blocks */
- int c_count = 0;
+ int c_count = 0, have_nonc = 0;
for (i = 0; i < read; i++) {
if (set[i] == 'C') {
if (source[i] == '\x1D') {
if (c_count & 1) {
- if ((i - c_count) != 0) {
+ have_nonc = 1;
+ if (i > c_count) {
set[i - c_count] = 'B';
} else {
set[i - 1] = 'B';
@@ -319,8 +320,9 @@ INTERNAL void c128_put_in_set(int list[2][C128_MAX], const int indexliste, char
c_count++;
}
} else {
+ have_nonc = 1;
if (c_count & 1) {
- if ((i - c_count) != 0) {
+ if (i > c_count) {
set[i - c_count] = 'B';
} else {
set[i - 1] = 'B';
@@ -330,17 +332,26 @@ INTERNAL void c128_put_in_set(int list[2][C128_MAX], const int indexliste, char
}
}
if (c_count & 1) {
- if ((i - c_count) != 0) {
+ if (i > c_count && have_nonc) {
set[i - c_count] = 'B';
+ if (c_count < 4) {
+ /* Rule 1b */
+ for (j = i - c_count + 1; j < i; j++) {
+ set[j] = 'B';
+ }
+ }
} else {
set[i - 1] = 'B';
}
}
for (i = 1; i < read - 1; i++) {
- if ((set[i] == 'C') && ((set[i - 1] == 'B') && (set[i + 1] == 'B'))) {
- set[i] = 'B';
+ if (set[i] == 'C' && set[i - 1] != 'C' && set[i + 1] != 'C') {
+ set[i] = set[i + 1];
}
}
+ if (read > 1 && set[read - 1] == 'C' && set[read - 2] != 'C') {
+ set[read - 1] = set[read - 2];
+ }
}
}
@@ -351,8 +362,10 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len
unsigned char src_buf[C128_MAX + 1];
unsigned char *src = source;
char manual_set[C128_MAX] = {0};
+ unsigned char fncs[C128_MAX] = {0}; /* Manual FNC1 positions */
int list[2][C128_MAX] = {{0}};
char set[C128_MAX] = {0}, fset[C128_MAX], mode, last_set, current_set = ' ';
+ int have_fnc1 = 0; /* Whether have at least 1 manual FNC1 */
int glyph_count = 0; /* Codeword estimate times 2 */
char dest[1000];
char *d = dest;
@@ -373,16 +386,22 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len
j = 0;
for (i = 0; i < length; i++) {
if (source[i] == '\\' && i + 2 < length && source[i + 1] == '^'
- && ((source[i + 2] >= 'A' && source[i + 2] <= 'C') || source[i + 2] == '^')) {
- if (source[i + 2] != '^') {
- i += 2;
- manual_ch = source[i];
- } else { /* Escape sequence '\^^' */
+ && ((source[i + 2] >= 'A' && source[i + 2] <= 'C') || source[i + 2] == '1'
+ || source[i + 2] == '^')) {
+ if (source[i + 2] == '^') { /* Escape sequence '\^^' */
manual_set[j] = manual_ch;
src_buf[j++] = source[i++];
manual_set[j] = manual_ch;
src_buf[j++] = source[i++];
/* Drop second '^' */
+ } else if (source[i + 2] == '1') { /* FNC1 */
+ i += 2;
+ fncs[j] = have_fnc1 = 1;
+ manual_set[j] = manual_ch;
+ src_buf[j++] = '\x1D'; /* Manual FNC1 dummy */
+ } else { /* Manual mode A/B/C */
+ i += 2;
+ manual_ch = source[i];
}
} else {
manual_set[j] = manual_ch;
@@ -456,10 +475,10 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len
indexliste = 0;
indexchaine = 0;
- mode = c128_parunmodd(src[indexchaine]);
+ mode = c128_parunmodd(src[indexchaine], fncs[indexchaine]);
if (mode == C128_ABORC
&& (symbol->symbology == BARCODE_CODE128AB
- || (manual_set[indexchaine] == 'A' || manual_set[indexchaine] == 'B'))) {
+ || manual_set[indexchaine] == 'A' || manual_set[indexchaine] == 'B')) {
mode = C128_AORB;
}
@@ -471,10 +490,10 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len
if (indexchaine == length) {
break;
}
- mode = c128_parunmodd(src[indexchaine]);
+ mode = c128_parunmodd(src[indexchaine], fncs[indexchaine]);
if (mode == C128_ABORC
&& (symbol->symbology == BARCODE_CODE128AB
- || (manual_set[indexchaine] == 'A' || manual_set[indexchaine] == 'B'))) {
+ || manual_set[indexchaine] == 'A' || manual_set[indexchaine] == 'B')) {
mode = C128_AORB;
}
if (manual_set[indexchaine] != manual_set[indexchaine - 1]) {
@@ -494,29 +513,32 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len
}
c128_dxsmooth(list, &indexliste, src == src_buf ? manual_set : NULL);
- /* Resolve odd length C128_LATCHC blocks */
- if ((list[1][0] == C128_LATCHC) && (list[0][0] & 1)) {
- /* Rule 2 */
- list[0][1]++;
- list[0][0]--;
- if (indexliste == 1) {
- list[0][1] = 1;
- list[1][1] = C128_LATCHB;
- indexliste = 2;
+ if (!have_fnc1) {
+ /* Resolve odd length C128_LATCHC blocks */
+ if ((list[1][0] == C128_LATCHC) && (list[0][0] & 1)) {
+ /* Rule 2 */
+ list[0][1]++;
+ list[0][0]--;
+ if (indexliste == 1) {
+ list[0][1] = 1;
+ list[1][1] = C128_LATCHB;
+ indexliste = 2;
+ }
}
- }
- if (indexliste > 1) {
- for (i = 1; i < indexliste; i++) {
- if ((list[1][i] == C128_LATCHC) && (list[0][i] & 1)) {
- /* Rule 3b */
- list[0][i - 1]++;
- list[0][i]--;
+ if (indexliste > 1) {
+ for (i = 1; i < indexliste; i++) {
+ if ((list[1][i] == C128_LATCHC) && (list[0][i] & 1)) {
+ /* Rule 3b */
+ list[0][i - 1]++;
+ list[0][i]--;
+ }
}
}
}
- /* Put set data into set[]. Giving NULL as source as used to resolve odd C blocks which has been done above */
- c128_put_in_set(list, indexliste, set, NULL /*source*/);
+ /* Put set data into set[]. Give NULL as source if no manual FNC1s as used to resolve odd C blocks
+ which has been done above */
+ c128_put_in_set(list, indexliste, set, have_fnc1 ? src : NULL);
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("Data: %.*s (%d)\n", length, src, length);
@@ -547,13 +569,12 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len
} else {
if ((fset[i] == 'F') && (fset[i - 1] != 'F')) {
glyph_count += 4;
- }
- if ((fset[i] != 'F') && (fset[i - 1] == 'F')) {
+ } else if ((fset[i] != 'F') && (fset[i - 1] == 'F')) {
glyph_count += 4;
}
}
- if (set[i] == 'C') {
+ if (set[i] == 'C' && !fncs[i]) {
glyph_count += 1; /* Half a codeword */
} else {
glyph_count += 2;
@@ -622,25 +643,25 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len
read = 0;
do {
- if ((read != 0) && (set[read] != current_set)) {
- /* Latch different code set */
- switch (set[read]) {
- case 'A':
- values[bar_characters++] = 101;
- current_set = 'A';
- break;
- case 'B':
- values[bar_characters++] = 100;
- current_set = 'B';
- break;
- case 'C':
- values[bar_characters++] = 99;
- current_set = 'C';
- break;
- }
- }
-
if (read != 0) {
+ if (set[read] != current_set) {
+ /* Latch different code set */
+ switch (set[read]) {
+ case 'A':
+ values[bar_characters++] = 101;
+ current_set = 'A';
+ break;
+ case 'B':
+ values[bar_characters++] = 100;
+ current_set = 'B';
+ break;
+ case 'C':
+ values[bar_characters++] = 99;
+ current_set = 'C';
+ break;
+ }
+ }
+
if ((fset[read] == 'F') && (f_state == 0)) {
/* Latch beginning of extended mode */
switch (current_set) {
@@ -690,18 +711,24 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len
values[bar_characters++] = 98;
}
- switch (set[read]) { /* Encode data characters */
- case 'a':
- case 'A': c128_set_a(src[read], values, &bar_characters);
- read++;
- break;
- case 'b':
- case 'B': (void) c128_set_b(src[read], values, &bar_characters);
- read++;
- break;
- case 'C': c128_set_c(src[read], src[read + 1], values, &bar_characters);
- read += 2;
- break;
+ if (!fncs[read]) {
+ switch (set[read]) { /* Encode data characters */
+ case 'a':
+ case 'A':
+ c128_set_a(src[read++], values, &bar_characters);
+ break;
+ case 'b':
+ case 'B':
+ (void) c128_set_b(src[read++], values, &bar_characters);
+ break;
+ case 'C':
+ c128_set_c(src[read], src[read + 1], values, &bar_characters);
+ read += 2;
+ break;
+ }
+ } else {
+ values[bar_characters++] = 102; /* FNC1 in all modes */
+ read++;
}
} while (read < length);
@@ -744,6 +771,16 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len
/* ISO/IEC 15417:2007 leaves dimensions/height as application specification */
+ /* HRT */
+ if (have_fnc1) {
+ /* Remove any manual FNC1 dummies ('\x1D') */
+ for (i = 0, j = 0; i < length; i++) {
+ if (!fncs[i]) {
+ src[j++] = src[i];
+ }
+ }
+ length = j;
+ }
error_number = hrt_cpy_iso8859_1(symbol, src, length);
return error_number;
@@ -788,7 +825,7 @@ INTERNAL int gs1_128_cc(struct zint_symbol *symbol, unsigned char source[], int
indexliste = 0;
indexchaine = 0;
- mode = c128_parunmodd(reduced[indexchaine]);
+ mode = c128_parunmodd(reduced[indexchaine], 1 /*check_fnc1*/);
do {
list[1][indexliste] = mode;
@@ -798,10 +835,7 @@ INTERNAL int gs1_128_cc(struct zint_symbol *symbol, unsigned char source[], int
if (indexchaine == reduced_length) {
break;
}
- mode = c128_parunmodd(reduced[indexchaine]);
- if (reduced[indexchaine] == '\x1D') {
- mode = C128_ABORC;
- }
+ mode = c128_parunmodd(reduced[indexchaine], 1 /*check_fnc1*/);
}
indexliste++;
} while (indexchaine < reduced_length);
@@ -853,7 +887,7 @@ INTERNAL int gs1_128_cc(struct zint_symbol *symbol, unsigned char source[], int
break;
}
- values[bar_characters++] = 102;
+ values[bar_characters++] = 102; /* FNC1 */
/* Encode the data */
read = 0;
@@ -882,13 +916,11 @@ INTERNAL int gs1_128_cc(struct zint_symbol *symbol, unsigned char source[], int
switch (set[read]) { /* Encode data characters */
case 'A':
case 'a':
- c128_set_a(reduced[read], values, &bar_characters); /* Not reached */
- read++;
+ c128_set_a(reduced[read++], values, &bar_characters); /* Not reached */
break;
case 'B':
case 'b':
- (void) c128_set_b(reduced[read], values, &bar_characters);
- read++;
+ (void) c128_set_b(reduced[read++], values, &bar_characters);
break;
case 'C':
c128_set_c(reduced[read], reduced[read + 1], values, &bar_characters);
@@ -896,7 +928,7 @@ INTERNAL int gs1_128_cc(struct zint_symbol *symbol, unsigned char source[], int
break;
}
} else {
- values[bar_characters++] = 102;
+ values[bar_characters++] = 102; /* FNC1 in all modes */
read++;
}
} while (read < reduced_length);
@@ -1194,8 +1226,7 @@ INTERNAL int dpd(struct zint_symbol *symbol, unsigned char source[], int length)
case 21:
case 24:
case 27:
- symbol->text[p] = ' ';
- p++;
+ symbol->text[p++] = ' ';
break;
}
}
diff --git a/backend/code128.h b/backend/code128.h
index 4b1c573c..3102eb60 100644
--- a/backend/code128.h
+++ b/backend/code128.h
@@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
- Copyright (C) 2020-2023 Robin Stuart June 2024 September 2024Zint Barcode Generator and Zint Barcode Studio User
Manual
-
Input data can be read directly from file using the -i
or --input
switch as shown below. The input file is assumed
to be UTF-8 formatted unless an alternative mode is selected. This
@@ -4831,6 +4832,11 @@ special code sequence, it can be escaped by doubling the caret
zint -b CODE128 -d "\^AABC\^^BDEF" --extraesc
will encode the data "ABC\^BDEF"
in Code Set A.
There is also the extra escape \^1
, which will encode a
+special Function Code 1 character (FNC1) anywhere you chose in the data,
+for instance
zint -b CODE128 -d "A\^1BC\^1DEF" --extraesc
Code 128 is the default barcode symbology used by Zint. In addition Zint supports the encoding of ISO/IEC 8859-1 (non-English) characters in Code 128 symbols. The ISO/IEC 8859-1 character set is shown in Annex BARCODE_CODE128AB14 variant (symbology 60) suppresses Code Set C in favour of Code Sets A and B.
-Note that the special escapes to manually switch Code Sets mentioned -above are not available for this variant (nor for any other).
+Note that the special extra escapes mentioned above are not available +for this variant (nor for any other).
zint -b 16 -d "[01]98898765432106[3202]012345[15]991231"
or using the --gs1parens
option:
zint -b 16 --gs1parens -d "(01)98898765432106(3202)012345(15)991231"
zint -b 16 -d "[01]98898765432106[3202]012345[15]991231"
+or using the --gs1parens
option:
zint -b 16 --gs1parens -d "(01)98898765432106(3202)012345(15)991231"
zint -b 31 -d "[01]98898765432106[3202]012345[15]991231"
zint -b 31 -d "[01]98898765432106[3202]012345[15]991231"
zint -d "This" -d "That"
zint -d "This" -d "That"
will draw two Code 128 symbols, one on top of the other. The same
result can be achieved using the API by executing the
ZBarcode_Encode()
function more than once on a symbol. For
example:
->symbology = BARCODE_CODE128;
- my_symbol
-= ZBarcode_Encode(my_symbol, "This", 0);
- error
-= ZBarcode_Encode(my_symbol, "That", 0);
- error
-= ZBarcode_Print(my_symbol); error
->symbology = BARCODE_CODE128;
+ my_symbol
+= ZBarcode_Encode(my_symbol, "This", 0);
+ error
+= ZBarcode_Encode(my_symbol, "That", 0);
+ error
+= ZBarcode_Print(my_symbol); error
--bind
(API
separator bars in integral multiples of the X-dimension (minimum and
default 1, maximum 4) can be set by --separator
(API
option_3
):
-zint --bind --notext --separator=2 -d "This" -d "That"
zint --bind --notext --separator=2 -d "This" -d "That"
--primary
switch (API primary
).
For example:
-zint -b EANX_CC --mode=1 --primary=331234567890 -d "[99]1234-abcd"
zint -b EANX_CC --mode=1 --primary=331234567890 -d "[99]1234-abcd"
This creates an EAN-13 linear component with the data
"331234567890"
and a 2D CC-A (see below) component with the data
"(99)1234-abcd"
. The same results can be achieved using the
API as shown below:
->symbology = BARCODE_EANX_CC;
- my_symbol
-->option_1 = 1;
- my_symbol
-(my_symbol->primary, "331234567890");
- strcpy
-(my_symbol, "[99]1234-abcd", 0, 0); ZBarcode_Encode_and_Print
->symbology = BARCODE_EANX_CC;
+ my_symbol
+->option_1 = 1;
+ my_symbol
+(my_symbol->primary, "331234567890");
+ strcpy
+(my_symbol, "[99]1234-abcd", 0, 0); ZBarcode_Encode_and_Print
EAN-2 and EAN-5 add-on data can be used with EAN and UPC symbols
using the + symbol as described in sections 6.1.3 UPC (Universal
@@ -5819,13 +5825,13 @@ size to full height can be given in thousandths (permille) using the
--vers
option (API option_2
). The default
value is 250 (25%).
For example the following
-zint -b DAFT -d AAFDTTDAFADTFTTFFFDATFTADTTFFTDAFAFDTF --height=8.494 --vers=256
zint -b DAFT -d AAFDTTDAFADTFTTFFFDATFTADTTFFTDAFAFDTF --height=8.494 --vers=256
produces the same barcode (see 6.5.3 Royal Mail 4-State Customer Code (RM4SCC)) as
-zint -b RM4SCC --compliantheight -d "W1J0TR01"
zint -b RM4SCC --compliantheight -d "W1J0TR01"
--mask
switch with
values 0-7, or in the API by setting
option_3 = (N + 1) << 8
where N is 0-7. To use with
ZINT_FULL_MULTIBYTE
set
-= ZINT_FULL_MULTIBYTE | (N + 1) << 8 option_3
= ZINT_FULL_MULTIBYTE | (N + 1) << 8 option_3
The --fast
option (API
input_mode |= FAST_MODE
) may be used when leaving Zint to
automatically select a mask to reduce the number of masks to try to four
@@ -6602,8 +6608,8 @@ be manually specified by using the --mask
switch with
values 0-3, or in the API by setting
option_3 = (N + 1) << 8
where N is 0-3. To use with
ZINT_FULL_MULTIBYTE
set
= ZINT_FULL_MULTIBYTE | (N + 1) << 8 option_3
= ZINT_FULL_MULTIBYTE | (N + 1) << 8 option_3
--binary
switch (API
input_mode = DATA_MODE
).
The following example creates a symbol from data saved as a Latin-2 file:
-zint -o upnqr.png -b 143 --scale=3 --binary -i upn.txt
zint -o upnqr.png -b 143 --scale=3 --binary -i upn.txt
A mask may be manually specified or the --fast
option
used as with QRCODE.
The primary message can be set at the command prompt using the
--primary
switch (API primary
). The secondary
message uses the normal data entry method. For example:
zint -o test.eps -b 57 --primary="999999999840012" \
--d "Secondary Message Here"
zint -o test.eps -b 57 --primary="999999999840012" \
+-d "Secondary Message Here"
When using the API the primary message must be placed in the
primary
string. The secondary is entered in the same way as
described in 5.2 Encoding and
@@ -6961,9 +6967,9 @@ to be prefixed by the ISO/IEC 15434 Format "01"
vv
is a 2-digit version, by using the --scmvv
switch (API option_2 = vv + 1
). For example to use the
common version "96"
(ASC MH10/SC 8):
zint -b 57 --primary="152382802840001" --scmvv=96 --esc -d \
-"1Z00004951\GUPSN\G06X610\G159\G1234567\G1/1\G\GY\G1 MAIN ST\GNY\GNY\R\E"
zint -b 57 --primary="152382802840001" --scmvv=96 --esc -d \
+"1Z00004951\GUPSN\G06X610\G159\G1234567\G1/1\G\GY\G1 MAIN ST\GNY\GNY\R\E"
will prefix "[)>\R01\G96"
to the secondary message.
(\R
, \G
and \E
are the escape
sequences for Record Separator, Group Separator and End of Transmission
@@ -6972,8 +6978,8 @@ Sequences.)
Modes 4 to 6 can be accessed using the --mode
switch
(API option_1
). Modes 4 to 6 do not have a primary message.
For example:
zint -o test.eps -b 57 --mode=4 -d "A MaxiCode Message in Mode 4"
zint -o test.eps -b 57 --mode=4 -d "A MaxiCode Message in Mode 4"
Mode 6 is reserved for the maintenance of scanner hardware and should not be used to encode user data.
This symbology uses Latin-1 character encoding by default but also
@@ -7898,8 +7904,8 @@ be manually specified by using the --mask
switch with
values 0-3, or in the API by setting
option_3 = (N + 1) << 8
where N is 0-3. To use with
ZINT_FULL_MULTIBYTE
set
= ZINT_FULL_MULTIBYTE | (N + 1) << 8 option_3
= ZINT_FULL_MULTIBYTE | (N + 1) << 8 option_3
Zint does not currently implement data compression by default, but this can be initiated through the API by setting
-->option_3 = ULTRA_COMPRESSION; symbol
->option_3 = ULTRA_COMPRESSION; symbol
With compression, up to 504 digits, 375 alphanumerics or 252 bytes can be encoded.
Revision 2 of Ultracode (2023) may be specified using
@@ -8613,28 +8619,28 @@ properties that correspond to the zint_symbol
structure
method render()
which takes a Qt QPainter
to
paint with, and a QRectF
rectangular area specifying where
to paint into:
/* Encode and display barcode in `paintRect` using `painter`.
- Note: legacy argument `mode` is not used */
-void render(QPainter& painter, const QRectF& paintRect,
-= IgnoreAspectRatio); AspectRatioMode mode
/* Encode and display barcode in `paintRect` using `painter`.
+ Note: legacy argument `mode` is not used */
+void render(QPainter& painter, const QRectF& paintRect,
+= IgnoreAspectRatio); AspectRatioMode mode
render()
will emit one of two Qt signals -
encoded
on successful encoding and drawing, or
errored
on failure. The client can connect and act
appropriately, for instance:
connect(qzint, SIGNAL(encoded()), SLOT(on_encoded()));
-connect(qzint, SIGNAL(errored()), SLOT(on_errored()));
connect(qzint, SIGNAL(encoded()), SLOT(on_encoded()));
+connect(qzint, SIGNAL(errored()), SLOT(on_errored()));
where qzint
is an instance of Zint::QZint
and on_encoded()
and on_error()
are Qt slot
methods provided by the caller. On error, the error value and message
can be retrieved by the methods getError()
and
lastError()
respectively.
The other main method is save_to_file()
:
/* Encode and print barcode to file `filename`.
- Only sets `getError()` on error, not on warning */
-bool save_to_file(const QString& filename); // `ZBarcode_Print()`
/* Encode and print barcode to file `filename`.
+ Only sets `getError()` on error, not on warning */
+bool save_to_file(const QString& filename); // `ZBarcode_Print()`
which takes a filename
to output to. It too will emit an
errored
signal on failure, returning false
(but nothing on success, which just returns true
). Note
@@ -8649,33 +8655,33 @@ symbology capabilities, and utility methods such as
A Tcl binding is available in the "backend_tcl
”
sub-directory. To make on Unix:
cd backend_tcl
-autoconf
-./configure
-make
-sudo make install
cd backend_tcl
+autoconf
+./configure
+make
+sudo make install
For Windows, a Visual Studio 6.0 project file is available at
"backend_tcl\zint_tcl.dsp"
. This can also be opened (and
converted) by more modern Visual Studio versions, though some fixing up
of the project configuration will likely be required.
Once built and installed, invoke the Tcl/Tk CLI
"wish"
:
wish
wish
and ignoring the Tk window click back to the command prompt
"%"
and type:
require package zint
-zint help
require package zint
+zint help
which will show the usage message, with options very similiar to the
Zint CLI. (One notable difference is that boolean options such as
-bold
take a 1
or 0
as an
argument.)
A demonstration Tcl/Tk program which is also useful in itself is
available at "backend_tcl/demo/demo.tcl"
. To run type:
wish demo/demo.tcl
wish demo/demo.tcl
which will display the following window.
--extraesc
Process the special escape sequences \^A
,
-\^B
and \^C
that allow manual switching of
-Code Sets (Code 128 only). The sequence \^^
can be used to
-encode data that contains special escape sequences.
For Code 128 only, process the special escape sequences
+\^A
, \^B
and \^C
that allow
+manual switching of Code Sets, and the special escape sequence
+\^1
that inserts an FNC1
character. The
+sequence \^^
can be used to encode data that contains
+special escape sequences.
--fast
--werror
given
Create “out.png” (or “out.gif” if zint built without PNG support) in the current directory, as a Code 128 symbol.
-zint -d 'This Text'
Create “qr.svg” in the current directory, as a QR Code symbol.
zint -b QRCode -d 'This Text' -o 'qr.svg'
zint -d 'This Text'
+Create “qr.svg” in the current directory, as a QR Code symbol.
+zint -b QRCode -d 'This Text' -o 'qr.svg'
Use batch mode to read from an input file “ean13nos.txt” containing 13-digit GTINs, to create a series of EAN-13 barcodes, formatting the output filenames to “ean001.gif”, “ean002.gif” etc. using the special character “~”.
-zint -b EANX --batch -i 'ean13nos.txt' -o 'ean~~~.gif'
zint -b EANX --batch -i 'ean13nos.txt' -o 'ean~~~.gif'
Please send bug reports to https://sourceforge.net/p/zint/tickets/.
diff --git a/docs/manual.pmd b/docs/manual.pmd index ec4253c0..3dff515c 100644 --- a/docs/manual.pmd +++ b/docs/manual.pmd @@ -1,6 +1,6 @@ % Zint Barcode Generator and Zint Barcode Studio User Manual % Version 2.13.0.9 -% June 2024 +% September 2024 # 1. Introduction @@ -574,7 +574,8 @@ codeset from U+0000 to U+D7FF and U+E000 to U+FFFF (i.e. excluding surrogates). Not to be confused with the Windows Bitmap file format BMP! (Special escape sequences are available for Code 128 only to manually switch -Code Sets - see [6.1.10.1 Standard Code 128 (ISO 15417)] for details.) +Code Sets and/or insert special FNC1 characters - see [6.1.10.1 Standard Code +128 (ISO 15417)] for details.) Input data can be read directly from file using the `-i` or `--input` switch as shown below. The input file is assumed to be UTF-8 formatted unless an @@ -3131,6 +3132,13 @@ zint -b CODE128 -d "\^AABC\^^BDEF" --extraesc will encode the data `"ABC\^BDEF"` in Code Set A. +There is also the extra escape `\^1`, which will encode a special Function Code +1 character (FNC1) anywhere you chose in the data, for instance + +```bash +zint -b CODE128 -d "A\^1BC\^1DEF" --extraesc +``` + Code 128 is the default barcode symbology used by Zint. In addition Zint supports the encoding of ISO/IEC 8859-1 (non-English) characters in Code 128 symbols. The ISO/IEC 8859-1 character set is shown in Annex [A.2 Latin Alphabet @@ -3147,8 +3155,8 @@ It is sometimes advantageous to stop Code 128 from using Code Set C which compresses numerical data. The `BARCODE_CODE128AB`[^14] variant (symbology 60) suppresses Code Set C in favour of Code Sets A and B. -Note that the special escapes to manually switch Code Sets mentioned above are -not available for this variant (nor for any other). +Note that the special extra escapes mentioned above are not available for this +variant (nor for any other). [^14]: `BARCODE_CODE128AB` previously used the name `BARCODE_CODE128B`, which is still recognised. diff --git a/docs/manual.txt b/docs/manual.txt index 1bbcec59..c2d2c940 100644 --- a/docs/manual.txt +++ b/docs/manual.txt @@ -1,6 +1,6 @@ Zint Barcode Generator and Zint Barcode Studio User Manual Version 2.13.0.9 -June 2024 +September 2024 ******************************************************************************* * For reference the following is a text-only version of the Zint manual, * @@ -720,7 +720,8 @@ sequences are shown in the table below. Table : Escape Sequences (Special escape sequences are available for Code 128 only to manually switch -Code Sets - see 6.1.10.1 Standard Code 128 (ISO 15417) for details.) +Code Sets and/or insert special FNC1 characters - see 6.1.10.1 Standard Code 128 +(ISO 15417) for details.) Input data can be read directly from file using the -i or --input switch as shown below. The input file is assumed to be UTF-8 formatted unless an @@ -3029,6 +3030,11 @@ sequence, it can be escaped by doubling the caret (^). For instance will encode the data "ABC\^BDEF" in Code Set A. +There is also the extra escape \^1, which will encode a special Function Code 1 +character (FNC1) anywhere you chose in the data, for instance + + zint -b CODE128 -d "A\^1BC\^1DEF" --extraesc + Code 128 is the default barcode symbology used by Zint. In addition Zint supports the encoding of ISO/IEC 8859-1 (non-English) characters in Code 128 symbols. The ISO/IEC 8859-1 character set is shown in Annex A.2 Latin Alphabet @@ -3045,8 +3051,8 @@ It is sometimes advantageous to stop Code 128 from using Code Set C which compresses numerical data. The BARCODE_CODE128AB[14] variant (symbology 60) suppresses Code Set C in favour of Code Sets A and B. -Note that the special escapes to manually switch Code Sets mentioned above are -not available for this variant (nor for any other). +Note that the special extra escapes mentioned above are not available for this +variant (nor for any other). 6.1.10.3 GS1-128 @@ -4817,7 +4823,7 @@ configured barcode is displayed once the "Generate" button is pressed. Annex D. Man Page ZINT(1) -% ZINT(1) Version 2.13.0.9 % % June 2024 +% ZINT(1) Version 2.13.0.9 % % September 2024 NAME @@ -5011,9 +5017,10 @@ OPTIONS --extraesc - Process the special escape sequences \^A, \^B and \^C that allow manual - switching of Code Sets (Code 128 only). The sequence \^^ can be used to - encode data that contains special escape sequences. + For Code 128 only, process the special escape sequences \^A, \^B and \^C + that allow manual switching of Code Sets, and the special escape sequence + \^1 that inserts an FNC1 character. The sequence \^^ can be used to encode + data that contains special escape sequences. --fast diff --git a/docs/zint.1 b/docs/zint.1 index fe50dadd..715819e7 100644 --- a/docs/zint.1 +++ b/docs/zint.1 @@ -1,6 +1,6 @@ -.\" Automatically generated by Pandoc 3.2 +.\" Automatically generated by Pandoc 3.3 .\" -.TH "ZINT" "1" "June 2024" "Version 2.13.0.9" "" +.TH "ZINT" "1" "September 2024" "Version 2.13.0.9" .SH NAME \f[CR]zint\f[R] \- encode data as a barcode image .SH SYNOPSIS @@ -195,9 +195,11 @@ The escape sequences are: .RE .TP \f[CR]\-\-extraesc\f[R] -Process the special escape sequences \f[CR]\[rs]\[ha]A\f[R], -\f[CR]\[rs]\[ha]B\f[R] and \f[CR]\[rs]\[ha]C\f[R] that allow manual -switching of Code Sets (Code 128 only). +For Code 128 only, process the special escape sequences +\f[CR]\[rs]\[ha]A\f[R], \f[CR]\[rs]\[ha]B\f[R] and +\f[CR]\[rs]\[ha]C\f[R] that allow manual switching of Code Sets, and the +special escape sequence \f[CR]\[rs]\[ha]1\f[R] that inserts an +\f[CR]FNC1\f[R] character. The sequence \f[CR]\[rs]\[ha]\[ha]\f[R] can be used to encode data that contains special escape sequences. .TP diff --git a/docs/zint.1.pmd b/docs/zint.1.pmd index fb2b46d0..58908cc9 100644 --- a/docs/zint.1.pmd +++ b/docs/zint.1.pmd @@ -1,6 +1,6 @@ % ZINT(1) Version 2.13.0.9 % -% June 2024 +% September 2024 # NAME @@ -174,8 +174,9 @@ Paintbrush (`PCX`), Portable Network Format (`PNG`), Scalable Vector Graphic (`S `--extraesc` -: Process the special escape sequences `\^A`, `\^B` and `\^C` that allow manual switching of Code Sets (Code 128 - only). The sequence `\^^` can be used to encode data that contains special escape sequences. +: For Code 128 only, process the special escape sequences `\^A`, `\^B` and `\^C` that allow manual switching of Code + Sets, and the special escape sequence `\^1` that inserts an `FNC1` character. The sequence `\^^` can be used to + encode data that contains special escape sequences. `--fast` diff --git a/frontend_qt/grpC128.ui b/frontend_qt/grpC128.ui index f5974ab2..9fec28d0 100644 --- a/frontend_qt/grpC128.ui +++ b/frontend_qt/grpC128.ui @@ -48,11 +48,12 @@