rbpdf 1.19.0 → 1.19.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +10 -0
  3. data/Gemfile +4 -0
  4. data/MIT-LICENSE +20 -0
  5. data/README.md +16 -0
  6. data/Rakefile +4 -0
  7. data/lib/core/rmagick.rb +1 -1
  8. data/lib/rbpdf.rb +82 -47
  9. data/lib/rbpdf/version.rb +5 -1
  10. data/lib/rbpdf_encode_ok.rb +15170 -0
  11. data/lib/rbpdf_encode_ok2.rb +15178 -0
  12. data/lib/unicode_data.rb +18 -1
  13. data/rbpdf.gemspec +21 -5
  14. data/test/_rbpdf_image_test.rb_ +161 -0
  15. data/test/err_font1.rb +4 -0
  16. data/test/err_font2.rb +4 -0
  17. data/test/logo_rbpdf_8bit .png +0 -0
  18. data/test/logo_rbpdf_8bit+ .png +0 -0
  19. data/test/logo_rbpdf_8bit_/343/201/202/343/201/204/343/201/206/343/201/210/343/201/212.png +0 -0
  20. data/test/rbpdf_bidi_test.rb +76 -71
  21. data/test/rbpdf_bookmark_test.rb +38 -28
  22. data/test/rbpdf_cell_test.rb +120 -40
  23. data/test/rbpdf_content_test.rb +62 -45
  24. data/test/rbpdf_css_test.rb +275 -271
  25. data/test/rbpdf_dom_test.rb +123 -113
  26. data/test/rbpdf_font_func_test.rb +6 -2
  27. data/test/rbpdf_font_style_test.rb +7 -3
  28. data/test/rbpdf_font_test.rb +44 -27
  29. data/test/rbpdf_format_test.rb +15 -11
  30. data/test/rbpdf_func_test.rb +26 -22
  31. data/test/rbpdf_html_anchor_test.rb +11 -13
  32. data/test/rbpdf_html_func_test.rb +34 -30
  33. data/test/rbpdf_html_test.rb +58 -5
  34. data/test/rbpdf_htmlcell_test.rb +10 -6
  35. data/test/rbpdf_http_test.rb +67 -0
  36. data/test/rbpdf_image_rmagick_test.rb +70 -87
  37. data/test/rbpdf_image_test.rb +86 -22
  38. data/test/rbpdf_test.rb +88 -90
  39. data/test/rbpdf_transaction_test.rb +4 -0
  40. data/test/rbpdf_viewerpreferences_test.rb +5 -1
  41. data/test/rbpdf_write_test.rb +49 -45
  42. data/test/test_helper.rb +5 -0
  43. data/test_unicode.rbpdf +4 -0
  44. metadata +22 -9
@@ -1,8 +1,25 @@
1
1
  # coding: ASCII-8BIT
2
2
  #============================================================+
3
- # File name : unicode_data.php
3
+ # File name : unicode_data.rb
4
4
  # Begin : 2008-01-01
5
5
  # Last Update : 2008-01-08
6
+ # License : GNU LGPL (http://www.gnu.org/copyleft/lesser.html)
7
+ # ----------------------------------------------------------------------------
8
+ # This program is free software: you can redistribute it and/or modify
9
+ # it under the terms of the GNU Lesser General Public License as published by
10
+ # the Free Software Foundation, either version 2.1 of the License, or
11
+ # (at your option) any later version.
12
+ #
13
+ # This program is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU Lesser General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU Lesser General Public License
19
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+ #
21
+ # See LICENSE.TXT file for more information.
22
+ # ----------------------------------------------------------------------------
6
23
  #
7
24
  # Description : Unicode Include file for RBPDF.
8
25
  #
@@ -1,4 +1,8 @@
1
1
  # coding: utf-8
2
+ # Copyright (c) 2011-2017 NAITOH Jun
3
+ # Released under the MIT license
4
+ # http://www.opensource.org/licenses/MIT
5
+
2
6
  lib = File.expand_path('../lib', __FILE__)
3
7
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
8
  require 'rbpdf/version'
@@ -11,13 +15,13 @@ Gem::Specification.new do |spec|
11
15
  spec.summary = %q{RBPDF via TCPDF.}
12
16
  spec.description = %q{A template plugin allowing the inclusion of ERB-enabled RBPDF template files.}
13
17
  spec.homepage = ""
14
- spec.license = "LGPL 2.1 or later"
18
+ spec.licenses = ['MIT', 'LGPL 2.1 or later']
15
19
  spec.files = Dir.glob("lib/rbpdf/version.rb") +
16
20
  Dir.glob("lib/*.rb") +
17
21
  Dir.glob("lib/core/rmagick.rb") +
