prawn-svg 0.22.1 → 0.23.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +29 -13
  3. data/lib/prawn-svg.rb +7 -0
  4. data/lib/prawn/svg/attributes.rb +1 -1
  5. data/lib/prawn/svg/attributes/color.rb +5 -0
  6. data/lib/prawn/svg/attributes/display.rb +1 -1
  7. data/lib/prawn/svg/attributes/font.rb +11 -11
  8. data/lib/prawn/svg/attributes/opacity.rb +3 -3
  9. data/lib/prawn/svg/css.rb +40 -0
  10. data/lib/prawn/svg/document.rb +23 -8
  11. data/lib/prawn/svg/elements/base.rb +20 -10
  12. data/lib/prawn/svg/elements/container.rb +1 -1
  13. data/lib/prawn/svg/elements/gradient.rb +7 -4
  14. data/lib/prawn/svg/elements/image.rb +2 -6
  15. data/lib/prawn/svg/elements/root.rb +4 -0
  16. data/lib/prawn/svg/elements/text.rb +14 -14
  17. data/lib/prawn/svg/font.rb +9 -91
  18. data/lib/prawn/svg/font_registry.rb +73 -0
  19. data/lib/prawn/svg/interface.rb +9 -22
  20. data/lib/prawn/svg/loaders/data.rb +18 -0
  21. data/lib/prawn/svg/loaders/file.rb +66 -0
  22. data/lib/prawn/svg/loaders/web.rb +28 -0
  23. data/lib/prawn/svg/state.rb +39 -0
  24. data/lib/prawn/svg/ttf.rb +61 -0
  25. data/lib/prawn/svg/url_loader.rb +35 -23
  26. data/lib/prawn/svg/version.rb +1 -1
  27. data/spec/integration_spec.rb +7 -6
  28. data/spec/prawn/svg/attributes/font_spec.rb +8 -5
  29. data/spec/prawn/svg/css_spec.rb +24 -0
  30. data/spec/prawn/svg/document_spec.rb +35 -10
  31. data/spec/prawn/svg/elements/base_spec.rb +32 -10
  32. data/spec/prawn/svg/elements/gradient_spec.rb +1 -1
  33. data/spec/prawn/svg/elements/text_spec.rb +4 -4
  34. data/spec/prawn/svg/font_registry_spec.rb +54 -0
  35. data/spec/prawn/svg/font_spec.rb +0 -27
  36. data/spec/prawn/svg/loaders/data_spec.rb +55 -0
  37. data/spec/prawn/svg/loaders/file_spec.rb +84 -0
  38. data/spec/prawn/svg/loaders/web_spec.rb +37 -0
  39. data/spec/prawn/svg/ttf_spec.rb +32 -0
  40. data/spec/prawn/svg/url_loader_spec.rb +90 -24
  41. data/spec/sample_svg/image03.svg +30 -0
  42. data/spec/sample_svg/tspan03-cc.svg +21 -0
  43. data/spec/sample_ttf/OpenSans-SemiboldItalic.ttf +0 -0
  44. data/spec/spec_helper.rb +17 -2
  45. metadata +28 -2
@@ -0,0 +1,30 @@
1
+ <?xml version="1.0" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
+ <svg width="210mm" height="297mm" viewBox="0 0 1050 1485"
4
+ xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">
5
+
6
+ <g transform="translate(50 0)">
7
+ <text y="25" font-size="12pt">wide image, aspect ratio meet</text>
8
+
9
+ <rect y="50" width="100" height="100" fill="none" stroke="blue" stroke-width="2"/>
10
+ <image y="50" width="100" height="100" preserveAspectRatio="xMidYMid" xlink:href="sample_images/mushroom-wide.jpg"></image>
11
+
12
+ <rect y="200" width="150" height="100" fill="none" stroke="blue" stroke-width="2"/>
13
+ <image y="200" width="150" height="100" xlink:href="sample_images/mushroom-wide.jpg"></image>
14
+
15
+ <rect y="350" width="100" height="150" fill="none" stroke="blue" stroke-width="2"/>
16
+ <image y="350" width="100" height="150" xlink:href="sample_images/mushroom-wide.jpg"></image>
17
+
18
+ <rect y="550" width="150" height="100" fill="none" stroke="blue" stroke-width="2"/>
19
+ <image y="550" width="150" height="100" preserveAspectRatio="xMinYMin" xlink:href="sample_images/mushroom-wide.jpg"></image>
20
+
21
+ <rect y="700" width="100" height="150" fill="none" stroke="blue" stroke-width="2"/>
22
+ <image y="700" width="100" height="150" preserveAspectRatio="xMinYMin" xlink:href="sample_images/mushroom-wide.jpg"></image>
23
+
24
+ <rect y="900" width="150" height="100" fill="none" stroke="blue" stroke-width="2"/>
25
+ <image y="900" width="150" height="100" preserveAspectRatio="xMaxYMax" xlink:href="sample_images/mushroom-wide.jpg"></image>
26
+
27
+ <rect y="1050" width="100" height="150" fill="none" stroke="blue" stroke-width="2"/>
28
+ <image y="1050" width="100" height="150" preserveAspectRatio="xMaxYMax" xlink:href="sample_images/mushroom-wide.jpg"></image>
29
+ </g>
30
+ </svg>
@@ -0,0 +1,21 @@
1
+ <?xml version="1.0" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
3
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <svg width="10cm" height="3cm" viewBox="0 0 1000 300"
5
+ xmlns="http://www.w3.org/2000/svg" version="1.1">
6
+ <desc>Example tspan03 - using tspan's x and y attributes
7
+ for multiline text and precise glyph positioning</desc>
8
+ <g font-family="Verdana" font-size="45" style="color: rgb(255,164,0)">
9
+ <text style="fill: currentColor">
10
+ <tspan x="300 350 400 450 500 550 600 650" y="100">
11
+ Cute and
12
+ </tspan>
13
+ <tspan x="375 425 475 525 575" y="200">
14
+ fuzzy
15
+ </tspan>
16
+ </text>
17
+ </g>
18
+ <!-- Show outline of canvas using 'rect' element -->
19
+ <rect x="1" y="1" width="998" height="298"
20
+ fill="none" stroke="blue" stroke-width="2" />
21
+ </svg>
data/spec/spec_helper.rb CHANGED
@@ -5,6 +5,21 @@ Bundler.require(:default, :development)
5
5
  # in ./support/ and its subdirectories.
