prawn-svg 0.15.0.0 → 0.23.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +6 -0
  3. data/README.md +51 -20
  4. data/lib/prawn/svg/attributes/clip_path.rb +17 -0
  5. data/lib/prawn/svg/attributes/color.rb +5 -0
  6. data/lib/prawn/svg/attributes/display.rb +5 -0
  7. data/lib/prawn/svg/attributes/font.rb +38 -0
  8. data/lib/prawn/svg/attributes/opacity.rb +15 -0
  9. data/lib/prawn/svg/attributes/stroke.rb +35 -0
  10. data/lib/prawn/svg/attributes/transform.rb +50 -0
  11. data/lib/prawn/svg/attributes.rb +6 -0
  12. data/lib/prawn/svg/calculators/aspect_ratio.rb +58 -0
  13. data/lib/prawn/svg/calculators/document_sizing.rb +99 -0
  14. data/lib/prawn/svg/calculators/pixels.rb +21 -0
  15. data/lib/prawn/svg/color.rb +197 -12
  16. data/lib/prawn/svg/css.rb +40 -0
  17. data/lib/prawn/svg/document.rb +37 -48
  18. data/lib/prawn/svg/elements/base.rb +238 -0
  19. data/lib/prawn/svg/elements/circle.rb +25 -0
  20. data/lib/prawn/svg/elements/container.rb +15 -0
  21. data/lib/prawn/svg/elements/ellipse.rb +23 -0
  22. data/lib/prawn/svg/elements/gradient.rb +120 -0
  23. data/lib/prawn/svg/elements/ignored.rb +5 -0
  24. data/lib/prawn/svg/elements/image.rb +81 -0
  25. data/lib/prawn/svg/elements/line.rb +16 -0
  26. data/lib/prawn/svg/elements/path.rb +405 -0
  27. data/lib/prawn/svg/elements/polygon.rb +17 -0
  28. data/lib/prawn/svg/elements/polyline.rb +22 -0
  29. data/lib/prawn/svg/elements/rect.rb +33 -0
  30. data/lib/prawn/svg/elements/root.rb +13 -0
  31. data/lib/prawn/svg/elements/style.rb +10 -0
  32. data/lib/prawn/svg/elements/text.rb +87 -0
  33. data/lib/prawn/svg/elements/use.rb +29 -0
  34. data/lib/prawn/svg/elements.rb +33 -0
  35. data/lib/prawn/svg/extension.rb +4 -4
  36. data/lib/prawn/svg/font.rb +10 -92
  37. data/lib/prawn/svg/font_registry.rb +73 -0
  38. data/lib/prawn/svg/interface.rb +91 -31
  39. data/lib/prawn/svg/loaders/data.rb +18 -0
  40. data/lib/prawn/svg/loaders/file.rb +66 -0
  41. data/lib/prawn/svg/loaders/web.rb +28 -0
  42. data/lib/prawn/svg/state.rb +39 -0
  43. data/lib/prawn/svg/ttf.rb +61 -0
  44. data/lib/prawn/svg/url_loader.rb +46 -0
  45. data/lib/prawn/svg/version.rb +2 -2
  46. data/lib/prawn-svg.rb +20 -6
  47. data/prawn-svg.gemspec +8 -5
  48. data/spec/integration_spec.rb +141 -0
  49. data/spec/prawn/svg/attributes/font_spec.rb +52 -0
  50. data/spec/prawn/svg/attributes/transform_spec.rb +56 -0
  51. data/spec/prawn/svg/calculators/aspect_ratio_spec.rb +95 -0
  52. data/spec/prawn/svg/calculators/document_sizing_spec.rb +128 -0
  53. data/spec/prawn/svg/color_spec.rb +43 -8
  54. data/spec/prawn/svg/css_spec.rb +24 -0
  55. data/spec/prawn/svg/document_spec.rb +48 -19
  56. data/spec/prawn/svg/elements/base_spec.rb +147 -0
  57. data/spec/prawn/svg/elements/gradient_spec.rb +61 -0
  58. data/spec/prawn/svg/elements/path_spec.rb +123 -0
  59. data/spec/prawn/svg/elements/style_spec.rb +23 -0
  60. data/spec/prawn/svg/elements/text_spec.rb +61 -0
  61. data/spec/prawn/svg/font_registry_spec.rb +54 -0
  62. data/spec/prawn/svg/font_spec.rb +1 -28
  63. data/spec/prawn/svg/interface_spec.rb +94 -0
  64. data/spec/prawn/svg/loaders/data_spec.rb +55 -0
  65. data/spec/prawn/svg/loaders/file_spec.rb +84 -0
  66. data/spec/prawn/svg/loaders/web_spec.rb +37 -0
  67. data/spec/prawn/svg/ttf_spec.rb +32 -0
  68. data/spec/prawn/svg/url_loader_spec.rb +112 -0
  69. data/spec/sample_images/mushroom-long.jpg +0 -0
  70. data/spec/sample_images/mushroom-wide.jpg +0 -0
  71. data/spec/sample_svg/cap_styles.svg +13 -0
  72. data/spec/sample_svg/display_none.svg +13 -0
  73. data/spec/sample_svg/gistfile1.svg +36 -0
  74. data/spec/sample_svg/gradients.svg +40 -0
  75. data/spec/sample_svg/hidden_paths.svg +6 -0
  76. data/spec/sample_svg/image01.svg +31 -31
  77. data/spec/sample_svg/image03.svg +30 -0
  78. data/spec/sample_svg/negminy.svg +25 -0
  79. data/spec/sample_svg/no_width_or_height.svg +4 -0
  80. data/spec/sample_svg/path.svg +5 -0
  81. data/spec/sample_svg/pie_piece.svg +7 -0
  82. data/spec/sample_svg/preserve-space.svg +19 -0
  83. data/spec/sample_svg/rect02.svg +8 -11
  84. data/spec/sample_svg/tspan03-cc.svg +21 -0
  85. data/spec/sample_svg/viewbox.svg +4 -0
  86. data/spec/sample_svg/viewport.svg +23 -0
  87. data/spec/sample_ttf/OpenSans-SemiboldItalic.ttf +0 -0
  88. data/spec/spec_helper.rb +24 -2
  89. metadata +150 -36
  90. data/lib/prawn/svg/element.rb +0 -237
  91. data/lib/prawn/svg/parser/image.rb +0 -134
  92. data/lib/prawn/svg/parser/path.rb +0 -374
  93. data/lib/prawn/svg/parser/text.rb +0 -66
  94. data/lib/prawn/svg/parser.rb +0 -233
  95. data/spec/lib/parser_spec.rb +0 -55
  96. data/spec/lib/path_spec.rb +0 -54
  97. data/spec/lib/svg_spec.rb +0 -47
  98. data/spec/prawn/svg/element_spec.rb +0 -36
  99. data/spec/prawn/svg/parser/text_spec.rb +0 -4