18
22
  Dir.glob("test/*") +
19
23
  ["Rakefile", "rbpdf.gemspec", "Gemfile",
20
- "CHANGELOG", "test_unicode.rbpdf", "README.md", "LICENSE.TXT",
24
+ "CHANGELOG", "test_unicode.rbpdf", "README.md", "LICENSE.TXT", "MIT-LICENSE",
21
25
  "utf8test.txt", "logo_example.png" ]
22
26
  spec.rdoc_options += [ '--exclude', 'lib/fonts/',
23
27
  '--exclude', 'lib/htmlcolors.rb',
@@ -27,11 +31,23 @@ Gem::Specification.new do |spec|
27
31
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
28
32
  spec.require_paths = ["lib"]
29
33
 
30
- spec.add_runtime_dependency "htmlentities", "= 4.3.1"
34
+ if RUBY_VERSION == "1.8.7"
35
+ spec.add_runtime_dependency "htmlentities", "= 4.3.1"
36
+ else
37
+ spec.add_runtime_dependency "htmlentities"
38
+ end
31
39
  spec.add_runtime_dependency "rbpdf-font", "~> 1.19.0"
32
40
  spec.required_ruby_version = '>= 1.8.7'
33
41
 
34
42
  spec.add_development_dependency "bundler", "~> 1.6"
35
- spec.add_development_dependency "rake"
36
- spec.add_development_dependency "test-unit", "~> 3.0"
43
+ if RUBY_VERSION <'1.9.3' # Ruby 1.8.7 or 1.9.2
44
+ spec.add_development_dependency "rake", "<= 10.5"
45
+ else
46
+ spec.add_development_dependency "rake"
47
+ end
48
+ if RUBY_VERSION <'1.9' # Ruby 1.8.7
49
+ spec.add_development_dependency "test-unit", "<= 3.1.5"
50
+ else
51
+ spec.add_development_dependency "test-unit", "~> 3.2"
52
+ end
37
53
  end
@@ -0,0 +1,161 @@
1
+ require 'test_helper'
2
+
3
+ class RbpdfTest < Test::Unit::TestCase
4
+ class MYPDF < RBPDF
5
+ def get_image_file(uri)
6
+ super
7
+ end
8
+ end
9
+
10
+ test "Image basic func extension test" do
11
+ pdf = RBPDF.new
12
+
13
+ type = pdf.get_image_file_type("/tmp/rbpdf_logo.gif")
14
+ assert_equal 'gif', type
15
+
16
+ type = pdf.get_image_file_type("/tmp/rbpdf_logo.PNG")
17
+ assert_equal 'png', type
18
+
19
+ type = pdf.get_image_file_type("/tmp/rbpdf_logo.jpg")
20
+ assert_equal 'jpeg', type
21
+
22
+ type = pdf.get_image_file_type("/tmp/rbpdf_logo.jpeg")
23
+ assert_equal 'jpeg', type
24
+
25
+ type = pdf.get_image_file_type("/tmp/rbpdf_logo")
26
+ assert_equal '', type
27
+
28
+ type = pdf.get_image_file_type("")
29
+ assert_equal '', type
30
+
31
+ type = pdf.get_image_file_type(nil)
32
+ assert_equal '', type
33
+ end
34
+
35
+ test "Image basic func mime type test" do
36
+ pdf = RBPDF.new
37
+
38
+ type = pdf.get_image_file_type(nil, {})
39
+ assert_equal '', type
40
+
41
+ type = pdf.get_image_file_type(nil, {'mime' => 'image/gif'})
42
+ assert_equal 'gif', type
43
+
44
+ type = pdf.get_image_file_type(nil, {'mime' => 'image/jpeg'})
45
+ assert_equal 'jpeg', type
46
+
47
+ type = pdf.get_image_file_type('/tmp/rbpdf_logo.gif', {'mime' => 'image/png'})
48
+ assert_equal 'png', type
49
+
50
+ type = pdf.get_image_file_type('/tmp/rbpdf_logo.gif', {})
51
+ assert_equal 'gif', type
52
+
53
+ type = pdf.get_image_file_type(nil, {'mime' => 'text/html'})
54
+ assert_equal '', type
55
+
56
+ type = pdf.get_image_file_type(nil, [])
57
+ assert_equal '', type
58
+ end
59
+
60
+ test "Image basic filename test" do
61
+ pdf = RBPDF.new
62
+ err = assert_raises(RuntimeError) {
63
+ pdf.image(nil)
64
+ }
65
+ assert_equal 'RBPDF error: Image filename is empty.', err.message
66
+
67
+ err = assert_raises(RuntimeError) {
68
+ pdf.image('')
69
+ }
70
+ assert_equal 'RBPDF error: Image filename is empty.', err.message
71
+
72
+ err = assert_raises(RuntimeError) {
73
+ pdf.image('foo.png')
74
+ }
75
+ assert_equal 'RBPDF error: Missing image file: foo.png', err.message
76
+ end
77
+
78
+ test "Image basic test" do
79
+ pdf = RBPDF.new
80
+ pdf.add_page
81
+ img_file = File.join(File.dirname(__FILE__), '..', 'logo_example.png')
82
+
83
+ result_img = pdf.image(img_file, 50, 0, 0, '', '', '', '', false, 300, '', true)
84
+
85
+ no = pdf.get_num_pages
86
+ assert_equal 1, no
87
+ end
88
+
89
+ test "Image fitonpage test 1" do
90
+ pdf = RBPDF.new
91
+ pdf.add_page
92
+ img_file = File.join(File.dirname(__FILE__), '..', 'logo_example.png')
93
+
94
+ result_img = pdf.image(img_file, 50, 140, 100, '', '', '', '', false, 300, '', true, false, 0, false, false, true)
95
+
96
+ no = pdf.get_num_pages
97
+ assert_equal 1, no
98
+ end
99
+
100
+ test "Image fitonpage test 2" do
101
+ pdf = RBPDF.new
102
+ pdf.add_page
103
+ img_file = File.join(File.dirname(__FILE__), '..', 'logo_example.png')
104
+
105
+ y = 100
106
+ w = pdf.get_page_width * 2
107
+ h = pdf.get_page_height
108
+ result_img = pdf.image(img_file, '', y, w, h, '', '', '', false, 300, '', true, false, 0, false, false, true)
109
+
110
+ no = pdf.get_num_pages
111
+ assert_equal 1, no
112
+ end
113
+
114
+ test "Image get image file test" do
115
+ port = 51234
116
+ #=begin
117
+ require 'webrick'
118
+
119
+ # dir = File.expand_path("test")
120
+ dir = File.dirname(__FILE__)
121
+ #port = 8000
122
+ s = WEBrick::HTTPServer.new(:Port => port, :DocumentRoot => dir, :BindAddress => "0.0.0.0")
123
+ # s = WEBrick::HTTPServer.new(:Port => port, :DocumentRoot => dir)
124
+ t = Thread.new { s.start }
125
+ # trap(:INT) do
126
+ # s.shutdown
127
+ # t.join
128
+ # exit
129
+ # end
130
+ #=end
131
+
132
+ #sleep 100
133
+ pdf = MYPDF.new
134
+ pdf.add_page
135
+ #uri = 'http://localhost:' + port.to_s + '/logo_rbpdf_8bit.png'
136
+ # tmpFile = pdf.get_image_file('http://localhost:' + port.to_s + '/logo_rbpdf_8bit.png')
137
+ tmpFile = pdf.get_image_file('http://127.0.0.1:' + port.to_s + '/logo_rbpdf_8bit.png')
138
+ #puts uri
139
+ # tmpFile = pdf.get_image_file(uri)
140
+ img_file = tmpFile.path
141
+ assert_not_equal "", img_file
142
+ unless File.exists?(img_file)
143
+ assert false, "file not found. :" + img_file
144
+ end
145
+
146
+ #sleep 100
147
+ result_img = pdf.image(img_file, 50, 0, 0, '', '', '', '', false, 300, '', true)
148
+ no = pdf.get_num_pages
149
+ assert_equal 1, no
150
+
151
+ # remove temp files
152
+ tmpFile.delete unless tmpFile.nil?
153
+
154
+ if File.exists?(img_file)
155
+ assert false, "file found. :" + img_file
156
+ end
157
+
158
+ s.shutdown
159
+ t.join
160
+ end
161
+ end
@@ -1,3 +1,7 @@
1
+ # Copyright (c) 2011-2017 NAITOH Jun
2
+ # Released under the MIT license
3
+ # http://www.opensource.org/licenses/MIT
4
+
1
5
  RBPDFFontDescriptor.define('err_font1') do |font|
2
6
  font[:type]='Type0'
3
7
  end
@@ -1,3 +1,7 @@
1
+ # Copyright (c) 2011-2017 NAITOH Jun
2
+ # Released under the MIT license
3
+ # http://www.opensource.org/licenses/MIT
4
+
1
5
  RBPDFFontDescriptor.define('err_font2') do |font|
2
6
  font[:type]='Type0'
3
7
  font[:cw]={}
Binary file
@@ -1,4 +1,9 @@
1
1
  # coding: ASCII-8BIT
2
+ #
3
+ # Copyright (c) 2011-2017 NAITOH Jun
4
+ # Released under the MIT license
5
+ # http://www.opensource.org/licenses/MIT
6
+
2
7
  require 'test_helper'
3
8
 
4
9
  class RbpdfTest < Test::Unit::TestCase
@@ -25,32 +30,32 @@ class RbpdfTest < Test::Unit::TestCase
25
30
 
26
31
  # LTR
27
32
  rtl = pdf.get_rtl
28
- assert_equal rtl, false
33
+ assert_equal false, rtl
29
34
  rtl = pdf.is_rtl_text_dir
30
- assert_equal rtl, false
35
+ assert_equal false, rtl
31
36
  rtl = pdf.rtl_text_dir
32
- assert_equal rtl, 'L'
37
+ assert_equal 'L', rtl
33
38
 
34
39
  pdf.set_temp_rtl('rtl')
35
40
  rtl = pdf.is_rtl_text_dir
36
- assert_equal rtl, true
41
+ assert_equal true, rtl
37
42
  rtl = pdf.rtl_text_dir
38
- assert_equal rtl, 'R'
43
+ assert_equal 'R', rtl
39
44
 
40
45
  # RTL
41
46
  pdf.set_rtl(true)
42
47
  rtl = pdf.get_rtl
43
- assert_equal rtl, true
48
+ assert_equal true, rtl
44
49
  rtl = pdf.is_rtl_text_dir
45
- assert_equal rtl, true
50
+ assert_equal true, rtl
46
51
  rtl = pdf.rtl_text_dir
47
- assert_equal rtl, 'R'
52
+ assert_equal 'R', rtl
48
53
 
49
54
  pdf.set_temp_rtl('ltr')
50
55
  rtl = pdf.is_rtl_text_dir
51
- assert_equal rtl, false
56
+ assert_equal false, rtl
52
57
  rtl = pdf.rtl_text_dir
53
- assert_equal rtl, 'L'
58
+ assert_equal 'L', rtl
54
59
  end
55
60
 
56
61
  test "Bidi subset font test" do
@@ -144,35 +149,35 @@ class RbpdfTest < Test::Unit::TestCase
144
149
 
145
150
  ascii_str = "abc def"
146
151
  ary_ucs4_1 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str))
