ruby-zint 1.1.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +9 -0
  3. data/README.md +13 -5
  4. data/ext/ruby-zint/extconf.rb +2 -2
  5. data/lib/zint/aus_post.rb +3 -2
  6. data/lib/zint/aus_redirect.rb +3 -2
  7. data/lib/zint/aus_reply.rb +3 -2
  8. data/lib/zint/aus_route.rb +3 -2
  9. data/lib/zint/azrune.rb +3 -2
  10. data/lib/zint/aztec.rb +3 -2
  11. data/lib/zint/barcode.rb +109 -105
  12. data/lib/zint/bc_412.rb +8 -0
  13. data/lib/zint/c25iata.rb +3 -2
  14. data/lib/zint/c25ind.rb +3 -2
  15. data/lib/zint/c25inter.rb +3 -2
  16. data/lib/zint/c25logic.rb +3 -2
  17. data/lib/zint/c25matrix.rb +3 -2
  18. data/lib/zint/c25standard.rb +3 -2
  19. data/lib/zint/cep_net.rb +8 -0
  20. data/lib/zint/channel.rb +3 -2
  21. data/lib/zint/codabar.rb +3 -2
  22. data/lib/zint/codablock_f.rb +3 -2
  23. data/lib/zint/code11.rb +3 -2
  24. data/lib/zint/code128.rb +3 -2
  25. data/lib/zint/code128ab.rb +8 -0
  26. data/lib/zint/code128b.rb +2 -4
  27. data/lib/zint/code16k.rb +3 -2
  28. data/lib/zint/code32.rb +3 -2
  29. data/lib/zint/code39.rb +3 -2
  30. data/lib/zint/code49.rb +3 -2
  31. data/lib/zint/code93.rb +3 -2
  32. data/lib/zint/code_one.rb +3 -2
  33. data/lib/zint/constants/capability_flags.rb +14 -11
  34. data/lib/zint/constants/input_data_types.rb +8 -7
  35. data/lib/zint/constants/output_options.rb +14 -11
  36. data/lib/zint/constants/symbologies.rb +13 -6
  37. data/lib/zint/constants/warn_levels.rb +1 -1
  38. data/lib/zint/daft.rb +3 -2
  39. data/lib/zint/data_matrix.rb +4 -3
  40. data/lib/zint/dbarexp.rb +3 -2
  41. data/lib/zint/dbarexpstk.rb +3 -2
  42. data/lib/zint/dbarltd.rb +3 -2
  43. data/lib/zint/dbaromn.rb +3 -2
  44. data/lib/zint/dbaromnstk.rb +3 -2
  45. data/lib/zint/dbarstk.rb +3 -2
  46. data/lib/zint/dependencies.rb +2 -3
  47. data/lib/zint/dot_code.rb +3 -2
  48. data/lib/zint/dpd.rb +3 -2
  49. data/lib/zint/dpident.rb +3 -2
  50. data/lib/zint/dpleit.rb +3 -2
  51. data/lib/zint/ean128.rb +3 -2
  52. data/lib/zint/ean14.rb +3 -2
  53. data/lib/zint/eanx.rb +3 -2
  54. data/lib/zint/eanxchk.rb +3 -2
  55. data/lib/zint/excode39.rb +3 -2
  56. data/lib/zint/fim.rb +3 -2
  57. data/lib/zint/flat.rb +3 -2
  58. data/lib/zint/grid_matrix.rb +3 -2
  59. data/lib/zint/gs1_128.rb +3 -2
  60. data/lib/zint/hanxin.rb +3 -2
  61. data/lib/zint/hibc128.rb +3 -2
  62. data/lib/zint/hibc39.rb +3 -2
  63. data/lib/zint/hibcaztec.rb +3 -2
  64. data/lib/zint/hibcblockf.rb +3 -2
  65. data/lib/zint/hibcdm.rb +3 -2
  66. data/lib/zint/hibcmicpdf.rb +3 -2
  67. data/lib/zint/hibcpdf.rb +3 -2
  68. data/lib/zint/hibcqr.rb +3 -2
  69. data/lib/zint/isbnx.rb +3 -2
  70. data/lib/zint/itf14.rb +3 -2
  71. data/lib/zint/japan_post.rb +3 -2
  72. data/lib/zint/kix.rb +3 -2
  73. data/lib/zint/korea_post.rb +3 -2
  74. data/lib/zint/logmars.rb +3 -2
  75. data/lib/zint/mailmark.rb +3 -2
  76. data/lib/zint/mailmark_2d.rb +8 -0
  77. data/lib/zint/mailmark_4s.rb +8 -0
  78. data/lib/zint/maxi_code.rb +3 -2
  79. data/lib/zint/micro_pdf417.rb +3 -2
  80. data/lib/zint/micro_qr.rb +3 -2
  81. data/lib/zint/msiplessey.rb +3 -2
  82. data/lib/zint/native.rb +1 -1
  83. data/lib/zint/nve18.rb +3 -2
  84. data/lib/zint/one_code.rb +3 -2
  85. data/lib/zint/pdf417.rb +3 -2
  86. data/lib/zint/pdf417comp.rb +3 -2
  87. data/lib/zint/pdf417trunc.rb +3 -2
  88. data/lib/zint/pharma.rb +3 -2
  89. data/lib/zint/pharmatwo.rb +3 -2
  90. data/lib/zint/planet.rb +3 -2
  91. data/lib/zint/plessey.rb +3 -2
  92. data/lib/zint/postnet.rb +3 -2
  93. data/lib/zint/pzn.rb +3 -2
  94. data/lib/zint/qr.rb +3 -2
  95. data/lib/zint/rmqr.rb +3 -2
  96. data/lib/zint/rss14.rb +3 -2
  97. data/lib/zint/rss14stack.rb +3 -2
  98. data/lib/zint/rss14stackomni.rb +3 -2
  99. data/lib/zint/rssexp.rb +3 -2
  100. data/lib/zint/rssexpstack.rb +3 -2
  101. data/lib/zint/rssltd.rb +3 -2
  102. data/lib/zint/structs/structapp.rb +25 -0
  103. data/lib/zint/structs/symbol.rb +38 -35
  104. data/lib/zint/structs/vector_circle.rb +3 -2
  105. data/lib/zint/telepen.rb +3 -2
  106. data/lib/zint/telepennum.rb +3 -2
  107. data/lib/zint/ultra.rb +3 -2
  108. data/lib/zint/upc_a.rb +3 -2
  109. data/lib/zint/upc_a_chk.rb +3 -2
  110. data/lib/zint/upc_e.rb +3 -2
  111. data/lib/zint/upc_e_chk.rb +3 -2
  112. data/lib/zint/upnqr.rb +3 -2
  113. data/lib/zint/upu_s10.rb +8 -0
  114. data/lib/zint/uspsimail.rb +3 -2
  115. data/lib/zint/version.rb +1 -1
  116. data/lib/zint/vin.rb +3 -2
  117. data/lib/zint.rb +8 -1
  118. data/ports/archives/zint-2.12.0-src.tar.gz +0 -0
  119. metadata +128 -10
  120. data/lib/zint/bind.rb +0 -7
  121. data/lib/zint/box.rb +0 -7
  122. data/lib/zint/dotty_mode.rb +0 -7
  123. data/lib/zint/noascii.rb +0 -7
  124. data/lib/zint/stdout.rb +0 -7
  125. data/ports/archives/zint-2.10.0-src.tar.gz +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ccdb5e197e8d714e8f2d336b7448a1e104a69a5969b2d811ee6b0ef8998e6cac
