ruby-zint 1.0.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. checksums.yaml +4 -4
  2. data/.standard.yml +2 -0
  3. data/Gemfile +2 -0
  4. data/README.md +30 -8
  5. data/Rakefile +12 -0
  6. data/ext/ruby-zint/extconf.rb +86 -0
  7. data/lib/zint/aus_post.rb +1 -0
  8. data/lib/zint/aus_redirect.rb +1 -0
  9. data/lib/zint/aus_reply.rb +1 -0
  10. data/lib/zint/aus_route.rb +1 -0
  11. data/lib/zint/azrune.rb +1 -0
  12. data/lib/zint/aztec.rb +1 -0
  13. data/lib/zint/barcode.rb +439 -47
  14. data/lib/zint/{noascii.rb → bc_412.rb} +3 -2
  15. data/lib/zint/c25iata.rb +1 -0
  16. data/lib/zint/c25ind.rb +1 -0
  17. data/lib/zint/c25inter.rb +1 -0
  18. data/lib/zint/c25logic.rb +1 -0
  19. data/lib/zint/c25matrix.rb +1 -0
  20. data/lib/zint/c25standard.rb +1 -0
  21. data/lib/zint/{box.rb → cep_net.rb} +3 -2
  22. data/lib/zint/channel.rb +1 -0
  23. data/lib/zint/codabar.rb +1 -0
  24. data/lib/zint/codablock_f.rb +1 -0
  25. data/lib/zint/code11.rb +1 -0
  26. data/lib/zint/code128.rb +1 -0
  27. data/lib/zint/{dotty_mode.rb → code128ab.rb} +3 -2
  28. data/lib/zint/code128b.rb +2 -4
  29. data/lib/zint/code16k.rb +1 -0
  30. data/lib/zint/code32.rb +1 -0
  31. data/lib/zint/code39.rb +1 -0
  32. data/lib/zint/code49.rb +1 -0
  33. data/lib/zint/code93.rb +1 -0
  34. data/lib/zint/code_one.rb +1 -0
  35. data/lib/zint/constants/capability_flags.rb +14 -11
  36. data/lib/zint/constants/input_data_types.rb +8 -7
  37. data/lib/zint/constants/output_options.rb +14 -11
  38. data/lib/zint/constants/symbologies.rb +13 -6
  39. data/lib/zint/constants/warn_levels.rb +1 -1
  40. data/lib/zint/daft.rb +1 -0
  41. data/lib/zint/data_matrix.rb +1 -0
  42. data/lib/zint/dbarexp.rb +1 -0
  43. data/lib/zint/dbarexpstk.rb +1 -0
  44. data/lib/zint/dbarltd.rb +1 -0
  45. data/lib/zint/dbaromn.rb +1 -0
  46. data/lib/zint/dbaromnstk.rb +1 -0
  47. data/lib/zint/dbarstk.rb +1 -0
  48. data/lib/zint/dependencies.rb +8 -0
  49. data/lib/zint/dot_code.rb +1 -0
  50. data/lib/zint/dpd.rb +1 -0
  51. data/lib/zint/dpident.rb +1 -0
  52. data/lib/zint/dpleit.rb +1 -0
  53. data/lib/zint/ean128.rb +1 -0
  54. data/lib/zint/ean14.rb +1 -0
  55. data/lib/zint/eanx.rb +1 -0
  56. data/lib/zint/eanxchk.rb +1 -0
  57. data/lib/zint/excode39.rb +1 -0
  58. data/lib/zint/fim.rb +1 -0
  59. data/lib/zint/flat.rb +1 -0
  60. data/lib/zint/grid_matrix.rb +1 -0
  61. data/lib/zint/gs1_128.rb +1 -0
  62. data/lib/zint/hanxin.rb +1 -0
  63. data/lib/zint/hibc128.rb +1 -0
  64. data/lib/zint/hibc39.rb +1 -0
  65. data/lib/zint/hibcaztec.rb +1 -0
  66. data/lib/zint/hibcblockf.rb +1 -0
  67. data/lib/zint/hibcdm.rb +1 -0
  68. data/lib/zint/hibcmicpdf.rb +1 -0
  69. data/lib/zint/hibcpdf.rb +1 -0
  70. data/lib/zint/hibcqr.rb +1 -0
  71. data/lib/zint/isbnx.rb +1 -0
  72. data/lib/zint/itf14.rb +1 -0
  73. data/lib/zint/japan_post.rb +1 -0
  74. data/lib/zint/kix.rb +1 -0
  75. data/lib/zint/korea_post.rb +1 -0
  76. data/lib/zint/logmars.rb +1 -0
  77. data/lib/zint/mailmark.rb +1 -0
  78. data/lib/zint/mailmark_2d.rb +8 -0
  79. data/lib/zint/mailmark_4s.rb +8 -0
  80. data/lib/zint/maxi_code.rb +1 -0
  81. data/lib/zint/micro_pdf417.rb +1 -0
  82. data/lib/zint/micro_qr.rb +1 -0
  83. data/lib/zint/msiplessey.rb +1 -0
  84. data/lib/zint/native.rb +87 -0
  85. data/lib/zint/nve18.rb +1 -0
  86. data/lib/zint/one_code.rb +1 -0
  87. data/lib/zint/pdf417.rb +1 -0
  88. data/lib/zint/pdf417comp.rb +1 -0
  89. data/lib/zint/pdf417trunc.rb +1 -0
  90. data/lib/zint/pharma.rb +1 -0
  91. data/lib/zint/pharmatwo.rb +1 -0
  92. data/lib/zint/planet.rb +1 -0
  93. data/lib/zint/plessey.rb +1 -0
  94. data/lib/zint/postnet.rb +1 -0
  95. data/lib/zint/pzn.rb +1 -0
  96. data/lib/zint/qr.rb +1 -0
  97. data/lib/zint/rmqr.rb +1 -0
  98. data/lib/zint/rss14.rb +1 -0
  99. data/lib/zint/rss14stack.rb +1 -0
  100. data/lib/zint/rss14stackomni.rb +1 -0
  101. data/lib/zint/rssexp.rb +1 -0
  102. data/lib/zint/rssexpstack.rb +1 -0
  103. data/lib/zint/rssltd.rb +1 -0
  104. data/lib/zint/structs/structapp.rb +25 -0
  105. data/lib/zint/structs/symbol.rb +44 -36
  106. data/lib/zint/structs/vector.rb +47 -5
  107. data/lib/zint/structs/vector_circle.rb +32 -0
  108. data/lib/zint/structs/vector_hexagon.rb +31 -0
  109. data/lib/zint/structs/vector_rect.rb +37 -0
  110. data/lib/zint/structs/vector_string.rb +43 -8
  111. data/lib/zint/telepen.rb +1 -0
  112. data/lib/zint/telepennum.rb +1 -0
  113. data/lib/zint/ultra.rb +1 -0
  114. data/lib/zint/upc_a.rb +1 -0
  115. data/lib/zint/upc_a_chk.rb +1 -0
  116. data/lib/zint/upc_e.rb +1 -0
  117. data/lib/zint/upc_e_chk.rb +1 -0
  118. data/lib/zint/upnqr.rb +1 -0
  119. data/lib/zint/{bind.rb → upu_s10.rb} +3 -2
  120. data/lib/zint/uspsimail.rb +1 -0
  121. data/lib/zint/version.rb +1 -1
  122. data/lib/zint/vin.rb +1 -0
  123. data/lib/zint/zint_recipe.rb +27 -0
  124. data/lib/zint.rb +15 -83
  125. data/ports/archives/zint-2.12.0-src.tar.gz +0 -0
  126. metadata +34 -12
  127. data/Gemfile.lock +0 -79
  128. data/lib/zint/stdout.rb +0 -7
  129. data/lib/zint/structs/circle.rb +0 -11
  130. data/lib/zint/structs/hexagon.rb +0 -11
  131. data/lib/zint/structs/rect.rb +0 -12
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,33 +25,23 @@ 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
- # @param path [String] Path to export file
34
+ # @param path [String] Path to export file.
35
+ # Contains the name of the file to output a resulting barcode symbol to.
36
+ # Must end in .png, .gif, .bmp, .emf, .eps, .pcx, .svg, .tif or .txt
49
37
  # @param rotate_angle [Integer] Rotate angle in degrees (0, 90, 180, 270)