@@ -0,0 +1,40 @@
1
+ <svg width="240" height="240" version="1.1" xmlns="http://www.w3.org/2000/svg">
2
+ <defs>
3
+ <style type="text/css"><![CDATA[
4
+ #rect1 { fill: url(#Gradient1); }
5
+ .stop1 { stop-color: red; }
6
+ .stop2 { stop-color: black; stop-opacity: 0; }
7
+ .stop3 { stop-color: blue; }
8
+ ]]></style>
9
+ <linearGradient id="Gradient1">
10
+ <stop class="stop1" offset="0%"/>
11
+ <stop class="stop2" offset="50%"/>
12
+ <stop class="stop3" offset="100%"/>
13
+ </linearGradient>
14
+ <linearGradient id="Gradient2" x1="0" x2="0" y1="0" y2="1">
15
+ <stop offset="25%" stop-color="red"/>
16
+ <stop offset="50%" stop-color="black" stop-opacity="0"/>
17
+ <stop offset="75%" stop-color="blue"/>
18
+ </linearGradient>
19
+ <linearGradient id="Gradient3" x1="0" x2="1" y1="0" y2="1">
20
+ <stop offset="0%" stop-color="red"/>
21
+ <stop offset="30%" stop-color="yellow"/>
22
+ <stop offset="60%" stop-color="orange"/>
23
+ <stop offset="100%" stop-color="blue"/>
24
+ </linearGradient>
25
+ <linearGradient id="userspace" gradientUnits="userSpaceOnUse" x1="160" y1="90" x2="220" y2="90">
26
+ <stop offset="0" stop-color="red"/>
27
+ <stop offset="1" stop-color="blue"/>
28
+ </linearGradient>
29
+ </defs>
30
+
31
+ <rect id="rect1" x="10" y="10" rx="15" ry="15" width="50" height="100" stroke="black"/>
32
+ <rect x="10" y="120" rx="15" ry="15" width="50" height="100" fill="url(#Gradient2)" stroke="black"/>
33
+ <circle cx="110" cy="40" r="30" stroke="black" fill="url(#Gradient3)"/>
34
+ <ellipse cx="110" cy="100" rx="30" ry="20" stroke="black" fill="url(#Gradient1)"/>
35
+ <line x1="65" y1="120" x2="200" y2="200" stroke="url(#Gradient3)" stroke-width="5"/>
36
+ <path d="M80,140l0,50l30,20l0-40z" stroke="url(#Gradient3)" fill="url(#Gradient1)" stroke-width="3"/>
37
+ <polygon points="150,30 170,80 190,55 200,10" fill="url(#Gradient1)"/>
38
+ <rect x="150" y="90" width="80" height="30" fill="url(#userspace)" stroke="black"/>
39
+ <polyline points="150,130 170,170 190,155 200,110" stroke="url(#Gradient1)" stroke-width="3" fill="none"/>
40
+ </svg>
@@ -0,0 +1,6 @@
1
+ <svg style="fill: none;">
2
+ <g class="x axis" transform="translate(0,227.9359)">
3
+ <path class="domain" d="M0,0V0H470V0" style="fill: none; stroke: none;"></path>
4
+ <path d="M 44.82625 0 L 44.82625 -3 L 94 -3 L 94 0" class="cantilever" style="stroke: black; fill: none;"></path>
5
+ </g>
6
+ </svg>
@@ -18,113 +18,113 @@
18
18
  <text y="25" font-size="12pt">wide image, aspect ratio meet</text>
