rbpdf 1.20.0 → 1.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +4 -0
  3. data/lib/rbpdf/version.rb +1 -1
  4. data/rbpdf.gemspec +1 -2
  5. metadata +4 -90
  6. data/test/err_font1.rb +0 -7
  7. data/test/err_font2.rb +0 -8
  8. data/test/input.jpg +0 -0
  9. data/test/json: +0 -0
  10. data/test/logo_rbpdf_8bit .png +0 -0
  11. data/test/logo_rbpdf_8bit+ .png +0 -0
  12. data/test/logo_rbpdf_8bit.gif +0 -0
  13. data/test/logo_rbpdf_8bit.jpg +0 -0
  14. data/test/logo_rbpdf_8bit.png +0 -0
  15. data/test/logo_rbpdf_8bit_alpha.gif +0 -0
  16. data/test/logo_rbpdf_mono_gray.jpg +0 -0
  17. data/test/logo_rbpdf_mono_gray.png +0 -0
  18. data/test/logo_rbpdf_mono_rgb.jpg +0 -0
  19. data/test/logo_rbpdf_mono_rgb.png +0 -0
  20. data/test/output.png +0 -0
  21. data/test/png_test_alpha.png +0 -0
  22. data/test/png_test_msk_alpha.png +0 -0
  23. data/test/png_test_non_alpha.png +0 -0
  24. data/test/rbpdf_bidi_test.rb +0 -453
  25. data/test/rbpdf_bookmark_test.rb +0 -66
  26. data/test/rbpdf_cell_test.rb +0 -231
  27. data/test/rbpdf_content_test.rb +0 -213
  28. data/test/rbpdf_css_test.rb +0 -640
  29. data/test/rbpdf_dom_test.rb +0 -272
  30. data/test/rbpdf_examples_test.rb +0 -83
  31. data/test/rbpdf_font_func_test.rb +0 -45
  32. data/test/rbpdf_font_style_test.rb +0 -37
  33. data/test/rbpdf_font_test.rb +0 -308
  34. data/test/rbpdf_format_test.rb +0 -30
  35. data/test/rbpdf_func_test.rb +0 -139
  36. data/test/rbpdf_html_anchor_test.rb +0 -105
  37. data/test/rbpdf_html_func_test.rb +0 -170
  38. data/test/rbpdf_html_test.rb +0 -658
  39. data/test/rbpdf_htmlcell_test.rb +0 -60
  40. data/test/rbpdf_http_test.rb +0 -76
  41. data/test/rbpdf_image_rmagick_test.rb +0 -170
  42. data/test/rbpdf_image_test.rb +0 -174
  43. data/test/rbpdf_test.rb +0 -375
  44. data/test/rbpdf_transaction_test.rb +0 -203
  45. data/test/rbpdf_viewerpreferences_test.rb +0 -41
  46. data/test/rbpdf_write_test.rb +0 -229
  47. data/test/test.rb +0 -22
  48. data/test/test_helper.rb +0 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b80cab6ce3fb2d7d57010d42f7b82963ad0c467
4
- data.tar.gz: 26efc4e45882f2a043d848e730f2f754209c7ae2
3
+ metadata.gz: 22e946db75367837ee71cc634ce52b97bef9428b
4
+ data.tar.gz: 5b32284cc5b1b9a226691dcb14898400eb7f9739
5
5
  SHA512:
6
- metadata.gz: 43c758cd4cb263758ee0177d8fe1548d4afeb5acf8956702f5c87d4b1bb041e142342150c86050713205c06be2e8754fd68857a90256dc621c26db14456382a4
7
- data.tar.gz: 59cca68008ee2c668f8fe04ed905bcb0cd22e95dd08439ca5ba26e2e45f1020aca89e5632533e882525b01b1521cf0679b3e839939129290d44e5872bfed058f
6
+ metadata.gz: 7180810606d801b53a8919fd0517156b96d128649ad690b7dddde93762ef2d289334f63ed1698ac5d679f688eb49923ee33b9da16202828327ce276ecac7c0ab
7
+ data.tar.gz: 0dcdd44e2e39bf9e153f2a45b521425f7dc75a1af8ecc4c2993c82caf591c09ce5e00e53b4bc69868c886bd04b0aefa8ec1f3461e8d3f776732e1ade0bca08f7
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ 1.20.1 2019-08-21
2
+ - fix license warning. (by pavel)
3
+ - Removed test resource from distribution target in gemspec.
4
+
1
5
  1.20.0 2019-08-11
2
6
  - Added support for MiniMagick.
3
7
  - Fix RMagick 4.0 compatible.
@@ -3,5 +3,5 @@
3
3
  # http://www.opensource.org/licenses/MIT
4
4
 
5
5
  module Rbpdf