50
38
  def to_file(path:, rotate_angle: 0)
51
39
  @zint_symbol[:outfile] = path
52
40
 
53
41
  if input_file
54
- call_function(:ZBarcode_Encode_File_and_Print, zint_symbol, input_file, rotate_angle)
42
+ call_function(:ZBarcode_Encode_File_and_Print, @zint_symbol, input_file, rotate_angle)
55
43
  else
56
- call_function(:ZBarcode_Encode_and_Print, zint_symbol, value, 0, rotate_angle)
44
+ call_function(:ZBarcode_Encode_and_Print, @zint_symbol, value, 0, rotate_angle)
57
45
  end
58
46
  end
59
47
 
@@ -79,37 +67,34 @@ module Zint
79
67
  # Exports barcode to buffer
80
68
  #
81
69
  # @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)
70
+ # @return [String] Exported barcode buffer
71
+ def to_buffer(rotate_angle: 0)
85
72
  @zint_symbol[:output_options] = Zint::OUT_BUFFER_INTERMEDIATE
86
73
 
87
74
  if input_file
88
- call_function(:ZBarcode_Encode_File_and_Buffer, zint_symbol, input_file, rotate_angle)
75
+ call_function(:ZBarcode_Encode_File_and_Buffer, @zint_symbol, input_file, rotate_angle)
89
76
  else
