ruby-zint 1.4.0 → 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 +4 -4
- data/README.md +42 -10
- data/ext/ruby-zint/extconf.rb +31 -4
- data/lib/zint/barcode.rb +41 -30
- data/lib/zint/constants/errors.rb +2 -1
- data/lib/zint/constants/input_data_types.rb +1 -0
- data/lib/zint/constants/output_options.rb +3 -0
- data/lib/zint/constants/specific_options.rb +1 -0
- data/lib/zint/constants/symbologies.rb +2 -1
- data/lib/zint/dependencies.rb +10 -2
- data/lib/zint/dxfilmedge.rb +8 -0
- data/lib/zint/native.rb +37 -18
- data/lib/zint/structs/seg.rb +26 -0
- data/lib/zint/structs/symbol.rb +14 -6
- data/lib/zint/version.rb +1 -1
- data/lib/zint/zint_recipe.rb +8 -4
- data/lib/zint.rb +2 -0
- data/ports/archives/libpng-1.6.50.tar.xz +0 -0
- data/ports/archives/zint-2.15.0-src.tar.gz +0 -0
- data/ports/archives/zlib-1.3.1.tar.gz +0 -0
- metadata +12 -15
- data/.rspec +0 -3
- data/.standard.yml +0 -5
- data/Gemfile +0 -20
- data/Rakefile +0 -23
- data/ports/archives/zint-2.12.0-src.tar.gz +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b952e9f08564e922af202d914688cf69a6d1fb424c09f8f0b28a623ae181a1b7
|
4
|
+
data.tar.gz: d480672da3110d322d84395ca8e5cb3f43e0c6433dc6170b1953e370dd0d88dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
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.
|
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
|
-
|
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
|
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
|
-
|
77
|
+
Optionally set the install option by running bundler like so:
|
48
78
|
|
49
|
-
|
79
|
+
```
|
80
|
+
bundle config build.ruby-zint --enable-system-libzint
|
81
|
+
```
|
50
82
|
|
51
83
|
## Usage
|
52
84
|
|
data/ext/ruby-zint/extconf.rb
CHANGED
@@ -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.
|
48
|
+
ffi_lib(%w[libzint.so.2.15 libzint zint])
|
49
49
|
attach_function(:ZBarcode_Version, [], :int32)
|
50
50
|
end
|
51
51
|
|
52
|
-
(
|
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
|
-
|
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
|
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
|
-
|
61
|
-
file = Tempfile.new(["zint", extension])
|
64
|
+
@zint_symbol[:output_options] = Zint::BARCODE_MEMORY_FILE
|
62
65
|
|
63
|
-
to_file(path:
|
66
|
+
to_file(path: extension, rotate_angle: rotate_angle)
|
64
67
|
|
65
|
-
|
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,11 +80,13 @@ 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
|
88
88
|
|
89
|
-
@zint_symbol[:bitmap].read_bytes(
|
89
|
+
@zint_symbol[:bitmap].read_bytes(@zint_symbol[:bitmap_width] * @zint_symbol[:bitmap_height])
|
90
90
|
end
|
91
91
|
|
92
92
|
# Exports barcode to buffer
|
@@ -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].
|
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
|
@@ -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
|
-
|
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
|
data/lib/zint/dependencies.rb
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
module Zint
|
2
|
-
|
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 = "
|
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
|
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
|
-
|
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
|
@@ -20,57 +22,74 @@ module Zint
|
|
20
22
|
typedef :pointer, :source
|
21
23
|
|
22
24
|
# Create and initialize a symbol structure
|
23
|
-
attach_function(:ZBarcode_Create, [], :zint_symbol)
|
25
|
+
attach_function(:ZBarcode_Create, [], :zint_symbol, blocking: true)
|
24
26
|
|
25
27
|
# Free any output buffers that may have been created and initialize output fields
|
26
|
-
attach_function(:ZBarcode_Clear, [:zint_symbol], :void)
|
28
|
+
attach_function(:ZBarcode_Clear, [:zint_symbol], :void, blocking: true)
|
27
29
|
|
28
30
|
# Free a symbol structure, including any output buffers
|
29
31
|
#
|
30
32
|
# For use with ruby's garbage collector ZBarcode_Delete must be called with a plain :pointer and not an :zint_symbol.
|
31
|
-
attach_function(:ZBarcode_Delete, [:pointer], :void)
|
33
|
+
attach_function(:ZBarcode_Delete, [:pointer], :void, blocking: true)
|
32
34
|
|
33
35
|
# Encode a barcode. If `length` is 0, `source` must be NUL-terminated.
|
34
|
-
attach_function(:ZBarcode_Encode, [:zint_symbol, :source, :length], :error_code)
|
36
|
+
attach_function(:ZBarcode_Encode, [:zint_symbol, :source, :length], :error_code, blocking: true)
|
35
37
|
|
36
38
|
# Encode a barcode using input data from file `filename`
|
37
|
-
attach_function(:ZBarcode_Encode_File, [:zint_symbol, :filename], :error_code)
|
39
|
+
attach_function(:ZBarcode_Encode_File, [:zint_symbol, :filename], :error_code, blocking: true)
|
38
40
|
|
39
41
|
# Output a previously encoded symbol to file `symbol->outfile`
|
40
|
-
attach_function(:ZBarcode_Print, [:zint_symbol, :rotate_angle], :error_code)
|
42
|
+
attach_function(:ZBarcode_Print, [:zint_symbol, :rotate_angle], :error_code, blocking: true)
|
41
43
|
|
42
44
|
# Encode and output a symbol to file `symbol->outfile`
|
43
|
-
attach_function(:ZBarcode_Encode_and_Print, [:zint_symbol, :source, :length, :rotate_angle], :error_code)
|
45
|
+
attach_function(:ZBarcode_Encode_and_Print, [:zint_symbol, :source, :length, :rotate_angle], :error_code, blocking: true)
|
44
46
|
|
45
47
|
# Encode a symbol using input data from file `filename` and output to file `symbol->outfile`
|
46
|
-
attach_function(:ZBarcode_Encode_File_and_Print, [:zint_symbol, :filename, :rotate_angle], :error_code)
|
48
|
+
attach_function(:ZBarcode_Encode_File_and_Print, [:zint_symbol, :filename, :rotate_angle], :error_code, blocking: true)
|
47
49
|
|
48
50
|
# Output a previously encoded symbol to memory as raster (`symbol->bitmap`)
|
49
|
-
attach_function(:ZBarcode_Buffer, [:zint_symbol, :rotate_angle], :error_code)
|
51
|
+
attach_function(:ZBarcode_Buffer, [:zint_symbol, :rotate_angle], :error_code, blocking: true)
|
50
52
|
|
51
53
|
# Encode and output a symbol to memory as raster (`symbol->bitmap`)
|
52
|
-
attach_function(:ZBarcode_Encode_and_Buffer, [:zint_symbol, :source, :length, :rotate_angle], :error_code)
|
54
|
+
attach_function(:ZBarcode_Encode_and_Buffer, [:zint_symbol, :source, :length, :rotate_angle], :error_code, blocking: true)
|
53
55
|
|
54
56
|
# Encode a symbol using input data from file `filename` and output to memory as raster (`symbol->bitmap`)
|
55
|
-
attach_function(:ZBarcode_Encode_File_and_Buffer, [:zint_symbol, :filename, :rotate_angle], :error_code)
|
57
|
+
attach_function(:ZBarcode_Encode_File_and_Buffer, [:zint_symbol, :filename, :rotate_angle], :error_code, blocking: true)
|
56
58
|
|
57
59
|
# Output a previously encoded symbol to memory as vector (`symbol->vector`)
|
58
|
-
attach_function(:ZBarcode_Buffer_Vector, [:zint_symbol, :rotate_angle], :error_code)
|
60
|
+
attach_function(:ZBarcode_Buffer_Vector, [:zint_symbol, :rotate_angle], :error_code, blocking: true)
|
59
61
|
|
60
62
|
# Encode and output a symbol to memory as vector (`symbol->vector`)
|
61
|
-
attach_function(:ZBarcode_Encode_and_Buffer_Vector, [:zint_symbol, :source, :length, :rotate_angle], :error_code)
|
63
|
+
attach_function(:ZBarcode_Encode_and_Buffer_Vector, [:zint_symbol, :source, :length, :rotate_angle], :error_code, blocking: true)
|
62
64
|
|
63
65
|
# Encode a symbol using input data from file `filename` and output to memory as vector (`symbol->vector`)
|
64
|
-
attach_function(:ZBarcode_Encode_File_and_Buffer_Vector, [:zint_symbol, :filename, :rotate_angle], :error_code)
|
66
|
+
attach_function(:ZBarcode_Encode_File_and_Buffer_Vector, [:zint_symbol, :filename, :rotate_angle], :error_code, blocking: true)
|
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)
|
65
84
|
|
66
85
|
# Is `symbol_id` a recognized symbology?
|
67
|
-
attach_function(:ZBarcode_ValidID, [:symbol_id], :bool)
|
86
|
+
attach_function(:ZBarcode_ValidID, [:symbol_id], :bool, blocking: true)
|
68
87
|
|
69
88
|
# Return the capability flags for symbology `symbol_id` that match `cap_flag`
|
70
|
-
attach_function(:ZBarcode_Cap, [:symbol_id, :cap_flag], :uint32)
|
89
|
+
attach_function(:ZBarcode_Cap, [:symbol_id, :cap_flag], :uint32, blocking: true)
|
71
90
|
|
72
91
|
# Return the version of Zint linked to
|
73
|
-
attach_function(:ZBarcode_Version, [], :int32)
|
92
|
+
attach_function(:ZBarcode_Version, [], :int32, blocking: true)
|
74
93
|
|
75
94
|
# Raises specific error for API return code
|
76
95
|
#
|
@@ -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
|
data/lib/zint/structs/symbol.rb
CHANGED
@@ -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,
|
12
|
-
:bgcolour, [:char,
|
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,
|
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
|
-
:
|
41
|
-
:
|
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
data/lib/zint/zint_recipe.rb
CHANGED
@@ -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(
|
11
|
+
def initialize(name, vers, url, sha1)
|
12
|
+
super(name, vers)
|
13
13
|
self.target = File.join(ROOT, "ports")
|
14
|
-
self.files = [url:
|
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}-#{
|
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
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-zint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elias Fröhner
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: ffi
|
@@ -38,7 +37,6 @@ dependencies:
|
|
38
37
|
- - "~>"
|
39
38
|
- !ruby/object:Gem::Version
|
40
39
|
version: '2.1'
|
41
|
-
description:
|
42
40
|
email:
|
43
41
|
- apiwalker96@gmail.com
|
44
42
|
executables: []
|
@@ -90,6 +88,7 @@ extra_rdoc_files:
|
|
90
88
|
- lib/zint/dpd.rb
|
91
89
|
- lib/zint/dpident.rb
|
92
90
|
- lib/zint/dpleit.rb
|
91
|
+
- lib/zint/dxfilmedge.rb
|
93
92
|
- lib/zint/ean128.rb
|
94
93
|
- lib/zint/ean14.rb
|
95
94
|
- lib/zint/eanx.rb
|
@@ -155,13 +154,9 @@ extra_rdoc_files:
|
|
155
154
|
- lib/zint/vin.rb
|
156
155
|
- lib/zint/zint_recipe.rb
|
157
156
|
files:
|
158
|
-
- ".rspec"
|
159
|
-
- ".standard.yml"
|
160
157
|
- ".yardopts"
|
161
|
-
- Gemfile
|
162
158
|
- LICENSE.txt
|
163
159
|
- README.md
|
164
|
-
- Rakefile
|
165
160
|
- ext/ruby-zint/extconf.rb
|
166
161
|
- lib/ruby-zint.rb
|
167
162
|
- lib/zint.rb
|
@@ -217,6 +212,7 @@ files:
|
|
217
212
|
- lib/zint/dpd.rb
|
218
213
|
- lib/zint/dpident.rb
|
219
214
|
- lib/zint/dpleit.rb
|
215
|
+
- lib/zint/dxfilmedge.rb
|
220
216
|
- lib/zint/ean128.rb
|
221
217
|
- lib/zint/ean14.rb
|
222
218
|
- lib/zint/eanx.rb
|
@@ -268,6 +264,7 @@ files:
|
|
268
264
|
- lib/zint/rssexp.rb
|
269
265
|
- lib/zint/rssexpstack.rb
|
270
266
|
- lib/zint/rssltd.rb
|
267
|
+
- lib/zint/structs/seg.rb
|
271
268
|
- lib/zint/structs/structapp.rb
|
272
269
|
- lib/zint/structs/symbol.rb
|
273
270
|
- lib/zint/structs/vector.rb
|
@@ -288,16 +285,17 @@ files:
|
|
288
285
|
- lib/zint/version.rb
|
289
286
|
- lib/zint/vin.rb
|
290
287
|
- lib/zint/zint_recipe.rb
|
291
|
-
- ports/archives/
|
292
|
-
|
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
|
293
292
|
licenses:
|
294
293
|
- MIT
|
295
294
|
metadata:
|
296
|
-
homepage_uri: https://github.com/
|
297
|
-
source_code_uri: https://github.com/
|
295
|
+
homepage_uri: https://github.com/eliasfroehner/ruby-zint
|
296
|
+
source_code_uri: https://github.com/eliasfroehner/ruby-zint
|
298
297
|
msys2_mingw_dependencies: cmake libpng
|
299
298
|
documentation_uri: https://rubydoc.info/gems/ruby-zint
|
300
|
-
post_install_message:
|
301
299
|
rdoc_options:
|
302
300
|
- "--main"
|
303
301
|
- README.md
|
@@ -318,8 +316,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
318
316
|
- !ruby/object:Gem::Version
|
319
317
|
version: '0'
|
320
318
|
requirements: []
|
321
|
-
rubygems_version: 3.
|
322
|
-
signing_key:
|
319
|
+
rubygems_version: 3.7.0
|
323
320
|
specification_version: 4
|
324
321
|
summary: Ruby FFI binding for libzint
|
325
322
|
test_files: []
|
data/.rspec
DELETED
data/.standard.yml
DELETED
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
|