6
- VERSION = "1.20.0"
6
+ VERSION = "1.20.1"
7
7
  end
@@ -15,12 +15,11 @@ Gem::Specification.new do |spec|
15
15
  spec.summary = %q{RBPDF via TCPDF.}
16
16
  spec.description = %q{A template plugin allowing the inclusion of ERB-enabled RBPDF template files.}
17
17
  spec.homepage = ""
18
- spec.licenses = ['MIT', 'LGPL 2.1 or later']
18
+ spec.licenses = ['MIT', 'LGPL-2.1-or-later']
19
19
  spec.files = Dir.glob("lib/rbpdf/version.rb") +
20
20
  Dir.glob("lib/*.rb") +
21
21
  Dir.glob("lib/core/rmagick.rb") +
22
22
  Dir.glob("lib/core/mini_magick.rb") +
23
- Dir.glob("test/*") +
24
23
  ["Rakefile", "rbpdf.gemspec", "Gemfile",
25
24
  "CHANGELOG", "test_unicode.rbpdf", "README.md", "LICENSE.TXT", "MIT-LICENSE",
26
25
  "utf8test.txt", "logo_example.png" ]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbpdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.20.0
4
+ version: 1.20.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - NAITOH Jun
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-11 00:00:00.000000000 Z
11
+ date: 2019-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities
@@ -102,55 +102,12 @@ files:
102
102
  - lib/unicode_data.rb
103
103
  - logo_example.png
104
104
  - rbpdf.gemspec
105
- - test/err_font1.rb
106
- - test/err_font2.rb
107
- - test/input.jpg
108
- - 'test/json:'
109
- - test/logo_rbpdf_8bit .png
110
- - test/logo_rbpdf_8bit+ .png
111
- - test/logo_rbpdf_8bit.gif
112
- - test/logo_rbpdf_8bit.jpg
113
- - test/logo_rbpdf_8bit.png
114
- - test/logo_rbpdf_8bit_alpha.gif
115
- - test/logo_rbpdf_mono_gray.jpg
116
- - test/logo_rbpdf_mono_gray.png
117
- - test/logo_rbpdf_mono_rgb.jpg
118
- - test/logo_rbpdf_mono_rgb.png
119
- - test/output.png
120
- - test/png_test_alpha.png
121
- - test/png_test_msk_alpha.png
122
- - test/png_test_non_alpha.png
123
- - test/rbpdf_bidi_test.rb
124
- - test/rbpdf_bookmark_test.rb
125
- - test/rbpdf_cell_test.rb
126
- - test/rbpdf_content_test.rb
127
- - test/rbpdf_css_test.rb
128
- - test/rbpdf_dom_test.rb
129
- - test/rbpdf_examples_test.rb
130
- - test/rbpdf_font_func_test.rb
131
- - test/rbpdf_font_style_test.rb
132
- - test/rbpdf_font_test.rb
133
- - test/rbpdf_format_test.rb
134
- - test/rbpdf_func_test.rb
135
- - test/rbpdf_html_anchor_test.rb
136
- - test/rbpdf_html_func_test.rb
137
- - test/rbpdf_html_test.rb
138
- - test/rbpdf_htmlcell_test.rb
139
- - test/rbpdf_http_test.rb
140
- - test/rbpdf_image_rmagick_test.rb
141
- - test/rbpdf_image_test.rb
142
- - test/rbpdf_test.rb
143
- - test/rbpdf_transaction_test.rb
144
- - test/rbpdf_viewerpreferences_test.rb
145
- - test/rbpdf_write_test.rb
146
- - test/test.rb
147
- - test/test_helper.rb
148
105
  - test_unicode.rbpdf
149
106
  - utf8test.txt
150
107
  homepage: ''
151
108
  licenses:
152
109
  - MIT
153
- - LGPL 2.1 or later
110
+ - LGPL-2.1-or-later
154
111
  metadata: {}
155
112
  post_install_message:
156
113
  rdoc_options:
@@ -178,47 +135,4 @@ rubygems_version: 2.6.10
178
135
  signing_key:
179
136
  specification_version: 4
180
137
  summary: RBPDF via TCPDF.