90
- call_function(:ZBarcode_Encode_and_Buffer, zint_symbol, value, 0, rotate_angle)
77
+ call_function(:ZBarcode_Encode_and_Buffer, @zint_symbol, value, 0, rotate_angle)
91
78
  end
92
79
 
93
- zint_bitmap = zint_symbol[:bitmap].read_string((zint_symbol[:bitmap_width] * zint_symbol[:bitmap_height]))
80
+ @zint_symbol[:bitmap].read_bytes((@zint_symbol[:bitmap_width] * @zint_symbol[:bitmap_height]))
81
+ end
94
82
 
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
83
+ # Exports barcode to buffer
84
+ #
85
+ # @param rotate_angle [Integer] Rotate angle in degrees (0, 90, 180, 270)
86
+ # @return [Zint::Bitmap] Exported bitmap
87
+ def to_bitmap(rotate_angle: 0)
88
+ zint_bitmap = to_buffer(rotate_angle: rotate_angle)
110
89
 
111
- Bitmap.new(zint_symbol[:bitmap_width], zint_symbol[:bitmap_height], pixels)
90
+ pixels = []
91
+ @zint_symbol[:bitmap_height].times do |row|
92
+ @zint_symbol[:bitmap_width].times do |column|
93
+ pixels << BitmapPixel.new(column, row, zint_bitmap[pixels.size])
94
+ end
112
95
  end
96
+
97
+ Bitmap.new(@zint_symbol[:bitmap_width], @zint_symbol[:bitmap_height], pixels)
113
98
  end
114
99
 
115
100
  # Exports barcode as Zint vector
@@ -118,28 +103,435 @@ module Zint
118
103
  # @return [Zint::Structs::Vector] Vector data of barcode
119
104
  def to_vector(rotate_angle: 0)
120
105
  if input_file
121
- call_function(:ZBarcode_Encode_File_and_Buffer_Vector, zint_symbol, input_file, rotate_angle)
106
+ call_function(:ZBarcode_Encode_File_and_Buffer_Vector, @zint_symbol, input_file, rotate_angle)
122
107
  else
123
- call_function(:ZBarcode_Encode_and_Buffer_Vector, zint_symbol, value, 0, rotate_angle)
108
+ call_function(:ZBarcode_Encode_and_Buffer_Vector, @zint_symbol, value, 0, rotate_angle)
124
109
  end
125
110
 
