ruby-zint 1.4.1 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 64af83d59b1d29bdae5808430c36817e3517bee6cd7bbd34147cb377cccc02b2
4
- data.tar.gz: 17a44a73c35894b6b7f7f8b884e18fa622400746cf9331c19e68b43994a2f958
3
+ metadata.gz: b952e9f08564e922af202d914688cf69a6d1fb424c09f8f0b28a623ae181a1b7
4
+ data.tar.gz: d480672da3110d322d84395ca8e5cb3f43e0c6433dc6170b1953e370dd0d88dc
5
5
  SHA512:
6
- metadata.gz: 580e3329db01adf7bae175780221cc3dbdbb45f4578e439e6c1cb6425e28ca7b0118f11576cb463d8588da6298ccf963f7edf481cba15b6b37d2d902bb1280b7
7
- data.tar.gz: ce7b11a96fd7ce11a16ecd97b4b479beb2a2ca09eb67da67409096b0b0a6b1eedd77eb1059b3cd9894ec426b36df9f6ef5bd52720eb39b75b2db7e47276eaa33
6
+ metadata.gz: c1aec4ba89a8117bf44121f427bf067ae15eb1df8f2d113c6d78dbb5d5fc866c344c499ca0de4dae69dc65691bd208893126315de462ab7d5836e86ebfa54841
7
+ data.tar.gz: '0619a5512ca7ba501f63e90c84015ddd28c6256cf162904e47b0d2ce869c1803ad0b2b5d575cc20af2a49985f9b997cf549b5c1b96ed6129f14901b840a62fed'
data/README.md CHANGED
@@ -8,26 +8,44 @@ See the [documentation](https://rubydoc.info/github/api-walker/ruby-zint) for a
8
8
 
9
9
  ## Installation
10
10
 
11
+ Install via RubyGems:
12
+
13
+ gem install ruby-zint
14
+
15
+ This installs the binary gem, specific to the running platform by default.
16
+
17
+ ### Binary gem
18
+
19
+ The binary gems don't depend on the libzint package on the running system or on CMake or libpng.
20
+ They have libzint builtin and should just work.
21
+
22
+ ### Source gem
23
+
24
+ If for some reason the binary gem doesn't work for you, the source gem can be installed alternatively.
25
+ It can be forced by:
26
+
27
+ gem uninstall ruby-zint --all
28
+ gem install ruby-zint --platform ruby
29
+
11
30
  By default ruby-zint first tries to use libzint installed on the system.
12
- If libzint can't be found or if it isn't a supported version, then the zint version, bundled into the gem, is compiled and used.
31
+ If libzint can't be found or if it isn't a supported version, then the zint version, bundled into the gem, is compiled and used instead.
13
32
  Both install methods can be enforced by using `--enable-system-libzint` or `--disable-system-libzint` options, see below.
14
33
 
15
- ### With libzint source code (recommended)
34
+ #### With libzint source code (recommended)
16
35
  First install CMake with your package manager (e. g. `apt install cmake`).
17
-
36
+ Please also install libpng (e. g. `apt install libpng-dev`) before installing the gem if you want to use the PNG format.
18
37
  Afterwards install the gem and force builtin libzint:
19
38
 
20
39
  ```
21
40
  $ gem install ruby-zint -- --disable-system-libzint
22
41
  ```
23
42
 
24
- ### With system libraries
43
+ #### With system libraries
25
44
 
26
45
  Install the libzint binary with your package manager (e. g. `apt install zint` or perhaps `brew install zint`).
27
-
28
46
  Other platforms require building [from source](https://www.zint.org.uk/manual/chapter/2).
29
47
 
30
- **NOTE:** It is assumed that you are using libzint with the version [2.12](https://sourceforge.net/projects/zint/files/zint/2.12.0/).
48
+ **NOTE:** It is assumed that you are using libzint with the version [2.15](https://sourceforge.net/projects/zint/files/zint/2.15.0/).
31
49
 
32
50
  Then install this gem and enforce system libzint:
33
51
 
@@ -38,15 +56,29 @@ $ gem install ruby-zint -- --enable-system-libzint
38
56
  ### Gemfile
39
57
 
40
58
  Include `gem "ruby-zint"` in your Gemfile.
41
- Optionally set the install option by running bundler like so:
59
+ To make sure, the necessary platforms and the source gem are fetched by bundler, they can be added like so
42
60
 
43
61
  ```
44
- bundle config build.ruby-zint --enable-system-libzint
62
+ bundle lock --add-platform x86_64-linux-gnu
63
+ bundle lock --add-platform arm64-darwin
64
+ bundle lock --add-platform x64-mingw-ucrt
65
+ bundle lock --add-platform ruby
66
+ bundle package --all-platforms
67
+ ```
68
+
69
+ A re-run of `bundle package` is also necessary after `bundle update`, in order to retrieve the new specific gems of all platforms.
70
+
71
+ If the binary gems don't work for some reason, it's easy to force the usage of the source gem in the Gemfile:
72
+
73
+ ```
74
+ gem "ruby-zint", force_ruby_platform: true
45
75
  ```
46
76
 
47
- ### PNG support
77
+ Optionally set the install option by running bundler like so:
48
78
 
49
- Please install libpng (e. g. `apt install libpng-dev`) before installing the gem if you want to use the PNG format.
79
+ ```
80
+ bundle config build.ruby-zint --enable-system-libzint
81
+ ```
50
82
 
51
83
  ## Usage
52
84
 
@@ -45,20 +45,41 @@ def libzint_usable?
45
45
  m = Module.new do
46
46
  extend FFI::Library
47
47
 
48
- ffi_lib(%w[libzint.so.2.12 libzint zint])
48
+ ffi_lib(%w[libzint.so.2.15 libzint zint])
49
49
  attach_function(:ZBarcode_Version, [], :int32)
50
50
  end
51
51
 
52
- (21200...21300) === m.ZBarcode_Version
52
+ (21500...21600) === m.ZBarcode_Version
53
53
  rescue LoadError
54
54
  false
55
55
  end
56
56
 
57
57
  def build_bundled_libzint
58
- puts "Build"
58
+ puts "Build libzint and dependencies"
59
59
  require_relative "../../lib/zint/zint_recipe"
60
60
 
61
- recipe = Zint::ZintRecipe.new
61
+ recipe_zlib = Zint::ZintRecipe.new("zlib", Zint::LIBZ_VERSION, Zint::LIBZ_SOURCE_URI, Zint::LIBZ_SOURCE_SHA1)
62
+ recipe_zlib.configure_options += [
63
+ "-DCMAKE_C_FLAGS=-fPIC",
64
+ "-DZLIB_SHARED=OFF"
65
+ ]
66
+ recipe_zlib.cook_and_activate
67
+
68
+ recipe_png = Zint::ZintRecipe.new("libpng", Zint::LIBPNG_VERSION, Zint::LIBPNG_SOURCE_URI, Zint::LIBPNG_SOURCE_SHA1)
69
+ recipe_png.configure_options += [
70
+ "-DCMAKE_C_FLAGS=-fPIC",
71
+ "-DZLIB_ROOT=#{recipe_zlib.path}",
72
+ "-DPNG_SHARED=OFF"
73
+ ]
74
+ recipe_png.cook_and_activate
75
+
76
+ recipe = Zint::ZintRecipe.new("libzint", Zint::ZINT_VERSION, Zint::ZINT_SOURCE_URI, Zint::ZINT_SOURCE_SHA1)
77
+ recipe.configure_options += [
78
+ "-DZLIB_INCLUDE_DIR=#{recipe_zlib.path}/include",
79
+ "-DZLIB_LIBRARY=#{recipe_zlib.path}/lib/#{(RUBY_PLATFORM =~ /mingw/) ? "libzlibstatic.a" : "libz.a"}",
80
+ "-DPNG_PNG_INCLUDE_DIR=#{recipe_png.path}/include",
81
+ "-DPNG_LIBRARY=#{recipe_png.path}/lib/libpng.a"
82
+ ]
62
83
  recipe.cook_and_activate
63
84
  recipe.path
64
85
  end
@@ -69,6 +90,11 @@ unless enable_config("system-libzint", libzint_usable?)
69
90
  libzint_path = build_bundled_libzint
70
91
  end
71
92
 
93
+ if libzint_path
94
+ # For cross compiled gem
95
+ FileUtils.cp Dir["#{libzint_path}/*/libzint.*"].first, "libzint.#{RbConfig::CONFIG["DLEXT"]}", verbose: true
96
+ end
97
+
72
98
  # Create a Makefile which copies the libzint library files to the gem's lib dir.
73
99
  File.open("Makefile", "wb") do |mf|
74
100
  mf.puts <<~EOT
@@ -79,6 +105,7 @@ File.open("Makefile", "wb") do |mf|
79
105
  EOT
80
106
 
81
107
  if libzint_path
108
+ # Only executed in source build
82
109
  mf.puts <<-EOT
83
110
  cp -r #{libzint_path.dump}/*/libzint* $(RUBYARCHDIR)
84
111
  EOT
data/lib/zint/barcode.rb CHANGED
@@ -16,10 +16,11 @@ module Zint
16
16
 
17
17
  # @param value [String, NilClass] Content of the barcode
18
18
  # @param input_file [String, NilClass] Path to input file with content of the barcode
19
+ # @param segments [Array<Hash>, NilClass] Array of ECI segments to encode
19
20
  # @param symbology [Integer] Type of barcode
20
21
  # @param kwargs [Hash] Specific options for zint symbol (height, scale, ...)
21
- def initialize(value: nil, input_file: nil, symbology: Zint::BARCODE_CODE128, **kwargs)
22
- raise ArgumentError, "value or input_file must be given!" if value&.empty? && input_file&.empty?
22
+ def initialize(value: nil, input_file: nil, segments: nil, symbology: Zint::BARCODE_CODE128, **kwargs)
23
+ raise ArgumentError, "value, input_file or segments must be given!" if value&.empty? && input_file&.empty? && segments.nil?
23
24
  raise ArgumentError, "input_file not found!" if input_file && !File.exist?(input_file)
24
25
 
25
26
  @zint_symbol = Native.ZBarcode_Create
@@ -30,6 +31,7 @@ module Zint
30
31
 
31
32
  @value = value
32
33
  @input_file = input_file
34
+ encode_segments(segments)
33
35
  end
34
36
 
35
37
  # Exports barcode to file
@@ -46,6 +48,8 @@ module Zint
46
48
 
47
49
  if input_file
48
50
  call_function(:ZBarcode_Encode_File_and_Print, @zint_symbol, input_file, rotate_angle)
51
+ elsif @p_segments
52
+ call_seg_function(:ZBarcode_Encode_Segs_and_Print, rotate_angle)
49
53
  else
50
54
  call_function(:ZBarcode_Encode_and_Print, @zint_symbol, value, value.bytesize, rotate_angle)
51
55
  end
@@ -57,17 +61,11 @@ module Zint
57
61
  # @param rotate_angle [Integer] Rotate angle in degrees (0, 90, 180, 270)
58
62
  # @return [String] Exported memory file
59
63
  def to_memory_file(extension: ".png", rotate_angle: 0)
60
- require "tempfile"
61
- file = Tempfile.new(["zint", extension])
64
+ @zint_symbol[:output_options] = Zint::BARCODE_MEMORY_FILE
62
65
 
63
- to_file(path: file.path, rotate_angle: rotate_angle)
66
+ to_file(path: extension, rotate_angle: rotate_angle)
64
67
 
65
- file.rewind
66
- buffer = file.read
67
- file.close
68
- file.unlink
69
-
70
- buffer
68
+ @zint_symbol[:memfile].read_bytes(@zint_symbol[:memfile_size])
71
69
  end
72
70
 
73
71
  # Exports barcode to buffer
@@ -82,6 +80,8 @@ module Zint
82
80
 
83
81
  if input_file
84
82
  call_function(:ZBarcode_Encode_File_and_Buffer, @zint_symbol, input_file, rotate_angle)
83
+ elsif @p_segments
84
+ call_seg_function(:ZBarcode_Encode_Segs_and_Buffer, rotate_angle)
85
85
  else
86
86
  call_function(:ZBarcode_Encode_and_Buffer, @zint_symbol, value, value.bytesize, rotate_angle)
87
87
  end
@@ -116,6 +116,8 @@ module Zint
116
116
  end
117
117
  if input_file
118
118
  call_function(:ZBarcode_Encode_File_and_Buffer_Vector, @zint_symbol, input_file, rotate_angle)
119
+ elsif @p_segments
120
+ call_seg_function(:ZBarcode_Encode_Segs_and_Buffer_Vector, rotate_angle)
119
121
  else
120
122
  call_function(:ZBarcode_Encode_and_Buffer_Vector, @zint_symbol, value, value.bytesize, rotate_angle)
121
123
  end
@@ -134,6 +136,8 @@ module Zint
134
136
  def encode
135
137
  if input_file
136
138
  call_function(:ZBarcode_Encode_File, @zint_symbol, input_file)
139
+ elsif @p_segments
140
+ call_seg_function(:ZBarcode_Encode_Segs)
137
141
  else
138
142
  call_function(:ZBarcode_Encode, @zint_symbol, value, value.bytesize)
139
143
  end
@@ -314,18 +318,6 @@ module Zint
314
318
  @zint_symbol[:show_hrt] = show_hrt
315
319
  end
316
320
 
317
- # Gets font size of barcode
318
- def fontsize
319
- @zint_symbol[:fontsize]
320
- end
321
-
322
- # Sets font size of barcode (Unused)
323
- #
324
- # @param fontsize [Integer] Font size of barcode
325
- def fontsize=(fontsize)
326
- @zint_symbol[:fontsize] = fontsize
327
- end
328
-
329
321
  # Gets input mode of barcode
330
322
  def input_mode
331
323
  @zint_symbol[:input_mode]
@@ -388,7 +380,7 @@ module Zint
388
380
 
389
381
  # Human Readable Text, which usually consists of input data plus one more check digit. Uses UTF-8 formatting.
390
382
  def text
391
- @zint_symbol[:text].to_s.force_encoding(Encoding::UTF_8)
383
+ @zint_symbol[:text].to_ptr.read_bytes(@zint_symbol[:text_length]).force_encoding(Encoding::UTF_8)
392
384
  end
393
385
 
394
386
  # Gets rows of barcode
@@ -479,11 +471,6 @@ module Zint
479
471
  @zint_symbol[:bitmap_height]
480
472
  end
481
473
 
482
- # Gets bitmap byte length of barcode
483
- def bitmap_byte_length
484
- @zint_symbol[:bitmap_byte_length]
485
- end
486
-
487
474
  # Gets dot size of barcode
488
475
  def dot_size
489
476
  @zint_symbol[:dot_size]
@@ -535,5 +522,29 @@ module Zint
535
522
 
536
523
  error_code
537
524
  end
525
+
526
+ def call_seg_function(function_name, *args)
527
+ call_function(function_name, @zint_symbol, @p_segments, @p_strings.size, *args)
528
+ end
529
+
530
+ def encode_segments(segments)
531
+ @p_segments = nil
532
+ return unless segments
533
+
534
+ raise ArgumentError, "segments must be Array<Hash<source: String, eci: Integer>>!" if !segments.is_a?(Array) || !segments.first.is_a?(Hash)
535
+
536
+ @p_segments = FFI::MemoryPointer.new Structs::Seg, segments.size
537
+ @p_strings = [] # Prevent garbage collection
538
+ segments.each_with_index do |seg, sidx|
539
+ p_seg = Structs::Seg.new(@p_segments + Structs::Seg.size * sidx)
540
+ source = seg[:source] || raise(ArgumentError, ":source not defined")
541
+ eci = seg[:eci] || raise(ArgumentError, ":eci not defined")
542
+
543
+ @p_strings << FFI::MemoryPointer.from_string(source)
544
+ p_seg[:source] = @p_strings.last
545
+ p_seg[:length] = source.bytesize
546
+ p_seg[:eci] = eci
547
+ end
548
+ end
538
549
  end
539
550
  end
@@ -12,7 +12,8 @@ module Zint
12
12
  error_memory: 11,
13
13
  error_file_write: 12,
14
14
  error_uses_eci: 13,
15
- error_noncompliant: 14
15
+ error_noncompliant: 14,
16
+ error_hrt_truncated: 15 # Error counterpart of warning if WARN_FAIL_ALL set */
16
17
  }
17
18
  end
18
19
  end
@@ -10,6 +10,7 @@ module Zint
10
10
  GS1NOCHECK_MODE = 0x0020 # Do not check validity of GS1 data (except that printable ASCII only)
11
11
  HEIGHTPERROW_MODE = 0x0040 # Interpret `height` as per-row rather than as overall height
12
12
  FAST_MODE = 0x0080 # Use faster if less optimal encodation or other shortcuts if available (affects DATAMATRIX, MICROPDF417, PDF417, QRCODE & UPNQR only)
13
+ EXTRA_ESCAPE_MODE = 0x0100 # Process special symbology-specific escape sequences as well as others. Note: currently Code 128 only.
13
14
  end
14
15
  end
15
16
  end
@@ -16,6 +16,9 @@ module Zint
16
16
  BARCODE_QUIET_ZONES = 0x0800 # Add compliant quiet zones (additional to any specified whitespace); Note: CODE16K, CODE49, CODABLOCKF, ITF14, EAN/UPC have default quiet zones */
17
17
  BARCODE_NO_QUIET_ZONES = 0x1000 # Disable quiet zones, notably those with defaults as listed above */
18
18
  COMPLIANT_HEIGHT = 0x2000 # Warn if height not compliant and use standard height (if any) as default */
19
+ EANUPC_GUARD_WHITESPACE = 0x04000 # Add quiet zone indicators ("<"/">") to HRT whitespace (EAN/UPC) */
20
+ EMBED_VECTOR_FONT = 0x08000 # Embed font in vector output - currently only for SVG output */
21
+ BARCODE_MEMORY_FILE = 0x10000 # Write output to in-memory buffer `memfile` instead of to `outfile` */
19
22
  end
20
23
  end
21
24
  end
@@ -4,6 +4,7 @@ module Zint
4
4
  module SpecificOptions
5
5
  DM_SQUARE = 100 # Only consider square versions on automatic symbol size selection
6
6
  DM_DMRE = 101 # Consider DMRE versions on automatic symbol size selection
7
+ DM_ISO_144 = 128 # Use ISO instead of "de facto" format for 144x144 (i.e. don't skew ECC)
7
8
 
8
9
  ZINT_FULL_MULTIBYTE = 200 # Enable Kanji/Hanzi compression for Latin-1 & binary data
9
10
  ULTRA_COMPRESSION = 128 # Enable Ultracode compression (experimental)
@@ -131,7 +131,8 @@ module Zint
131
131
  BARCODE_ULTRA = 144 # Ultracode
132
132
  BARCODE_RMQR = 145 # Rectangular Micro QR Code (rMQR)
133
133
  BARCODE_BC412 = 146 # IBM BC412 (SEMI T1-95)
134
- BARCODE_LAST = 146 # Max barcode number marker, not barcode
134
+ BARCODE_DXFILMEDGE = 147 # DX Film Edge Barcode on 35mm and APS films
135
+ BARCODE_LAST = 147 # Max barcode number marker, not barcode
135
136
  end
136
137
  end
137
138
  end
@@ -1,7 +1,15 @@
1
1
  module Zint
2
- ZINT_VERSION = ENV["ZINT_VERSION"] || "2.12.0"
2
+ LIBZ_VERSION = ENV["LIBZ_VERSION"] || "1.3.1"
3
+ LIBZ_SOURCE_URI = "http://zlib.net/fossils/zlib-#{LIBZ_VERSION}.tar.gz"
4
+ LIBZ_SOURCE_SHA1 = "f535367b1a11e2f9ac3bec723fb007fbc0d189e5"
5
+
6
+ ZINT_VERSION = ENV["ZINT_VERSION"] || "2.15.0"
3
7
  ZINT_SOURCE_URI = "https://downloads.sourceforge.net/zint/zint-#{ZINT_VERSION}-src.tar.gz"
4
- ZINT_SOURCE_SHA1 = "6e16036d9822895edededd96e65da755ef3fdb69"
8
+ ZINT_SOURCE_SHA1 = "e18966972d77feaa62a33d73d2f06ffec3356f66"
9
+
10
+ LIBPNG_VERSION = ENV["LIBPNG_VERSION"] || "1.6.50"
11
+ LIBPNG_SOURCE_URI = "https://netcologne.dl.sourceforge.net/project/libpng/libpng16/#{LIBPNG_VERSION}/libpng-#{LIBPNG_VERSION}.tar.xz"
12
+ LIBPNG_SOURCE_SHA1 = "ecd92ba84628a8ace430706c85fd2fb26ba0882c"
5
13
 
6
14
  MINI_PORTILE_VERSION = "~> 2.1"
7
15
  end
@@ -0,0 +1,8 @@
1
+ module Zint
2
+ # DX Film Edge Barcode on 35mm and APS films
3
+ class Dxfilmedge < Barcode
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_DXFILMEDGE, **kwargs)
6
+ end
7
+ end
8
+ end
data/lib/zint/native.rb CHANGED
@@ -5,7 +5,9 @@ module Zint
5
5
  root_path = File.expand_path("../../..", __FILE__)
6
6
  prefix = FFI::Platform::LIBPREFIX.empty? ? "lib" : FFI::Platform::LIBPREFIX
7
7
  bundled_dll = File.join(root_path, "lib/#{prefix}zint.#{FFI::Platform::LIBSUFFIX}")
8
- ffi_lib [bundled_dll, "libzint.so.2.12", "libzint", "zint"]
8
+ native_gem1 = File.join(root_path, "lib/3.4/libzint.#{RbConfig::CONFIG["DLEXT"]}") # This is where rake-compiler places the file in the gem
9
+ native_gem2 = File.join(root_path, "lib/3.0/libzint.#{RbConfig::CONFIG["DLEXT"]}") # ... for non-ucrt windows builds
10
+ ffi_lib [bundled_dll, native_gem1, native_gem2, "libzint.so.2.15", "libzint", "zint"]
9
11
 
10
12
  # Error codes (API return values)
11
13
  enum :error_code, [Constants::Warnings::WARNINGS, Constants::Errors::ERRORS].map { |h| h.to_a }.flatten
@@ -63,6 +65,23 @@ module Zint
63
65
  # Encode a symbol using input data from file `filename` and output to memory as vector (`symbol->vector`)
64
66
  attach_function(:ZBarcode_Encode_File_and_Buffer_Vector, [:zint_symbol, :filename, :rotate_angle], :error_code, blocking: true)
65
67
 
68
+ # ********* Segment support *********
69
+ # int ZBarcode_Encode_Segs(struct zint_symbol *symbol,
70
+ # const struct zint_seg segs[], const int seg_count);
71
+ attach_function(:ZBarcode_Encode_Segs, [:zint_symbol, :pointer, :int], :error_code, blocking: true)
72
+
73
+ # int ZBarcode_Encode_Segs_and_Print(struct zint_symbol *symbol,
74
+ # const struct zint_seg segs[], const int seg_count, int rotate_angle);
75
+ attach_function(:ZBarcode_Encode_Segs_and_Print, [:zint_symbol, :pointer, :int, :rotate_angle], :error_code, blocking: true)
76
+
77
+ # int ZBarcode_Encode_Segs_and_Buffer(struct zint_symbol *symbol,
78
+ # const struct zint_seg segs[], const int seg_count, int rotate_angle);
79
+ attach_function(:ZBarcode_Encode_Segs_and_Buffer, [:zint_symbol, :pointer, :int, :rotate_angle], :error_code, blocking: true)
80
+
81
+ # int ZBarcode_Encode_Segs_and_Buffer_Vector(struct zint_symbol *symbol,
82
+ # const struct zint_seg segs[], const int seg_count, int rotate_angle);
83
+ attach_function(:ZBarcode_Encode_Segs_and_Buffer_Vector, [:zint_symbol, :pointer, :int, :rotate_angle], :error_code, blocking: true)
84
+
66
85
  # Is `symbol_id` a recognized symbology?
67
86
  attach_function(:ZBarcode_ValidID, [:symbol_id], :bool, blocking: true)
68
87
 
@@ -0,0 +1,26 @@
1
+ module Zint
2
+ module Structs
3
+ class Seg < FFI::Struct
4
+ # /* Segment for use with `raw_segs` and API `ZBarcode_Encode_Segs()` */
5
+ # struct zint_seg {
6
+ # unsigned char *source; /* Data to encode, or (`raw_segs`) data encoded */
7
+ # int length; /* Length of `source`. If 0 or negative, `source` must be NUL-terminated */
8
+ # int eci; /* Extended Channel Interpretation */
9
+ # };
10
+
11
+ layout :source, :pointer, # Data to encode, or (`raw_segs`) data encoded
12
+ :length, :int, # Length of `source`. If 0 or negative, `source` must be NUL-terminated
13
+ :eci, :int # Extended Channel Interpretation
14
+
15
+ # Data to encode, or (`raw_segs`) data encoded
16
+ def source
17
+ self[:source].read_bytes(self[:length])
18
+ end
19
+
20
+ # Extended Channel Interpretation
21
+ def eci
22
+ self[:eci]
23
+ end
24
+ end
25
+ end
26
+ end
@@ -8,8 +8,8 @@ module Zint
8
8
  :whitespace_height, :int, # Height in X-dimensions of whitespace above & below the barcode
9
9
  :border_width, :int, # Size of border in X-dimensions
10
10
  :output_options, :int, # Various output parameters (bind, box etc, see below)
11
- :fgcolour, [:char, 10], # Foreground as RGB/RGBA hexadecimal string, 6 or 8 characters, NUL-terminated
12
- :bgcolour, [:char, 10], # Background as RGB/RGBA hexadecimal string, 6 or 8 characters, NUL-terminated
11
+ :fgcolour, [:char, 16], # Foreground as RGB/RGBA hexadecimal string, 6 or 8 characters, NUL-terminated
12
+ :bgcolour, [:char, 16], # Background as RGB/RGBA hexadecimal string, 6 or 8 characters, NUL-terminated
13
13
  :fgcolor, :pointer, # Pointer to fgcolour (alternate spelling)
14
14
  :bgcolor, :pointer, # Pointer to bgcolour (alternate spelling)
15
15
  :outfile, [:char, 256], # Name of file to output to, NUL-terminated. Default "out.png" ("out.gif" if NO_PNG)
@@ -18,16 +18,17 @@ module Zint
18
18
  :option_2, :int, # Symbol-specific options
19
19
  :option_3, :int, # Symbol-specific options
20
20
  :show_hrt, :int, # Show (1) or hide (0) Human Readable Text (HRT). Default 1
21
- :fontsize, :int, # Unused
22
21
  :input_mode, :int, # Encoding of input data (see DATA_MODE etc below). Default DATA_MODE
23
22
  :eci, :int, # Extended Channel Interpretation. Default 0 (none)
24
23
  :dpmm, :float, # Resolution of output in dots per mm (BMP/EMF/PCX/PNG/TIF only). Default 0 (none)
25
24
  :dot_size, :float, # Size of dots used in BARCODE_DOTTY_MODE. Default 0.8
25
+ :text_gap, :float, # float text_gap; /* Gap between barcode and text (HRT) in X-dimensions. Default 1 */
26
26
  :guard_descent, :float, # Height in X-dimensions that EAN/UPC guard bars descend. Default 5
27
27
  :structapp, Structapp, # Structured Append info. Default structapp.count 0 (none)
28
28
  :warn_level, :int, # Affects error/warning value returned by Zint API (see WARN_XXX below)
29
29
  :debug, :int, # Debugging flags
30
- :text, [:uchar, 128], # Human Readable Text (if any), UTF-8, NUL-terminated (output only)
30
+ :text, [:uchar, 256], # Human Readable Text (if any), UTF-8, NUL-terminated (output only)
31
+ :text_length, :int, # int text_length; /* Length of text in bytes (output only) */
31
32
  :rows, :int, # Number of rows used by the symbol (output only)
32
33
  :width, :int, # Width of the generated symbol (output only)
33
34
  :encoded_data, [:uchar, 200 * 144], # Encoded data (output only). Allows for rows of 1152 modules
@@ -37,8 +38,15 @@ module Zint
37
38
  :bitmap_width, :int, # Width of bitmap image (raster output only)
38
39
  :bitmap_height, :int, # Height of bitmap image (raster output only)
39
40
  :alphamap, :pointer, # Array of alpha values used (raster output only)
40
- :bitmap_byte_length, :uchar, # Size of BMP bitmap data (raster output only)
41
- :vector, Vector.by_ref # Pointer to vector header (vector output only)
41
+ :vector, Vector.by_ref, # Pointer to vector header (vector output only)
42
+ :memfile, :pointer, # unsigned char *memfile; /* Pointer to in-memory file buffer if BARCODE_MEMORY_FILE (output only) */
43
+ :memfile_size, :int # int memfile_size; /* Length of in-memory file buffer (output only) */
44
+
45
+ # Upcomming zint-2.16:
46
+ # struct zint_seg *raw_segs; /* Pointer to array of raw segs if BARCODE_RAW_TEXT (output only) */
47
+ # :raw_segs, Seg.by_ref,
48
+ # int raw_seg_count; /* Number of `raw_segs` (output only) */
49
+ # :raw_seg_count, :int
42
50
 
43
51
  # @private
44
52
  def self.release(ptr)
data/lib/zint/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Zint
2
- VERSION = "1.4.1"
2
+ VERSION = "1.5.0"
3
3
  end
@@ -8,14 +8,18 @@ module Zint
8
8
  class ZintRecipe < MiniPortileCMake
9
9
  ROOT = File.expand_path("../../..", __FILE__)
10
10
 
11
- def initialize
12
- super("libzint", ZINT_VERSION)
11
+ def initialize(name, vers, url, sha1)
12
+ super(name, vers)
13
13
  self.target = File.join(ROOT, "ports")
14
- self.files = [url: ZINT_SOURCE_URI, sha1: ZINT_SOURCE_SHA1]
14
+ self.files = [url: url, sha1: sha1]
15
+ end
16
+
17
+ def port_path
18
+ "#{target}/#{RUBY_PLATFORM}"
15
19
  end
16
20
 
17
21
  def cook_and_activate
18
- checkpoint = File.join(target, "#{name}-#{version}-#{host}.installed")
22
+ checkpoint = File.join(target, "#{name}-#{version}-#{RUBY_PLATFORM}.installed")
19
23
  unless File.exist?(checkpoint)
20
24
  cook
21
25
  FileUtils.touch checkpoint
data/lib/zint.rb CHANGED
@@ -20,6 +20,7 @@ require "zint/structs/vector_hexagon"
20
20
  require "zint/structs/vector_rect"
21
21
  require "zint/structs/vector_string"
22
22
  require "zint/structs/vector"
23
+ require "zint/structs/seg"
23
24
  require "zint/structs/structapp"
24
25
  require "zint/structs/symbol"
25
26
  require "zint/native"
@@ -82,6 +83,7 @@ module Zint
82
83
  autoload :Dpd, "zint/dpd"
83
84
  autoload :Dpident, "zint/dpident"
84
85
  autoload :Dpleit, "zint/dpleit"
86
+ autoload :Dxfilmedge, "zint/dxfilmedge"
85
87
  autoload :Ean128, "zint/ean128"
86
88
  autoload :Ean14, "zint/ean14"
87
89
  autoload :Eanx, "zint/eanx"
Binary file
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-zint
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elias Fröhner
@@ -88,6 +88,7 @@ extra_rdoc_files:
88
88
  - lib/zint/dpd.rb
89
89
  - lib/zint/dpident.rb
90
90
  - lib/zint/dpleit.rb
91
+ - lib/zint/dxfilmedge.rb
91
92
  - lib/zint/ean128.rb
92
93
  - lib/zint/ean14.rb
93
94
  - lib/zint/eanx.rb
@@ -153,13 +154,9 @@ extra_rdoc_files:
153
154
  - lib/zint/vin.rb
154
155
  - lib/zint/zint_recipe.rb
155
156
  files:
156
- - ".rspec"
157
- - ".standard.yml"
158
157
  - ".yardopts"
159
- - Gemfile
160
158
  - LICENSE.txt
161
159
  - README.md
162
- - Rakefile
163
160
  - ext/ruby-zint/extconf.rb
164
161
  - lib/ruby-zint.rb
165
162
  - lib/zint.rb
@@ -215,6 +212,7 @@ files:
215
212
  - lib/zint/dpd.rb
216
213
  - lib/zint/dpident.rb
217
214
  - lib/zint/dpleit.rb
215
+ - lib/zint/dxfilmedge.rb
218
216
  - lib/zint/ean128.rb
219
217
  - lib/zint/ean14.rb
220
218
  - lib/zint/eanx.rb
@@ -266,6 +264,7 @@ files:
266
264
  - lib/zint/rssexp.rb
267
265
  - lib/zint/rssexpstack.rb
268
266
  - lib/zint/rssltd.rb
267
+ - lib/zint/structs/seg.rb
269
268
  - lib/zint/structs/structapp.rb
270
269
  - lib/zint/structs/symbol.rb
271
270
  - lib/zint/structs/vector.rb
@@ -286,13 +285,15 @@ files:
286
285
  - lib/zint/version.rb
287
286
  - lib/zint/vin.rb
288
287
  - lib/zint/zint_recipe.rb
289
- - ports/archives/zint-2.12.0-src.tar.gz
290
- homepage: https://github.com/api-walker/ruby-zint
288
+ - ports/archives/libpng-1.6.50.tar.xz
289
+ - ports/archives/zint-2.15.0-src.tar.gz
290
+ - ports/archives/zlib-1.3.1.tar.gz
291
+ homepage: https://github.com/eliasfroehner/ruby-zint
291
292
  licenses:
292
293
  - MIT
293
294
  metadata:
294
- homepage_uri: https://github.com/api-walker/ruby-zint
295
- source_code_uri: https://github.com/api-walker/ruby-zint
295
+ homepage_uri: https://github.com/eliasfroehner/ruby-zint
296
+ source_code_uri: https://github.com/eliasfroehner/ruby-zint
296
297
  msys2_mingw_dependencies: cmake libpng
297
298
  documentation_uri: https://rubydoc.info/gems/ruby-zint
298
299
  rdoc_options:
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.standard.yml DELETED
@@ -1,5 +0,0 @@
1
- parallel: true
2
- format: progress
3
- ruby_version: 2.6
4
- ignore:
5
- - 'ext/ruby-zint/tmp/**/*'
data/Gemfile DELETED
@@ -1,20 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in ruby-zint.gemspec
4
- gemspec
5
-
6
- gem "rake", "~> 13.0"
7
-
8
- gem "rspec", "~> 3.0"
9
-
10
- gem "simplecov", require: false
11
-
12
- gem "chunky_png"
13
-
14
- gem "byebug"
15
-
16
- gem "standard", "~> 1.3"
17
-
18
- gem "mini_portile2"
19
-
20
- gem "yard"
data/Rakefile DELETED
@@ -1,23 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
- require_relative "lib/zint/zint_recipe"
4
-
5
- CLOBBER.include "pkg"
6
- CLOBBER.add("ports/*").exclude(%r{ports/archives$})
7
- CLEAN.include "tmp"
8
- CLEAN.include "ext/ruby-zint/tmp"
9
- CLEAN.include "lib/*.a"
10
- CLEAN.include "lib/*.so*"
11
- CLEAN.include "lib/*.dll*"
12
-
13
- RSpec::Core::RakeTask.new(:spec)
14
-
15
- require "standard/rake"
16
-
17
- task default: %i[spec standard]
18
-
19
- task gem: :build
20
- task :compile do
21
- sh "ruby -C ext/ruby-zint extconf.rb --disable-system-libzint"
22
- sh "make -C ext/ruby-zint install RUBYARCHDIR=../../lib"
23
- end
Binary file