6
6
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
7
7
 
8
+ module Support
9
+ def flatten_calls(calls)
10
+ [].tap do |flattened_calls|
11
+ add = -> (calls) do
12
+ calls.each do |call|
13
+ flattened_calls << call[0..1]
14
+ add.call call[2]
15
+ end
16
+ end
17
+
18
+ add.call element.base_calls
19
+ end
20
+ end
21
+ end
22
+
8
23
  RSpec.configure do |config|
9
24
  config.mock_with :rspec do |c|
10
25
  c.syntax = [:should, :expect]
@@ -13,6 +28,6 @@ RSpec.configure do |config|
13
28
  config.expect_with :rspec do |c|
14
29
  c.syntax = [:should, :expect]
15
30
  end
16
- end
17
31
 
18
- Prawn::SVG::Font.load_external_fonts(Prawn::Document.new.font_families)
32
+ config.include Support
33
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prawn-svg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.1
4
+ version: 0.23.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roger Nesbitt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-08 00:00:00.000000000 Z
11
+ date: 2016-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prawn
@@ -90,6 +90,7 @@ files:
90
90
  - lib/prawn-svg.rb
91
91
  - lib/prawn/svg/attributes.rb
92
92
  - lib/prawn/svg/attributes/clip_path.rb
93
+ - lib/prawn/svg/attributes/color.rb
93
94
  - lib/prawn/svg/attributes/display.rb
94
95
  - lib/prawn/svg/attributes/font.rb
95
96
  - lib/prawn/svg/attributes/opacity.rb
@@ -99,6 +100,7 @@ files:
99
100
  - lib/prawn/svg/calculators/document_sizing.rb
100
101
  - lib/prawn/svg/calculators/pixels.rb
101
102
  - lib/prawn/svg/color.rb
103
+ - lib/prawn/svg/css.rb
102
104
  - lib/prawn/svg/document.rb
103
105
  - lib/prawn/svg/elements.rb
104
106
  - lib/prawn/svg/elements/base.rb
@@ -119,7 +121,13 @@ files:
119
121
  - lib/prawn/svg/elements/use.rb
120
122
  - lib/prawn/svg/extension.rb
121
123
  - lib/prawn/svg/font.rb
124
+ - lib/prawn/svg/font_registry.rb
122
125
  - lib/prawn/svg/interface.rb
126
+ - lib/prawn/svg/loaders/data.rb
127
+ - lib/prawn/svg/loaders/file.rb
128
+ - lib/prawn/svg/loaders/web.rb
129
+ - lib/prawn/svg/state.rb
130
+ - lib/prawn/svg/ttf.rb
123
131
  - lib/prawn/svg/url_loader.rb
124
132
  - lib/prawn/svg/version.rb
125
133
  - prawn-svg.gemspec
@@ -129,14 +137,20 @@ files:
129
137
  - spec/prawn/svg/calculators/aspect_ratio_spec.rb
130
138
  - spec/prawn/svg/calculators/document_sizing_spec.rb
131
139
  - spec/prawn/svg/color_spec.rb
140
+ - spec/prawn/svg/css_spec.rb
132
141
  - spec/prawn/svg/document_spec.rb