147
- assert_equal ary_ucs4_1, [0x61, 0x62, 0x63, 0x20, 0x64, 0x65, 0x66]
152
+ assert_equal [0x61, 0x62, 0x63, 0x20, 0x64, 0x65, 0x66], ary_ucs4_1
148
153
  ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'R')
149
- assert_equal ary_ucs4_2, ary_ucs4_1
154
+ assert_equal ary_ucs4_1, ary_ucs4_2
150
155
  ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'L')
151
- assert_equal ary_ucs4_2, ary_ucs4_1
156
+ assert_equal ary_ucs4_1, ary_ucs4_2
152
157
 
153
158
  ascii_str = "abc def"
154
159
  ary_ucs4_1 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str))
155
- assert_equal ary_ucs4_1, [0x61, 0x62, 0x63, 0x20, 0x20, 0x64, 0x65, 0x66]
160
+ assert_equal [0x61, 0x62, 0x63, 0x20, 0x20, 0x64, 0x65, 0x66], ary_ucs4_1
156
161
  ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'R')
157
- assert_equal ary_ucs4_2, ary_ucs4_1
162
+ assert_equal ary_ucs4_1, ary_ucs4_2
158
163
  ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'L')
159
- assert_equal ary_ucs4_2, ary_ucs4_1
164
+ assert_equal ary_ucs4_1, ary_ucs4_2
160
165
 