19
19
 
20
20
  <rect y="50" width="100" height="100" fill="none" stroke="blue" stroke-width="2"/>
21
- <image y="50" width="100" height="100" preserveAspectRatio="xMidYMid" xlink:href="http://files.myopera.com/baby2u/albums/423302/smiley-cool.jpg"></image>
21
+ <image y="50" width="100" height="100" preserveAspectRatio="xMidYMid" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-wide.jpg"></image>
22
22
 
23
23
  <rect y="200" width="150" height="100" fill="none" stroke="blue" stroke-width="2"/>
24
- <image y="200" width="150" height="100" xlink:href="http://files.myopera.com/baby2u/albums/423302/smiley-cool.jpg"></image>
24
+ <image y="200" width="150" height="100" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-wide.jpg"></image>
25
25
 
26
26
  <rect y="350" width="100" height="150" fill="none" stroke="blue" stroke-width="2"/>
27
- <image y="350" width="100" height="150" xlink:href="http://files.myopera.com/baby2u/albums/423302/smiley-cool.jpg"></image>
27
+ <image y="350" width="100" height="150" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-wide.jpg"></image>
28
28
 
29
29
  <rect y="550" width="150" height="100" fill="none" stroke="blue" stroke-width="2"/>
30
- <image y="550" width="150" height="100" preserveAspectRatio="xMinYMin" xlink:href="http://files.myopera.com/baby2u/albums/423302/smiley-cool.jpg"></image>
30
+ <image y="550" width="150" height="100" preserveAspectRatio="xMinYMin" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-wide.jpg"></image>
31
31
 
32
32
  <rect y="700" width="100" height="150" fill="none" stroke="blue" stroke-width="2"/>
33
- <image y="700" width="100" height="150" preserveAspectRatio="xMinYMin" xlink:href="http://files.myopera.com/baby2u/albums/423302/smiley-cool.jpg"></image>
33
+ <image y="700" width="100" height="150" preserveAspectRatio="xMinYMin" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-wide.jpg"></image>
34
34
 
35
35
  <rect y="900" width="150" height="100" fill="none" stroke="blue" stroke-width="2"/>
36
- <image y="900" width="150" height="100" preserveAspectRatio="xMaxYMax" xlink:href="http://files.myopera.com/baby2u/albums/423302/smiley-cool.jpg"></image>
36
+ <image y="900" width="150" height="100" preserveAspectRatio="xMaxYMax" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-wide.jpg"></image>
37
37
 
38
38
  <rect y="1050" width="100" height="150" fill="none" stroke="blue" stroke-width="2"/>
39
- <image y="1050" width="100" height="150" preserveAspectRatio="xMaxYMax" xlink:href="http://files.myopera.com/baby2u/albums/423302/smiley-cool.jpg"></image>
39
+ <image y="1050" width="100" height="150" preserveAspectRatio="xMaxYMax" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-wide.jpg"></image>
40
40
  </g>
41
41
 
42
42
  <g transform="translate(250 0)">
43
43
  <text y="25" font-size="12pt">wide image, aspect ratio slice</text>