126
- Structs::Vector.new(zint_symbol[:vector])
111
+ v = @zint_symbol[:vector]
112
+ # Avoid garbage collection of Symbol before Vector, since the Vector is also freed by ZBarcode_Delete()
113
+ v.instance_variable_set(:@symbol, @zint_symbol)
114
+ v
115
+ end
116
+
117
+ # Free barcode and all memory associated with it.
118
+ def free
119
+ @zint_symbol.pointer.free
120
+ end
121
+
122
+ # Attributes
123
+
124
+ # Gets type of barcode
125
+ def symbology
126
+ @zint_symbol[:symbology]
127
+ end
128
+
129
+ # Sets symbol to use (see BARCODE_XXX below)
130
+ #
131
+ # @param type [Integer] Type of barcode
132
+ def symbology=(type)
133
+ reset_symbol
134
+
135
+ @zint_symbol[:symbology] = type
136
+ end
137
+
138
+ # Gets height of barcode
139
+ def height
140
+ @zint_symbol[:height]
141
+ end
142
+
143
+ # Sets height in X-dimensions (ignored for fixed-width barcodes)
144
+ #
145
+ # @param height [Float] Height of barcode
146
+ def height=(height)
147
+ reset_symbol
148
+
149
+ @zint_symbol[:height] = height
150
+ end
151
+
152
+ # Gets scale factor of barcode
153
+ def scale
154
+ @zint_symbol[:scale]
155
+ end
156
+
157
+ # Sets scale factor when printing barcode
158
+ #
159
+ # @param scale [Float] Scale of barcode
160
+ def scale=(scale)
161
+ reset_symbol
162
+
163
+ @zint_symbol[:scale] = scale
164
+ end
165
+
166
+ # Gets width in X-dimensions of whitespace to left & right of barcode
167
+ def whitespace_width
168
+ @zint_symbol[:whitespace_width]
169
+ end
170
+
171
+ # Sets width in X-dimensions of whitespace to left & right of barcode
172
+ #
173
+ # @param whitespace width [Integer] Whitespace width of barcode
174
+ def whitespace_width=(whitespace_width)
175
+ reset_symbol
176
+
177
+ @zint_symbol[:whitespace_width] = whitespace_width
178
+ end
179
+
180
+ # Gets height in X-dimensions of whitespace above & below the barcode
181
+ def whitespace_height
182
+ @zint_symbol[:whitespace_height]
183
+ end
184
+
185
+ # Sets height in X-dimensions of whitespace above & below the barcode
186
+ #
187
+ # @param whitespace height [Integer] Whitespace height of barcode
188
+ def whitespace_height=(whitespace_height)
189
+ reset_symbol
190
+
191
+ @zint_symbol[:whitespace_height] = whitespace_height
192
+ end
193
+
194
+ # Gets size of border in X-dimensions
195
+ def border_width
196
+ @zint_symbol[:border_width]
197
+ end
198
+
199
+ # Sets size of border in X-dimensions
200
+ #
201
+ # @param border width [Integer] Border width of barcode
202
+ def border_width=(border_width)
203
+ reset_symbol
204
+
205
+ @zint_symbol[:border_width] = border_width
206
+ end
207
+
208
+ # Gets output options of barcode
209
+ def output_options
210
+ @zint_symbol[:output_options]
211
+ end
212
+
213
+ # Set various output parameters (bind, box etc, see below) of barcode
214
+ #
215
+ # @param output options [Integer] Output options of barcode
216
+ def output_options=(output_options)
217
+ reset_symbol
218
+
219
+ @zint_symbol[:output_options] = output_options
220
+ end
221
+
222
+ # Gets foreground colour of barcode
223
+ def fgcolour
224
+ @zint_symbol[:fgcolour].to_s
225
+ end
226
+
227
+ # Sets foreground as RGB/RGBA hexadecimal string, 6 or 8 characters, NUL-terminated
228
+ #
229
+ # @param fgcolour [String] Foreground colour of barcode
230
+ def fgcolour=(fgcolour)
231
+ reset_symbol
232
+
233
+ @zint_symbol[:fgcolour] = fgcolour
234
+ end
235
+
236
+ # Gets background colour of barcode
237
+ def bgcolour
238
+ @zint_symbol[:bgcolour].to_s
239
+ end
240
+
241
+ # Sets background as RGB/RGBA hexadecimal string, 6 or 8 characters, NUL-terminated
242
+ #
243
+ # @param bgcolour [String] Background color of barcode
244
+ def bgcolour=(bgcolour)
245
+ reset_symbol
246
+
247
+ @zint_symbol[:bgcolour] = bgcolour
248
+ end
249
+
250
+ # Contains the name of the file to output a resulting barcode symbol to.
251
+ #
252
+ # Must end in .png, .gif, .bmp, .emf, .eps, .pcx, .svg, .tif or .txt
253
+ def outfile
254
+ @zint_symbol[:outfile].to_s
255
+ end
256
+
257
+ # Gets option 1 of barcode
258
+ def option_1
259
+ @zint_symbol[:option_1]
260
+ end
261
+
262
+ # Sets option 1 (symbol-specific options (see "../docs/manual.txt"))
263
+ #
264
+ # @param option_1 [Integer] Option 1 of barcode
265
+ def option_1=(option_1)
266
+ reset_symbol
267
+
268
+ @zint_symbol[:option_1] = option_1
269
+ end
270
+
271
+ # Gets option 2 of barcode
272
+ def option_2
273
+ @zint_symbol[:option_2]
274
+ end
275
+
276
+ # Sets option 2 (symbol-specific options) of barcode
277
+ #
278
+ # @param option 2 [Integer] Option 2 of barcode
279
+ def option_2=(option_2)
280
+ reset_symbol
281
+
282
+ @zint_symbol[:option_2] = option_2
283
+ end
284
+
285
+ # Gets option 3 of barcode
286
+ def option_3
287
+ @zint_symbol[:option_3]
288
+ end
289
+
290
+ # Sets option 3 (symbol-specific options) of barcode
291
+ #
292
+ # @param option 3 [Integer] Option 3 of barcode
293
+ def option_3=(option_3)
294
+ reset_symbol
295
+
296
+ @zint_symbol[:option_3] = option_3
297
+ end
298
+
299
+ # Gets show_hrt of barcode
300
+ def show_hrt
301
+ @zint_symbol[:show_hrt]
302
+ end
303
+
304
+ # Sets show_hrt of barcode
305
+ # show = 1 or hide = 0 Human Readable Text. Default is show (1)
306
+ #
307
+ # @param show_hrt [Integer] show_hrt of barcode
308
+ def show_hrt=(show_hrt)
309
+ reset_symbol
310
+
311
+ @zint_symbol[:show_hrt] = show_hrt
312
+ end
313
+
314
+ # Gets font size of barcode
315
+ def fontsize
316
+ @zint_symbol[:fontsize]
317
+ end
318
+
319
+ # Sets font size of barcode (Unused)
320
+ #
321
+ # @param font size [Integer] Font size of barcode
322
+ def fontsize=(fontsize)
323
+ reset_symbol
324
+
325
+ @zint_symbol[:fontsize] = fontsize
326
+ end
327
+
328
+ # Gets input mode of barcode
329
+ def input_mode
330
+ @zint_symbol[:input_mode]
331
+ end
332
+
333
+ # Sets encoding of input data (see DATA_MODE etc below). Default DATA_MODE
334
+ #
335
+ # @param input_mode [Integer] Input mode of barcode
336
+ def input_mode=(input_mode)
337
+ reset_symbol
338
+
339
+ @zint_symbol[:input_mode] = input_mode
340
+ end
341
+
342
+ # Gets ECI of barcode
343
+ def eci
344
+ @zint_symbol[:eci]
345
+ end
346
+
347
+ # Sets extended Channel Interpretation. Default 0 (none)
348
+ #
349
+ # @param eci [Integer] ECI of barcode
350
+ def eci=(eci)
351
+ reset_symbol
352
+
353
+ @zint_symbol[:eci] = eci
354
+ end
355
+
356
+ # Gets resolution of output in dots per mm (BMP/EMF/PCX/PNG/TIF only). Default 0 (none)
357
+ def dpmm
358
+ @zint_symbol[:dpmm]
359
+ end
360
+
361
+ # Sets resolution of output in dots per mm (BMP/EMF/PCX/PNG/TIF only). Default 0 (none)
362
+ #
363
+ # @param text [Float] Text of barcode
364
+ def dpmm=(dpmm)
365
+ reset_symbol
366
+
367
+ @zint_symbol[:dpmm] = dpmm
368
+ end
369
+
370
+ # Gets height in X-dimensions that EAN/UPC guard bars descend. Default 5
371
+ def guard_descent
372
+ @zint_symbol[:guard_descent]
373
+ end
374
+
375
+ # Sets height in X-dimensions that EAN/UPC guard bars descend. Default 5
376
+ #
377
+ # @param text [Float] Text of barcode
378
+ def guard_descent=(guard_descent)
379
+ reset_symbol
380
+
381
+ @zint_symbol[:guard_descent] = guard_descent
382
+ end
383
+
384
+ # Gets structured append info. Default structapp.count 0 (none)
385
+ def structapp
386
+ @zint_symbol[:structapp]
387
+ end
388
+
389
+ # Sets structured append info. Default structapp.count 0 (none)
390
+ #
391
+ # @param text [Structs::Structapp] Text of barcode
392
+ def structapp=(structapp)
393
+ reset_symbol
394
+
395
+ @zint_symbol[:structapp] = structapp
396
+ end
397
+
398
+ # Human Readable Text, which usually consists of input data plus one more check digit. Uses UTF-8 formatting.
399
+ def text
400
+ @zint_symbol[:text].to_s.force_encoding(Encoding::UTF_8)
401
+ end
402
+
403
+ # Sets Human Readable Text (if any), UTF-8, NUL-terminated (output only) of barcode
404
+ #
405
+ # @param text [String] Text of barcode
406
+ def text=(text)
407
+ reset_symbol
408
+
409
+ @zint_symbol[:text] = text
410
+ end
411
+
412
+ # Gets rows of barcode
413
+ def rows
414
+ @zint_symbol[:rows]
415
+ end
416
+
417
+ # Gets width of barcode
418
+ def width
419
+ @zint_symbol[:width]
420
+ end
421
+
422
+ # Gets primary message data for more complex symbols
423
+ def primary
424
+ @zint_symbol[:primary].to_s
425
+ end
426
+
427
+ # Sets primary message data (MaxiCode, Composite), NUL-terminated of barcode
428
+ #
429
+ # @param primary [String] Primary of barcode
430
+ def primary=(primary)
431
+ reset_symbol
432
+
433
+ @zint_symbol[:primary] = primary
434
+ end
435
+
436
+ # Gets encoded data of barcode
437
+ def encoded_data
438
+ @zint_symbol[:encoded_data]
439
+ end
440
+
441
+ # Sets encoded data (output only). Allows for rows of 1144 modules of barcode
442
+ #
443
+ # @param encoded_data [String] Encoded data of barcode
444
+ def encoded_data=(encoded_data)
445
+ reset_symbol
446
+
447
+ @zint_symbol[:encoded_data] = encoded_data
448
+ end
449
+
450
+ # Gets row height of barcode
451
+ def row_height
452
+ @zint_symbol[:row_height]
453
+ end
454
+
455
+ # Gets error message in the event that an error occurred
456
+ def errtxt
457
+ @zint_symbol[:errtxt].to_s.force_encoding(Encoding::UTF_8)
458
+ end
459
+
460
+ # Gets bitmap width of barcode
461
+ def bitmap_width
462
+ @zint_symbol[:bitmap_width]
463
+ end
464
+
465
+ # Gets bitmap height of barcode
466
+ def bitmap_height
467
+ @zint_symbol[:bitmap_height]
468
+ end
469
+
470
+ # Gets bitmap byte length of barcode
471
+ def bitmap_byte_length
472
+ @zint_symbol[:bitmap_byte_length]
473
+ end
474
+
475
+ # Gets dot size of barcode
476
+ def dot_size
477
+ @zint_symbol[:dot_size]
478
+ end
479
+
480
+ # Sets size of dots used in BARCODE_DOTTY_MODE
481
+ #
482
+ # @param dot size [Float] Dot size of barcode
483
+ def dot_size=(dot_size)
484
+ reset_symbol
485
+
486
+ @zint_symbol[:dot_size] = dot_size
487
+ end
488
+
489
+ # Gets debugging flags
490
+ def debug
491
+ @zint_symbol[:debug]
492
+ end
493
+
494
+ # Sets debugging flags
495
+ #
496
+ # @param debug [Integer] Debug level of barcode
497
+ def debug=(debug)
498
+ reset_symbol
499
+
500
+ @zint_symbol[:debug] = debug
501
+ end
502
+
503
+ # Gets warn level of barcode
504
+ def warn_level
505
+ @zint_symbol[:warn_level]
506
+ end
507
+
508
+ # Sets warn level (affects error/warning value returned by Zint API (see WARN_XXX below)) of barcode
509
+ #
510
+ # @param warn_level [Integer] Warn level of barcode
511
+ def warn_level=(warn_level)
512
+ reset_symbol
513
+
514
+ @zint_symbol[:warn_level] = warn_level
127
515
  end
