Commit graph

85 commits

Author SHA1 Message Date
gitlost
93c3e27fba CODE128: Add minimal encodation algorithm (non-extended ASCII only)
from ZXing (props Alex Geller) - about 25-60% slower depending on
  data & stack heavy but does improve some outcomes when FNC1s
  present (GS1_MODE or manual) although not much else it appears
  (the previous algorithm was very good), but has a logical clarity
  the other lacked - funcs `c128_dxsmooth()` etc shared with
  CODE16K now moved there and renamed as `c16k_`;
  also fix extended char latching when exactly 4 extended chars
  at end
  also manual code set switching now honoured exactly even if
  immediate shift required;
manual: make explicit that AI "(00)" and "(01)" prefixes added by
  Zint are HRT-only
general: add `extern "C"` wrappers to a few header files
2024-09-07 12:44:16 +01:00
gitlost
7246d67175 gs1/gs1_lint: update to latest gs1-syntax-dictionary, removing
`iso3166list` linter and adjusting all others to allow for
  multiple optional linters (by checking `data_len` vs `offset`)
library: change invalid `input_mode` reset to return warning;
  split func table into 2 - func declarations without prototype
  will be error in C23;
  make invalid symbology check a separate function using a table
  and call near beginning of `ZBarcode_Encode_Segs()`;
  in `ZBarcode_BarcodeName()` save some bytes by simplifying
  name table and removing "BARCODE_" prefix from entries
output: fix pack logic to use pragma by default (actually more
  portable than `__attribute__`)
common.h: remove C99 detection which was artifice of specifying
  "-std=", and rejig layout to be more logical
BWIPP: update to latest version
general: change `ZINT_VERSION_BUILD` tests to `#if`s
general: further fiddling with some tables to save a few bytes
CLI: change function arg `optarg` -> `arg` so doesn't shadow
  global