44
44
 
45
45
  <rect y="50" width="100" height="100" fill="none" stroke="blue" stroke-width="2"/>
46
- <image y="50" width="100" height="100" preserveAspectRatio="xMidYMid slice" xlink:href="http://files.myopera.com/baby2u/albums/423302/smiley-cool.jpg"></image>
46
+ <image y="50" width="100" height="100" preserveAspectRatio="xMidYMid slice" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-wide.jpg"></image>
47
47
 
48
48
  <rect y="200" width="150" height="100" fill="none" stroke="blue" stroke-width="2"/>
49
- <image y="200" width="150" height="100" preserveAspectRatio="xMidYMid slice" xlink:href="http://files.myopera.com/baby2u/albums/423302/smiley-cool.jpg"></image>
49
+ <image y="200" width="150" height="100" preserveAspectRatio="xMidYMid slice" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-wide.jpg"></image>
50
50
 
51
51
  <rect y="350" width="100" height="150" fill="none" stroke="blue" stroke-width="2"/>
52
- <image y="350" width="100" height="150" preserveAspectRatio="xMidYMid slice" xlink:href="http://files.myopera.com/baby2u/albums/423302/smiley-cool.jpg"></image>
52
+ <image y="350" width="100" height="150" preserveAspectRatio="xMidYMid slice" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-wide.jpg"></image>
53
53
 
54
54
  <rect y="550" width="150" height="100" fill="none" stroke="blue" stroke-width="2"/>
55
- <image y="550" width="150" height="100" preserveAspectRatio="xMinYMin slice" xlink:href="http://files.myopera.com/baby2u/albums/423302/smiley-cool.jpg"></image>
55
+ <image y="550" width="150" height="100" preserveAspectRatio="xMinYMin slice" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-wide.jpg"></image>
56
56
 
57
57
  <rect y="700" width="100" height="150" fill="none" stroke="blue" stroke-width="2"/>
58
- <image y="700" width="100" height="150" preserveAspectRatio="xMinYMin slice" xlink:href="http://files.myopera.com/baby2u/albums/423302/smiley-cool.jpg"></image>
58
+ <image y="700" width="100" height="150" preserveAspectRatio="xMinYMin slice" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-wide.jpg"></image>
59
59
 
60
60
  <rect y="900" width="150" height="100" fill="none" stroke="blue" stroke-width="2"/>
61
- <image y="900" width="150" height="100" preserveAspectRatio="xMaxYMax slice" xlink:href="http://files.myopera.com/baby2u/albums/423302/smiley-cool.jpg"></image>
61
+ <image y="900" width="150" height="100" preserveAspectRatio="xMaxYMax slice" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-wide.jpg"></image>
62
62
 
63
63
  <rect y="1050" width="100" height="150" fill="none" stroke="blue" stroke-width="2"/>
64
- <image y="1050" width="100" height="150" preserveAspectRatio="xMaxYMax slice" xlink:href="http://files.myopera.com/baby2u/albums/423302/smiley-cool.jpg"></image>
64
+ <image y="1050" width="100" height="150" preserveAspectRatio="xMaxYMax slice" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-wide.jpg"></image>
65
65
  </g>
66
66
 
67
67
  <g transform="translate(450 0)">
68
68
  <text y="25" font-size="12pt">long image, aspect ratio meet</text>
69
69
 
70
70
  <rect y="50" width="100" height="100" fill="none" stroke="blue" stroke-width="2"/>
71
- <image y="50" width="100" height="100" xlink:href="http://imalbum.aufeminin.com/album/D20090809/583007_KWWH1ZQ8FU5ATJXSR84C5MRBUWW33L_989174388_H143954_L.jpg"></image>
71
+ <image y="50" width="100" height="100" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-long.jpg"></image>
72
72
 
73
73
  <rect y="200" width="150" height="100" fill="none" stroke="blue" stroke-width="2"/>
74
- <image y="200" width="150" height="100" xlink:href="http://imalbum.aufeminin.com/album/D20090809/583007_KWWH1ZQ8FU5ATJXSR84C5MRBUWW33L_989174388_H143954_L.jpg"></image>
74
+ <image y="200" width="150" height="100" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-long.jpg"></image>
75
75
 
76
76
  <rect y="350" width="100" height="200" fill="none" stroke="blue" stroke-width="2"/>