128
516
 
129
517
  private
130
518
 
519
+ def reset_symbol
520
+ call_function(:ZBarcode_Clear, @zint_symbol)
521
+ end
522
+
131
523
  def call_function(function_name, *args)
132
- error_code = Zint.send(function_name.to_s, *args)
524
+ error_code = Native.send(function_name.to_sym, *args)
133
525
 
134
526
  if Zint::ERRORS[error_code]
135
- Zint.raise_error(error_code, zint_symbol[:errtxt])
527
+ Native.raise_error(error_code, @zint_symbol[:errtxt])
136
528
  end
137
529
 
138
530
  error_code
139
531
  end
140
532
 
141
533
  def create_symbol(type)
142
- symbol = Structs::Symbol.new(Zint.ZBarcode_Create)
534
+ symbol = Native.ZBarcode_Create
143
535
  symbol[:symbology] = type
144
536
 
145
537
  symbol
@@ -1,7 +1,8 @@
1
1
  module Zint
2
- class NoAscii < Barcode
2
+ # IBM BC412 (SEMI T1-95)
3
+ class Bc412 < Barcode
3
4
  def initialize(value: nil, input_file: nil, options: {})
4
- super(value: value, input_file: input_file, type: Zint::BARCODE_NO_ASCII, options: options)
5
+ super(value: value, input_file: input_file, type: Zint::BARCODE_BC412, options: options)
5
6
  end