4
- data.tar.gz: 547681f881a38f9168ac6330f07f300f578e2655eb3241633992e619394239e9
3
+ metadata.gz: 486ea5eb1e9c5382337612a19ce2101cbbcba980dc30b9d1ff702f2dbc4beba9
4
+ data.tar.gz: 0be779d097b3e9f99d7c79d4f8da8895c2e8931ea6be84165f77d40bc9f0a5a8
5
5
  SHA512:
6
- metadata.gz: 772885463ca263b7a44405a78851961817a04d97b7e2fe2bb7691a5f5b06c0a7c2055bcf5f9dcfc07e1c2b5d235dbf75dcd8a161d5b0d2d2f04629fb4fb603b4
7
- data.tar.gz: 565dcf8defee2948e4a4335e9681111056b7ee81a5dd03134f77cb030425131829964f7e2847813ee8866e61de3210e1796f855ae9c09ad601b623a8609dd9e4
6
+ metadata.gz: a33d8244d461e0dac91b66f086aa153d26ed188ae418fa3b1ba1d03139e424d678b2ef92a988f8db7c23d6e46627912e2f04a753c66e77b7c5b1b51e9383f3e5
7
+ data.tar.gz: c97890ca409f5393478f14b4630147229c8e4f282b640a51ff781d98fc8f4c31f42eaed3167d9e16d6b2dc021884af14fd92a75234f573bcbb46562db62d326d
data/.yardopts ADDED
@@ -0,0 +1,9 @@
1
+ --readme README.md
2
+ --title 'Ruby FFI binding for libzint'
3
+ --exclude '/ext.ruby-zint/'
4
+ --no-private
5
+ --charset utf-8
6
+ lib/**/*.rb
7
+ -
8
+ README.md
9
+ LICENSE.txt
data/README.md CHANGED
@@ -27,7 +27,7 @@ Install the libzint binary with your package manager (e. g. `apt install zint` o
27
27
 
28
28
  Other platforms require building [from source](https://www.zint.org.uk/manual/chapter/2).
29
29
 
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/).
30
+ **NOTE:** It is assumed that you are using libzint with the version [2.12](https://sourceforge.net/projects/zint/files/zint/2.12.0/).
31
31
 
32
32
  Then install this gem and enforce system libzint:
33
33
 
@@ -49,7 +49,7 @@ bundle config build.ruby-zint --enable-system-libzint
49
49
  ```ruby
50
50
  require "zint"
51
51
 
52
- barcode = Zint::Barcode.new(value: "Test", type: Zint::BARCODE_CODE128)
52
+ barcode = Zint::Barcode.new(value: "Test", symbology: Zint::BARCODE_CODE128)
53
53
 
54
54
  # Export to file
55
55
  barcode.to_file(path: "out.png")
@@ -71,8 +71,16 @@ end
71
71
  png.save("out.png")
72
72
 
73
73
  # Use vector export
74
- vector_struct = barcode.to_vector
75
- # See manual: https://zint.org.uk/manual/chapter/5#buffering-symbols-in-memory-vector
74
+ vec = Zint::Qr.new(value: "Test").to_vector
75
+ png = ChunkyPNG::Image.new(vec.width.to_i, vec.height.to_i, ChunkyPNG::Color::WHITE)
76
+ vec.each_rectangle do |rec|
77
+ png.rect(rec.x.to_i, rec.y.to_i,
78
+ rec.x.to_i+rec.width.to_i-1, rec.y.to_i+rec.height.to_i-1,
79
+ ChunkyPNG::Color::BLACK, ChunkyPNG::Color::BLACK)
80
+ end
81
+ png.save("out.png")
82
+
83
+ # See also manual: https://zint.org.uk/manual/chapter/5#buffering-symbols-in-memory-vector
76
84
 
77
85
  # Use file as input
78
86
  barcode = Zint::Barcode.new(input_file: "/tmp/test.txt")
@@ -99,4 +107,4 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/api-wa
99
107
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
100
108
 
101
109
  ## Credits
102
- The project is based on the work and ideas of Angel Pizarro's [zint](https://github.com/delagoya/zint).
110
+ 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.
@@ -45,11 +45,11 @@ def libzint_usable?
45
45
  m = Module.new do
46
46
  extend FFI::Library
47
47
 
48
- ffi_lib(%w[libzint.so.2.10 libzint zint])
48
+ ffi_lib(%w[libzint.so.2.12 libzint zint])
49
49
  attach_function(:ZBarcode_Version, [], :int32)
50
50
  end
51
51
 
52
- (21000...21100) === m.ZBarcode_Version
52
+ (21200...21300) === m.ZBarcode_Version
53
53
  rescue LoadError
54
54
  false
55
55
  end
data/lib/zint/aus_post.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  module Zint
2
+ # Australia Post 4-State Barcode
2
3
  class AusPost < Barcode
3
- def initialize(value: nil, input_file: nil, options: {})
4
- super(value: value, input_file: input_file, type: Zint::BARCODE_AUSPOST, options: options)
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_AUSPOST, **kwargs)
5
6
  end
6
7
  end
7
8
  end
@@ -1,7 +1,8 @@
1
1
  module Zint
2
+ # Australia Post Redirection
2
3
  class AusRedirect < Barcode
3
- def initialize(value: nil, input_file: nil, options: {})
4
- super(value: value, input_file: input_file, type: Zint::BARCODE_AUSREDIRECT, options: options)
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_AUSREDIRECT, **kwargs)
5
6
  end
6
7
  end
7
8
  end
@@ -1,7 +1,8 @@
1
1
  module Zint
2
+ # Australia Post Reply Paid
2
3
  class AusReply < Barcode
3
- def initialize(value: nil, input_file: nil, options: {})
4
- super(value: value, input_file: input_file, type: Zint::BARCODE_AUSREPLY, options: options)
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_AUSREPLY, **kwargs)
5
6
  end
6
7
  end
7
8
  end
@@ -1,7 +1,8 @@
1
1
  module Zint
2
+ # Australia Post Routing
2
3
  class AusRoute < Barcode
3
- def initialize(value: nil, input_file: nil, options: {})
4
- super(value: value, input_file: input_file, type: Zint::BARCODE_AUSROUTE, options: options)
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_AUSROUTE, **kwargs)
5
6
  end
6
7
  end
7
8
  end
data/lib/zint/azrune.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  module Zint
2
+ # Aztec Runes
2
3
  class Azrune < Barcode
3
- def initialize(value: nil, input_file: nil, options: {})
4
- super(value: value, input_file: input_file, type: Zint::BARCODE_AZRUNE, options: options)
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_AZRUNE, **kwargs)
5
6
  end
6
7
  end
7
8
  end
data/lib/zint/aztec.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  module Zint
2
+ # Aztec Code
2
3
  class Aztec < Barcode
3
- def initialize(value: nil, input_file: nil, options: {})
4
- super(value: value, input_file: input_file, type: Zint::BARCODE_AZTEC, options: options)
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_AZTEC, **kwargs)
5
6
  end
6
7
  end
7
8
  end
data/lib/zint/barcode.rb CHANGED
@@ -2,11 +2,13 @@ module Zint
2
2
  # Base class to represent the barcode
3
3
  #
4
4
  # @example Create new barcode
5
- # barcode = Zint::Barcode.new(value: "Test", type: Zint::BARCODE_QRCODE, options: {option_1: 1})
5
+ # barcode = Zint::Barcode.new(value: "Test", symbology: Zint::BARCODE_QRCODE, option_1: 1)
6
6
  # barcode.to_file(path: "qr.png")
7
7
  class Barcode
8
8
  include Native
9
9
 
10
+ class AlreadyGenerated < Error; end
11
+
10
12
  # @return [String, NilClass] Content of the barcode
11
13
  attr_accessor :value
12
14
  # @return [String, NilClass] Path to input file with content of the barcode
@@ -14,15 +16,16 @@ module Zint
14
16
 
15
17
  # @param value [String, NilClass] Content of the barcode
16
18
  # @param input_file [String, NilClass] Path to input file with content of the barcode
17
- # @param type [Integer] Type of barcode
18
- # @param options [Hash] Specific options for Zint symbol
19
- def initialize(value: nil, input_file: nil, type: Zint::BARCODE_CODE128, options: {})
19
+ # @param symbology [Integer] Type of barcode
20
+ # @param kwargs [Hash] Specific options for zint symbol (height, scale, ...)
21
+ def initialize(value: nil, input_file: nil, symbology: Zint::BARCODE_CODE128, **kwargs)
20
22
  raise ArgumentError, "value or input_file must be given!" if value&.empty? && input_file&.empty?
21
23
  raise ArgumentError, "input_file not found!" if input_file && !File.exist?(input_file)
22
24
 
23
- @zint_symbol = create_symbol(type)
24
- options.each do |key, value|
25
- @zint_symbol[key] = value
25
+ @zint_symbol = Native.ZBarcode_Create
26
+ self.symbology = symbology
27
+ kwargs.each do |k, v|
28
+ send("#{k}=", v)
26
29
  end
27
30
 
28
31
  @value = value
@@ -31,9 +34,14 @@ module Zint
31
34
 
32
35
  # Exports barcode to file
33
36
  #
34
- # @param path [String] Path to export file
37
+ # @param path [String] Path to export file.
38
+ # Contains the name of the file to output a resulting barcode symbol to.
39
+ # Must end in .png, .gif, .bmp, .emf, .eps, .pcx, .svg, .tif or .txt
35
40
  # @param rotate_angle [Integer] Rotate angle in degrees (0, 90, 180, 270)
36
41
  def to_file(path:, rotate_angle: 0)
42
+ unless outfile == 'out.png'
43
+ raise AlreadyGenerated, "to_file was already executed"
44
+ end
37
45
  @zint_symbol[:outfile] = path
38
46
 
39
47
  if input_file
@@ -67,6 +75,9 @@ module Zint
67
75
  # @param rotate_angle [Integer] Rotate angle in degrees (0, 90, 180, 270)
68
76
  # @return [String] Exported barcode buffer
69
77
  def to_buffer(rotate_angle: 0)
78
+ unless @zint_symbol[:bitmap].null?
79
+ raise AlreadyGenerated, "to_vector was already executed"
80
+ end
70
81
  @zint_symbol[:output_options] = Zint::OUT_BUFFER_INTERMEDIATE
71
82
 
72
83
  if input_file
@@ -100,6 +111,9 @@ module Zint
100
111
  # @param rotate_angle [Integer] Rotate angle in degrees (0, 90, 180, 270)
101
112
  # @return [Zint::Structs::Vector] Vector data of barcode
102
113
  def to_vector(rotate_angle: 0)
114
+ unless @zint_symbol[:vector].pointer.null?
115
+ raise AlreadyGenerated, "to_vector was already executed"
116
+ end
103
117
  if input_file
104
118
  call_function(:ZBarcode_Encode_File_and_Buffer_Vector, @zint_symbol, input_file, rotate_angle)
105
119
  else
@@ -113,6 +127,9 @@ module Zint
113
127
  end
114
128
 
115
129
  # Free barcode and all memory associated with it.
130
+ #
131
+ # Note: This method is dangerous insofar, that previously exported vectors (by #to_vector ) are no longer usable and any access to them will result in a segfault.
132
+ # It is better to not call this method and leave cleaning up to the garbage collector.
116
133
  def free
117
134
  @zint_symbol.pointer.free
118
135
  end
@@ -124,12 +141,10 @@ module Zint
124
141
  @zint_symbol[:symbology]
125
142
  end
126
143
 
127
- # Sets type of barcode
144
+ # Sets symbol to use (see BARCODE_XXX below)
128
145
  #
129
146
  # @param type [Integer] Type of barcode
130
147
  def symbology=(type)
131
- reset_symbol
132
-
133
148
  @zint_symbol[:symbology] = type
134
149
  end
135
150
 
@@ -138,68 +153,58 @@ module Zint
138
153
  @zint_symbol[:height]
139
154
  end
140
155
 
141
- # Sets height of barcode
156
+ # Sets height in X-dimensions (ignored for fixed-width barcodes)
142
157
  #
143
158
  # @param height [Float] Height of barcode
144
159
  def height=(height)
145
- reset_symbol
146
-
147
160
  @zint_symbol[:height] = height
148
161
  end
149
162
 
150
- # Gets scale of barcode
163
+ # Gets scale factor of barcode
151
164
  def scale
152
165
  @zint_symbol[:scale]
153
166
  end
154
167
 
155
- # Sets scale of barcode
168
+ # Sets scale factor when printing barcode
156
169
  #
157
170
  # @param scale [Float] Scale of barcode
158
171
  def scale=(scale)
159
- reset_symbol
160
-
161
172
  @zint_symbol[:scale] = scale
162
173
  end
163
174
 
164
- # Gets whitespace width of barcode
175
+ # Gets width in X-dimensions of whitespace to left & right of barcode
165
176
  def whitespace_width
166
177
  @zint_symbol[:whitespace_width]
167
178
  end
168
179
 
169
- # Sets whitespace width of barcode
180
+ # Sets width in X-dimensions of whitespace to left & right of barcode
170
181
  #
171
- # @param whitespace width [Integer] Whitespace width of barcode
182
+ # @param whitespace_width [Integer] Whitespace width of barcode
172
183
  def whitespace_width=(whitespace_width)
173
- reset_symbol
174
-
175
184
  @zint_symbol[:whitespace_width] = whitespace_width
176
185
  end
177
186
 
178
- # Gets whitespace height of barcode
187
+ # Gets height in X-dimensions of whitespace above & below the barcode
179
188
  def whitespace_height
180
189
  @zint_symbol[:whitespace_height]
181
190
  end
182
191
 
183
- # Sets whitespace height of barcode
192
+ # Sets height in X-dimensions of whitespace above & below the barcode
184
193
  #
185
- # @param whitespace height [Integer] Whitespace height of barcode
194
+ # @param whitespace_height [Integer] Whitespace height of barcode
186
195
  def whitespace_height=(whitespace_height)
187
- reset_symbol
188
-
189
196
  @zint_symbol[:whitespace_height] = whitespace_height
190
197
  end
191
198
 
192
- # Gets border width of barcode
199
+ # Gets size of border in X-dimensions
193
200
  def border_width
194
201
  @zint_symbol[:border_width]
195
202
  end
196
203
 
197
- # Sets border width of barcode
204
+ # Sets size of border in X-dimensions
198
205
  #
199
- # @param border width [Integer] Border width of barcode
206
+ # @param border_width [Integer] Border width of barcode
200
207
  def border_width=(border_width)
201
- reset_symbol
202
-
203
208
  @zint_symbol[:border_width] = border_width
204
209
  end
205
210
 
@@ -208,46 +213,42 @@ module Zint
208
213
  @zint_symbol[:output_options]
209
214
  end
210
215
 
211
- # Sets output options of barcode
216
+ # Set various output parameters (bind, box etc, see below) of barcode
212
217
  #
213
- # @param output options [Integer] Output options of barcode
218
+ # @param output_options [Integer] Output options of barcode
214
219
  def output_options=(output_options)
215
- reset_symbol
216
-
217
220
  @zint_symbol[:output_options] = output_options
218
221
  end
219
222
 
220
223
  # Gets foreground colour of barcode
221
224
  def fgcolour
222
- @zint_symbol[:fgcolour]
225
+ @zint_symbol[:fgcolour].to_s
223
226
  end
224
227
 
225
- # Sets foreground colour of barcode
228
+ # Sets foreground as RGB/RGBA hexadecimal string, 6 or 8 characters, NUL-terminated
226
229
  #
227
230
  # @param fgcolour [String] Foreground colour of barcode
228
231
  def fgcolour=(fgcolour)
229
- reset_symbol
230
-
231
232
  @zint_symbol[:fgcolour] = fgcolour
232
233
  end
233
234
 
234
235
  # Gets background colour of barcode
235
236
  def bgcolour
236
- @zint_symbol[:bgcolour]
237
+ @zint_symbol[:bgcolour].to_s
237
238
  end
238
239
 
239
- # Sets background colour of barcode
240
+ # Sets background as RGB/RGBA hexadecimal string, 6 or 8 characters, NUL-terminated
240
241
  #
241
242
  # @param bgcolour [String] Background color of barcode
242
243
  def bgcolour=(bgcolour)
243
- reset_symbol
244
-
245
244
  @zint_symbol[:bgcolour] = bgcolour
246
245
  end
247
246
 
248
- # Gets outfile of barcode
247
+ # Contains the name of the file to output a resulting barcode symbol to.
248
+ #
249
+ # Must end in .png, .gif, .bmp, .emf, .eps, .pcx, .svg, .tif or .txt
249
250
  def outfile
250
- @zint_symbol[:outfile]
251
+ @zint_symbol[:outfile].to_s
251
252
  end
252
253
 
253
254
  # Gets option 1 of barcode
@@ -255,12 +256,10 @@ module Zint
255
256
  @zint_symbol[:option_1]
256
257
  end
257
258
 
258
- # Sets option 1 of barcode
259
+ # Sets option 1 (symbol-specific options (see "../docs/manual.txt"))
259
260
  #
260
261
  # @param option_1 [Integer] Option 1 of barcode
261
262
  def option_1=(option_1)
262
- reset_symbol
263
-
264
263
  @zint_symbol[:option_1] = option_1
265
264
  end
266
265
 
@@ -269,12 +268,10 @@ module Zint
269
268
  @zint_symbol[:option_2]
270
269
  end
271
270
 
272
- # Sets option 2 of barcode
271
+ # Sets option 2 (symbol-specific options) of barcode
273
272
  #
274
- # @param option 2 [Integer] Option 2 of barcode
273
+ # @param option_2 [Integer] Option 2 of barcode
275
274
  def option_2=(option_2)
276
- reset_symbol
277
-
278
275
  @zint_symbol[:option_2] = option_2
279
276
  end
280
277
 
@@ -283,12 +280,10 @@ module Zint
283
280
  @zint_symbol[:option_3]
284
281
  end
285
282
 
286
- # Sets option 3 of barcode
283
+ # Sets option 3 (symbol-specific options) of barcode
287
284
  #
288
- # @param option 3 [Integer] Option 3 of barcode
285
+ # @param option_3 [Integer] Option 3 of barcode
289
286
  def option_3=(option_3)
290
- reset_symbol
291
-
292
287
  @zint_symbol[:option_3] = option_3
293
288
  end
294
289
 
@@ -298,12 +293,10 @@ module Zint
298
293
  end
299
294
 
300
295
  # Sets show_hrt of barcode
301
- # Set to 0 to hide text.
296
+ # show = 1 or hide = 0 Human Readable Text. Default is show (1)
302
297
  #
303
298
  # @param show_hrt [Integer] show_hrt of barcode
304
299
  def show_hrt=(show_hrt)
305
- reset_symbol
306
-
307
300
  @zint_symbol[:show_hrt] = show_hrt
308
301
  end
309
302
 
@@ -312,12 +305,10 @@ module Zint
312
305
  @zint_symbol[:fontsize]
313
306
  end
314
307
 
315
- # Sets font size of barcode
308
+ # Sets font size of barcode (Unused)
316
309
  #
317
- # @param font size [Integer] Font size of barcode
310
+ # @param fontsize [Integer] Font size of barcode
318
311
  def fontsize=(fontsize)
319
- reset_symbol
320
-
321
312
  @zint_symbol[:fontsize] = fontsize
322
313
  end
323
314
 
@@ -326,12 +317,10 @@ module Zint
326
317
  @zint_symbol[:input_mode]
327
318
  end
328
319
 
329
- # Sets input mode of barcode
320
+ # Sets encoding of input data (see DATA_MODE etc below). Default DATA_MODE
330
321
  #
331
322
  # @param input_mode [Integer] Input mode of barcode
332
323
  def input_mode=(input_mode)
333
- reset_symbol
334
-
335
324
  @zint_symbol[:input_mode] = input_mode
336
325
  end
337
326
 
@@ -340,26 +329,58 @@ module Zint
340
329
  @zint_symbol[:eci]
341
330
  end
342
331
 
343
- # Sets ECI of barcode
332
+ # Sets extended Channel Interpretation. Default 0 (none)
344
333
  #
345
334
  # @param eci [Integer] ECI of barcode
346
335
  def eci=(eci)
347
- reset_symbol
348
-
349
336
  @zint_symbol[:eci] = eci
350
337
  end
351
338
 
352
- # Gets text of barcode
339
+ # Gets resolution of output in dots per mm (BMP/EMF/PCX/PNG/TIF only). Default 0 (none)
340
+ def dpmm
341
+ @zint_symbol[:dpmm]
342
+ end
343
+
344
+ # Sets resolution of output in dots per mm (BMP/EMF/PCX/PNG/TIF only). Default 0 (none)
345
+ #
346
+ # @param dpmm [Float] Resolution of output in dots per mm
347
+ def dpmm=(dpmm)
348
+ @zint_symbol[:dpmm] = dpmm
349
+ end
350
+
351
+ # Gets height in X-dimensions that EAN/UPC guard bars descend. Default 5
352
+ def guard_descent
353
+ @zint_symbol[:guard_descent]
354
+ end
355
+
356
+ # Sets height in X-dimensions that EAN/UPC guard bars descend. Default 5
357
+ #
358
+ # @param guard_descent [Float] Height in X-dimensions that EAN/UPC guard bars descend
359
+ def guard_descent=(guard_descent)
360
+ @zint_symbol[:guard_descent] = guard_descent
361
+ end
362
+
363
+ # Gets structured append info. Default structapp.count 0 (none)
364
+ def structapp
365
+ @zint_symbol[:structapp]
366
+ end
367
+
368
+ # Sets structured append info. Default structapp.count 0 (none)
369
+ #
370
+ # @param structapp [Structs::Structapp] Structured append info
371
+ def structapp=(structapp)
372
+ @zint_symbol[:structapp] = structapp
373
+ end
374
+
375
+ # Human Readable Text, which usually consists of input data plus one more check digit. Uses UTF-8 formatting.
353
376
  def text
354
- @zint_symbol[:text]
377
+ @zint_symbol[:text].to_s.force_encoding(Encoding::UTF_8)
355
378
  end
356
379
 
357
- # Sets text of barcode
380
+ # Sets Human Readable Text (if any), UTF-8, NUL-terminated (output only) of barcode
358
381
  #
359
382
  # @param text [String] Text of barcode
360
383
  def text=(text)
361
- reset_symbol
362
-
363
384
  @zint_symbol[:text] = text
364
385
  end
365
386
 
@@ -373,31 +394,27 @@ module Zint
373
394
  @zint_symbol[:width]
374
395
  end
375
396
 
376
- # Gets primary message data for more complex symbols, with a terminating NUL, of barcode
397
+ # Gets primary message data for more complex symbols
377
398
  def primary
378
- @zint_symbol[:primary]
399
+ @zint_symbol[:primary].to_s
379
400
  end
380
401
 
381
- # Sets primary message of barcode
402
+ # Sets primary message data (MaxiCode, Composite), NUL-terminated of barcode
382
403
  #
383
404
  # @param primary [String] Primary of barcode
384
405
  def primary=(primary)
385
- reset_symbol
386
-
387
406
  @zint_symbol[:primary] = primary
388
407
  end
389
408
 
390
- # Gets encoded_data of barcode
409
+ # Gets encoded data of barcode
391
410
  def encoded_data
392
411
  @zint_symbol[:encoded_data]
393
412
  end
394
413
 
395
- # Sets encoded_data of barcode
414
+ # Sets encoded data (output only). Allows for rows of 1144 modules of barcode
396
415
  #
397
416
  # @param encoded_data [String] Encoded data of barcode
398
417
  def encoded_data=(encoded_data)
399
- reset_symbol
400
-
401
418
  @zint_symbol[:encoded_data] = encoded_data
402
419
  end
403
420
 
@@ -406,9 +423,9 @@ module Zint
406
423
  @zint_symbol[:row_height]
407
424
  end
408
425
 
409
- # Gets error text of barcode
426
+ # Gets error message in the event that an error occurred
410
427
  def errtxt
411
- @zint_symbol[:errtxt]
428
+ @zint_symbol[:errtxt].to_s.force_encoding(Encoding::UTF_8)
412
429
  end
413
430
 
414
431
  # Gets bitmap width of barcode
@@ -431,26 +448,22 @@ module Zint
431
448
  @zint_symbol[:dot_size]
432
449
  end
433
450
 
434
- # Sets dot size of barcode
451
+ # Sets size of dots used in BARCODE_DOTTY_MODE
435
452
  #
436
- # @param dot size [Float] Dot size of barcode
453
+ # @param dot_size [Float] Dot size of barcode
437
454
  def dot_size=(dot_size)
438
- reset_symbol
439
-
440
455
  @zint_symbol[:dot_size] = dot_size
441
456
  end
442
457
 
443
- # Gets debug level of barcode
458
+ # Gets debugging flags
444
459
  def debug
445
460
  @zint_symbol[:debug]
446
461
  end
447
462
 
448
- # Sets debug level of barcode
463
+ # Sets debugging flags
449
464
  #
450
465
  # @param debug [Integer] Debug level of barcode
451
466
  def debug=(debug)
452
- reset_symbol
453
-
454
467
  @zint_symbol[:debug] = debug
455
468
  end
456
469
 
@@ -459,12 +472,10 @@ module Zint
459
472
  @zint_symbol[:warn_level]
460
473
  end
461
474
 
462
- # Sets warn level of barcode
475
+ # Sets warn level (affects error/warning value returned by Zint API (see WARN_XXX below)) of barcode
463
476
  #
464
477
  # @param warn_level [Integer] Warn level of barcode
465
478
  def warn_level=(warn_level)
466
- reset_symbol
467
-
468
479
  @zint_symbol[:warn_level] = warn_level
469
480
  end
470
481
 
@@ -483,12 +494,5 @@ module Zint
483
494
 
484
495
  error_code
485
496
  end
486
-
487
- def create_symbol(type)
488
- symbol = Native.ZBarcode_Create
489
- symbol[:symbology] = type
490
-
491
- symbol
492
- end
493
497
  end
494
498
  end
@@ -0,0 +1,8 @@
1
+ module Zint
2
+ # IBM BC412 (SEMI T1-95)
3
+ class Bc412 < Barcode
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_BC412, **kwargs)
6
+ end
7
+ end
8
+ end
data/lib/zint/c25iata.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  module Zint
2
+ # 2 of 5 IATA
2
3
  class C25iata < Barcode
3
- def initialize(value: nil, input_file: nil, options: {})
4
- super(value: value, input_file: input_file, type: Zint::BARCODE_C25IATA, options: options)
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_C25IATA, **kwargs)
5
6
  end
6
7
  end
7
8
  end
data/lib/zint/c25ind.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  module Zint
2
+ # 2 of 5 Industrial
2
3
  class C25ind < Barcode
3
- def initialize(value: nil, input_file: nil, options: {})
4
- super(value: value, input_file: input_file, type: Zint::BARCODE_C25IND, options: options)
4
+ def initialize(value: nil, input_file: nil, **kwargs)
5
+ super(value: value, input_file: input_file, symbology: Zint::BARCODE_C25IND, **kwargs)
5
6
  end
6
7
  end
7
8
  end