181
- test_files:
182
- - test/err_font1.rb
183
- - test/err_font2.rb
184
- - test/input.jpg
185
- - 'test/json:'
186
- - test/logo_rbpdf_8bit .png
187
- - test/logo_rbpdf_8bit+ .png
188
- - test/logo_rbpdf_8bit.gif
189
- - test/logo_rbpdf_8bit.jpg
190
- - test/logo_rbpdf_8bit.png
191
- - test/logo_rbpdf_8bit_alpha.gif
192
- - test/logo_rbpdf_mono_gray.jpg
193
- - test/logo_rbpdf_mono_gray.png
194
- - test/logo_rbpdf_mono_rgb.jpg
195
- - test/logo_rbpdf_mono_rgb.png
196
- - test/output.png
197
- - test/png_test_alpha.png
198
- - test/png_test_msk_alpha.png
199
- - test/png_test_non_alpha.png
200
- - test/rbpdf_bidi_test.rb
201
- - test/rbpdf_bookmark_test.rb
202
- - test/rbpdf_cell_test.rb
203
- - test/rbpdf_content_test.rb
204
- - test/rbpdf_css_test.rb
205
- - test/rbpdf_dom_test.rb
206
- - test/rbpdf_examples_test.rb
207
- - test/rbpdf_font_func_test.rb
208
- - test/rbpdf_font_style_test.rb
209
- - test/rbpdf_font_test.rb
210
- - test/rbpdf_format_test.rb
211
- - test/rbpdf_func_test.rb
212
- - test/rbpdf_html_anchor_test.rb
213
- - test/rbpdf_html_func_test.rb
214
- - test/rbpdf_html_test.rb
215
- - test/rbpdf_htmlcell_test.rb
216
- - test/rbpdf_http_test.rb
217
- - test/rbpdf_image_rmagick_test.rb
218
- - test/rbpdf_image_test.rb
219
- - test/rbpdf_test.rb
220
- - test/rbpdf_transaction_test.rb
221
- - test/rbpdf_viewerpreferences_test.rb
222
- - test/rbpdf_write_test.rb
223
- - test/test.rb
224
- - test/test_helper.rb
138
+ test_files: []
@@ -1,7 +0,0 @@
1
- # Copyright (c) 2011-2017 NAITOH Jun
2
- # Released under the MIT license
3
- # http://www.opensource.org/licenses/MIT
4
-
5
- RBPDFFontDescriptor.define('err_font1') do |font|
6
- font[:type]='Type0'
7
- end
@@ -1,8 +0,0 @@
1
- # Copyright (c) 2011-2017 NAITOH Jun
2
- # Released under the MIT license
3
- # http://www.opensource.org/licenses/MIT
4
-
5
- RBPDFFontDescriptor.define('err_font2') do |font|
6
- font[:type]='Type0'
7
- font[:cw]={}
8
- end
Binary file
data/test/json: DELETED
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,453 +0,0 @@
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
-
7
- require 'test_helper'
8
-
9
- class RbpdfTest < Test::Unit::TestCase
10
- require 'unicode_data.rb'
11
- include Unicode_data
12
-
13
- class MYPDF < RBPDF
14
- def UTF8StringToArray(str)
15
- super
16
- end
17
- def utf8Bidi(ta, str='', forcertl=false)
18
- super
19
- end
20
- def cache_utf8_string_to_array(str)
21
- @cache_utf8_string_to_array[str]
22
- end
23
- def rtl_text_dir
24
- super
25
- end
26
- def get_current_font
27
- return @current_font
28
- end
29
- end
30
-
31
- test "RTL test" do
32
- pdf = MYPDF.new
33
-
34
- # LTR
35
- rtl = pdf.get_rtl
36
- assert_equal false, rtl
37
- rtl = pdf.is_rtl_text_dir
38
- assert_equal false, rtl
39
- rtl = pdf.rtl_text_dir
40
- assert_equal 'L', rtl
41
-
42
- pdf.set_temp_rtl('rtl')
43
- rtl = pdf.is_rtl_text_dir
44
- assert_equal true, rtl
45
- rtl = pdf.rtl_text_dir
46
- assert_equal 'R', rtl
47
-
48
- # RTL
49
- pdf.set_rtl(true)
50
- rtl = pdf.get_rtl
51
- assert_equal true, rtl
52
- rtl = pdf.is_rtl_text_dir
53
- assert_equal true, rtl
54
- rtl = pdf.rtl_text_dir
55
- assert_equal 'R', rtl
56
-
57
- pdf.set_temp_rtl('ltr')
58
- rtl = pdf.is_rtl_text_dir
59
- assert_equal false, rtl
60
- rtl = pdf.rtl_text_dir
61
- assert_equal 'L', rtl
62
- end
63
-
64
- test "Bidi subset font test" do
65
- pdf = MYPDF.new
66
- ary_ucs4 = pdf.UTF8StringToArray("abc")
67
- assert_equal [0x61, 0x62, 0x63], ary_ucs4
68
- current_font = pdf.get_current_font
69
- assert_equal 256, current_font['subsetchars'].length
70
-
71
- ary_ucs4 = pdf.UTF8StringToArray("\xd7\xa2\xd7\x91\xd7\xa8\xd7\x99\xd7\xaa")
72
- assert_equal [0x5e2, 0x5d1, 0x5e8, 0x5d9, 0x5ea], ary_ucs4
73
- current_font = pdf.get_current_font
74
- assert_equal 261, current_font['subsetchars'].compact.length
75
- end
76
-
77
- test "Bidi" do
78
- pdf = MYPDF.new
79
-
80
- # UCS4 charactor -> UTF-8 charactor
81
- utf8_chr = pdf.unichr(0x61)
82
- assert_equal "a", utf8_chr
83
- utf8_chr = pdf.unichr(0x5e2)
84
- assert_equal "\xd7\xa2", utf8_chr
85
-
86
- # UTF-8 string -> array of UCS4 charactor
87
- ary_ucs4 = pdf.UTF8StringToArray("abc")
88
- assert_equal [0x61, 0x62, 0x63], ary_ucs4
89
- current_font = pdf.get_current_font
90
- assert_equal 256, current_font['subsetchars'].compact.length
91
-
92
- ary_ucs4 = pdf.UTF8StringToArray("\xd7\xa2\xd7\x91\xd7\xa8\xd7\x99\xd7\xaa")
93
- assert_equal [0x5e2, 0x5d1, 0x5e8, 0x5d9, 0x5ea], ary_ucs4
94
- current_font = pdf.get_current_font
95
- assert_equal 256 + 5, current_font['subsetchars'].compact.length
96
-
97
- # Bidirectional Algorithm
98
- ascii_str = "abc"
99
- utf8_str_1 = "\xd7\xa2"
100
- utf8_str_2 = "\xd7\xa2\xd7\x91\xd7\xa8\xd7\x99\xd7\xaa"
101
-
102
- ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str))
103
- assert_equal [0x61, 0x62, 0x63], ary_ucs4
104
-
105
- ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), ascii_str, 'R')
106
- assert_equal [0x61, 0x62, 0x63], ary_ucs4
107
-
108
- ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_str_1))
109
- assert_equal [0x5e2], ary_ucs4
110
- current_font = pdf.get_current_font
111
- assert_equal 256 + 5, current_font['subsetchars'].compact.length
112
-
113
- ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_str_1), utf8_str_1, 'R')
114
- assert_equal [0x5e2], ary_ucs4
115
- current_font = pdf.get_current_font
116
- assert_equal 256 + 5, current_font['subsetchars'].compact.length
117
-
118
- ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_str_2))
119
- assert_equal [0x5ea, 0x5d9, 0x5e8, 0x5d1, 0x5e2], ary_ucs4
120
- current_font = pdf.get_current_font
121
- assert_equal 256 + 5, current_font['subsetchars'].compact.length
122
-
123
- ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_str_2), utf8_str_2, 'R')
124
- assert_equal [0x5ea, 0x5d9, 0x5e8, 0x5d1, 0x5e2], ary_ucs4 ##
125
- current_font = pdf.get_current_font
126
- assert_equal 256 + 5, current_font['subsetchars'].compact.length
127
-
128
- ary_str = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str + utf8_str_2), ascii_str + utf8_str_2, 'L')
129
- assert_equal [0x61, 0x62, 0x63, 0x5ea, 0x5d9, 0x5e8, 0x5d1, 0x5e2], ary_str
130
- current_font = pdf.get_current_font
131
- assert_equal 256 + 5, current_font['subsetchars'].compact.length
132
-
133
- ary_str = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str + utf8_str_2)) # LTR
134
- assert_equal [0x61, 0x62, 0x63, 0x5ea, 0x5d9, 0x5e8, 0x5d1, 0x5e2], ary_str
135
- current_font = pdf.get_current_font
136
- assert_equal 256 + 5, current_font['subsetchars'].compact.length
137
-
138
- ary_str = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str + utf8_str_2), ascii_str + utf8_str_2, 'R') # LTR -> RTL
139
- assert_equal [0x5ea, 0x5d9, 0x5e8, 0x5d1, 0x5e2, 0x61, 0x62, 0x63], ary_str
140
- current_font = pdf.get_current_font
141
- assert_equal 256 + 5, current_font['subsetchars'].compact.length
142
-
143
- # Left-to-right embedding (LRE) : 202A
144
- ary_str = pdf.utf8Bidi([@@k_lre] + pdf.UTF8StringToArray(ascii_str + utf8_str_2), ascii_str + utf8_str_2, 'R') # LTR -> RTL -> LTR
145
- assert_equal [0x61, 0x62, 0x63, 0x5ea, 0x5d9, 0x5e8, 0x5d1, 0x5e2], ary_str
146
- current_font = pdf.get_current_font
147
- assert_equal 256 + 5, current_font['subsetchars'].compact.length
148
-
149
- ary_str = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_str_2 + ascii_str), utf8_str_2 + ascii_str, 'L')
150
- assert_equal [0x5ea, 0x5d9, 0x5e8, 0x5d1, 0x5e2, 0x61, 0x62, 0x63], ary_str
151
- ary_str = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_str_2 + ascii_str)) # RTL
152
- assert_equal [0x61, 0x62, 0x63, 0x5ea, 0x5d9, 0x5e8, 0x5d1, 0x5e2], ary_str
153
- ary_str = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_str_2 + ascii_str), utf8_str_2 + ascii_str, 'R')
154
- assert_equal [0x61, 0x62, 0x63, 0x5ea, 0x5d9, 0x5e8, 0x5d1, 0x5e2], ary_str
155
- end
156
-
157
- test "Bidi ascii space test" do
158
- pdf = MYPDF.new
159
-
160
- ascii_str = "abc def"
161
- ary_ucs4_1 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str))
162
- assert_equal [0x61, 0x62, 0x63, 0x20, 0x64, 0x65, 0x66], ary_ucs4_1
163
- ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'R')
164
- assert_equal ary_ucs4_1, ary_ucs4_2
165
- ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'L')
166
- assert_equal ary_ucs4_1, ary_ucs4_2
167
-
168
- ascii_str = "abc def"
169
- ary_ucs4_1 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str))
170
- assert_equal [0x61, 0x62, 0x63, 0x20, 0x20, 0x64, 0x65, 0x66], ary_ucs4_1
171
- ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'R')
172
- assert_equal ary_ucs4_1, ary_ucs4_2
173
- ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'L')
174
- assert_equal ary_ucs4_1, ary_ucs4_2
175
-
176
- ascii_str = "abc "
177
- ary_ucs4_1 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str))
178
- assert_equal [0x61, 0x62, 0x63, 0x20, 0x20], ary_ucs4_1
179
- ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'L')
180
- assert_equal ary_ucs4_1, ary_ucs4_2
181
- ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'R')
182
- assert_equal [0x20, 0x20, 0x61, 0x62, 0x63], ary_ucs4_2
183
-
184
- ascii_str = "abc_def"
185
- ary_ucs4_1 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str))
186
- assert_equal [0x61, 0x62, 0x63, 0x5f, 0x64, 0x65, 0x66], ary_ucs4_1
187
- ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'R')
188
- assert_equal ary_ucs4_1, ary_ucs4_2
189
- ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'L')
190
- assert_equal ary_ucs4_1, ary_ucs4_2
191
- end
192
-
193
- test "Bidi ascii numeric space test" do
194
- pdf = MYPDF.new
195
-
196
- ascii_str = "abc 123 def"
197
- ary_ucs4_1 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str))
198
- assert_equal [0x61, 0x62, 0x63, 0x20, 0x31, 0x32, 0x33, 0x20, 0x64, 0x65, 0x66], ary_ucs4_1
199
- ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'R')
200
- assert_equal ary_ucs4_1, ary_ucs4_2
201
- ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'L')
202
- assert_equal ary_ucs4_1, ary_ucs4_2
203
-
204
- ascii_str = "abc_123_def"
205
- ary_ucs4_1 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str))
206
- assert_equal [0x61, 0x62, 0x63, 0x5f, 0x31, 0x32, 0x33, 0x5f, 0x64, 0x65, 0x66], ary_ucs4_1
207
- ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'R')
208
- assert_equal ary_ucs4_1, ary_ucs4_2
209
- ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'L')
210
- assert_equal ary_ucs4_1, ary_ucs4_2
211
- end
212
-
213
- test "Bidi ascii colon test" do
214
- pdf = MYPDF.new
215
-
216
- ascii_str = "abc:def"
217
- ary_ucs4_1 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str))
218
- assert_equal [0x61, 0x62, 0x63, 0x3a, 0x64, 0x65, 0x66], ary_ucs4_1
219
- ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'R')
220
- assert_equal ary_ucs4_1, ary_ucs4_2
221
- ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'L')
222
- assert_equal ary_ucs4_1, ary_ucs4_2
223
-
224
- ascii_str = "abc: def"
225
- ary_ucs4_1 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str))
226
- assert_equal [0x61, 0x62, 0x63, 0x3a, 0x20, 0x64, 0x65, 0x66], ary_ucs4_1
227
- ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'R')
228
- assert_equal ary_ucs4_1, ary_ucs4_2
229
- ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'L')
230
- assert_equal ary_ucs4_1, ary_ucs4_2
231
-
232
- ascii_str = "abc : def"
233
- ary_ucs4_1 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str))
234
- assert_equal [0x61, 0x62, 0x63, 0x20, 0x3a, 0x20, 0x64, 0x65, 0x66], ary_ucs4_1
235
- ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'R')
236
- assert_equal ary_ucs4_1, ary_ucs4_2
237
- ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'L')
238
- assert_equal ary_ucs4_1, ary_ucs4_2
239
-
240
- ascii_str = "abc :: def"
241
- ary_ucs4_1 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str))
242
- assert_equal [0x61, 0x62, 0x63, 0x20, 0x20, 0x3a, 0x3a, 0x20, 0x20, 0x64, 0x65, 0x66], ary_ucs4_1
243
- ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'R')
244
- assert_equal ary_ucs4_1, ary_ucs4_2
245
- ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), '', 'L')
246
- assert_equal ary_ucs4_1, ary_ucs4_2
247
- end
248
-
249
-
250
- test "Bidi arabic test" do
251
- pdf = MYPDF.new
252
-
253
- # Bidirectional Algorithm
254
- ascii_str = "role"
255
- utf8_arabic_str_1 = "\xd8\xaf\xd9\x88\xd8\xb1"
256
- utf8_arabic_char_1 = "\xd8\xaf"
257
-
258
- # UCS4 charactor -> UTF-8 charactor
259
- utf8_chr = pdf.unichr(0x62f)
260
- assert_equal "\xd8\xaf", utf8_chr
261
-
262
- # UTF-8 string -> array of UCS4 charactor
263
- ary_ucs4 = pdf.UTF8StringToArray(ascii_str)
264
- assert_equal [0x72, 0x6f, 0x6c, 0x65], ary_ucs4
265
- ary_ucs4 = pdf.UTF8StringToArray(utf8_arabic_str_1)
266
- assert_equal [0x62f, 0x648, 0x631], ary_ucs4
267
- ary_ucs4 = pdf.UTF8StringToArray(utf8_arabic_char_1)
268
- assert_equal [0x62f], ary_ucs4
269
-
270
-
271
- ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str))
272
- assert_equal [0x72, 0x6f, 0x6c, 0x65], ary_ucs4
273
-
274
- ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(ascii_str), ascii_str, 'R')
275
- assert_equal [0x72, 0x6f, 0x6c, 0x65], ary_ucs4
276
-
277
- ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_arabic_char_1))
278
- assert_equal [0xfea9], ary_ucs4
279
- ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_arabic_char_1), utf8_arabic_char_1, 'R')
280
- assert_equal [0xfea9], ary_ucs4
281
-
282
- ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_arabic_str_1))
283
- assert_equal [0xfead, 0xfeed, 0xfea9], ary_ucs4
284
- end
285
-
286
- test "Bidi Persian Sunday test" do
287
- pdf = MYPDF.new
288
-
289
- utf8_persian_str_1 = "\xdb\x8c" # 0x06cc
290
- utf8_persian_str_2 = "\xdb\x8c\xda\xa9" # 0x06cc, 0x06a9
291
- utf8_persian_str_3 = "\xdb\x8c\xda\xa9\xe2\x80\x8c" # 0x06cc, 0x06a9, 0x200c
292
- utf8_persian_str_4 = "\xdb\x8c\xda\xa9\xe2\x80\x8c\xd8\xb4" # 0x06cc, 0x06a9, 0x200c, 0x0634
293
- utf8_persian_str_5 = "\xdb\x8c\xda\xa9\xe2\x80\x8c\xd8\xb4\xd9\x86" # 0x06cc, 0x06a9, 0x200c, 0x0634, 0x0646
294
- utf8_persian_str_6 = "\xdb\x8c\xda\xa9\xe2\x80\x8c\xd8\xb4\xd9\x86\xd8\xa8" # 0x06cc, 0x06a9, 0x200c, 0x0634, 0x0646, 0x0628
295
- 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
296
-
297
- ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_1))
298
- assert_equal [0xfbfc], ary_ucs4
299
- current_font = pdf.get_current_font
300
- assert_equal 256 + 2, current_font['subsetchars'].compact.length # 0x06cc, 0xfbfc
301
-
302
- ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_2))
303
- assert_equal [0xfb8f, 0xfbfe], ary_ucs4
304
- current_font = pdf.get_current_font
305
- assert_equal 256 + 5, current_font['subsetchars'].compact.length # 0xfbfc + 0x06cc, 0x06a9, 0xfb8f, 0xfbfe
306
-
307
- ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_3))
308
- assert_equal [0x200c, 0xfb8f, 0xfbfe], ary_ucs4
309
- current_font = pdf.get_current_font
310
- assert_equal 256 + 6, current_font['subsetchars'].compact.length # 0xfbfc + 0x06cc, 0x06a9, 0x200c, 0xfb8f, 0xfbfe
311
-
312
- ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_4))
313
- assert_equal [0xfeb5, 0x200c, 0xfb8f, 0xfbfe], ary_ucs4
314
- current_font = pdf.get_current_font
315
- assert_equal 256 + 8, current_font['subsetchars'].compact.length # 0xfbfc + 0x06cc, 0x06a9, 0x200c, 0x0634, 0xfeb5, 0xfb8f, 0xfbfe
316
-
317
- ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_5))
318
- assert_equal [0xfee6, 0xfeb7, 0x200c, 0xfb8f, 0xfbfe], ary_ucs4
319
- current_font = pdf.get_current_font
320
- assert_equal 256 + 11, current_font['subsetchars'].compact.length # 0xfbfc, 0xfeb5 + 0x06cc, 0x06a9, 0x200c, 0x0634, 0x0646, 0xfee6, 0xfeb7, 0xfb8f, 0xfbfe
321
-
322
- ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_6))
323
- assert_equal [0xfe90, 0xfee8, 0xfeb7, 0x200c, 0xfb8f, 0xfbfe], ary_ucs4
324
- current_font = pdf.get_current_font
325
- assert_equal 256 + 14, current_font['subsetchars'].compact.length # 0xfbfc, 0xfeb5, 0xfee6 + 0x06cc, 0x06a9, 0x200c, 0x0634, 0x0646, 0x0628, 0xfe90, 0xfee8, 0xfeb7, 0xfb8f, 0xfbfe
326
-
327
- ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_7))
328
- assert_equal [0xfeea, 0xfe92, 0xfee8, 0xfeb7, 0x200c, 0xfb8f, 0xfbfe], ary_ucs4
329
- current_font = pdf.get_current_font
330
- 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
331
- end
332
-
333
- test "Bidi Persian Sunday forcertl test" do
334
- pdf = MYPDF.new
335
- utf8_persian_str_sunday = "\xdb\x8c\xda\xa9\xe2\x80\x8c\xd8\xb4\xd9\x86\xd8\xa8\xd9\x87"
336
-
337
- ary_ucs4_1 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_sunday), '', 'R')
338
- assert_equal [0xfeea, 0xfe92, 0xfee8, 0xfeb7, 0x200C, 0xfb8f, 0xfbfe], ary_ucs4_1
339
- ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_sunday), '', 'L')
340
- assert_equal ary_ucs4_1, ary_ucs4_2
341
- end
342
-
343
- test "Bidi Persian Monday test" do
344
- pdf = MYPDF.new
345
-
346
- utf8_persian_str_1 = "\xd8\xaf"
347
- utf8_persian_str_2 = "\xd8\xaf\xd9\x88"
348
- utf8_persian_str_3 = "\xd8\xaf\xd9\x88\xd8\xb4"
349
- utf8_persian_str_4 = "\xd8\xaf\xd9\x88\xd8\xb4\xd9\x86"
350
- utf8_persian_str_5 = "\xd8\xaf\xd9\x88\xd8\xb4\xd9\x86\xd8\xa8"
351
- utf8_persian_str_6 = "\xd8\xaf\xd9\x88\xd8\xb4\xd9\x86\xd8\xa8\xd9\x87" # Monday
352
-
353
- ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_1))
354
- assert_equal [0xfea9], ary_ucs4
355
- ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_2))
356
- assert_equal [0xfeed, 0xfea9], ary_ucs4
357
- ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_3))
358
- assert_equal [0xfeb5, 0xfeed, 0xfea9], ary_ucs4
359
- ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_4))
360
- assert_equal [0xfee6, 0xfeb7, 0xfeed, 0xfea9], ary_ucs4
361
- ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_5))
362
- assert_equal [0xfe90, 0xfee8, 0xfeb7, 0xfeed, 0xfea9], ary_ucs4
363
- ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_6))
364
- assert_equal [0xfeea, 0xfe92, 0xfee8, 0xfeb7, 0xfeed, 0xfea9], ary_ucs4
365
- end
366
-
367
- test "Bidi Persian Monday forcertl test" do
368
- pdf = MYPDF.new
369
- utf8_persian_str_monday = "\xd8\xaf\xd9\x88\xd8\xb4\xd9\x86\xd8\xa8\xd9\x87"
370
-
371
- ary_ucs4_1 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_monday), '', 'R')
372
- assert_equal [0xfeea, 0xfe92, 0xfee8, 0xfeb7, 0xfeed, 0xfea9], ary_ucs4_1
373
- ary_ucs4_2 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_monday), '', 'L')
374
- assert_equal ary_ucs4_1, ary_ucs4_2
375
- end
376
-
377
- test "Bidi Persian and English test" do
378
- pdf = MYPDF.new
379
-
380
- utf8_persian_str_sunday = "\xdb\x8c\xda\xa9\xe2\x80\x8c\xd8\xb4\xd9\x86\xd8\xa8\xd9\x87"
381
- ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_sunday + ' abc'))
382
- assert_equal [0x61, 0x62, 0x63, 0x20, # 'abc '
383
- 0xfeea, 0xfe92, 0xfee8, 0xfeb7, 0x200C, 0xfb8f, 0xfbfe], ary_ucs4 # Sunday
384
- ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_sunday + ' abc'), '', 'R')
385
- assert_equal [0x61, 0x62, 0x63, 0x20, # 'abc '
386
- 0xfeea, 0xfe92, 0xfee8, 0xfeb7, 0x200C, 0xfb8f, 0xfbfe], ary_ucs4 # Sunday
387
- ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_persian_str_sunday + ' abc'), '', 'L')
388
- assert_equal [0xfeea, 0xfe92, 0xfee8, 0xfeb7, 0x200C, 0xfb8f, 0xfbfe, # Sunday
389
- 0x20, 0x61, 0x62, 0x63], ary_ucs4 # 'abc '
390
- end
391
-
392
- test "Bidi English and Persian test" do
393
- pdf = MYPDF.new
394
-
395
- utf8_persian_str_sunday = "\xdb\x8c\xda\xa9\xe2\x80\x8c\xd8\xb4\xd9\x86\xd8\xa8\xd9\x87"
396
- ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray('abc ' + utf8_persian_str_sunday))
397
- assert_equal [0x61, 0x62, 0x63, 0x20, # 'abc '
398
- 0xfeea, 0xfe92, 0xfee8, 0xfeb7, 0x200C, 0xfb8f, 0xfbfe], ary_ucs4 # Sunday
399
- ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray('abc ' + utf8_persian_str_sunday), '', 'L')
400
- assert_equal [0x61, 0x62, 0x63, 0x20, # 'abc '
401
- 0xfeea, 0xfe92, 0xfee8, 0xfeb7, 0x200C, 0xfb8f, 0xfbfe], ary_ucs4 # Sunday
402
- ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray('abc ' + utf8_persian_str_sunday), '', 'R')
403
- assert_equal [0xfeea, 0xfe92, 0xfee8, 0xfeb7, 0x200C, 0xfb8f, 0xfbfe, # Sunday
404
- 0x20, 0x61, 0x62, 0x63], ary_ucs4 # 'abc '
405
- end
406
-
407
- test "Bidi date test" do
408
- pdf = MYPDF.new
409
-
410
- utf8_date_str_1 = '12/01/2014'
411
-
412
- pdf.set_rtl(true)
413
- pdf.set_temp_rtl('rtl')
414
- # UTF-8 string -> array of UCS4 charactor
415
- ary_ucs4 = pdf.UTF8StringToArray(utf8_date_str_1)
416
- assert_equal [0x31, 0x32, 0x2f, 0x30, 0x31, 0x2f, 0x32, 0x30, 0x31, 0x34], ary_ucs4 # 12/01/2014
417
-
418
- ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_date_str_1))
419
- assert_equal [0x31, 0x32, 0x2f, 0x30, 0x31, 0x2f, 0x32, 0x30, 0x31, 0x34], ary_ucs4 # 12/01/2014
420
-
421
- ary_ucs4 = pdf.utf8Bidi(pdf.UTF8StringToArray(utf8_date_str_1), utf8_date_str_1, 'R')
422
- assert_equal [0x31, 0x32, 0x2f, 0x30, 0x31, 0x2f, 0x32, 0x30, 0x31, 0x34], ary_ucs4 # 12/01/2014
423
- end
424
-
425
- test "Bidi Japanese test" do
426
- pdf = MYPDF.new
427
-
428
- utf8_japanese_aiueo_str_1 = "\xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88\xe3\x81\x8a"
429
-
430
- # UTF-8 string -> array of UCS4 charactor
431
- ary_ucs4 = pdf.UTF8StringToArray(utf8_japanese_aiueo_str_1)
432
- assert_equal [0x3042, 0x3044, 0x3046, 0x3048, 0x304a], ary_ucs4 # Japanese aiueo
433
-
434
- current_font = pdf.get_current_font
435
- assert_equal 256 + 5, current_font['subsetchars'].compact.length
436
- end
437
-
438
- test "UTF8StringToArray cache_utf8_string_to_array test" do
439
- pdf = MYPDF.new
440
-
441
- chars = pdf.UTF8StringToArray('1234')
442
- chars.reverse!
443
-
444
- rtn = pdf.cache_utf8_string_to_array('1234')
445
- assert_equal [0x31, 0x32, 0x33, 0x34], rtn
446
- end
447
-
448
- test "UniArrSubString test" do
449
- pdf = RBPDF.new
450
- str = pdf.uni_arr_sub_string(['a', 'b', 'c', ' ', 'd', 'e', 'f'])
451
- assert_equal 'abc def', str
452
- end
453
- end