6
7
  end
7
8
  end
data/lib/zint/c25iata.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  module Zint
2
+ # 2 of 5 IATA
2
3
  class C25iata < Barcode
3
4
  def initialize(value: nil, input_file: nil, options: {})
4
5
  super(value: value, input_file: input_file, type: Zint::BARCODE_C25IATA, options: options)
data/lib/zint/c25ind.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  module Zint
2
+ # 2 of 5 Industrial
2
3
  class C25ind < Barcode
3
4
  def initialize(value: nil, input_file: nil, options: {})
4
5
  super(value: value, input_file: input_file, type: Zint::BARCODE_C25IND, options: options)
data/lib/zint/c25inter.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  module Zint
2
+ # 2 of 5 Interleaved
2
3
  class C25inter < Barcode
3
4
  def initialize(value: nil, input_file: nil, options: {})
4
5
  super(value: value, input_file: input_file, type: Zint::BARCODE_C25INTER, options: options)
data/lib/zint/c25logic.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  module Zint
2
+ # 2 of 5 Data Logic
2
3
  class C25logic < Barcode
3
4
  def initialize(value: nil, input_file: nil, options: {})
4
5
  super(value: value, input_file: input_file, type: Zint::BARCODE_C25LOGIC, options: options)
@@ -1,4 +1,5 @@
1
1
  module Zint