133
142
  - spec/prawn/svg/elements/base_spec.rb
134
143
  - spec/prawn/svg/elements/gradient_spec.rb
135
144
  - spec/prawn/svg/elements/path_spec.rb
136
145
  - spec/prawn/svg/elements/style_spec.rb
137
146
  - spec/prawn/svg/elements/text_spec.rb
147
+ - spec/prawn/svg/font_registry_spec.rb
138
148
  - spec/prawn/svg/font_spec.rb
139
149
  - spec/prawn/svg/interface_spec.rb
150
+ - spec/prawn/svg/loaders/data_spec.rb
151
+ - spec/prawn/svg/loaders/file_spec.rb
152
+ - spec/prawn/svg/loaders/web_spec.rb
153
+ - spec/prawn/svg/ttf_spec.rb
140
154
  - spec/prawn/svg/url_loader_spec.rb
141
155
  - spec/sample_images/mushroom-long.jpg
142
156
  - spec/sample_images/mushroom-wide.jpg
@@ -158,6 +172,7 @@ files:
158
172
  - spec/sample_svg/highcharts.svg
159
173
  - spec/sample_svg/image01.svg
160
174
  - spec/sample_svg/image02_base64.svg
175
+ - spec/sample_svg/image03.svg
161
176
  - spec/sample_svg/line01.svg
162
177
  - spec/sample_svg/maths.svg
163
178
  - spec/sample_svg/matrix_transform.svg
@@ -182,11 +197,13 @@ files:
182
197
  - spec/sample_svg/triangle01.svg
183
198
  - spec/sample_svg/tspan01.svg
184
199
  - spec/sample_svg/tspan02.svg
200
+ - spec/sample_svg/tspan03-cc.svg
185
201
  - spec/sample_svg/tspan03.svg
186
202
  - spec/sample_svg/tspan04.svg
187
203
  - spec/sample_svg/use.svg
188
204
  - spec/sample_svg/viewbox.svg
189
205
  - spec/sample_svg/viewport.svg
206
+ - spec/sample_ttf/OpenSans-SemiboldItalic.ttf
190
207
  - spec/spec_helper.rb
191
208
  homepage: http://github.com/mogest/prawn-svg
192
209
  licenses:
@@ -219,14 +236,20 @@ test_files:
219
236
  - spec/prawn/svg/calculators/aspect_ratio_spec.rb
220
237
  - spec/prawn/svg/calculators/document_sizing_spec.rb
221
238
  - spec/prawn/svg/color_spec.rb
239
+ - spec/prawn/svg/css_spec.rb
222
240
  - spec/prawn/svg/document_spec.rb
223
241
  - spec/prawn/svg/elements/base_spec.rb
224
242
  - spec/prawn/svg/elements/gradient_spec.rb
225
243
  - spec/prawn/svg/elements/path_spec.rb
226
244
  - spec/prawn/svg/elements/style_spec.rb
227
245
  - spec/prawn/svg/elements/text_spec.rb
246
+ - spec/prawn/svg/font_registry_spec.rb
228
247
  - spec/prawn/svg/font_spec.rb
229
248
  - spec/prawn/svg/interface_spec.rb
249
+ - spec/prawn/svg/loaders/data_spec.rb
250
+ - spec/prawn/svg/loaders/file_spec.rb
251
+ - spec/prawn/svg/loaders/web_spec.rb
252
+ - spec/prawn/svg/ttf_spec.rb
230
253
  - spec/prawn/svg/url_loader_spec.rb
231
254
  - spec/sample_images/mushroom-long.jpg
232
255
  - spec/sample_images/mushroom-wide.jpg
@@ -248,6 +271,7 @@ test_files:
248
271
  - spec/sample_svg/highcharts.svg
249
272
  - spec/sample_svg/image01.svg
250
273
  - spec/sample_svg/image02_base64.svg
274
+ - spec/sample_svg/image03.svg
251
275
  - spec/sample_svg/line01.svg
252
276
  - spec/sample_svg/maths.svg
253
277
  - spec/sample_svg/matrix_transform.svg
@@ -272,9 +296,11 @@ test_files:
272
296
  - spec/sample_svg/triangle01.svg
273
297
  - spec/sample_svg/tspan01.svg
274
298
  - spec/sample_svg/tspan02.svg
299
+ - spec/sample_svg/tspan03-cc.svg
275
300
  - spec/sample_svg/tspan03.svg
276
301
  - spec/sample_svg/tspan04.svg
277
302
  - spec/sample_svg/use.svg
278
303
  - spec/sample_svg/viewbox.svg
279
304
  - spec/sample_svg/viewport.svg
305
+ - spec/sample_ttf/OpenSans-SemiboldItalic.ttf
280
306
  - spec/spec_helper.rb