prawn-svg 0.31.0 → 0.33.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +35 -0
- data/README.md +8 -6
- data/lib/prawn/svg/attributes/stroke.rb +5 -0
- data/lib/prawn/svg/color.rb +46 -22
- data/lib/prawn/svg/css/selector_parser.rb +11 -11
- data/lib/prawn/svg/css/stylesheets.rb +4 -4
- data/lib/prawn/svg/document.rb +15 -2
- data/lib/prawn/svg/elements/base.rb +15 -16
- data/lib/prawn/svg/elements/call_duplicator.rb +1 -1
- data/lib/prawn/svg/elements/gradient.rb +2 -2
- data/lib/prawn/svg/elements/image.rb +6 -7
- data/lib/prawn/svg/elements/path.rb +0 -2
- data/lib/prawn/svg/elements/root.rb +1 -1
- data/lib/prawn/svg/elements/text_component.rb +10 -5
- data/lib/prawn/svg/gradients.rb +48 -0
- data/lib/prawn/svg/interface.rb +23 -8
- data/lib/prawn/svg/properties.rb +2 -0
- data/lib/prawn/svg/version.rb +1 -1
- data/lib/prawn-svg.rb +1 -0
- data/prawn-svg.gemspec +17 -15
- data/spec/integration_spec.rb +24 -24
- data/spec/prawn/svg/color_spec.rb +29 -16
- data/spec/prawn/svg/css/stylesheets_spec.rb +1 -19
- data/spec/prawn/svg/document_spec.rb +17 -0
- data/spec/prawn/svg/elements/base_spec.rb +15 -15
- data/spec/prawn/svg/elements/line_spec.rb +12 -12
- data/spec/prawn/svg/elements/marker_spec.rb +27 -27
- data/spec/prawn/svg/elements/polygon_spec.rb +9 -9
- data/spec/prawn/svg/elements/polyline_spec.rb +7 -7
- data/spec/prawn/svg/elements/root_spec.rb +28 -0
- data/spec/prawn/svg/elements/text_spec.rb +80 -53
- data/spec/prawn/svg/interface_spec.rb +10 -2
- data/spec/prawn/svg/pathable_spec.rb +4 -4
- data/spec/sample_svg/cmyk.svg +5 -0
- data/spec/sample_svg/gradients-cmyk.svg +40 -0
- data/spec/sample_svg/ordering.svg +12 -0
- data/spec/spec_helper.rb +2 -2
- metadata +53 -16
- data/.travis.yml +0 -8
@@ -15,7 +15,7 @@ describe Prawn::SVG::Elements::Text do
|
|
15
15
|
it "converts newlines and tabs to spaces, and preserves spaces" do
|
16
16
|
element.process
|
17
17
|
|
18
|
-
expect(flatten_calls(element.calls)).to include ["draw_text", ["some text", {:size=>16, :style=>:normal, :text_anchor=>'start', :at=>[:relative, :relative], :offset=>[0,0]}]
|
18
|
+
expect(flatten_calls(element.calls)).to include ["draw_text", ["some text"], {:size=>16, :style=>:normal, :text_anchor=>'start', :at=>[:relative, :relative], :offset=>[0,0]}]
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -25,7 +25,7 @@ describe Prawn::SVG::Elements::Text do
|
|
25
25
|
it "strips space" do
|
26
26
|
element.process
|
27
27
|
|
28
|
-
expect(flatten_calls(element.calls)).to include ["draw_text", ["some text", {:size=>16, :style=>:normal, :text_anchor=>'start', :at=>[:relative, :relative], :offset=>[0,0]}]
|
28
|
+
expect(flatten_calls(element.calls)).to include ["draw_text", ["some text"], {:size=>16, :style=>:normal, :text_anchor=>'start', :at=>[:relative, :relative], :offset=>[0,0]}]
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -78,10 +78,10 @@ Even more
|
|
78
78
|
element.process
|
79
79
|
|
80
80
|
expect(element.base_calls).to eq [
|
81
|
-
["text_group", [], [
|
82
|
-
["font", ["Helvetica", {style: :normal}
|
83
|
-
["character_spacing", [5.0], [
|
84
|
-
["draw_text", ["spaced", default_style
|
81
|
+
["text_group", [], {}, [
|
82
|
+
["font", ["Helvetica"], {style: :normal}, []],
|
83
|
+
["character_spacing", [5.0], {}, [
|
84
|
+
["draw_text", ["spaced"], default_style, []]
|
85
85
|
]]
|
86
86
|
]]
|
87
87
|
]
|
@@ -95,9 +95,9 @@ Even more
|
|
95
95
|
element.process
|
96
96
|
|
97
97
|
expect(element.base_calls).to eq [
|
98
|
-
["text_group", [], [
|
99
|
-
["font", ["Helvetica", {:style=>:normal}
|
100
|
-
["draw_text", ["underlined", default_style.merge(decoration: 'underline')
|
98
|
+
["text_group", [], {},[
|
99
|
+
["font", ["Helvetica"], {:style=>:normal}, []],
|
100
|
+
["draw_text", ["underlined"], default_style.merge(decoration: 'underline'), []]
|
101
101
|
]]
|
102
102
|
]
|
103
103
|
end
|
@@ -111,11 +111,11 @@ Even more
|
|
111
111
|
element.process
|
112
112
|
|
113
113
|
expect(element.base_calls).to eq [
|
114
|
-
["text_group", [], [
|
115
|
-
["stroke_color", ["ff0000"], []],
|
116
|
-
["font", ["Helvetica", {style: :normal}
|
117
|
-
["text_rendering_mode", [:stroke], [
|
118
|
-
["draw_text", ["stroked", default_style
|
114
|
+
["text_group", [], {}, [
|
115
|
+
["stroke_color", ["ff0000"], {}, []],
|
116
|
+
["font", ["Helvetica"], {style: :normal}, []],
|
117
|
+
["text_rendering_mode", [:stroke], {}, [
|
118
|
+
["draw_text", ["stroked"], default_style, []]
|
119
119
|
]]
|
120
120
|
]]
|
121
121
|
]
|
@@ -129,24 +129,24 @@ Even more
|
|
129
129
|
element.process
|
130
130
|
|
131
131
|
expect(element.base_calls).to eq [
|
132
|
-
["text_group", [], [
|
133
|
-
["stroke_color", ["ff0000"], []],
|
134
|
-
["font", ["Helvetica", {style: :normal}
|
135
|
-
["text_rendering_mode", [:stroke], [
|
136
|
-
["draw_text", ["stroked ", default_style
|
137
|
-
["save", [], []],
|
138
|
-
["fill_color", ["000000"], []],
|
139
|
-
["font", ["Helvetica", {style: :normal}
|
140
|
-
["text_rendering_mode", [:fill_stroke], [
|
141
|
-
["draw_text", ["both", default_style
|
132
|
+
["text_group", [], {}, [
|
133
|
+
["stroke_color", ["ff0000"], {}, []],
|
134
|
+
["font", ["Helvetica"], {style: :normal}, []],
|
135
|
+
["text_rendering_mode", [:stroke], {}, [
|
136
|
+
["draw_text", ["stroked "], default_style, []],
|
137
|
+
["save", [], {}, []],
|
138
|
+
["fill_color", ["000000"], {}, []],
|
139
|
+
["font", ["Helvetica"], {style: :normal}, []],
|
140
|
+
["text_rendering_mode", [:fill_stroke], {}, [
|
141
|
+
["draw_text", ["both"], default_style, []]
|
142
142
|
]],
|
143
|
-
["restore", [], []],
|
144
|
-
["save", [], []],
|
145
|
-
["font", ["Helvetica", {style: :normal}
|
146
|
-
["text_rendering_mode", [:invisible], [
|
147
|
-
["draw_text", ["neither", default_style
|
143
|
+
["restore", [], {}, []],
|
144
|
+
["save", [], {}, []],
|
145
|
+
["font", ["Helvetica"], {style: :normal}, []],
|
146
|
+
["text_rendering_mode", [:invisible], {}, [
|
147
|
+
["draw_text", ["neither"], default_style, []]
|
148
148
|
]],
|
149
|
-
["restore", [], []],
|
149
|
+
["restore", [], {}, []],
|
150
150
|
]]
|
151
151
|
]]
|
152
152
|
]
|
@@ -160,7 +160,7 @@ Even more
|
|
160
160
|
|
161
161
|
it "finds the font and uses it" do
|
162
162
|
element.process
|
163
|
-
expect(flatten_calls(element.base_calls)).to include ['font', ['Courier', {style: :normal}]
|
163
|
+
expect(flatten_calls(element.base_calls)).to include ['font', ['Courier'], {style: :normal}]
|
164
164
|
end
|
165
165
|
end
|
166
166
|
|
@@ -169,7 +169,7 @@ Even more
|
|
169
169
|
|
170
170
|
it "uses the fallback font" do
|
171
171
|
element.process
|
172
|
-
expect(flatten_calls(element.base_calls)).to include ['font', ['Times-Roman', {style: :normal}]
|
172
|
+
expect(flatten_calls(element.base_calls)).to include ['font', ['Times-Roman'], {style: :normal}]
|
173
173
|
end
|
174
174
|
|
175
175
|
context "when there is no fallback font" do
|
@@ -191,9 +191,9 @@ Even more
|
|
191
191
|
it "references the text" do
|
192
192
|
element.process
|
193
193
|
expect(flatten_calls(element.base_calls)[9..11]).to eq [
|
194
|
-
["fill_color", ["ff0000"]],
|
195
|
-
["font", ["Helvetica", {:style=>:normal}]
|
196
|
-
["draw_text", ["my reference text", {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[10.0, :relative], :offset=>[0,0]}]
|
194
|
+
["fill_color", ["ff0000"], {}],
|
195
|
+
["font", ["Helvetica"], {:style=>:normal}],
|
196
|
+
["draw_text", ["my reference text"], {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[10.0, :relative], :offset=>[0,0]}],
|
197
197
|
]
|
198
198
|
end
|
199
199
|
end
|
@@ -205,11 +205,11 @@ Even more
|
|
205
205
|
element.process
|
206
206
|
|
207
207
|
expect(flatten_calls(element.base_calls)).to eq [
|
208
|
-
["text_group", []],
|
209
|
-
["font", ["Helvetica", {:style=>:normal}]
|
210
|
-
["draw_text", ["H", {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[10.0, :relative], :offset=>[30.0, 2.0]}]
|
211
|
-
["draw_text", ["i", {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[20.0, :relative], :offset=>[50.0, 0]}]
|
212
|
-
["draw_text", [" there, this is a good test", {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[80.0, 0]}]
|
208
|
+
["text_group", [], {}],
|
209
|
+
["font", ["Helvetica"], {:style=>:normal}],
|
210
|
+
["draw_text", ["H"], {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[10.0, :relative], :offset=>[30.0, 2.0]}],
|
211
|
+
["draw_text", ["i"], {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[20.0, :relative], :offset=>[50.0, 0]}],
|
212
|
+
["draw_text", [" there, this is a good test"], {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[80.0, 0]}]
|
213
213
|
]
|
214
214
|
end
|
215
215
|
end
|
@@ -221,19 +221,46 @@ Even more
|
|
221
221
|
element.process
|
222
222
|
|
223
223
|
expect(flatten_calls(element.base_calls)).to eq [
|
224
|
-
["text_group", []],
|
225
|
-
["font", ["Helvetica", {:style=>:normal}]
|
226
|
-
["draw_text", ["H", {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[0, 0], :rotate=>-10.0}]
|
227
|
-
["draw_text", ["i", {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[0, 0], :rotate=>-20.0}]
|
228
|
-
["draw_text", [" ", {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[0, 0], :rotate=>-30.0}]
|
229
|
-
["save", []],
|
230
|
-
["font", ["Helvetica", {:style=>:normal}]
|
231
|
-
["draw_text", ["this", {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[0, 0]}]
|
232
|
-
["restore", []],
|
233
|
-
["draw_text", [" ", {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[0, 0], :rotate=>-80.0}]
|
234
|
-
["draw_text", ["o", {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[0, 0], :rotate=>-90.0}]
|
235
|
-
["draw_text", ["k", {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[0, 0], :rotate=>-100.0}]
|
236
|
-
["draw_text", ["!", {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[0, 0], :rotate=>-100.0}]
|
224
|
+
["text_group", [], {}],
|
225
|
+
["font", ["Helvetica"], {:style=>:normal}],
|
226
|
+
["draw_text", ["H"], {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[0, 0], :rotate=>-10.0}],
|
227
|
+
["draw_text", ["i"], {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[0, 0], :rotate=>-20.0}],
|
228
|
+
["draw_text", [" "], {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[0, 0], :rotate=>-30.0}],
|
229
|
+
["save", [], {}],
|
230
|
+
["font", ["Helvetica"], {:style=>:normal}],
|
231
|
+
["draw_text", ["this"], {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[0, 0]}],
|
232
|
+
["restore", [], {}],
|
233
|
+
["draw_text", [" "], {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[0, 0], :rotate=>-80.0}],
|
234
|
+
["draw_text", ["o"], {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[0, 0], :rotate=>-90.0}],
|
235
|
+
["draw_text", ["k"], {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[0, 0], :rotate=>-100.0}],
|
236
|
+
["draw_text", ["!"], {:size=>16, :style=>:normal, :text_anchor=>"start", :at=>[:relative, :relative], :offset=>[0, 0], :rotate=>-100.0}]
|
237
|
+
]
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
describe "when there's a comment inside the text element" do
|
242
|
+
let(:svg) { '<text>Hi <!-- comment --> there</text>' }
|
243
|
+
|
244
|
+
it "ignores the comment" do
|
245
|
+
element.process
|
246
|
+
|
247
|
+
expect(flatten_calls(element.calls)).to eq [
|
248
|
+
["text_group", [], {}],
|
249
|
+
["font", ["Helvetica"], {:style=>:normal}],
|
250
|
+
["draw_text",
|
251
|
+
["Hi "],
|
252
|
+
{:size=>16,
|
253
|
+
:style=>:normal,
|
254
|
+
:text_anchor=>"start",
|
255
|
+
:at=>[:relative, :relative],
|
256
|
+
:offset=>[0, 0]}],
|
257
|
+
["draw_text",
|
258
|
+
["there"],
|
259
|
+
{:size=>16,
|
260
|
+
:style=>:normal,
|
261
|
+
:text_anchor=>"start",
|
262
|
+
:at=>[:relative, :relative],
|
263
|
+
:offset=>[0, 0]}]
|
237
264
|
]
|
238
265
|
end
|
239
266
|
end
|
@@ -39,11 +39,19 @@ describe Prawn::SVG::Interface do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
context "when fill_and_stroke is issued" do
|
42
|
+
def expect_rectangle
|
43
|
+
if RUBY_VERSION.start_with?("2.7.")
|
44
|
+
expect(prawn).to receive(:rectangle)
|
45
|
+
else
|
46
|
+
expect(prawn).to receive(:rectangle).with([0, 100], 10, 10)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
42
50
|
context "and fill rule is not set" do
|
43
51
|
let(:interface) { Prawn::SVG::Interface.new('<svg width="250" height="100"><rect width="10" height="10" stroke="red"></rect></svg>', prawn, {}) }
|
44
52
|
|
45
53
|
it "adds content 'B'" do
|
46
|
-
|
54
|
+
expect_rectangle
|
47
55
|
expect(prawn).to receive(:add_content).with("W n")
|
48
56
|
expect(prawn).to receive(:add_content).with("B")
|
49
57
|
interface.draw
|
@@ -54,7 +62,7 @@ describe Prawn::SVG::Interface do
|
|
54
62
|
let(:interface) { Prawn::SVG::Interface.new('<svg width="250" height="100"><rect width="10" height="10" stroke="red" fill-rule="evenodd"></rect></svg>', prawn, {}) }
|
55
63
|
|
56
64
|
it "adds content 'B*'" do
|
57
|
-
|
65
|
+
expect_rectangle
|
58
66
|
expect(prawn).to receive(:add_content).with("W n")
|
59
67
|
expect(prawn).to receive(:add_content).with("B*")
|
60
68
|
interface.draw
|
@@ -40,10 +40,10 @@ RSpec.describe Prawn::SVG::Pathable do
|
|
40
40
|
subject.apply_commands
|
41
41
|
|
42
42
|
expect(subject.base_calls).to eq [
|
43
|
-
["move_to", [[10.0, 590.0]], []],
|
44
|
-
["line_to", [[20.0, 580.0]], []],
|
45
|
-
["curve_to", [[30.0, 570.0], {bounds: [[25.0, 580.0], [25.0, 575.0]]}
|
46
|
-
["close_path", [], []]
|
43
|
+
["move_to", [[10.0, 590.0]], {}, []],
|
44
|
+
["line_to", [[20.0, 580.0]], {}, []],
|
45
|
+
["curve_to", [[30.0, 570.0]], {bounds: [[25.0, 580.0], [25.0, 575.0]]}, []],
|
46
|
+
["close_path", [], {}, []]
|
47
47
|
]
|
48
48
|
end
|
49
49
|
end
|
@@ -0,0 +1,5 @@
|
|
1
|
+
<svg width="154" height="28" viewBox="0 0 154 28" xmlns="http://www.w3.org/2000/svg">
|
2
|
+
<g fill="device-cmyk(0.5, 50%, 0.0, 0)" fill-rule="evenodd">
|
3
|
+
<path d="m19.88 23.715-4.083 3.337a4.243 4.243 0 0 1-1.626-.965c-.463-.44-.768-.943-.915-1.508l-3.185 1.812c-.125.068-.336.138-.635.212a3.29 3.29 0 0 1-.754.11c-2.451 0-4.476-.841-6.073-2.524C1.011 22.506.212 20.168.212 17.175c0-2.846.83-5.192 2.491-7.039 1.66-1.847 3.777-2.77 6.353-2.77 1.027 0 1.988.203 2.88.61.892.407 1.479.768 1.762 1.084l2.948-1.067 1.034.305V19.92c0 1.016.178 1.824.533 2.422.354.599.91 1.057 1.667 1.373zm-7.166-2.541v-7.945a4.404 4.404 0 0 0-1.33-1.087c-.548-.303-1.217-.454-2.008-.454-1.141 0-2.086.416-2.837 1.248-.751.831-1.126 2.208-1.126 4.131 0 1.527.35 2.752 1.05 3.674.7.922 1.683 1.383 2.948 1.383.723 0 1.4-.113 2.033-.339.632-.227 1.055-.431 1.27-.611zM39.463 26.51h-3.947l-1.118-1.66-2.728 1.491c-.226.125-.553.217-.982.28a7.964 7.964 0 0 1-1.118.093c-2.666 0-4.69-.897-6.073-2.693s-2.081-4.049-2.092-6.759c-.011-2.937.822-5.274 2.499-7.014 1.677-1.739 3.894-2.609 6.649-2.609.79 0 1.485.062 2.083.187a5.903 5.903 0 0 1 1.728.661V.491h5.099V26.51zm-5.099-5.607v-8.03c-.283-.35-.751-.652-1.406-.906a5.855 5.855 0 0 0-2.134-.381c-1.423 0-2.482.415-3.177 1.245-.694.83-1.042 2.149-1.042 3.956 0 1.841.37 3.216 1.109 4.125.74.91 1.742 1.364 3.007 1.364.813 0 1.527-.135 2.143-.406.616-.271 1.116-.595 1.5-.967zM67.009 26.51h-5.184V15.075c0-.666-.237-1.256-.711-1.77-.475-.514-1.203-.771-2.186-.771-.938 0-1.722.195-2.354.584-.633.39-1.135.754-1.508 1.093V26.51h-5.184V8.299l5.184-.373v1.779l2.155-1.237a7.47 7.47 0 0 1 1.976-.805 8.464 8.464 0 0 1 2.01-.246c1.798 0 3.215.557 4.25 1.669 1.035 1.112 1.553 2.578 1.553 4.396V26.51h-.001zM89.303 17.057c0 2.993-.857 5.376-2.572 7.149-1.716 1.773-4.068 2.66-7.059 2.66-3.216 0-5.625-.892-7.227-2.677-1.603-1.784-2.404-4.162-2.404-7.132 0-2.699.863-5.008 2.59-6.929 1.726-1.92 4.073-2.88 7.041-2.88 2.979 0 5.328.887 7.05 2.66 1.72 1.774 2.581 4.156 2.581 7.149zm-5.252 0c0-1.479-.387-2.795-1.16-3.947-.773-1.152-1.844-1.728-3.21-1.728-1.57 0-2.694.525-3.372 1.575-.677 1.05-1.016 2.417-1.016 4.1 0 1.57.406 2.908 1.22 4.015.813 1.107 1.903 1.66 3.27 1.66 1.524 0 2.617-.449 3.278-1.347.66-.897.99-2.34.99-4.328zM101.145 23.325l-3.762 3.541c-1.559-.643-2.727-1.581-3.506-2.814-.779-1.233-1.17-2.708-1.17-4.42v-7.944H90.98V8.3h1.727V2.286l5.185-.373v6.404h2.71v3.354h-2.71v6.486c0 1.295.294 2.37.881 3.226.587.856 1.377 1.503 2.372 1.942zM121.981 23.715l-4.083 3.337a4.243 4.243 0 0 1-1.626-.965c-.464-.44-.769-.943-.915-1.508l-3.185 1.812c-.124.068-.337.138-.636.212a3.29 3.29 0 0 1-.754.11c-2.451 0-4.475-.841-6.072-2.524-1.599-1.683-2.398-4.021-2.398-7.014 0-2.846.83-5.192 2.491-7.039 1.66-1.847 3.777-2.77 6.353-2.77 1.027 0 1.988.203 2.88.61.892.407 1.479.768 1.762 1.084l2.948-1.067 1.033.305V19.92c0 1.016.178 1.824.533 2.422.355.598.913 1.057 1.669 1.373zm-7.166-2.541v-7.945a4.412 4.412 0 0 0-1.329-1.087c-.549-.303-1.218-.454-2.008-.454-1.141 0-2.087.416-2.838 1.248-.752.831-1.127 2.208-1.127 4.131 0 1.527.35 2.752 1.051 3.674.7.922 1.683 1.383 2.947 1.383.723 0 1.4-.113 2.033-.339.634-.227 1.057-.431 1.271-.611zM153.068 26.51h-5.15V15.075c0-.666-.229-1.256-.687-1.77-.457-.514-1.177-.771-2.159-.771-.803 0-1.52.155-2.152.466a4.972 4.972 0 0 0-1.592 1.211V26.51h-5.15V15.075c0-.666-.229-1.256-.686-1.77-.458-.514-1.178-.771-2.16-.771-.926 0-1.705.189-2.338.567-.633.378-1.096.749-1.389 1.11V26.51h-5.15V8.299l5.15-.373v1.779l2.016-1.237c.666-.406 1.32-.683 1.965-.83a8.86 8.86 0 0 1 1.965-.22c1.197 0 2.219.246 3.066.737a4.986 4.986 0 0 1 1.948 2.024l2.796-1.711a6.749 6.749 0 0 1 1.846-.788 8.17 8.17 0 0 1 2.084-.263c1.795 0 3.207.557 4.234 1.669 1.028 1.112 1.543 2.578 1.543 4.396V26.51zm0 0"/>
|
4
|
+
</g>
|
5
|
+
</svg>
|
@@ -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: device-cmyk(0, 1, 1, 0); }
|
6
|
+
.stop2 { stop-color: device-cmyk(0, 0, 0, 1); stop-opacity: 0; }
|
7
|
+
.stop3 { stop-color: device-cmyk(1, 0, 1, 0); }
|
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="device-cmyk(0, 1, 1, 0)"/>
|
16
|
+
<stop offset="50%" stop-color="device-cmyk(0, 0, 0, 1)" stop-opacity="0"/>
|
17
|
+
<stop offset="75%" stop-color="device-cmyk(1, 0, 1, 0)"/>
|
18
|
+
</linearGradient>
|
19
|
+
<linearGradient id="Gradient3" x1="0" x2="1" y1="0" y2="1">
|
20
|
+
<stop offset="0%" stop-color="device-cmyk(0, 1, 1, 0)"/>
|
21
|
+
<stop offset="30%" stop-color="device-cmyk(1, 0, 1, 0)"/>
|
22
|
+
<stop offset="60%" stop-color="device-cmyk(1, 0, 1, 0)"/>
|
23
|
+
<stop offset="100%" stop-color="device-cmyk(1, 0, 1, 0)"/>
|
24
|
+
</linearGradient>
|
25
|
+
<linearGradient id="userspace" gradientUnits="userSpaceOnUse" x1="160" y1="90" x2="220" y2="90">
|
26
|
+
<stop offset="0" stop-color="device-cmyk(0, 1, 1, 0)"/>
|
27
|
+
<stop offset="1" stop-color="device-cmyk(1, 0, 1, 0)"/>
|
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,12 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<svg width="177.649" height="244.929" version="1.1" viewBox="0 0 177.649 244.929" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
3
|
+
<g transform="translate(-21.1667 -31.75)">
|
4
|
+
<rect x="21.1667" y="31.75" width="177.649" height="244.929" fill="url(#linearGradient18)" stroke-width=".264583"/>
|
5
|
+
</g>
|
6
|
+
<defs>
|
7
|
+
<linearGradient id="linearGradient18" x1="109.032" x2="109.74" y1="34.6919" y2="273.287" gradientUnits="userSpaceOnUse">
|
8
|
+
<stop stop-color="orange" offset="0"/>
|
9
|
+
<stop stop-color="blue" offset="1"/>
|
10
|
+
</linearGradient>
|
11
|
+
</defs>
|
12
|
+
</svg>
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prawn-svg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.33.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Mog Nesbitt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: css_parser
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: matrix
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.4.2
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.4.2
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: prawn
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -31,58 +59,58 @@ dependencies:
|
|
31
59
|
- !ruby/object:Gem::Version
|
32
60
|
version: '3'
|
33
61
|
- !ruby/object:Gem::Dependency
|
34
|
-
name:
|
62
|
+
name: rexml
|
35
63
|
requirement: !ruby/object:Gem::Requirement
|
36
64
|
requirements:
|
37
65
|
- - "~>"
|
38
66
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
67
|
+
version: '3.2'
|
40
68
|
type: :runtime
|
41
69
|
prerelease: false
|
42
70
|
version_requirements: !ruby/object:Gem::Requirement
|
43
71
|
requirements:
|
44
72
|
- - "~>"
|
45
73
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
74
|
+
version: '3.2'
|
47
75
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
76
|
+
name: rake
|
49
77
|
requirement: !ruby/object:Gem::Requirement
|
50
78
|
requirements:
|
51
79
|
- - "~>"
|
52
80
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
81
|
+
version: '13.0'
|
54
82
|
type: :development
|
55
83
|
prerelease: false
|
56
84
|
version_requirements: !ruby/object:Gem::Requirement
|
57
85
|
requirements:
|
58
86
|
- - "~>"
|
59
87
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
88
|
+
version: '13.0'
|
61
89
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
90
|
+
name: rspec
|
63
91
|
requirement: !ruby/object:Gem::Requirement
|
64
92
|
requirements:
|
65
93
|
- - "~>"
|
66
94
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
95
|
+
version: '3.0'
|
68
96
|
type: :development
|
69
97
|
prerelease: false
|
70
98
|
version_requirements: !ruby/object:Gem::Requirement
|
71
99
|
requirements:
|
72
100
|
- - "~>"
|
73
101
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
102
|
+
version: '3.0'
|
75
103
|
description: This gem allows you to render SVG directly into a PDF using the 'prawn'
|
76
104
|
gem. Since PDF is vector-based, you'll get nice scaled graphics if you use SVG
|
77
105
|
instead of an image.
|
78
|
-
email:
|
106
|
+
email: mog@seriousorange.com
|
79
107
|
executables: []
|
80
108
|
extensions: []
|
81
109
|
extra_rdoc_files: []
|
82
110
|
files:
|
111
|
+
- ".github/workflows/test.yml"
|
83
112
|
- ".gitignore"
|
84
113
|
- ".rspec"
|
85
|
-
- ".travis.yml"
|
86
114
|
- Gemfile
|
87
115
|
- LICENSE
|
88
116
|
- README.md
|
@@ -129,6 +157,7 @@ files:
|
|
129
157
|
- lib/prawn/svg/extensions/additional_gradient_transforms.rb
|
130
158
|
- lib/prawn/svg/font.rb
|
131
159
|
- lib/prawn/svg/font_registry.rb
|
160
|
+
- lib/prawn/svg/gradients.rb
|
132
161
|
- lib/prawn/svg/interface.rb
|
133
162
|
- lib/prawn/svg/loaders/data.rb
|
134
163
|
- lib/prawn/svg/loaders/file.rb
|
@@ -159,6 +188,7 @@ files:
|
|
159
188
|
- spec/prawn/svg/elements/path_spec.rb
|
160
189
|
- spec/prawn/svg/elements/polygon_spec.rb
|
161
190
|
- spec/prawn/svg/elements/polyline_spec.rb
|
191
|
+
- spec/prawn/svg/elements/root_spec.rb
|
162
192
|
- spec/prawn/svg/elements/text_spec.rb
|
163
193
|
- spec/prawn/svg/font_registry_spec.rb
|
164
194
|
- spec/prawn/svg/font_spec.rb
|
@@ -180,6 +210,7 @@ files:
|
|
180
210
|
- spec/sample_svg/circle01.svg
|
181
211
|
- spec/sample_svg/clip_path.svg
|
182
212
|
- spec/sample_svg/close_path.svg
|
213
|
+
- spec/sample_svg/cmyk.svg
|
183
214
|
- spec/sample_svg/cubic01.svg
|
184
215
|
- spec/sample_svg/cubic01a.svg
|
185
216
|
- spec/sample_svg/cubic02.svg
|
@@ -189,6 +220,7 @@ files:
|
|
189
220
|
- spec/sample_svg/gistfile1.svg
|
190
221
|
- spec/sample_svg/google_charts.svg
|
191
222
|
- spec/sample_svg/gradient_transform.svg
|
223
|
+
- spec/sample_svg/gradients-cmyk.svg
|
192
224
|
- spec/sample_svg/gradients.svg
|
193
225
|
- spec/sample_svg/hidden_paths.svg
|
194
226
|
- spec/sample_svg/highcharts.svg
|
@@ -207,6 +239,7 @@ files:
|
|
207
239
|
- spec/sample_svg/offset_viewport.svg
|
208
240
|
- spec/sample_svg/omnigraffle.svg
|
209
241
|
- spec/sample_svg/opacity01.svg
|
242
|
+
- spec/sample_svg/ordering.svg
|
210
243
|
- spec/sample_svg/path.svg
|
211
244
|
- spec/sample_svg/pie_piece.svg
|
212
245
|
- spec/sample_svg/polygon01.svg
|
@@ -256,14 +289,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
256
289
|
requirements:
|
257
290
|
- - ">="
|
258
291
|
- !ruby/object:Gem::Version
|
259
|
-
version: 2.
|
292
|
+
version: 2.5.0
|
260
293
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
261
294
|
requirements:
|
262
295
|
- - ">="
|
263
296
|
- !ruby/object:Gem::Version
|
264
297
|
version: '0'
|
265
298
|
requirements: []
|
266
|
-
rubygems_version: 3.
|
299
|
+
rubygems_version: 3.4.10
|
267
300
|
signing_key:
|
268
301
|
specification_version: 4
|
269
302
|
summary: SVG renderer for Prawn PDF library
|
@@ -286,6 +319,7 @@ test_files:
|
|
286
319
|
- spec/prawn/svg/elements/path_spec.rb
|
287
320
|
- spec/prawn/svg/elements/polygon_spec.rb
|
288
321
|
- spec/prawn/svg/elements/polyline_spec.rb
|
322
|
+
- spec/prawn/svg/elements/root_spec.rb
|
289
323
|
- spec/prawn/svg/elements/text_spec.rb
|
290
324
|
- spec/prawn/svg/font_registry_spec.rb
|
291
325
|
- spec/prawn/svg/font_spec.rb
|
@@ -307,6 +341,7 @@ test_files:
|
|
307
341
|
- spec/sample_svg/circle01.svg
|
308
342
|
- spec/sample_svg/clip_path.svg
|
309
343
|
- spec/sample_svg/close_path.svg
|
344
|
+
- spec/sample_svg/cmyk.svg
|
310
345
|
- spec/sample_svg/cubic01.svg
|
311
346
|
- spec/sample_svg/cubic01a.svg
|
312
347
|
- spec/sample_svg/cubic02.svg
|
@@ -316,6 +351,7 @@ test_files:
|
|
316
351
|
- spec/sample_svg/gistfile1.svg
|
317
352
|
- spec/sample_svg/google_charts.svg
|
318
353
|
- spec/sample_svg/gradient_transform.svg
|
354
|
+
- spec/sample_svg/gradients-cmyk.svg
|
319
355
|
- spec/sample_svg/gradients.svg
|
320
356
|
- spec/sample_svg/hidden_paths.svg
|
321
357
|
- spec/sample_svg/highcharts.svg
|
@@ -334,6 +370,7 @@ test_files:
|
|
334
370
|
- spec/sample_svg/offset_viewport.svg
|
335
371
|
- spec/sample_svg/omnigraffle.svg
|
336
372
|
- spec/sample_svg/opacity01.svg
|
373
|
+
- spec/sample_svg/ordering.svg
|
337
374
|
- spec/sample_svg/path.svg
|
338
375
|
- spec/sample_svg/pie_piece.svg
|
339
376
|
- spec/sample_svg/polygon01.svg
|