2
+ # Legacy
2
3
  class C25matrix < Barcode
3
4
  def initialize(value: nil, input_file: nil, options: {})
4
5
  super(value: value, input_file: input_file, type: Zint::BARCODE_C25MATRIX, options: options)
@@ -1,4 +1,5 @@
1
1
  module Zint
2
+ # 2 of 5 Standard (Matrix)
2
3
  class C25standard < Barcode
3
4
  def initialize(value: nil, input_file: nil, options: {})
4
5
  super(value: value, input_file: input_file, type: Zint::BARCODE_C25STANDARD, options: options)
@@ -1,7 +1,8 @@
1
1
  module Zint
2
- class Box < Barcode
2
+ # Brazilian CEPNet Postal Code
3
+ class CepNet < Barcode
3
4
  def initialize(value: nil, input_file: nil, options: {})
4
- super(value: value, input_file: input_file, type: Zint::BARCODE_BOX, options: options)
5
+ super(value: value, input_file: input_file, type: Zint::BARCODE_CEPNET, options: options)
5
6
  end
6
7
  end
7
8
  end
data/lib/zint/channel.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  module Zint
2
+ # Channel Code
2
3
  class Channel < Barcode
3
4
  def initialize(value: nil, input_file: nil, options: {})
4
5
  super(value: value, input_file: input_file, type: Zint::BARCODE_CHANNEL, options: options)