161
166
  ascii_str = "abc "
162
167
  ary_ucs4_1 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str))
163
- assert_equal ary_ucs4_1, [0x61, 0x62, 0x63, 0x20, 0x20]
168
+ assert_equal [0x61, 0x62, 0x63, 0x20, 0x20], ary_ucs4_1
164
169
  ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'L')
165
- assert_equal ary_ucs4_2, ary_ucs4_1
170
+ assert_equal ary_ucs4_1, ary_ucs4_2
166
171
  ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'R')
167
- assert_equal ary_ucs4_2, [0x20, 0x20, 0x61, 0x62, 0x63]
172
+ assert_equal [0x20, 0x20, 0x61, 0x62, 0x63], ary_ucs4_2
168
173
 
169
174
  ascii_str = "abc_def"
170
175
  ary_ucs4_1 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str))
171
- assert_equal ary_ucs4_1, [0x61, 0x62, 0x63, 0x5f, 0x64, 0x65, 0x66]
176
+ assert_equal [0x61, 0x62, 0x63, 0x5f, 0x64, 0x65, 0x66], ary_ucs4_1
172
177
  ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'R')
173
- assert_equal ary_ucs4_2, ary_ucs4_1
178
+ assert_equal ary_ucs4_1, ary_ucs4_2
174
179
  ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'L')
