ruby-zint 1.5.0-x86_64-linux-gnu
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 +7 -0
- data/.yardopts +9 -0
- data/LICENSE.txt +21 -0
- data/README.md +146 -0
- data/ext/ruby-zint/extconf.rb +113 -0
- data/lib/3.4/libzint.so +0 -0
- data/lib/ruby-zint.rb +1 -0
- data/lib/zint/aus_post.rb +8 -0
- data/lib/zint/aus_redirect.rb +8 -0
- data/lib/zint/aus_reply.rb +8 -0
- data/lib/zint/aus_route.rb +8 -0
- data/lib/zint/azrune.rb +8 -0
- data/lib/zint/aztec.rb +8 -0
- data/lib/zint/barcode.rb +550 -0
- data/lib/zint/bc_412.rb +8 -0
- data/lib/zint/bitmap.rb +4 -0
- data/lib/zint/bitmap_pixel.rb +4 -0
- data/lib/zint/c25iata.rb +8 -0
- data/lib/zint/c25ind.rb +8 -0
- data/lib/zint/c25inter.rb +8 -0
- data/lib/zint/c25logic.rb +8 -0
- data/lib/zint/c25matrix.rb +8 -0
- data/lib/zint/c25standard.rb +8 -0
- data/lib/zint/cep_net.rb +8 -0
- data/lib/zint/channel.rb +8 -0
- data/lib/zint/codabar.rb +8 -0
- data/lib/zint/codablock_f.rb +8 -0
- data/lib/zint/code11.rb +8 -0
- data/lib/zint/code128.rb +8 -0
- data/lib/zint/code128ab.rb +8 -0
- data/lib/zint/code128b.rb +5 -0
- data/lib/zint/code16k.rb +8 -0
- data/lib/zint/code32.rb +8 -0
- data/lib/zint/code39.rb +8 -0
- data/lib/zint/code49.rb +8 -0
- data/lib/zint/code93.rb +8 -0
- data/lib/zint/code_one.rb +8 -0
- data/lib/zint/constants/capability_flags.rb +21 -0
- data/lib/zint/constants/debug_flags.rb +9 -0
- data/lib/zint/constants/errors.rb +20 -0
- data/lib/zint/constants/input_data_types.rb +16 -0
- data/lib/zint/constants/output_options.rb +24 -0
- data/lib/zint/constants/specific_options.rb +13 -0
- data/lib/zint/constants/symbologies.rb +138 -0
- data/lib/zint/constants/warn_levels.rb +9 -0
- data/lib/zint/constants/warnings.rb +12 -0
- data/lib/zint/daft.rb +8 -0
- data/lib/zint/data_matrix.rb +19 -0
- data/lib/zint/dbarexp.rb +8 -0
- data/lib/zint/dbarexpstk.rb +8 -0
- data/lib/zint/dbarltd.rb +8 -0
- data/lib/zint/dbaromn.rb +8 -0
- data/lib/zint/dbaromnstk.rb +8 -0
- data/lib/zint/dbarstk.rb +8 -0
- data/lib/zint/dependencies.rb +15 -0
- data/lib/zint/dot_code.rb +8 -0
- data/lib/zint/dpd.rb +8 -0
- data/lib/zint/dpident.rb +8 -0
- data/lib/zint/dpleit.rb +8 -0
- data/lib/zint/dxfilmedge.rb +8 -0
- data/lib/zint/ean128.rb +8 -0
- data/lib/zint/ean14.rb +8 -0
- data/lib/zint/eanx.rb +8 -0
- data/lib/zint/eanxchk.rb +8 -0
- data/lib/zint/excode39.rb +8 -0
- data/lib/zint/fim.rb +8 -0
- data/lib/zint/flat.rb +8 -0
- data/lib/zint/grid_matrix.rb +8 -0
- data/lib/zint/gs1_128.rb +10 -0
- data/lib/zint/hanxin.rb +8 -0
- data/lib/zint/hibc128.rb +8 -0
- data/lib/zint/hibc39.rb +8 -0
- data/lib/zint/hibcaztec.rb +8 -0
- data/lib/zint/hibcblockf.rb +8 -0
- data/lib/zint/hibcdm.rb +8 -0
- data/lib/zint/hibcmicpdf.rb +8 -0
- data/lib/zint/hibcpdf.rb +8 -0
- data/lib/zint/hibcqr.rb +8 -0
- data/lib/zint/isbnx.rb +8 -0
- data/lib/zint/itf14.rb +8 -0
- data/lib/zint/japan_post.rb +8 -0
- data/lib/zint/kix.rb +8 -0
- data/lib/zint/korea_post.rb +8 -0
- data/lib/zint/logmars.rb +8 -0
- data/lib/zint/mailmark.rb +8 -0
- data/lib/zint/mailmark_2d.rb +8 -0
- data/lib/zint/mailmark_4s.rb +8 -0
- data/lib/zint/maxi_code.rb +8 -0
- data/lib/zint/micro_pdf417.rb +8 -0
- data/lib/zint/micro_qr.rb +8 -0
- data/lib/zint/msiplessey.rb +8 -0
- data/lib/zint/native.rb +106 -0
- data/lib/zint/nve18.rb +8 -0
- data/lib/zint/one_code.rb +8 -0
- data/lib/zint/pdf417.rb +8 -0
- data/lib/zint/pdf417comp.rb +8 -0
- data/lib/zint/pdf417trunc.rb +8 -0
- data/lib/zint/pharma.rb +8 -0
- data/lib/zint/pharmatwo.rb +8 -0
- data/lib/zint/planet.rb +8 -0
- data/lib/zint/plessey.rb +8 -0
- data/lib/zint/postnet.rb +8 -0
- data/lib/zint/pzn.rb +8 -0
- data/lib/zint/qr.rb +18 -0
- data/lib/zint/rmqr.rb +8 -0
- data/lib/zint/rss14.rb +8 -0
- data/lib/zint/rss14stack.rb +8 -0
- data/lib/zint/rss14stackomni.rb +8 -0
- data/lib/zint/rssexp.rb +8 -0
- data/lib/zint/rssexpstack.rb +8 -0
- data/lib/zint/rssltd.rb +8 -0
- data/lib/zint/structs/seg.rb +26 -0
- data/lib/zint/structs/structapp.rb +25 -0
- data/lib/zint/structs/symbol.rb +57 -0
- data/lib/zint/structs/vector.rb +54 -0
- data/lib/zint/structs/vector_circle.rb +32 -0
- data/lib/zint/structs/vector_hexagon.rb +31 -0
- data/lib/zint/structs/vector_rect.rb +37 -0
- data/lib/zint/structs/vector_string.rb +50 -0
- data/lib/zint/telepen.rb +8 -0
- data/lib/zint/telepennum.rb +8 -0
- data/lib/zint/ultra.rb +8 -0
- data/lib/zint/upc_a.rb +8 -0
- data/lib/zint/upc_a_chk.rb +8 -0
- data/lib/zint/upc_e.rb +8 -0
- data/lib/zint/upc_e_chk.rb +8 -0
- data/lib/zint/upnqr.rb +8 -0
- data/lib/zint/upu_s10.rb +8 -0
- data/lib/zint/uspsimail.rb +8 -0
- data/lib/zint/version.rb +3 -0
- data/lib/zint/vin.rb +8 -0
- data/lib/zint/zint_recipe.rb +31 -0
- data/lib/zint.rb +170 -0
- data/ruby-zint.gemspec +43 -0
- metadata +305 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e880d27afdd8ede003d49eef0c9e05f7b1d1c7eed1708c4c7f6a1a00f1706edb
|
4
|
+
data.tar.gz: 4e93c70135736b41fe200d3b5a0c753e718a1f644ec981c5c9626df26b5f2f08
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cb9bab70916801509ac6ca30328f9b011a5b078723361d64371ae1c8b122ba0c218ae081d6ca242fda3f6df580e943baa2163e6f0c6b488d7c66daa941ab3d09
|
7
|
+
data.tar.gz: 89c473ad72a662ca369988f7bed84d44f49bc6b28ca8d73fba05cb2d73380b7725d5eaaf2f26a3fc832f1f5ae687de275e6a0e08a340697c553fa9555ea28bb9
|
data/.yardopts
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2023 Elias Fröhner
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
# ruby-zint
|
2
|
+
|
3
|
+
[](https://github.com/api-walker/ruby-zint/actions/workflows/main.yml)
|
4
|
+
|
5
|
+
This gem is a Ruby FFI binding for the [libzint](http://www.zint.org.uk) barcode generation library.
|
6
|
+
|
7
|
+
See the [documentation](https://rubydoc.info/github/api-walker/ruby-zint) for a full API description.
|
8
|
+
|
9
|
+
## Installation
|
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
|
+
|
30
|
+
By default ruby-zint first tries to use libzint installed on the system.
|
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.
|
32
|
+
Both install methods can be enforced by using `--enable-system-libzint` or `--disable-system-libzint` options, see below.
|
33
|
+
|
34
|
+
#### With libzint source code (recommended)
|
35
|
+
First install CMake with your package manager (e. g. `apt install cmake`).
|
36
|
+
Please also install libpng (e. g. `apt install libpng-dev`) before installing the gem if you want to use the PNG format.
|
37
|
+
Afterwards install the gem and force builtin libzint:
|
38
|
+
|
39
|
+
```
|
40
|
+
$ gem install ruby-zint -- --disable-system-libzint
|
41
|
+
```
|
42
|
+
|
43
|
+
#### With system libraries
|
44
|
+
|
45
|
+
Install the libzint binary with your package manager (e. g. `apt install zint` or perhaps `brew install zint`).
|
46
|
+
Other platforms require building [from source](https://www.zint.org.uk/manual/chapter/2).
|
47
|
+
|
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/).
|
49
|
+
|
50
|
+
Then install this gem and enforce system libzint:
|
51
|
+
|
52
|
+
```
|
53
|
+
$ gem install ruby-zint -- --enable-system-libzint
|
54
|
+
```
|
55
|
+
|
56
|
+
### Gemfile
|
57
|
+
|
58
|
+
Include `gem "ruby-zint"` in your Gemfile.
|
59
|
+
To make sure, the necessary platforms and the source gem are fetched by bundler, they can be added like so
|
60
|
+
|
61
|
+
```
|
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
|
75
|
+
```
|
76
|
+
|
77
|
+
Optionally set the install option by running bundler like so:
|
78
|
+
|
79
|
+
```
|
80
|
+
bundle config build.ruby-zint --enable-system-libzint
|
81
|
+
```
|
82
|
+
|
83
|
+
## Usage
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
require "zint"
|
87
|
+
|
88
|
+
barcode = Zint::Barcode.new(value: "Test", symbology: Zint::BARCODE_CODE128)
|
89
|
+
|
90
|
+
# Export to file
|
91
|
+
barcode.to_file(path: "out.png")
|
92
|
+
|
93
|
+
# Export file to memory
|
94
|
+
barcode.to_memory_file(extension: ".png")
|
95
|
+
|
96
|
+
# Write from Bitmap to own canvas
|
97
|
+
require "chunky_png"
|
98
|
+
png = ChunkyPNG::Image.new(bitmap.width, bitmap.height, ChunkyPNG::Color::TRANSPARENT)
|
99
|
+
white = ChunkyPNG::Color("white")
|
100
|
+
black = ChunkyPNG::Color("black")
|
101
|
+
|
102
|
+
bitmap = barcode.to_bitmap
|
103
|
+
bitmap.pixels.each do |pixel|
|
104
|
+
png.compose_pixel(pixel.x, pixel.y, (pixel.colour == "1") ? black : white)
|
105
|
+
end
|
106
|
+
|
107
|
+
png.save("out.png")
|
108
|
+
|
109
|
+
# Use vector export
|
110
|
+
vec = Zint::Qr.new(value: "Test").to_vector
|
111
|
+
png = ChunkyPNG::Image.new(vec.width.to_i, vec.height.to_i, ChunkyPNG::Color::WHITE)
|
112
|
+
vec.each_rectangle do |rec|
|
113
|
+
png.rect(rec.x.to_i, rec.y.to_i,
|
114
|
+
rec.x.to_i+rec.width.to_i-1, rec.y.to_i+rec.height.to_i-1,
|
115
|
+
ChunkyPNG::Color::BLACK, ChunkyPNG::Color::BLACK)
|
116
|
+
end
|
117
|
+
png.save("out.png")
|
118
|
+
|
119
|
+
# See also manual: https://zint.org.uk/manual/chapter/5#buffering-symbols-in-memory-vector
|
120
|
+
|
121
|
+
# Use file as input
|
122
|
+
barcode = Zint::Barcode.new(input_file: "/tmp/test.txt")
|
123
|
+
barcode.to_file(path: "out.png")
|
124
|
+
|
125
|
+
# Use of comfort classes
|
126
|
+
|
127
|
+
# EAN
|
128
|
+
ean_barcode = Zint::Eanx.new(value: "012345678912")
|
129
|
+
ean_barcode.to_file(path: "ean.png")
|
130
|
+
|
131
|
+
# Code128
|
132
|
+
code_128_barcode = Zint::Code128.new(value: "012345678912")
|
133
|
+
code_128_barcode.to_file(path: "code_128.png")
|
134
|
+
|
135
|
+
```
|
136
|
+
|
137
|
+
## Contributing
|
138
|
+
|
139
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/api-walker/ruby-zint.
|
140
|
+
|
141
|
+
## License
|
142
|
+
|
143
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
144
|
+
|
145
|
+
## Credits
|
146
|
+
The project is based on the work and ideas of Angel Pizarro's [zint](https://github.com/delagoya/zint). I would also like to say a big thank you to [Lars Kanis](https://github.com/larskanis) for his great contributions.
|
@@ -0,0 +1,113 @@
|
|
1
|
+
# #!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "rubygems"
|
4
|
+
require "ffi"
|
5
|
+
require "fileutils"
|
6
|
+
|
7
|
+
if RUBY_PLATFORM.match?(/java/)
|
8
|
+
# JRuby's C extension support is disabled by default, so we can not use it
|
9
|
+
|
10
|
+
# Implement very simple verions of mkmf-helpers used below
|
11
|
+
def enable_config(name, default = nil)
|
12
|
+
if ARGV.include?("--enable-#{name}")
|
13
|
+
true
|
14
|
+
elsif ARGV.include?("--disable-#{name}")
|
15
|
+
false
|
16
|
+
else
|
17
|
+
default
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def arg_config(name)
|
22
|
+
ARGV.include?(name)
|
23
|
+
end
|
24
|
+
else
|
25
|
+
require "mkmf"
|
26
|
+
end
|
27
|
+
|
28
|
+
if RUBY_PLATFORM.match?(/darwin/)
|
29
|
+
ENV["SDKROOT"] ||= `xcrun --sdk macosx --show-sdk-path`.chomp
|
30
|
+
end
|
31
|
+
|
32
|
+
def do_help
|
33
|
+
print <<~HELP
|
34
|
+
usage: ruby #{$0} [options]
|
35
|
+
--enable-system-libzint / --disable-system-libzint
|
36
|
+
Force use of system or builtin libzint library.
|
37
|
+
Default is to prefer system libraries and fallback to builtin.
|
38
|
+
HELP
|
39
|
+
exit! 0
|
40
|
+
end
|
41
|
+
|
42
|
+
do_help if arg_config("--help")
|
43
|
+
|
44
|
+
def libzint_usable?
|
45
|
+
m = Module.new do
|
46
|
+
extend FFI::Library
|
47
|
+
|
48
|
+
ffi_lib(%w[libzint.so.2.15 libzint zint])
|
49
|
+
attach_function(:ZBarcode_Version, [], :int32)
|
50
|
+
end
|
51
|
+
|
52
|
+
(21500...21600) === m.ZBarcode_Version
|
53
|
+
rescue LoadError
|
54
|
+
false
|
55
|
+
end
|
56
|
+
|
57
|
+
def build_bundled_libzint
|
58
|
+
puts "Build libzint and dependencies"
|
59
|
+
require_relative "../../lib/zint/zint_recipe"
|
60
|
+
|
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
|
+
]
|
83
|
+
recipe.cook_and_activate
|
84
|
+
recipe.path
|
85
|
+
end
|
86
|
+
|
87
|
+
unless enable_config("system-libzint", libzint_usable?)
|
88
|
+
# Unable to load libzint library on this system,
|
89
|
+
# so we build our bundled version:
|
90
|
+
libzint_path = build_bundled_libzint
|
91
|
+
end
|
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
|
+
|
98
|
+
# Create a Makefile which copies the libzint library files to the gem's lib dir.
|
99
|
+
File.open("Makefile", "wb") do |mf|
|
100
|
+
mf.puts <<~EOT
|
101
|
+
RUBYARCHDIR = #{RbConfig::MAKEFILE_CONFIG["sitearchdir"].dump}
|
102
|
+
all:
|
103
|
+
clean:
|
104
|
+
install:
|
105
|
+
EOT
|
106
|
+
|
107
|
+
if libzint_path
|
108
|
+
# Only executed in source build
|
109
|
+
mf.puts <<-EOT
|
110
|
+
cp -r #{libzint_path.dump}/*/libzint* $(RUBYARCHDIR)
|
111
|
+
EOT
|
112
|
+
end
|
113
|
+
end
|
data/lib/3.4/libzint.so
ADDED
Binary file
|
data/lib/ruby-zint.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "zint"
|
data/lib/zint/azrune.rb
ADDED