general: library now compilable with Comp Cert C (though as it
  doesn't support `alloca()` will have multiple memory leaks)
2024-06-27 23:00:13 +01:00
gitlost
eb035a6372 GUI: fix foreground/background picker invocations (broken
[f3a982c1dd])
AZTEC/CODE16K/CODEONE/DATAMATRIX/DBAR_EXP/GRIDMATRIX/HANXIN
/MAILMARK_4S/PDF417/MSI_PLESSEY/QRCODE/RMQR/TIF/ULTRA/USPS_IMAIL:
  lessen storage of some tables by using least integral size
  required (saves ~3K); reformat some tables, comments
AUSPOST/AZTEC: remove unnecessary int casts on array indexing
CODE11/CODE39: move start/stop chars into one entry in tables to
  save a few bytes; some reformatting, comments
CODEONE: add `c1_` prefixes
common: more precise compiler/version checks
composite: add `cc_` prefixes; UINT -> unsigned short; use
  `sizeof()` instead of `strlen()` for `in_linear_comp` static;
  some reformatting, comments
EMF: use table instead of string for `ultra_chars[]`
GIF: remove unnecessary cast
library: use `sizeof()` instead of `strlen()` for static;
  add `consts` to `escape_char_process()` & use unsigned for `ch`
DBAR: use `dbar_`, `dbar_ltd_`, `dbar_exp_` prefixes
docs: update pandoc version
2024-05-27 23:19:45 +01:00
gitlost
e167f5b534 test suite: zxing-cpp: adjust for returnCodabarStartEnd no-op;
allow for old "libpng" (`png_set_scale_16()` not available)
general: Solaris compat
library: use proper function ptr instead of `void *` for function
  table; warning suppression "-Wpedantic" -> "-Wstrict-prototypes"
GRIDMATRIX/HANXIN/QRCODE: `xx_define_mode()`: multi-dim `char_modes`
2024-02-06 13:01:35 +00:00
gitlost
1449866d18 CMake: check for getopt_long_only() instead of just getopt()
so behaviour of CLI same
general: AIX compat, suppress some warnings
2024-01-17 21:55:11 +00:00
gitlost
98f86727cc Add BARCODE_MEMORY_FILE to symbol->output_options to allow
outputting to in-memory buffer `symbol->memfile` instead of to
  file `symbol->outfile`, ticket #301
Add "README.clang-tidy" and ".clang-tidy" options file
Suppress some warnings
2023-12-27 19:20:19 +00:00
gitlost
888db0bf00 QRCODE: fix out-of-bounds crash due to incorrect mode costings for
GS1 percents in `qr_in_alpha()`, ticket #300, props Andre Maute;
  also defensively re-calc version 40 mode to prevent possible
  further crashes
common: move `debug_print_escape()` from library to common
2023-11-30 09:12:11 +00:00
gitlost
a14fe77aa0 EANX_CC/UPCA_CC: fix crash in dbar_date() on not checking length
in `cc_binary_string()`, ticket #300 (#5 & #6), props Andre Maute;
  add other checks for length on processing encoding mode
PDF417: fix out-of-bounds crash on overrunning string and codeword
  buffers by tripling size (convert to `short` instead of `int` to
  guard against too much stack), ticket #300 (#7 & #10), props Andre
  Maute; (TODO: add some checks instead to bail out earlier?)
CODEONE: fix looping on latch crash in `c1_encode()`, ticket #300 (#8),
  props Andre Maute
CODABLOCKF: fix crash on negative overflow of `columns` (`option_2`),
  ticket #300 (#9), props Andre Maute
library: add `debug_print_escape()` helper for ZINT_DEBUG_PRINT
2023-11-27 12:55:53 +00:00
gitlost
323b34502b zint.h: increase symbol->text size 160 -> 200;
rename `ZINT_CAP_EXTENDABLE` -> `ZINT_CAP_EANUPC`
  (`ZINT_CAP_EXTENDABLE` marked as legacy)
CODE128: increase no. symbol chars max 60 -> 99
EAN-2/EAN-5: fix `BARCODE_BIND_TOP/BIND/BOX` output
GS1_128: warn if data > 48 (GS1 General Specifications max)
common: `is_extendable()` -> `is_ucpean()`
raster: add `ZFONT_HALIGN_CENTRE/LEFT/RIGHT` flags and process
  in `draw_string()` (for drawing EAN/UPC outside digits), and
  for `ZFONT_HALIGN_CENTRE` round when calculating centre
  (shifts some texts 1 pixel left)
raster/vector: use offsets into `symbol->text` for EAN/UPC
  instead of `out_upcean_split_text()` (removed)
BMP/EMF/GIF/PCX/PNG/PS/SVG/TIF: use new `out_colour_get_rgb()`
  routine (replaces `colour_to_XXX()`)
general: simplify/fix some `error_number` handling/returning
frontend: truncate overlong `--primary` instead of ignoring;
  negative floating pt option (for `--textgap`)
man page: list size detail for matrix symbols (`--vers`)
manual: further fiddling with scaling text; some typos
2023-11-19 19:39:54 +00:00
gitlost
607e4ed33a EAN/UPC: add quiet zone indicators option (API output_options
`EANUPC_GUARD_WHITESPACE`, CLI `--guardwhitespace`) (ticket #287)
EAN-2/EAN-5: HRT now at top instead of at bottom for standalones,
  following BWIPP
CLI: batch mode: don't close input if stdin
EAN/UPC: fix excess 1X to right of add-ons
Composites: fix excess whitespace; fix quiet zone calcs to allow
  for linear shifting
CLI: use own (Wine) version of `CommandLineToArgvW()` to avoid
  loading "shell32.dll"
Move "font.h" -> "raster_font.h"
EPS/SVG: use new `out_putsf()` func to output floats, avoiding
  trailing zeroes & locale dependency
EPS: simplify "TR" formula
SVG: change font from "Helvetica, sans serif" to "OCR-B, monospace";
  use single "<path>" instead of multiple "<rect>"s to draw boxes
  (reduces file size)
Add `EMBED_VECTOR_FONT` to `output_options` (CLI `--embedfont`) to
  enable embedding of font in vector output - currently only for
  SVG output of EAN/UPC
GUI: use "OCR-B" font for EAN/UPC and "Arimo" for all others (was
  "Helvetica" for both); paint background of screen preview light
  grey so as contrasts with whitespace and quiet zones
EMF: prefix funcs with `emf_`; simplify string `halign` handling
large: rename `large_int` -> `large_uint`
CODE128/common: move `c128_hrt_cpy_iso8859_1()` to
  `hrt_cpy_iso8859_1()` and add `ZINT_WARN_HRT_TRUNCATED` warning
  (for future use)
Various symbologies: replace `printf()` with `fputs()`
  (symbol->debug)
QRCODE: better assert(), removing a NOLINT (2 left)
CLI: add some more barcode synonyms for DBAR
common: various fiddlings
CMake: don't include png.c unless ZINT_USE_PNG (avoids clang
  warning)
2023-06-12 01:25:55 +01:00
gitlost
e515f63fab - PDF417/MICROPDF417: use latch not ps shift for padding when
spanning Text segments to avoid affecting 1st char of 2nd segment
- PDF417/MICROPDF417: add optimized encoding, FAST_MODE for
  previous scheme; formatting changes
- common.c/h: add `cnt_digits()`, comments in include and make more
  consistent, minor code fiddling
- DOTCODE: replace `dc_n_digits()` with new `cnt_digits()`
- test_qr: fix `test_qr_perf()`
- composite: minor code fiddling
- library: debug dump HIBC-processed input
- BWIPP: update to latest
2022-11-06 22:25:19 +00:00
gitlost
d0cfabba84 common.h: define ZINT_IS_C89 as __STDC_VERSION__ not defined by MSVC
zintconfig.h: edit generator file zintconfig.h.in
2022-09-14 14:48:57 +01:00
gitlost
ee23f92151 common.h: only include alloca.h if C89 or NuttX 2022-09-13 17:29:15 +01:00
gitlost
0d4aa6cce3 common.h: allow for no alloca.h on BSD 2022-09-12 17:27:42 +01:00
Xiang Xiao
62f788ce03 fix warning: implicit declaration of function 'alloca'
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ib79f7cfa9a059a90687683a77e53a3b8f74712fe
2022-09-09 05:15:31 +08:00
gitlost
78bda3b359 test suite: update to latest BWIPP (add dontlint, rebase patch file)
common.h: remove TRUE/FALSE (barely used)
test suite: gs1: proper val for longitude test; some comments // -> /*
2022-07-18 20:30:31 +01:00
gitlost
930f458979 backend: define z_alloca() and use for both Unix and Windows;
replace double-slash comments with old-skool slash asterisk ones;
  define uint16_t etc for Windows ourselves and remove ms_stdint.h &
  stdint_msvc.h as no longer used;
  (backend (excepting test suite) now C89 compatible)
LICENSE: move from backend to root and move COPYING to frontend, with
  copies in frontend_qt & backend_qt, so in where it applies;
  add LICENSE section from manual to root README
2022-07-14 16:01:30 +01:00
gitlost
0b3fe8db93 GUI: remove sizeConstraint so squashable again (sigh)
- make Sequence Format textbox bigger (on own line)
  - suppress question mark in Windows dialogs
AUSPOST: more standard error messages
backend: add & use z_isdigit/upper/lower() macros
docs: 20-bit Unicode -> 21-bit Unicode
2022-06-24 14:38:48 +01:00
gitlost
e30e1f9651 RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
  certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
  rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
  button, independently movable picker (NULL parent), preview colour changes,
  preview Data Window changes, add clear data (del) buttons, add zap button
  and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
  UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
  various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-09 21:52:02 +01:00
gitlost
719613d4c3 GRIDMATRIX: default char set is GB 2312 only, not Latin-1 with GB 2312 alt
HANXIN/QRCODE: use Hanzi/Kanji modes when compatible ECIs given
manual: one true source now manual.pmd from which manual.txt is generated
CLI: man page moved from frontend/zint.1.gz to docs/zint.1.gz, now
  generated from docs/zint.1.pmd
add README.linux to root dir
2022-05-19 10:17:51 +01:00
gitlost
f58c80e290 Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
  better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
  namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-09 19:50:50 +01:00
gitlost
25807ad43c Matrix symbols: change horizontal boundary bars to appear outside any
vertical whitespace, as they're decorative rather than functional (#247)
Allow for dot overspill in height of vertical box sides (dotty mode)
Move is_dotty(), is_fixed_ratio() from library.c to common.c
2022-01-01 15:24:59 +00:00
gitlost
739a64a6ff GUI: add CLI equivalent dialog (#163); use spinboxes in Sequence dialog
and restrict sequence to max 10,000, add button icons;
   make Export dialog sizable and show every 100 results, add button icon;
   fix saving CHANNEL option, fix Export painting main window (Windows), fix
   guard descent not-resetting
 qzint: add getAsCLI(), warnLevel(), extra isStackable()/isComposite() etc
 Add ZBarcode_BarcodeName()
 manual: doc above, some fixes, tweaks
2021-11-23 19:12:48 +00:00
gitlost
fab7435fac Performance improvements for linear encoding and raster output
- use fixed-length string tables (mostly) instead of (char *) pointer ones
   (saves ~40K)
 - re-use C128Table for CODABLOCKF and CODE16K
   (required removal of Stop character and extra CODE16K-only entry)
 - use pointer to destination and copy (memcpy/strcpy(), bin_append_posn())
   instead of concatenating (strcat()) (mostly)
 - replace last remaining bin_append()s with bin_append_posn();
   bin_append() removed
 - add length arg to toupper() and expand() (avoids strlen())
 - change is_sane() to use table-based flags (avoids an iteration)
 - rename lookup() to is_sane_lookup() and change to check and return posns
   and use in pointer to destination loops (avoids strcat()s)
 - remove special case PHARMA in expand() (dealt with in pharma())
 - make #define SILVER/CALCIUM/TECHNETIUM/KRSET etc static strings
 - replace strchr() -> posn()
 - CODE128: populate destination once in checksum loop; re-use and export
   some more routines (c128_set_a/b/c(), c128_put_in_set()) for sharing;
   prefix defines (SHIFTA -> C128_SHIFTA etc) and existing exported routines
 - use factor XOR toggle trick in checksum calcs (avoids branch)
 - raster.c: fill out single 1-pixel row and copy using new draw_bar_line(),
   copy_bar_line() routines; similarly in buffer_plot compare previous line &
   copy if same (same technique as used to improve non-half-integer scaling,
   significant performance increase, (c) codemonkey82);
   also done for PNG (BMP/GIF/PCX/TIFF not done)
 - raster/vector/output.c: shorten "output_" prefix -> "out_";
   sync vector to other raster changes to try to keep source files similar
 - 2of5.c: prefix "c25_"
JAPANPOST: return error if input data truncated (backward incompatible)
DAFT: max chars 50 -> 100
common.c: istwodigit() -> is_twodigit()
common.c/emf.c/output.c: use some further stripf()s (MSVC6 float variations)
library.c: new check_output_args() helper
zint.h: add BARCODE_LAST marker and use in library.c
QRCODE: remove a NOLINT (requires clang-tidy-13), one remaining
CMake: separate no-optimize from ZINT_DEBUG into new ZINT_NOOPT option
2021-10-20 23:05:30 +01:00
gitlost
c0791ad85e Add Structured Append support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, MAXICODE, MICROPDF417, PDF417, QRCODE, ULTRA
DOTCODE: use pre-calculated generator poly coeffs in Reed-Solomon for
  performance improvement
PDF417/MICROPDF417: use common routine pdf417_initial()
GUI: code lines <= 118, shorthand widget_obj(),
  shorten calling upcean_addon_gap(), upcean_guard_descent()
various backend: var name debug -> debug_print
2021-09-28 21:42:44 +01:00
gitlost
eb6e5daa2d raster.c: need ceilf(large_bar_height * si) to avoid zero height rows;
also improve non-half-int interpolation performance
raster/vector.c: use new stripf() func in "common.c" to workaround gcc
  32-bit float calculation variations
gs1.c: allow dummy AI "[]" if GS1NOCHECK_MODE and has data (#204);
  also add note re TPX AI 235 and terminating FNC1
Remove trailing whitespace in various files
2021-09-26 23:55:16 +01:00
gitlost
3c1869b032 library: compat symbology 39 fix; ISBN: "X" check
WARN_FAIL_ALL: always return error: ZINT_ERROR_USES_ECI/NON_COMPLIANT
Fuller error messages; more comments zint.h
mainwindow.cpp: replace metaobject ENUM with array
  (suppresses virtual in constructor warning)
2021-07-06 19:53:31 +01:00
gitlost
a312cd8e8e raster/output: use new isfintf() to test floats integral (CodeQL) 2021-06-30 11:57:21 +01:00
gitlost
37fac73cb1 DATAMATRIX/CODEONE: Use LCM in look ahead tests to avoid floats (#228) 2021-06-29 22:02:24 +01:00
gitlost
e5115bad07 Change height and row_height array to floats: VC6, CodeQL fixes 2021-06-20 00:05:45 +01:00
gitlost
c693482aa1 Change height and row_height array to floats; DAFT tracker ratio 2021-06-19 13:11:23 +01:00
gitlost
4a8cac2a5a CODEONE/DATAMATRIX/MAILMARK/PLESSEY: fix some 32-bit/portability bugs
PLESSEY: add options NCR weighted mod-10, hide check digit(s) in HRT
test suite: now runnable under MSVC 2019, 2017, 2015, MinGW/MSYS
win32/README: update with MSVC 2019 and CMake instructions
2021-06-10 11:15:39 +01:00
Schaich
f471bb6e50 Export the INTERNAL functions
The testcommon library, which is outside of this link unit, is
referencing the INTERNAL functions, so despite the name they
need to be exported. The export code is copy&pasted from the
ZINT_EXTERN definition which can't be reused over preprocessor
limitations.

We might just use ZINT_EXTERN instead though
2021-06-02 21:14:14 +09:00
gitlost
2d962c6321 get_best_eci: check UTF-8 before returning 26; move is_valid_utf8 to common 2021-03-21 17:35:52 +00:00
gitlost
7fe930b4dc eci: Add support for all ECIs (Big5, Korean, UCS-2BE) 2021-01-11 18:11:41 +00:00
gitlost
bee5f08f50 #209 rss.c, composite.c; DBAR_EXP encodation methods; symbol NO_PNG out.gif 2020-12-21 19:30:07 +00:00
gitlost
2b85585e69 MAXICODE: scmvv option #212; postcode needn't be space-filled 2020-12-19 17:13:35 +00:00
gitlost
cd214addba HANXIN: 0xFFE terminator; reedsol/AZTEC: stack-based; AZTEC/HANXIN/QR/GRIDMATRIX speedups; #209 2020-11-27 12:54:44 +00:00
Robin Stuart
3eb31fe3f8 Take version information from CmakeLists.txt
Warning: potential incompatibility because version number is no longer stored in zint.h
2020-11-22 11:29:45 +00:00
gitlost
44923349f3 PDF417/raster: performance large data; common.h inline, module_colour_is_set(); #209 2020-11-01 18:32:55 +00:00
gitlost
36c19053d7 vector.c: string halign; POSTNET/PLANET: 1 module space; ZBarcode_Cap(); GUI settings 2020-09-30 12:19:12 +01:00
Robin Stuart
b5e27d3e0b Better compression for Ultracode in BMP
Also corrects colour shifting bug
File size is still bigger than it needs to be for Ultracode, but now uses 4bpp
2020-08-12 13:19:56 +01:00
gitlost
980e039743 command line: avoid arg_opts buffer overflow if -d/i used without space before arg 2020-08-05 15:58:21 +01:00
gitlost
c1fb51ba42 rss.c: some fixes for separators, allow check digit, refactoring; bwipp_dump.ps 2020-07-10 19:39:32 +01:00
gitlost
d921cb11fb Windows: #196 MinGW/MSYS instructions; INTERNAL and printf %zu Windows-compat fixes 2020-06-18 15:51:57 +01:00
gitlost
e8a238aad1 large.c: replace binary_load/add() etc with uint64_t based large_load/add() etc for performance 2020-06-14 14:42:40 +01:00
gitlost
6242e02638 CODEONE/ULTRA overrun fixes; TELEPEN fixes; CODEONE/LOGMARS/VIN/CODABAR options; GUI updates; tests 2020-06-04 18:45:25 +01:00
gitlost
e04f662dc0 ULTRA: enable compression for GS1_MODE; compression changes; fixes; tests 2020-04-09 22:08:54 +01:00
gitlost
bca82ecc0d libzint.so: suppress exporting INTERNAL functions to the shared library; ZINT_TEST 2019-12-19 00:37:55 +00:00
gitlost
e331fd1e90 QR optimize encoding modes 2019-12-16 17:31:52 +00:00