ruby-zint 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f734d5ae4c7959fb5753621a438396bccf285508bb17d80a847e80722f30378
4
- data.tar.gz: 2207324efb9029cd4f6423b4b1aa04d8d8f9339e3fcca5464d048162c72f631d
3
+ metadata.gz: ccdb5e197e8d714e8f2d336b7448a1e104a69a5969b2d811ee6b0ef8998e6cac
4
+ data.tar.gz: 547681f881a38f9168ac6330f07f300f578e2655eb3241633992e619394239e9
5
5
  SHA512:
6
- metadata.gz: 58b054d6ca8c39d9421a9dfdc49517402659b0935455fc61d0d3b7a65791980ef93b8ce10c36a820940d1a54240589dd928c6cb6ef618e7d87dddd655ae450b0
7
- data.tar.gz: 9b7184006218407385bd2f84c1eb465ab3aa1742b08a98eae58dde5a6653e839d80835f8d234f2d6f768908b10926de94f215a32d6446c0c1de2e202f9a85a7b
6
+ metadata.gz: 772885463ca263b7a44405a78851961817a04d97b7e2fe2bb7691a5f5b06c0a7c2055bcf5f9dcfc07e1c2b5d235dbf75dcd8a161d5b0d2d2f04629fb4fb603b4
7
+ data.tar.gz: 565dcf8defee2948e4a4335e9681111056b7ee81a5dd03134f77cb030425131829964f7e2847813ee8866e61de3210e1796f855ae9c09ad601b623a8609dd9e4
data/.standard.yml CHANGED
@@ -1,3 +1,5 @@
1
1
  parallel: true
2
2
  format: progress
3
3
  ruby_version: 2.6
4
+ ignore:
5
+ - 'ext/ruby-zint/tmp/**/*'
data/Gemfile CHANGED
@@ -14,3 +14,5 @@ gem "chunky_png"
14
14
  gem "byebug"
15
15
 
16
16
  gem "standard", "~> 1.3"