175
- assert_equal ary_ucs4_2, ary_ucs4_1
180
+ assert_equal ary_ucs4_1, ary_ucs4_2
176
181
  end
177
182
 
178
183
  test "Bidi ascii numeric space test" do
@@ -180,19 +185,19 @@ class RbpdfTest < Test::Unit::TestCase
180
185
 
181
186
  ascii_str = "abc 123 def"
182
187
  ary_ucs4_1 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str))
183
- assert_equal ary_ucs4_1, [0x61, 0x62, 0x63, 0x20, 0x31, 0x32, 0x33, 0x20, 0x64, 0x65, 0x66]
188
+ assert_equal [0x61, 0x62, 0x63, 0x20, 0x31, 0x32, 0x33, 0x20, 0x64, 0x65, 0x66], ary_ucs4_1
184
189
  ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'R')
185
- assert_equal ary_ucs4_2, ary_ucs4_1
190
+ assert_equal ary_ucs4_1, ary_ucs4_2
186
191
  ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'L')
187
- assert_equal ary_ucs4_2, ary_ucs4_1
192
+ assert_equal ary_ucs4_1, ary_ucs4_2
188
193
 
189
194
  ascii_str = "abc_123_def"
190
195
  ary_ucs4_1 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str))
191
- assert_equal ary_ucs4_1, [0x61, 0x62, 0x63, 0x5f, 0x31, 0x32, 0x33, 0x5f, 0x64, 0x65, 0x66]
196
+ assert_equal [0x61, 0x62, 0x63, 0x5f, 0x31, 0x32, 0x33, 0x5f, 0x64, 0x65, 0x66], ary_ucs4_1
192
197
  ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'R')
193
- assert_equal ary_ucs4_2, ary_ucs4_1
198
+ assert_equal ary_ucs4_1, ary_ucs4_2
194
199
  ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'L')
195
- assert_equal ary_ucs4_2, ary_ucs4_1
200
+ assert_equal ary_ucs4_1, ary_ucs4_2
196
201
  end
197
202
 
198
203
  test "Bidi ascii colon test" do
@@ -200,35 +205,35 @@ class RbpdfTest < Test::Unit::TestCase
200
205
 
201
206
  ascii_str = "abc:def"
202
207
  ary_ucs4_1 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str))
203
- assert_equal ary_ucs4_1, [0x61, 0x62, 0x63, 0x3a, 0x64, 0x65, 0x66]
208
+ assert_equal [0x61, 0x62, 0x63, 0x3a, 0x64, 0x65, 0x66], ary_ucs4_1
204
209
  ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'R')
205
- assert_equal ary_ucs4_2, ary_ucs4_1
210
+ assert_equal ary_ucs4_1, ary_ucs4_2
206
211
  ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'L')
207
- assert_equal ary_ucs4_2, ary_ucs4_1
212
+ assert_equal ary_ucs4_1, ary_ucs4_2
208
213
 
209
214
  ascii_str = "abc: def"
210
215
  ary_ucs4_1 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str))
211
- assert_equal ary_ucs4_1, [0x61, 0x62, 0x63, 0x3a, 0x20, 0x64, 0x65, 0x66]
216
+ assert_equal [0x61, 0x62, 0x63, 0x3a, 0x20, 0x64, 0x65, 0x66], ary_ucs4_1
212
217
  ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'R')
213
- assert_equal ary_ucs4_2, ary_ucs4_1
218
+ assert_equal ary_ucs4_1, ary_ucs4_2
214
219
  ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'L')
215
- assert_equal ary_ucs4_2, ary_ucs4_1
220
+ assert_equal ary_ucs4_1, ary_ucs4_2
216
221
 
217
222
  ascii_str = "abc : def"
218
223
  ary_ucs4_1 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str))
219
- assert_equal ary_ucs4_1, [0x61, 0x62, 0x63, 0x20, 0x3a, 0x20, 0x64, 0x65, 0x66]
224
+ assert_equal [0x61, 0x62, 0x63, 0x20, 0x3a, 0x20, 0x64, 0x65, 0x66], ary_ucs4_1
220
225
  ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'R')
221
- assert_equal ary_ucs4_2, ary_ucs4_1
226
+ assert_equal ary_ucs4_1, ary_ucs4_2
222
227
  ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'L')
223
- assert_equal ary_ucs4_2, ary_ucs4_1
228
+ assert_equal ary_ucs4_1, ary_ucs4_2
224
229
 
225
230
  ascii_str = "abc :: def"