77
- <image y="350" width="100" height="200" xlink:href="http://imalbum.aufeminin.com/album/D20090809/583007_KWWH1ZQ8FU5ATJXSR84C5MRBUWW33L_989174388_H143954_L.jpg"></image>
77
+ <image y="350" width="100" height="200" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-long.jpg"></image>
78
78
 
79
79
  <rect y="550" width="150" height="100" fill="none" stroke="blue" stroke-width="2"/>
80
- <image y="550" width="150" height="100" preserveAspectRatio="xMinYMin" xlink:href="http://imalbum.aufeminin.com/album/D20090809/583007_KWWH1ZQ8FU5ATJXSR84C5MRBUWW33L_989174388_H143954_L.jpg"></image>
80
+ <image y="550" width="150" height="100" preserveAspectRatio="xMinYMin" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-long.jpg"></image>
81
81
 
82
82
  <rect y="700" width="100" height="200" fill="none" stroke="blue" stroke-width="2"/>
83
- <image y="700" width="100" height="200" preserveAspectRatio="xMinYMin" xlink:href="http://imalbum.aufeminin.com/album/D20090809/583007_KWWH1ZQ8FU5ATJXSR84C5MRBUWW33L_989174388_H143954_L.jpg"></image>
83
+ <image y="700" width="100" height="200" preserveAspectRatio="xMinYMin" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-long.jpg"></image>
84
84
 
85
85
  <rect y="900" width="150" height="100" fill="none" stroke="blue" stroke-width="2"/>
86
- <image y="900" width="150" height="100" preserveAspectRatio="xMaxYMax" xlink:href="http://imalbum.aufeminin.com/album/D20090809/583007_KWWH1ZQ8FU5ATJXSR84C5MRBUWW33L_989174388_H143954_L.jpg"></image>
86
+ <image y="900" width="150" height="100" preserveAspectRatio="xMaxYMax" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-long.jpg"></image>
87
87
 
88
88
  <rect y="1050" width="100" height="200" fill="none" stroke="blue" stroke-width="2"/>
89
- <image y="1050" width="100" height="200" preserveAspectRatio="xMaxYMax" xlink:href="http://imalbum.aufeminin.com/album/D20090809/583007_KWWH1ZQ8FU5ATJXSR84C5MRBUWW33L_989174388_H143954_L.jpg"></image>
89
+ <image y="1050" width="100" height="200" preserveAspectRatio="xMaxYMax" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-long.jpg"></image>
90
90
  </g>
91
91
 
92
92
  <g transform="translate(650 0)">
93
93
  <text y="25" font-size="12pt">long image, aspect ratio slice</text>
94
94
 
95
95
  <rect y="50" width="100" height="100" fill="none" stroke="blue" stroke-width="2"/>
96
- <image y="50" width="100" height="100" preserveAspectRatio="xMidYMid slice" xlink:href="http://imalbum.aufeminin.com/album/D20090809/583007_KWWH1ZQ8FU5ATJXSR84C5MRBUWW33L_989174388_H143954_L.jpg"></image>
96
+ <image y="50" width="100" height="100" preserveAspectRatio="xMidYMid slice" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-long.jpg"></image>
97
97
 
98
98
  <rect y="200" width="150" height="100" fill="none" stroke="blue" stroke-width="2"/>
99
- <image y="200" width="150" height="100" preserveAspectRatio="xMidYMid slice" xlink:href="http://imalbum.aufeminin.com/album/D20090809/583007_KWWH1ZQ8FU5ATJXSR84C5MRBUWW33L_989174388_H143954_L.jpg"></image>
99
+ <image y="200" width="150" height="100" preserveAspectRatio="xMidYMid slice" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-long.jpg"></image>
100
100
 
101
101
  <rect y="350" width="100" height="200" fill="none" stroke="blue" stroke-width="2"/>
102
- <image y="350" width="100" height="200" preserveAspectRatio="xMidYMid slice" xlink:href="http://imalbum.aufeminin.com/album/D20090809/583007_KWWH1ZQ8FU5ATJXSR84C5MRBUWW33L_989174388_H143954_L.jpg"></image>
102
+ <image y="350" width="100" height="200" preserveAspectRatio="xMidYMid slice" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-long.jpg"></image>
103
103
 
104
104
  <rect y="550" width="150" height="100" fill="none" stroke="blue" stroke-width="2"/>
105
- <image y="550" width="150" height="100" preserveAspectRatio="xMinYMin slice" xlink:href="http://imalbum.aufeminin.com/album/D20090809/583007_KWWH1ZQ8FU5ATJXSR84C5MRBUWW33L_989174388_H143954_L.jpg"></image>
105
+ <image y="550" width="150" height="100" preserveAspectRatio="xMinYMin slice" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-long.jpg"></image>
106
106
 