17
+
18
+ gem "mini_portile2"
data/README.md CHANGED
@@ -8,19 +8,41 @@ See the [documentation](https://rubydoc.info/github/api-walker/ruby-zint) for a
8
8
 
9
9
  ## Installation
10
10
 
11
- Install the libzint binary with your package manager (eg. `apt install zint` or perhaps `brew install zint`).
11
+ 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.
13
+ Both install methods can be enforced by using `--enable-system-libzint` or `--disable-system-libzint` options, see below.
14
+
15
+ ### With libzint source code (recommended)
16
+ First install CMake with your package manager (e. g. `apt install cmake`).
17
+
18
+ Afterwards install the gem and force builtin libzint:
19
+
20
+ ```
21
+ $ gem install ruby-zint -- --disable-system-libzint
22
+ ```
23
+
24
+ ### With system libraries
25
+
26
+ Install the libzint binary with your package manager (e. g. `apt install zint` or perhaps `brew install zint`).
12
27
 
13
28
  Other platforms require building [from source](https://www.zint.org.uk/manual/chapter/2).
14
29
 
15
30
  **NOTE:** It is assumed that you are using libzint with the version [2.10](https://sourceforge.net/projects/zint/files/zint/2.10.0/).
16
31
 
17
- Then install this gem with:
32
+ Then install this gem and enforce system libzint:
18
33
 
19
34
  ```
20
- $ gem install ruby-zint
35
+ $ gem install ruby-zint -- --enable-system-libzint
21
36
  ```
22
37
 
23
- Or include `gem "ruby-zint"` in your Gemfile.
38
+ ### Gemfile
39
+
40
+ Include `gem "ruby-zint"` in your Gemfile.
41
+ Optionally set the install option by running bundler like so:
42
+
43
+ ```
44
+ bundle config build.ruby-zint --enable-system-libzint
45
+ ```
24
46
 
25
47
  ## Usage
26
48
 
@@ -41,12 +63,12 @@ png = ChunkyPNG::Image.new(bitmap.width, bitmap.height, ChunkyPNG::Color::TRANSP
41
63
  white = ChunkyPNG::Color("white")
42
64
  black = ChunkyPNG::Color("black")
43
65
 
44
- bitmap = barcode.to_buffer
66
+ bitmap = barcode.to_bitmap
45
67
  bitmap.pixels.each do |pixel|
46
- png.compose_pixel(pixel.x, pixel.y, (pixel.colour == "K") ? black : white)
68
+ png.compose_pixel(pixel.x, pixel.y, (pixel.colour == "1") ? black : white)
47
69
  end
48
70
 
49
- png.save(buffer_outfile)
71
+ png.save("out.png")
50
72
 
51
73
  # Use vector export
52
74
  vector_struct = barcode.to_vector
data/Rakefile CHANGED
@@ -1,8 +1,20 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
+ require_relative "lib/zint/zint_recipe"
4
+
5
+ CLOBBER.include "pkg"
6
+ CLEAN.include "ports"
7
+ CLEAN.include "tmp"
8
+ CLEAN.include "ext/ruby-zint/tmp"
3
9
 
4
10
  RSpec::Core::RakeTask.new(:spec)
5
11
 
6
12
  require "standard/rake"
7
13
 
8
14
  task default: %i[spec standard]
15
+
16
+ task gem: :build
17
+ task :compile do
18
+ sh "ruby -C ext/ruby-zint extconf.rb --disable-system-libzint"
19
+ sh "make -C ext/ruby-zint install RUBYARCHDIR=../../lib"
20
+ end
@@ -0,0 +1,86 @@
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.10 libzint zint])
49
+ attach_function(:ZBarcode_Version, [], :int32)
50
+ end
51
+
52
+ (21000...21100) === m.ZBarcode_Version
53
+ rescue LoadError
54
+ false
55
+ end
56
+
57
+ def build_bundled_libzint
58
+ puts "Build"
59
+ require_relative "../../lib/zint/zint_recipe"
60
+
61
+ recipe = Zint::ZintRecipe.new
62
+ recipe.cook_and_activate
63
+ recipe.path
64
+ end
65
+
66
+ unless enable_config("system-libzint", libzint_usable?)
67
+ # Unable to load libzint library on this system,
68
+ # so we build our bundled version:
69
+ libzint_path = build_bundled_libzint
70
+ end
71
+
72
+ # Create a Makefile which copies the libzint library files to the gem's lib dir.
73
+ File.open("Makefile", "wb") do |mf|
74
+ mf.puts <<~EOT
75
+ RUBYARCHDIR = #{RbConfig::MAKEFILE_CONFIG["sitearchdir"].dump}
76
+ all:
77
+ clean:
78
+ install:
79
+ EOT
80
+
81
+ if libzint_path
82
+ mf.puts <<-EOT
83
+ cp -r #{libzint_path.dump}/*/libzint* $(RUBYARCHDIR)
84
+ EOT
85
+ end
86
+ end
data/lib/zint/barcode.rb CHANGED
@@ -5,14 +5,12 @@ module Zint
5
5
  # barcode = Zint::Barcode.new(value: "Test", type: Zint::BARCODE_QRCODE, options: {option_1: 1})
6
6
  # barcode.to_file(path: "qr.png")
7
7
  class Barcode
8
+ include Native
9
+
8
10
  # @return [String, NilClass] Content of the barcode
9
11
  attr_accessor :value
10
12
  # @return [String, NilClass] Path to input file with content of the barcode
11
13
  attr_accessor :input_file
12
- # @return [Integer] Type of barcode
13
- attr_reader :type
14
- # @return [Zint::Structs::Symbol] The underlying FFI struct of the Zint C struct
15
- attr_reader :zint_symbol
16
14
 
17
15
  # @param value [String, NilClass] Content of the barcode
18
16
  # @param input_file [String, NilClass] Path to input file with content of the barcode
@@ -27,22 +25,10 @@ module Zint
27
25
  @zint_symbol[key] = value
28
26
  end
29
27
 
30
- @type = type
31
28
  @value = value
32
29
  @input_file = input_file
33
30
  end
34
31
 
35
- # Sets type of barcode
36
- #
37
- # @param type [Integer] Type of barcode
38
- def type=(type)
39
- @type = type
40
-
41
- call_function(:ZBarcode_Clear, zint_symbol)
42
-
43
- @zint_symbol[:symbology] = type
44
- end
45
-
46
32
  # Exports barcode to file
47
33
  #
48
34
  # @param path [String] Path to export file
@@ -51,9 +37,9 @@ module Zint
51
37
  @zint_symbol[:outfile] = path
52
38
 
53
39
  if input_file
54
- call_function(:ZBarcode_Encode_File_and_Print, zint_symbol, input_file, rotate_angle)
40
+ call_function(:ZBarcode_Encode_File_and_Print, @zint_symbol, input_file, rotate_angle)
55
41
  else
56
- call_function(:ZBarcode_Encode_and_Print, zint_symbol, value, 0, rotate_angle)
42
+ call_function(:ZBarcode_Encode_and_Print, @zint_symbol, value, 0, rotate_angle)
57
43
  end
58
44
  end
59
45
 
@@ -79,37 +65,34 @@ module Zint
79
65
  # Exports barcode to buffer
80
66
  #
81
67
  # @param rotate_angle [Integer] Rotate angle in degrees (0, 90, 180, 270)
82
- # @param raw_bitmap [Boolean] Export raw zint bitmap
83
- # @return [Zint::Bitmap, String] Exported memory file
84
- def to_buffer(rotate_angle: 0, raw_bitmap: false)
68
+ # @return [String] Exported barcode buffer
69
+ def to_buffer(rotate_angle: 0)
85
70
  @zint_symbol[:output_options] = Zint::OUT_BUFFER_INTERMEDIATE
86
71
 
87
72
  if input_file
88
- call_function(:ZBarcode_Encode_File_and_Buffer, zint_symbol, input_file, rotate_angle)
73
+ call_function(:ZBarcode_Encode_File_and_Buffer, @zint_symbol, input_file, rotate_angle)
89
74
  else
90
- call_function(:ZBarcode_Encode_and_Buffer, zint_symbol, value, 0, rotate_angle)
75
+ call_function(:ZBarcode_Encode_and_Buffer, @zint_symbol, value, 0, rotate_angle)
91
76
  end
92
77
 
93
- zint_bitmap = zint_symbol[:bitmap].read_string((zint_symbol[:bitmap_width] * zint_symbol[:bitmap_height]))
78
+ @zint_symbol[:bitmap].read_bytes((@zint_symbol[:bitmap_width] * @zint_symbol[:bitmap_height]))
79
+ end
94
80
 
95
- if raw_bitmap
96
- zint_bitmap
97
- else
98
- pixels = []
99
- zint_symbol[:bitmap_height].times do |row|
100
- zint_symbol[:bitmap_width].times do |column|
101
- pixel = zint_bitmap.slice!(0, 1)
102
- colour = if %w[0 1].include?(pixel)
103
- (pixel == "1") ? "K" : "W"
104
- else
105
- pixel
106
- end
107
- pixels << BitmapPixel.new(column, row, colour)
108
- end
109
- end
81
+ # Exports barcode to buffer
82
+ #
83
+ # @param rotate_angle [Integer] Rotate angle in degrees (0, 90, 180, 270)
84
+ # @return [Zint::Bitmap] Exported bitmap
85
+ def to_bitmap(rotate_angle: 0)
86
+ zint_bitmap = to_buffer(rotate_angle: rotate_angle)
110
87
 
111
- Bitmap.new(zint_symbol[:bitmap_width], zint_symbol[:bitmap_height], pixels)
88
+ pixels = []
89
+ @zint_symbol[:bitmap_height].times do |row|
90
+ @zint_symbol[:bitmap_width].times do |column|
91
+ pixels << BitmapPixel.new(column, row, zint_bitmap[pixels.size])
92
+ end
112
93
  end
94
+
95
+ Bitmap.new(@zint_symbol[:bitmap_width], @zint_symbol[:bitmap_height], pixels)
113
96
  end
114
97
 
115
98
  # Exports barcode as Zint vector
@@ -118,28 +101,391 @@ module Zint
118
101
  # @return [Zint::Structs::Vector] Vector data of barcode
119
102
  def to_vector(rotate_angle: 0)
120
103
  if input_file
121
- call_function(:ZBarcode_Encode_File_and_Buffer_Vector, zint_symbol, input_file, rotate_angle)
104
+ call_function(:ZBarcode_Encode_File_and_Buffer_Vector, @zint_symbol, input_file, rotate_angle)
122
105
  else
123
- call_function(:ZBarcode_Encode_and_Buffer_Vector, zint_symbol, value, 0, rotate_angle)
106
+ call_function(:ZBarcode_Encode_and_Buffer_Vector, @zint_symbol, value, 0, rotate_angle)
124
107
  end
125
108
 
126
- Structs::Vector.new(zint_symbol[:vector])
109
+ v = @zint_symbol[:vector]
110
+ # Avoid garbage collection of Symbol before Vector, since the Vector is also freed by ZBarcode_Delete()
111
+ v.instance_variable_set(:@symbol, @zint_symbol)
112
+ v
113
+ end
114
+
115
+ # Free barcode and all memory associated with it.
116
+ def free
117
+ @zint_symbol.pointer.free
118
+ end
119
+
120
+ # Attributes
121
+
122
+ # Gets type of barcode
123
+ def symbology
124
+ @zint_symbol[:symbology]
125
+ end
126
+
127
+ # Sets type of barcode
128
+ #
129
+ # @param type [Integer] Type of barcode
130
+ def symbology=(type)
131
+ reset_symbol
132
+
133
+ @zint_symbol[:symbology] = type
134
+ end
135
+
136
+ # Gets height of barcode
137
+ def height
138
+ @zint_symbol[:height]
139
+ end
140
+
141
+ # Sets height of barcode
142
+ #
143
+ # @param height [Float] Height of barcode
144
+ def height=(height)
145
+ reset_symbol
146
+
147
+ @zint_symbol[:height] = height
148
+ end
149
+
150
+ # Gets scale of barcode
151
+ def scale
152
+ @zint_symbol[:scale]
153
+ end
154
+
155
+ # Sets scale of barcode
156
+ #
157
+ # @param scale [Float] Scale of barcode
158
+ def scale=(scale)
159
+ reset_symbol
160
+
161
+ @zint_symbol[:scale] = scale
162
+ end
163
+
164
+ # Gets whitespace width of barcode
165
+ def whitespace_width
166
+ @zint_symbol[:whitespace_width]
167
+ end
168
+
169
+ # Sets whitespace width of barcode
170
+ #
171
+ # @param whitespace width [Integer] Whitespace width of barcode
172
+ def whitespace_width=(whitespace_width)
173
+ reset_symbol
174
+
175
+ @zint_symbol[:whitespace_width] = whitespace_width
176
+ end
177
+
178
+ # Gets whitespace height of barcode
179
+ def whitespace_height
180
+ @zint_symbol[:whitespace_height]
181
+ end
182
+
183
+ # Sets whitespace height of barcode
184
+ #
185
+ # @param whitespace height [Integer] Whitespace height of barcode
186
+ def whitespace_height=(whitespace_height)
187
+ reset_symbol
188
+
189
+ @zint_symbol[:whitespace_height] = whitespace_height
190
+ end
191
+
192
+ # Gets border width of barcode
193
+ def border_width
194
+ @zint_symbol[:border_width]
195
+ end
196
+
197
+ # Sets border width of barcode
198
+ #
199
+ # @param border width [Integer] Border width of barcode
200
+ def border_width=(border_width)
201
+ reset_symbol
202
+
203
+ @zint_symbol[:border_width] = border_width
204
+ end
205
+
206
+ # Gets output options of barcode
207
+ def output_options
208
+ @zint_symbol[:output_options]
209
+ end
210
+
211
+ # Sets output options of barcode
212
+ #
213
+ # @param output options [Integer] Output options of barcode
214
+ def output_options=(output_options)
215
+ reset_symbol
216
+
217
+ @zint_symbol[:output_options] = output_options
218
+ end
219
+
220
+ # Gets foreground colour of barcode
221
+ def fgcolour
222
+ @zint_symbol[:fgcolour]
223
+ end
224
+
225
+ # Sets foreground colour of barcode
226
+ #
227
+ # @param fgcolour [String] Foreground colour of barcode
228
+ def fgcolour=(fgcolour)
229
+ reset_symbol
230
+
231
+ @zint_symbol[:fgcolour] = fgcolour
232
+ end
233
+
234
+ # Gets background colour of barcode
235
+ def bgcolour
236
+ @zint_symbol[:bgcolour]
237
+ end
238
+
239
+ # Sets background colour of barcode
240
+ #
241
+ # @param bgcolour [String] Background color of barcode
242
+ def bgcolour=(bgcolour)
243
+ reset_symbol
244
+
245
+ @zint_symbol[:bgcolour] = bgcolour
246
+ end
247
+
248
+ # Gets outfile of barcode
249
+ def outfile
250
+ @zint_symbol[:outfile]
251
+ end
252
+
253
+ # Gets option 1 of barcode
254
+ def option_1
255
+ @zint_symbol[:option_1]
256
+ end
257
+
258
+ # Sets option 1 of barcode
259
+ #
260
+ # @param option_1 [Integer] Option 1 of barcode
261
+ def option_1=(option_1)
262
+ reset_symbol
263
+
264
+ @zint_symbol[:option_1] = option_1
265
+ end
266
+
267
+ # Gets option 2 of barcode
268
+ def option_2
269
+ @zint_symbol[:option_2]
270
+ end
271
+
272
+ # Sets option 2 of barcode
273
+ #
274
+ # @param option 2 [Integer] Option 2 of barcode
275
+ def option_2=(option_2)
276
+ reset_symbol
277
+
278
+ @zint_symbol[:option_2] = option_2
279
+ end
280
+
281
+ # Gets option 3 of barcode
282
+ def option_3
283
+ @zint_symbol[:option_3]
284
+ end
285
+
286
+ # Sets option 3 of barcode
287
+ #
288
+ # @param option 3 [Integer] Option 3 of barcode
289
+ def option_3=(option_3)
290
+ reset_symbol
291
+
292
+ @zint_symbol[:option_3] = option_3
293
+ end
294
+
295
+ # Gets show_hrt of barcode
296
+ def show_hrt
297
+ @zint_symbol[:show_hrt]
298
+ end
299
+
300
+ # Sets show_hrt of barcode
301
+ # Set to 0 to hide text.
302
+ #
303
+ # @param show_hrt [Integer] show_hrt of barcode
304
+ def show_hrt=(show_hrt)
305
+ reset_symbol
306
+
307
+ @zint_symbol[:show_hrt] = show_hrt
308
+ end
309
+
310
+ # Gets font size of barcode
311
+ def fontsize
312
+ @zint_symbol[:fontsize]
313
+ end
314
+
315
+ # Sets font size of barcode
316
+ #
317
+ # @param font size [Integer] Font size of barcode
318
+ def fontsize=(fontsize)
319
+ reset_symbol
320
+
321
+ @zint_symbol[:fontsize] = fontsize
322
+ end
323
+
324
+ # Gets input mode of barcode
325
+ def input_mode
326
+ @zint_symbol[:input_mode]
327
+ end
328
+
329
+ # Sets input mode of barcode
330
+ #
331
+ # @param input_mode [Integer] Input mode of barcode
332
+ def input_mode=(input_mode)
333
+ reset_symbol
334
+
335
+ @zint_symbol[:input_mode] = input_mode
336
+ end
337
+
338
+ # Gets ECI of barcode
339
+ def eci
340
+ @zint_symbol[:eci]
341
+ end
342
+
343
+ # Sets ECI of barcode
344
+ #
345
+ # @param eci [Integer] ECI of barcode
346
+ def eci=(eci)
347
+ reset_symbol
348
+
349
+ @zint_symbol[:eci] = eci
350
+ end
351
+
352
+ # Gets text of barcode
353
+ def text
354
+ @zint_symbol[:text]
355
+ end
356
+
357
+ # Sets text of barcode
358
+ #
359
+ # @param text [String] Text of barcode
360
+ def text=(text)
361
+ reset_symbol
362
+
363
+ @zint_symbol[:text] = text
364
+ end
365
+
366
+ # Gets rows of barcode
367
+ def rows
368
+ @zint_symbol[:rows]
369
+ end
370
+
371
+ # Gets width of barcode
372
+ def width
373
+ @zint_symbol[:width]
374
+ end
375
+
376
+ # Gets primary message data for more complex symbols, with a terminating NUL, of barcode
377
+ def primary
378
+ @zint_symbol[:primary]
379
+ end
380
+
381
+ # Sets primary message of barcode
382
+ #
383
+ # @param primary [String] Primary of barcode
384
+ def primary=(primary)
385
+ reset_symbol
386
+
387
+ @zint_symbol[:primary] = primary
388
+ end
389
+
390
+ # Gets encoded_data of barcode
391
+ def encoded_data
392
+ @zint_symbol[:encoded_data]
393
+ end
394
+
395
+ # Sets encoded_data of barcode
396
+ #
397
+ # @param encoded_data [String] Encoded data of barcode
398
+ def encoded_data=(encoded_data)
399
+ reset_symbol
400
+
401
+ @zint_symbol[:encoded_data] = encoded_data
402
+ end
403
+
404
+ # Gets row height of barcode
405
+ def row_height
406
+ @zint_symbol[:row_height]
407
+ end
408
+
409
+ # Gets error text of barcode
410
+ def errtxt
411
+ @zint_symbol[:errtxt]
412
+ end
413
+
414
+ # Gets bitmap width of barcode
415
+ def bitmap_width
416
+ @zint_symbol[:bitmap_width]
417
+ end
418
+
419
+ # Gets bitmap height of barcode
420
+ def bitmap_height
421
+ @zint_symbol[:bitmap_height]
422
+ end
423
+
424
+ # Gets bitmap byte length of barcode
425
+ def bitmap_byte_length
426
+ @zint_symbol[:bitmap_byte_length]
427
+ end
428
+
429
+ # Gets dot size of barcode
430
+ def dot_size
431
+ @zint_symbol[:dot_size]
432
+ end
433
+
434
+ # Sets dot size of barcode
435
+ #
436
+ # @param dot size [Float] Dot size of barcode
437
+ def dot_size=(dot_size)
438
+ reset_symbol
439
+
440
+ @zint_symbol[:dot_size] = dot_size
441
+ end
442
+
443
+ # Gets debug level of barcode
444
+ def debug
445
+ @zint_symbol[:debug]
446
+ end
447
+
448
+ # Sets debug level of barcode
449
+ #
450
+ # @param debug [Integer] Debug level of barcode
451
+ def debug=(debug)
452
+ reset_symbol
453
+
454
+ @zint_symbol[:debug] = debug
455
+ end
456
+
457
+ # Gets warn level of barcode
458
+ def warn_level
459
+ @zint_symbol[:warn_level]
460
+ end
461
+
462
+ # Sets warn level of barcode
463
+ #
464
+ # @param warn_level [Integer] Warn level of barcode
465
+ def warn_level=(warn_level)
466
+ reset_symbol
467
+
468
+ @zint_symbol[:warn_level] = warn_level
127
469
  end
128
470
 
129
471
  private
130
472
 
473
+ def reset_symbol
474
+ call_function(:ZBarcode_Clear, @zint_symbol)
475
+ end
476
+
131
477
  def call_function(function_name, *args)
132
- error_code = Zint.send(function_name.to_s, *args)
478
+ error_code = Native.send(function_name.to_sym, *args)
133
479
 
134
480
  if Zint::ERRORS[error_code]
135
- Zint.raise_error(error_code, zint_symbol[:errtxt])
481
+ Native.raise_error(error_code, @zint_symbol[:errtxt])
136
482
  end
137
483
 
138
484
  error_code
139
485
  end
140
486
 
141
487
  def create_symbol(type)
142
- symbol = Structs::Symbol.new(Zint.ZBarcode_Create)
488
+ symbol = Native.ZBarcode_Create
143
489
  symbol[:symbology] = type
144
490
 
145
491
  symbol
@@ -0,0 +1,8 @@
1
+ module Zint
2
+ ZINT_VERSION = ENV["ZINT_VERSION"] || "2.10.0"
3
+ # ZINT_SOURCE_URI = "file://#{File.join(File.expand_path("../../../", __FILE__))}/ports/archives/zint-#{ZINT_VERSION}-src.tar.gz"
4
+ ZINT_SOURCE_URI = "https://downloads.sourceforge.net/zint/zint-#{ZINT_VERSION}-src.tar.gz"
5
+ ZINT_SOURCE_SHA1 = "e4a8a5ccbc9e1901e4b592ccc80e17184f2ff5e8"
6
+
7
+ MINI_PORTILE_VERSION = "~> 2.1"
8
+ end