226
231
  ary_ucs4_1 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str))
227
- assert_equal ary_ucs4_1, [0x61, 0x62, 0x63, 0x20, 0x20, 0x3a, 0x3a, 0x20, 0x20, 0x64, 0x65, 0x66]
232
+ assert_equal [0x61, 0x62, 0x63, 0x20, 0x20, 0x3a, 0x3a, 0x20, 0x20, 0x64, 0x65, 0x66], ary_ucs4_1
228
233
  ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'R')
229
- assert_equal ary_ucs4_2, ary_ucs4_1
234
+ assert_equal ary_ucs4_1, ary_ucs4_2
230
235
  ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'L')
231
- assert_equal ary_ucs4_2, ary_ucs4_1
236
+ assert_equal ary_ucs4_1, ary_ucs4_2
232
237
  end
233
238
 
234
239
 
@@ -280,37 +285,37 @@ class RbpdfTest < Test::Unit::TestCase
280
285
  utf8_persian_str_7 = "\xdb\x8c\xda\xa9\xe2\x80\x8c\xd8\xb4\xd9\x86\xd8\xa8\xd9\x87" # Sunday # 0x06cc, 0x06a9, 0x200c, 0x0634, 0x0646, 0x0628, 0x0647
281
286
 
282
287
  ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_1))
283
- assert_equal ary_ucs4, [0xfbfc]
288
+ assert_equal [0xfbfc], ary_ucs4
284
289
  current_font = pdf.get_current_font
285
290
  assert_equal 256 + 2, current_font['subsetchars'].compact.length # 0x06cc, 0xfbfc
286
291
 
287
292
  ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_2))
288
- assert_equal ary_ucs4, [0xfb8f, 0xfbfe]
293
+ assert_equal [0xfb8f, 0xfbfe], ary_ucs4
289
294
  current_font = pdf.get_current_font
290
295
  assert_equal 256 + 5, current_font['subsetchars'].compact.length # 0xfbfc + 0x06cc, 0x06a9, 0xfb8f, 0xfbfe
291
296
 
292
297
  ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_3))
293
- assert_equal ary_ucs4, [0x200c, 0xfb8f, 0xfbfe]
298
+ assert_equal [0x200c, 0xfb8f, 0xfbfe], ary_ucs4
294
299
  current_font = pdf.get_current_font
295
300
  assert_equal 256 + 6, current_font['subsetchars'].compact.length # 0xfbfc + 0x06cc, 0x06a9, 0x200c, 0xfb8f, 0xfbfe
296
301
 
297
302
  ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_4))
298
- assert_equal ary_ucs4, [0xfeb5, 0x200c, 0xfb8f, 0xfbfe]
303
+ assert_equal [0xfeb5, 0x200c, 0xfb8f, 0xfbfe], ary_ucs4
299
304
  current_font = pdf.get_current_font
300
305
  assert_equal 256 + 8, current_font['subsetchars'].compact.length # 0xfbfc + 0x06cc, 0x06a9, 0x200c, 0x0634, 0xfeb5, 0xfb8f, 0xfbfe
301
306
 
302
307
  ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_5))
303
- assert_equal ary_ucs4, [0xfee6, 0xfeb7, 0x200c, 0xfb8f, 0xfbfe]
308
+ assert_equal [0xfee6, 0xfeb7, 0x200c, 0xfb8f, 0xfbfe], ary_ucs4
304
309
  current_font = pdf.get_current_font
305
310
  assert_equal 256 + 11, current_font['subsetchars'].compact.length # 0xfbfc, 0xfeb5 + 0x06cc, 0x06a9, 0x200c, 0x0634, 0x0646, 0xfee6, 0xfeb7, 0xfb8f, 0xfbfe
306
311
 
307
312
  ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_6))
308
- assert_equal ary_ucs4, [0xfe90, 0xfee8, 0xfeb7, 0x200c, 0xfb8f, 0xfbfe]
313
+ assert_equal [0xfe90, 0xfee8, 0xfeb7, 0x200c, 0xfb8f, 0xfbfe], ary_ucs4
309
314
  current_font = pdf.get_current_font
310
315
  assert_equal 256 + 14, current_font['subsetchars'].compact.length # 0xfbfc, 0xfeb5, 0xfee6 + 0x06cc, 0x06a9, 0x200c, 0x0634, 0x0646, 0x0628, 0xfe90, 0xfee8, 0xfeb7, 0xfb8f, 0xfbfe
311
316
 
312
317
  ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_7))
313
- assert_equal ary_ucs4, [0xfeea, 0xfe92, 0xfee8, 0xfeb7, 0x200c, 0xfb8f, 0xfbfe]
318
+ assert_equal [0xfeea, 0xfe92, 0xfee8, 0xfeb7, 0x200c, 0xfb8f, 0xfbfe], ary_ucs4
314
319
  current_font = pdf.get_current_font