107
107
  <rect y="700" width="100" height="200" fill="none" stroke="blue" stroke-width="2"/>
108
- <image y="700" width="100" height="200" preserveAspectRatio="xMinYMin slice" xlink:href="http://imalbum.aufeminin.com/album/D20090809/583007_KWWH1ZQ8FU5ATJXSR84C5MRBUWW33L_989174388_H143954_L.jpg"></image>
108
+ <image y="700" width="100" height="200" preserveAspectRatio="xMinYMin slice" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-long.jpg"></image>
109
109
 
110
110
  <rect y="900" width="150" height="100" fill="none" stroke="blue" stroke-width="2"/>
111
- <image y="900" width="150" height="100" preserveAspectRatio="xMaxYMax slice" xlink:href="http://imalbum.aufeminin.com/album/D20090809/583007_KWWH1ZQ8FU5ATJXSR84C5MRBUWW33L_989174388_H143954_L.jpg"></image>
111
+ <image y="900" width="150" height="100" preserveAspectRatio="xMaxYMax slice" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-long.jpg"></image>
112
112
 
113
113
  <rect y="1050" width="100" height="200" fill="none" stroke="blue" stroke-width="2"/>
114
- <image y="1050" width="100" height="200" preserveAspectRatio="xMaxYMax slice" xlink:href="http://imalbum.aufeminin.com/album/D20090809/583007_KWWH1ZQ8FU5ATJXSR84C5MRBUWW33L_989174388_H143954_L.jpg"></image>
114
+ <image y="1050" width="100" height="200" preserveAspectRatio="xMaxYMax slice" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-long.jpg"></image>
115
115
  </g>
116
116
 
117
117
  <g transform="translate(850 0)">
118
118
  <text y="25" font-size="12pt">aspect ratio preservation disabled</text>
119
119
 
120
120
  <rect y="50" width="100" height="100" fill="none" stroke="blue" stroke-width="2"/>
121
- <image y="50" width="100" height="100" preserveAspectRatio="none" xlink:href="http://imalbum.aufeminin.com/album/D20090809/583007_KWWH1ZQ8FU5ATJXSR84C5MRBUWW33L_989174388_H143954_L.jpg"></image>
121
+ <image y="50" width="100" height="100" preserveAspectRatio="none" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-long.jpg"></image>
122
122
 
123
123
  <rect y="200" width="150" height="100" fill="none" stroke="blue" stroke-width="2"/>
124
- <image y="200" width="150" height="100" preserveAspectRatio="none" xlink:href="http://imalbum.aufeminin.com/album/D20090809/583007_KWWH1ZQ8FU5ATJXSR84C5MRBUWW33L_989174388_H143954_L.jpg"></image>
124
+ <image y="200" width="150" height="100" preserveAspectRatio="none" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-long.jpg"></image>
125
125
 
126
126
  <rect y="350" width="100" height="200" fill="none" stroke="blue" stroke-width="2"/>
127
- <image y="350" width="100" height="200" preserveAspectRatio="none" xlink:href="http://imalbum.aufeminin.com/album/D20090809/583007_KWWH1ZQ8FU5ATJXSR84C5MRBUWW33L_989174388_H143954_L.jpg"></image>
127
+ <image y="350" width="100" height="200" preserveAspectRatio="none" xlink:href="https://raw.githubusercontent.com/mogest/prawn-svg/master/spec/sample_images/mushroom-long.jpg"></image>
128
128
  </g>
129
129
 
130
130
  </svg>