data/lib/zint/codabar.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  module Zint
2
+ # Codabar
2
3
  class Codabar < Barcode
3
4
  def initialize(value: nil, input_file: nil, options: {})
4
5
  super(value: value, input_file: input_file, type: Zint::BARCODE_CODABAR, options: options)
@@ -1,4 +1,5 @@
1
1
  module Zint
2
+ # Codablock-F
2
3
  class CodablockF < Barcode
3
4
  def initialize(value: nil, input_file: nil, options: {})
4
5
  super(value: value, input_file: input_file, type: Zint::BARCODE_CODABLOCKF, options: options)
data/lib/zint/code11.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  module Zint
2
+ # Code 11
2
3
  class Code11 < Barcode
3
4
  def initialize(value: nil, input_file: nil, options: {})
4
5
  super(value: value, input_file: input_file, type: Zint::BARCODE_CODE11, options: options)
data/lib/zint/code128.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  module Zint
2
+ # Code 128
2
3
  class Code128 < Barcode
3
4
  def initialize(value: nil, input_file: nil, options: {})
4
5
  super(value: value, input_file: input_file, type: Zint::BARCODE_CODE128, options: options)
@@ -1,7 +1,8 @@
1
1
  module Zint
2
- class DottyMode < Barcode
2
+ # Code 128 (Suppress Code Set C)
3
+ class Code128AB < Barcode
3
4
  def initialize(value: nil, input_file: nil, options: {})
4
- super(value: value, input_file: input_file, type: Zint::BARCODE_DOTTY_MODE, options: options)
5
+ super(value: value, input_file: input_file, type: Zint::BARCODE_CODE128AB, options: options)
5
6
  end
6
7
  end
7
8
  end
data/lib/zint/code128b.rb CHANGED
@@ -1,7 +1,5 @@
1
1
  module Zint
2
- class Code128b < Barcode
3
- def initialize(value: nil, input_file: nil, options: {})
4
- super(value: value, input_file: input_file, type: Zint::BARCODE_CODE128B, options: options)
5
- end
2
+ # Legacy
3
+ class Code128B < Code128AB
6
4
  end
7
5
  end
data/lib/zint/code16k.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  module Zint
2
+ # Code 16k
2
3
  class Code16k < Barcode
3
4
  def initialize(value: nil, input_file: nil, options: {})
4
5
  super(value: value, input_file: input_file, type: Zint::BARCODE_CODE16K, options: options)
data/lib/zint/code32.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  module Zint
2
+ # Code 32
2
3
  class Code32 < Barcode
3
4
  def initialize(value: nil, input_file: nil, options: {})
4
5
  super(value: value, input_file: input_file, type: Zint::BARCODE_CODE32, options: options)
data/lib/zint/code39.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  module Zint
2
+ # Code 39
2
3
  class Code39 < Barcode
3
4
  def initialize(value: nil, input_file: nil, options: {})
4
5
  super(value: value, input_file: input_file, type: Zint::BARCODE_CODE39, options: options)