315
320
  assert_equal 256 + 17, current_font['subsetchars'].compact.length # 0xfbfc, 0xfeb5, 0xfee6, 0xfe90 + 0x06cc, 0x06a9, 0x200c, 0x0634, 0x0646, 0x0628, 0x0647, 0xfeea, 0xfe92, 0xfee8, 0xfeb7, 0xfb8f, 0xfbfe
316
321
  end
@@ -320,9 +325,9 @@ class RbpdfTest < Test::Unit::TestCase
320
325
  utf8_persian_str_sunday = "\xdb\x8c\xda\xa9\xe2\x80\x8c\xd8\xb4\xd9\x86\xd8\xa8\xd9\x87"
321
326
 
322
327
  ary_ucs4_1 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_sunday), '', 'R')
323
- assert_equal ary_ucs4_1, [0xfeea, 0xfe92, 0xfee8, 0xfeb7, 0x200C, 0xfb8f, 0xfbfe]
328
+ assert_equal [0xfeea, 0xfe92, 0xfee8, 0xfeb7, 0x200C, 0xfb8f, 0xfbfe], ary_ucs4_1
324
329
  ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_sunday), '', 'L')
325
- assert_equal ary_ucs4_2, ary_ucs4_1
330
+ assert_equal ary_ucs4_1, ary_ucs4_2
326
331
  end
327
332
 
328
333
  test "Bidi Persian Monday test" do
@@ -336,17 +341,17 @@ class RbpdfTest < Test::Unit::TestCase
336
341
  utf8_persian_str_6 = "\xd8\xaf\xd9\x88\xd8\xb4\xd9\x86\xd8\xa8\xd9\x87" # Monday
337
342
 
338
343
  ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_1))
339
- assert_equal ary_ucs4, [0xfea9]
344
+ assert_equal [0xfea9], ary_ucs4
340
345
  ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_2))
341
- assert_equal ary_ucs4, [0xfeed, 0xfea9]
346
+ assert_equal [0xfeed, 0xfea9], ary_ucs4
342
347
  ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_3))
343
- assert_equal ary_ucs4, [0xfeb5, 0xfeed, 0xfea9]
348
+ assert_equal [0xfeb5, 0xfeed, 0xfea9], ary_ucs4
344
349
  ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_4))
345
- assert_equal ary_ucs4, [0xfee6, 0xfeb7, 0xfeed, 0xfea9]
350
+ assert_equal [0xfee6, 0xfeb7, 0xfeed, 0xfea9], ary_ucs4
346
351
  ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_5))
347
- assert_equal ary_ucs4, [0xfe90, 0xfee8, 0xfeb7, 0xfeed, 0xfea9]
352
+ assert_equal [0xfe90, 0xfee8, 0xfeb7, 0xfeed, 0xfea9], ary_ucs4
348
353
  ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_6))
349
- assert_equal ary_ucs4, [0xfeea, 0xfe92, 0xfee8, 0xfeb7, 0xfeed, 0xfea9]
354
+ assert_equal [0xfeea, 0xfe92, 0xfee8, 0xfeb7, 0xfeed, 0xfea9], ary_ucs4
350
355
  end
351
356
 
352
357
  test "Bidi Persian Monday forcertl test" do
@@ -354,9 +359,9 @@ class RbpdfTest < Test::Unit::TestCase
354
359
  utf8_persian_str_monday = "\xd8\xaf\xd9\x88\xd8\xb4\xd9\x86\xd8\xa8\xd9\x87"
355
360
 
356
361
  ary_ucs4_1 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_monday), '', 'R')
357
- assert_equal ary_ucs4_1, [0xfeea, 0xfe92, 0xfee8, 0xfeb7, 0xfeed, 0xfea9]
362
+ assert_equal [0xfeea, 0xfe92, 0xfee8, 0xfeb7, 0xfeed, 0xfea9], ary_ucs4_1
358
363
  ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_monday), '', 'L')
359
- assert_equal ary_ucs4_2, ary_ucs4_1
364
+ assert_equal ary_ucs4_1, ary_ucs4_2
360
365
  end
361
366
 
362
367
  test "Bidi Persian and English test" do
@@ -364,14 +369,14 @@ class RbpdfTest < Test::Unit::TestCase
364
369
 
365
370
  utf8_persian_str_sunday = "\xdb\x8c\xda\xa9\xe2\x80\x8c\xd8\xb4\xd9\x86\xd8\xa8\xd9\x87"
366
371
  ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_sunday + ' abc'))