@@ -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,25 @@
1
+ <svg xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 -1329 4012.5722934428577 1964.1614245832113" xmlns="http://www.w3.org/2000/svg">
2
+ <defs id="MathJax_SVG_glyphs">
3
+ <path id="STIXWEBSIZE1-221A" stroke-width="10" d="M1089 1552l-562 -1847h-42l-231 751c-14 46 -30 68 -62 68c-19 0 -44 -8 -68 -27l-12 20l164 126h25l227 -737h4l500 1646h57Z"/>
4
+ <path id="STIXWEBMAINI-78" stroke-width="10" d="M243 355l12 -57c70 107 107 143 151 143c24 0 41 -15 41 -37c0 -21 -14 -36 -34 -36c-19 0 -28 17 -52 17c-18 0 -54 -44 -98 -121c0 -7 2 -21 8 -45l32 -134c7 -28 16 -41 30 -41c13 0 24 10 47 40c9 12 13 18 21 28l15 -9c-58 -90 -84 -114 -122 -114 c-32 0 -47 18 -59 68l-29 119l-88 -119c-44 -59 -64 -68 -95 -68s-50 16 -50 42c0 20 14 36 34 36c9 0 19 -4 32 -11c10 -6 20 -9 26 -9c11 0 30 19 51 49l82 116l-28 124c-14 60 -21 68 -46 68c-8 0 -20 -2 -39 -7l-18 -5l-3 16l11 4c61 22 94 29 117 29 c25 0 37 -18 51 -86Z"/>
5
+ <path id="STIXWEBMAIN-32" stroke-width="10" d="M474 137l-54 -137h-391v12l178 189c94 99 130 175 130 260c0 91 -54 141 -139 141c-72 0 -107 -32 -147 -130l-21 5c21 117 85 199 208 199c113 0 185 -77 185 -176c0 -79 -39 -154 -128 -248l-165 -176h234c42 0 63 11 96 67Z"/>
6
+ <path id="STIXWEBMAIN-2B" stroke-width="10" d="M636 220h-261v-261h-66v261h-261v66h261v261h66v-261h261v-66Z"/>
7
+ <path id="STIXWEBMAINI-79" stroke-width="10" d="M243 186l21 -110c85 141 122 213 122 257c0 14 -7 20 -26 32c-20 13 -26 23 -26 39c0 22 17 37 40 37c30 0 52 -25 52 -55c0 -57 -48 -167 -131 -305c-104 -172 -211 -287 -268 -287c-30 0 -51 17 -51 43c0 22 17 40 39 40c35 0 35 -28 61 -28c13 0 25 8 48 33 c18 19 63 78 71 91c6 12 10 24 10 35c0 40 -55 264 -82 332c-19 49 -37 64 -77 64c-11 0 -20 -1 -31 -4v17c11 2 22 4 32 6c20 4 53 10 107 18h4c15 0 68 -166 85 -255Z"/>
8
+ </defs>
9
+ <g transform="matrix(1 0 0 1 0 0)">
10
+ <rect x="0" y="-1329" width="4012" height="1964" stroke="green" fill="none" stroke-width="5" />
11
+ <g stroke="black" fill="black" stroke-width="0" transform="matrix(1 0 0 -1 0 0)">
12
+ <use href="#STIXWEBSIZE1-221A" x="0" y="-312" xlink:href="#STIXWEBSIZE1-221A"/>
13
+ <rect stroke="none" width="2950" height="60" x="1062" y="1190"/>
14
+ <g transform="translate(1062,0)">
15
+ <use href="#STIXWEBMAINI-78" xlink:href="#STIXWEBMAINI-78"/>
16
+ <use transform="scale(0.7071067811865476)" href="#STIXWEBMAIN-32" x="640" y="583" xlink:href="#STIXWEBMAIN-32"/>
17
+ <use href="#STIXWEBMAIN-2B" x="1132" y="0" xlink:href="#STIXWEBMAIN-2B"/>
18
+ <g transform="translate(2044,0)">
19
+ <use href="#STIXWEBMAINI-79" xlink:href="#STIXWEBMAINI-79"/>
20
+ <use transform="scale(0.7071067811865476)" href="#STIXWEBMAIN-32" x="634" y="583" xlink:href="#STIXWEBMAIN-32"/>
21
+ </g>
22
+ </g>
23
+ </g>
24
+ </g>
25
+ </svg>
@@ -0,0 +1,4 @@
1
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
2
+ <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="10 10 90 90">
3
+ <rect x="10" y="10" width="90" height="90" fill="blue" stroke="red"></rect>
4
+ </svg>
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="1100" height="400">
2
+ <rect x="100" y="100" width="900" height="300" fill="none" stroke="blue" stroke-width="2" />
3
+
4
+ <path d="M200 200 L800 300 L800 200" stroke="green" stroke-width="10" fill="red" />
5
+ </svg>
@@ -0,0 +1,7 @@
1
+ <svg xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" style="font-family:'lucida grande', 'lucida sans unicode', arial, helvetica, sans-serif;font-size:12px;" xmlns="http://www.w3.org/2000/svg" width="850" height="300">
2
+ <g transform="translate(10,10) scale(1 1)">
3
+ <path fill="#009ACB" d="M 414.97698492798247 39.00000234377684 A 113 113 0 1 1 311.39206002954353
4
+ 197.10426559737175 L 415 152 A 0 0 0 1 0 415 152 Z" stroke="#FFFFFF" stroke-width="1" stroke-linejoin="round"
5
+ transform="translate(0,0)"></path>
6
+ </g>
7
+ </svg>
@@ -0,0 +1,19 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="500" height="500">
3
+ <text x="0" y="40" xml:space="preserve" font-size="30" letter-spacing="5">Text (Far away text)</text>
4
+ <text x="0" y="80" font-size="30" letter-spacing="5">Text (Close text)</text>
5
+ <text x="0" y="120" xml:space="preserve" font-size="30" letter-spacing="5">
6
+ Text
7
+ With
8
+ Newlines
9
+ And
10
+ Preserve
11
+ </text>
12
+ <text x="0" y="160" font-size="30" letter-spacing="5">
13
+ Text
14
+ With
15
+ Newlines
16
+ No
17
+ Preserve
18
+ </text>
19
+ </svg>
@@ -1,16 +1,13 @@
1
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="12cm" height="4cm" viewBox="0 0 1200 400"
5
- xmlns="http://www.w3.org/2000/svg" version="1.1">
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
+ <svg width="12cm" height="8cm" viewBox="0 0 1200 800" xmlns="http://www.w3.org/2000/svg" version="1.1">
6
4
  <desc>Example rect02 - rounded rectangles</desc>