367
- assert_equal ary_ucs4, [0x61, 0x62, 0x63, 0x20, # 'abc '
368
- 0xfeea, 0xfe92, 0xfee8, 0xfeb7, 0x200C, 0xfb8f, 0xfbfe] # Sunday
372
+ assert_equal [0x61, 0x62, 0x63, 0x20, # 'abc '
373
+ 0xfeea, 0xfe92, 0xfee8, 0xfeb7, 0x200C, 0xfb8f, 0xfbfe], ary_ucs4 # Sunday
369
374
  ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_sunday + ' abc'), '', 'R')
370
- assert_equal ary_ucs4, [0x61, 0x62, 0x63, 0x20, # 'abc '
371
- 0xfeea, 0xfe92, 0xfee8, 0xfeb7, 0x200C, 0xfb8f, 0xfbfe] # Sunday
375
+ assert_equal [0x61, 0x62, 0x63, 0x20, # 'abc '
376
+ 0xfeea, 0xfe92, 0xfee8, 0xfeb7, 0x200C, 0xfb8f, 0xfbfe], ary_ucs4 # Sunday
372
377
  ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_sunday + ' abc'), '', 'L')
373
- assert_equal ary_ucs4, [0xfeea, 0xfe92, 0xfee8, 0xfeb7, 0x200C, 0xfb8f, 0xfbfe, # Sunday
374
- 0x20, 0x61, 0x62, 0x63] # 'abc '
378
+ assert_equal [0xfeea, 0xfe92, 0xfee8, 0xfeb7, 0x200C, 0xfb8f, 0xfbfe, # Sunday
379
+ 0x20, 0x61, 0x62, 0x63], ary_ucs4 # 'abc '
375
380
  end
376
381
 
377
382
  test "Bidi English and Persian test" do
@@ -379,14 +384,14 @@ class RbpdfTest < Test::Unit::TestCase
379
384
 
380
385
  utf8_persian_str_sunday = "\xdb\x8c\xda\xa9\xe2\x80\x8c\xd8\xb4\xd9\x86\xd8\xa8\xd9\x87"
381
386
  ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray('abc ' + utf8_persian_str_sunday))
382
- assert_equal ary_ucs4, [0x61, 0x62, 0x63, 0x20, # 'abc '
383
- 0xfeea, 0xfe92, 0xfee8, 0xfeb7, 0x200C, 0xfb8f, 0xfbfe] # Sunday
387
+ assert_equal [0x61, 0x62, 0x63, 0x20, # 'abc '
388
+ 0xfeea, 0xfe92, 0xfee8, 0xfeb7, 0x200C, 0xfb8f, 0xfbfe], ary_ucs4 # Sunday
384
389
  ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray('abc ' + utf8_persian_str_sunday), '', 'L')
385
- assert_equal ary_ucs4, [0x61, 0x62, 0x63, 0x20, # 'abc '
386
- 0xfeea, 0xfe92, 0xfee8, 0xfeb7, 0x200C, 0xfb8f, 0xfbfe] # Sunday
390
+ assert_equal [0x61, 0x62, 0x63, 0x20, # 'abc '
391
+ 0xfeea, 0xfe92, 0xfee8, 0xfeb7, 0x200C, 0xfb8f, 0xfbfe], ary_ucs4 # Sunday
387
392
  ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray('abc ' + utf8_persian_str_sunday), '', 'R')
388
- assert_equal ary_ucs4, [0xfeea, 0xfe92, 0xfee8, 0xfeb7, 0x200C, 0xfb8f, 0xfbfe, # Sunday
389
- 0x20, 0x61, 0x62, 0x63] # 'abc '
393
+ assert_equal [0xfeea, 0xfe92, 0xfee8, 0xfeb7, 0x200C, 0xfb8f, 0xfbfe, # Sunday
394
+ 0x20, 0x61, 0x62, 0x63], ary_ucs4 # 'abc '
390
395
  end
391
396
 
392
397
  test "Bidi date test" do
@@ -427,12 +432,12 @@ class RbpdfTest < Test::Unit::TestCase
427
432
  chars.reverse!
428
433
 
429
434
  rtn = pdf.cache_utf8_string_to_array('1234')
430
- assert_equal rtn, [0x31, 0x32, 0x33, 0x34]
435
+ assert_equal [0x31, 0x32, 0x33, 0x34], rtn
431
436
  end
432
437
 
433
438
  test "UniArrSubString test" do
434
439
  pdf = RBPDF.new
435
440
  str = pdf.uni_arr_sub_string(['a', 'b', 'c', ' ', 'd', 'e', 'f'])
436
- assert_equal str, 'abc def'
441
+ assert_equal 'abc def', str
437
442
  end
438
443
  end