7
- <!-- Show outline of canvas using 'rect' element -->
8
- <rect x="1" y="1" width="1198" height="398"
9
- fill="none" stroke="blue" stroke-width="2"/>
10
- <rect x="100" y="100" width="400" height="200" rx="50"
11
- fill="green" />
5
+
6
+ <rect x="1" y="1" width="1198" height="798" fill="none" stroke="blue" stroke-width="2"/>
7
+ <rect x="100" y="100" width="400" height="200" rx="50" fill="green" />
8
+ <rect x="100" y="500" width="400" height="200" rx="100" ry="10" fill="orange" />
9
+
12
10
  <g transform="translate(700 210) rotate(-30)">
13
- <rect x="0" y="0" width="400" height="200" rx="50"
14
- fill="none" stroke="purple" stroke-width="30" />
11
+ <rect x="0" y="0" width="400" height="200" rx="50" fill="none" stroke="purple" stroke-width="30" />
15
12
  </g>
16
13
  </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>
@@ -0,0 +1,4 @@
1
+ <svg xmlns:xlink="http://www.w3.org/1999/xlink" width="300" height="300" viewBox="-100 -100 100 100" xmlns="http://www.w3.org/2000/svg">
2
+ <rect x="-98" y="-98" width="96" height="96" fill="blue" stroke="red" />
3
+ <line x1="-1000" y1="-1000" x2="1000" y2="1000" stroke="green" />
4
+ </svg>
@@ -0,0 +1,23 @@
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="100px" height="200px" version="1.1"
5
+ viewBox="0 0 1500 1000" preserveAspectRatio="none"
6
+ xmlns="http://www.w3.org/2000/svg">
7
+ <desc>Example ViewBox - uses the viewBox
8
+ attribute to automatically create an initial user coordinate
9
+ system which causes the graphic to scale to fit into the
10
+ viewport no matter what size the viewport is.</desc>
11
+ <!-- This rectangle goes from (0,0) to (1500,1000) in user space.
12
+ Because of the viewBox attribute above,
13
+ the rectangle will end up filling the entire area
14
+ reserved for the SVG content. -->
15
+ <rect x="0" y="0" width="1500" height="1000"
16
+ fill="yellow" stroke="blue" stroke-width="12" />
17
+ <!-- A large, red triangle -->
18
+ <path fill="red" d="M 750,100 L 250,900 L 1250,900 z"/>
19
+ <!-- A text string that spans most of the viewport -->
20
+ <text x="100" y="600" font-size="200" font-family="Verdana" >
21
+ Stretch to fit
22
+ </text>
23
+ </svg>
data/spec/spec_helper.rb CHANGED
@@ -5,7 +5,29 @@ 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
- RSpec.configure do |config|
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
9
21
  end
10
22
 
11
- Prawn::Svg::Font.load_external_fonts(Prawn::Document.new.font_families)
23
+ RSpec.configure do |config|
24
+ config.mock_with :rspec do |c|
25
+ c.syntax = [:should, :expect]
26
+ end
27
+
28
+ config.expect_with :rspec do |c|
29
+ c.syntax = [:should, :expect]
30
+ end
31
+
32
+ config.include Support
33
+ end