prawn-svg 0.37.0 → 0.38.0

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.
@@ -2,16 +2,38 @@ require "#{File.dirname(__FILE__)}/../../spec_helper"
2
2
 
3
3
  describe Prawn::SVG::Font do
4
4
  describe '#initialize' do
5
- it 'maps generic font name to built-in font' do
6
- font_registry = Prawn::SVG::FontRegistry.new({})
7
- font = Prawn::SVG::Font.new('sans-serif', :normal, :normal, font_registry: font_registry)
8
- font.name.should == 'Helvetica'
5
+ it 'sets name, weight, and style' do
6
+ font = Prawn::SVG::Font.new('Arial', :bold, :italic)
7
+ expect(font.name).to eq('Arial')
8
+ expect(font.weight).to eq(:bold)
9
+ expect(font.style).to eq(:italic)
10
+ end
11
+ end
12
+
13
+ describe '#subfamily' do
14
+ it 'returns :normal when weight and style are both normal' do
15
+ font = Prawn::SVG::Font.new('Arial', :normal, nil)
16
+ expect(font.subfamily).to eq(:normal)
17
+ end
18
+
19
+ it 'returns style when weight is normal and style is present' do
20
+ font = Prawn::SVG::Font.new('Arial', :normal, :italic)
21
+ expect(font.subfamily).to eq(:italic)
22
+ end
23
+
24
+ it 'returns weight when only weight is present' do
25
+ font = Prawn::SVG::Font.new('Arial', :bold, nil)
26
+ expect(font.subfamily).to eq(:bold)
27
+ end
28
+
29
+ it 'returns combined weight and style when both are present' do
30
+ font = Prawn::SVG::Font.new('Arial', :bold, :italic)
31
+ expect(font.subfamily).to eq(:bold_italic)
9
32
  end
10
33
 
11
- it 'preserves generic font name if mapped' do
12
- font_registry = Prawn::SVG::FontRegistry.new('sans-serif' => { normal: 'Times-Roman' })
13
- font = Prawn::SVG::Font.new('sans-serif', :normal, :normal, font_registry: font_registry)
14
- font.name.should == 'sans-serif'
34
+ it 'returns :normal when both weight and style are nil' do
35
+ font = Prawn::SVG::Font.new('Arial', nil, nil)
36
+ expect(font.subfamily).to eq(:normal)
15
37
  end
16
38
  end
17
39
  end
@@ -0,0 +1,121 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg height="106" preserveAspectRatio="xMidYMid meet" version="1.0" viewBox="0 0 681 106" width="681" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
+ <text dominant-baseline="middle" font-family="Courier New, monospace" font-size="11" text-anchor="middle" x="60" y="8">0</text>
4
+ <text dominant-baseline="middle" font-family="Courier New, monospace" font-size="11" text-anchor="middle" x="100" y="8">1</text>
5
+ <text dominant-baseline="middle" font-family="Courier New, monospace" font-size="11" text-anchor="middle" x="140" y="8">2</text>
6
+ <text dominant-baseline="middle" font-family="Courier New, monospace" font-size="11" text-anchor="middle" x="180" y="8">3</text>
7
+ <text dominant-baseline="middle" font-family="Courier New, monospace" font-size="11" text-anchor="middle" x="220" y="8">4</text>
8
+ <text dominant-baseline="middle" font-family="Courier New, monospace" font-size="11" text-anchor="middle" x="260" y="8">5</text>
9
+ <text dominant-baseline="middle" font-family="Courier New, monospace" font-size="11" text-anchor="middle" x="300" y="8">6</text>
10
+ <text dominant-baseline="middle" font-family="Courier New, monospace" font-size="11" text-anchor="middle" x="340" y="8">7</text>
11
+ <text dominant-baseline="middle" font-family="Courier New, monospace" font-size="11" text-anchor="middle" x="380" y="8">8</text>
12
+ <text dominant-baseline="middle" font-family="Courier New, monospace" font-size="11" text-anchor="middle" x="420" y="8">9</text>
13
+ <text dominant-baseline="middle" font-family="Courier New, monospace" font-size="11" text-anchor="middle" x="460" y="8">a</text>
14
+ <text dominant-baseline="middle" font-family="Courier New, monospace" font-size="11" text-anchor="middle" x="500" y="8">b</text>
15
+ <text dominant-baseline="middle" font-family="Courier New, monospace" font-size="11" text-anchor="middle" x="540" y="8">c</text>
16
+ <text dominant-baseline="middle" font-family="Courier New, monospace" font-size="11" text-anchor="middle" x="580" y="8">d</text>
17
+ <text dominant-baseline="middle" font-family="Courier New, monospace" font-size="11" text-anchor="middle" x="620" y="8">e</text>
18
+ <text dominant-baseline="middle" font-family="Courier New, monospace" font-size="11" text-anchor="middle" x="660" y="8">f</text>
19
+ <rect fill="#a0ffa0" height="30" width="40" x="40" y="15"></rect>
20
+ <line stroke="#000000" stroke-width="1" x1="40" x2="80" y1="15" y2="15"></line>
21
+ <line stroke="#000000" stroke-width="1" x1="40" x2="80" y1="45" y2="45"></line>
22
+ <line stroke="#000000" stroke-dasharray="1,3" stroke-width="1" x1="80" x2="80" y1="15" y2="45"></line>
23
+ <line stroke="#000000" stroke-width="1" x1="40" x2="40" y1="15" y2="45"></line>
24
+ <text dominant-baseline="middle" font-family="Courier New, monospace" font-size="18" text-anchor="middle" x="60" y="31">51</text>
25
+ <rect fill="#a0ffa0" height="30" width="40" x="80" y="15"></rect>
26
+ <line stroke="#000000" stroke-width="1" x1="80" x2="120" y1="15" y2="15"></line>
27
+ <line stroke="#000000" stroke-width="1" x1="80" x2="120" y1="45" y2="45"></line>
28
+ <line stroke="#000000" stroke-dasharray="1,3" stroke-width="1" x1="120" x2="120" y1="15" y2="45"></line>
29
+ <line stroke="#000000" stroke-dasharray="1,3" stroke-width="1" x1="80" x2="80" y1="15" y2="45"></line>
30
+ <text dominant-baseline="middle" font-family="Courier New, monospace" font-size="18" text-anchor="middle" x="100" y="31">73</text>
31
+ <rect fill="#a0ffa0" height="30" width="40" x="120" y="15"></rect>
32
+ <line stroke="#000000" stroke-width="1" x1="120" x2="160" y1="15" y2="15"></line>
33
+ <line stroke="#000000" stroke-width="1" x1="120" x2="160" y1="45" y2="45"></line>
34
+ <line stroke="#000000" stroke-dasharray="1,3" stroke-width="1" x1="160" x2="160" y1="15" y2="45"></line>
35
+ <line stroke="#000000" stroke-dasharray="1,3" stroke-width="1" x1="120" x2="120" y1="15" y2="45"></line>
36
+ <text dominant-baseline="middle" font-family="Courier New, monospace" font-size="18" text-anchor="middle" x="140" y="31">70</text>
37
+ <rect fill="#a0ffa0" height="30" width="40" x="160" y="15"></rect>
38
+ <line stroke="#000000" stroke-width="1" x1="160" x2="200" y1="15" y2="15"></line>
39
+ <line stroke="#000000" stroke-width="1" x1="160" x2="200" y1="45" y2="45"></line>
40
+ <line stroke="#000000" stroke-dasharray="1,3" stroke-width="1" x1="200" x2="200" y1="15" y2="45"></line>
41
+ <line stroke="#000000" stroke-dasharray="1,3" stroke-width="1" x1="160" x2="160" y1="15" y2="45"></line>
42
+ <text dominant-baseline="middle" font-family="Courier New, monospace" font-size="18" text-anchor="middle" x="180" y="31">74</text>
43
+ <rect fill="#a0ffa0" height="30" width="40" x="200" y="15"></rect>
44
+ <line stroke="#000000" stroke-width="1" x1="200" x2="240" y1="15" y2="15"></line>
45
+ <line stroke="#000000" stroke-width="1" x1="200" x2="240" y1="45" y2="45"></line>
46
+ <line stroke="#000000" stroke-dasharray="1,3" stroke-width="1" x1="240" x2="240" y1="15" y2="45"></line>
47
+ <line stroke="#000000" stroke-dasharray="1,3" stroke-width="1" x1="200" x2="200" y1="15" y2="45"></line>
48
+ <text dominant-baseline="middle" font-family="Courier New, monospace" font-size="18" text-anchor="middle" x="220" y="31">31</text>
49
+ <rect fill="#a0ffa0" height="30" width="40" x="240" y="15"></rect>
50
+ <line stroke="#000000" stroke-width="1" x1="240" x2="280" y1="15" y2="15"></line>
51
+ <line stroke="#000000" stroke-width="1" x1="240" x2="280" y1="45" y2="45"></line>
52
+ <line stroke="#000000" stroke-dasharray="1,3" stroke-width="1" x1="280" x2="280" y1="15" y2="45"></line>
53
+ <line stroke="#000000" stroke-dasharray="1,3" stroke-width="1" x1="240" x2="240" y1="15" y2="45"></line>
54
+ <text dominant-baseline="middle" font-family="Courier New, monospace" font-size="18" text-anchor="middle" x="260" y="31">57</text>
55
+ <rect fill="#a0ffa0" height="30" width="40" x="280" y="15"></rect>
56
+ <line stroke="#000000" stroke-width="1" x1="280" x2="320" y1="15" y2="15"></line>
57
+ <line stroke="#000000" stroke-width="1" x1="280" x2="320" y1="45" y2="45"></line>
58
+ <line stroke="#000000" stroke-dasharray="1,3" stroke-width="1" x1="320" x2="320" y1="15" y2="45"></line>
59
+ <line stroke="#000000" stroke-dasharray="1,3" stroke-width="1" x1="280" x2="280" y1="15" y2="45"></line>
60
+ <text dominant-baseline="middle" font-family="Courier New, monospace" font-size="18" text-anchor="middle" x="300" y="31">6d</text>
61
+ <rect fill="#a0ffa0" height="30" width="40" x="320" y="15"></rect>
62
+ <line stroke="#000000" stroke-width="1" x1="320" x2="360" y1="15" y2="15"></line>
63
+ <line stroke="#000000" stroke-width="1" x1="320" x2="360" y1="45" y2="45"></line>
64
+ <line stroke="#000000" stroke-dasharray="1,3" stroke-width="1" x1="360" x2="360" y1="15" y2="45"></line>
65
+ <line stroke="#000000" stroke-dasharray="1,3" stroke-width="1" x1="320" x2="320" y1="15" y2="45"></line>
66
+ <text dominant-baseline="middle" font-family="Courier New, monospace" font-size="18" text-anchor="middle" x="340" y="31">4a</text>
67
+ <rect fill="#a0ffa0" height="30" width="40" x="360" y="15"></rect>
68
+ <line stroke="#000000" stroke-width="1" x1="360" x2="400" y1="15" y2="15"></line>
69
+ <line stroke="#000000" stroke-width="1" x1="360" x2="400" y1="45" y2="45"></line>
70
+ <line stroke="#000000" stroke-dasharray="1,3" stroke-width="1" x1="400" x2="400" y1="15" y2="45"></line>
71
+ <line stroke="#000000" stroke-dasharray="1,3" stroke-width="1" x1="360" x2="360" y1="15" y2="45"></line>
72
+ <text dominant-baseline="middle" font-family="Courier New, monospace" font-size="18" text-anchor="middle" x="380" y="31">4f</text>
73
+ <rect fill="#a0ffa0" height="30" width="40" x="400" y="15"></rect>
74
+ <line stroke="#000000" stroke-width="1" x1="400" x2="440" y1="15" y2="15"></line>
75
+ <line stroke="#000000" stroke-width="1" x1="400" x2="440" y1="45" y2="45"></line>
76
+ <line stroke="#000000" stroke-dasharray="1,3" stroke-width="1" x1="440" x2="440" y1="15" y2="45"></line>
77
+ <line stroke="#000000" stroke-dasharray="1,3" stroke-width="1" x1="400" x2="400" y1="15" y2="45"></line>
78
+ <text dominant-baseline="middle" font-family="Courier New, monospace" font-size="18" text-anchor="middle" x="420" y="31">4c</text>
79
+ <rect fill="#a0ffa0" height="30" width="40" x="440" y="15"></rect>
80
+ <line stroke="#000000" stroke-width="1" x1="440" x2="480" y1="15" y2="15"></line>
81
+ <line stroke="#000000" stroke-width="1" x1="440" x2="480" y1="45" y2="45"></line>
82
+ <line stroke="#000000" stroke-dasharray="1,3" stroke-width="1" x1="480" x2="480" y1="15" y2="45"></line>
83
+ <line stroke="#000000" stroke-dasharray="1,3" stroke-width="1" x1="440" x2="440" y1="15" y2="45"></line>
84
+ <text dominant-baseline="middle" font-family="Courier New, monospace" font-size="18" font-weight="bold" text-anchor="middle" x="460" y="31">0a</text>
85
+ <rect fill="#a0ffa0" height="30" width="40" x="480" y="15"></rect>
86
+ <line stroke="#000000" stroke-width="1" x1="480" x2="520" y1="15" y2="15"></line>
87
+ <line stroke="#000000" stroke-width="1" x1="480" x2="520" y1="45" y2="45"></line>
88
+ <line stroke="#000000" stroke-width="1" x1="520" x2="520" y1="15" y2="45"></line>
89
+ <line stroke="#000000" stroke-dasharray="1,3" stroke-width="1" x1="480" x2="480" y1="15" y2="45"></line>
90
+ <text dominant-baseline="middle" font-family="Courier New, monospace" font-size="18" text-anchor="middle" x="500" y="31">00</text>
91
+ <line stroke="#000000" stroke-width="1" x1="520" x2="680" y1="15" y2="15"></line>
92
+ <line stroke="#000000" stroke-width="1" x1="680" x2="680" y1="15" y2="45"></line>
93
+ <line stroke="#000000" stroke-width="1" x1="520" x2="520" y1="15" y2="45"></line>
94
+ <text dominant-baseline="middle" font-family="Courier New, monospace" font-size="11" font-style="normal" text-anchor="end" x="35" y="30">00</text>
95
+ <text dominant-baseline="middle" font-family="Courier New, monospace" font-size="11" font-style="normal" text-anchor="end" x="35" y="60">10</text>
96
+ <line stroke="#000000" stroke-width="1" x1="40" x2="680" y1="75" y2="75"></line>
97
+ <line stroke="#000000" stroke-width="1" x1="680" x2="680" y1="45" y2="75"></line>
98
+ <line stroke="#000000" stroke-width="1" x1="40" x2="40" y1="45" y2="75"></line>
99
+ <text dominant-baseline="middle" font-family="Palatino, Georgia, Times New Roman, serif" font-size="18" text-anchor="middle" x="360" y="61">Device Name (padded with <tspan dominant-baseline="middle" font-family="Courier New, monospace" font-size="18">00</tspan>)</text>
100
+ <text dominant-baseline="middle" font-family="Courier New, monospace" font-size="11" font-style="normal" text-anchor="end" x="35" y="90">20</text>
101
+ <line stroke="#000000" stroke-width="1" x1="40" x2="80" y1="75" y2="75"></line>
102
+ <line stroke="#000000" stroke-width="1" x1="40" x2="80" y1="105" y2="105"></line>
103
+ <line stroke="#000000" stroke-width="1" x1="80" x2="80" y1="75" y2="105"></line>
104
+ <line stroke="#000000" stroke-width="1" x1="40" x2="40" y1="75" y2="105"></line>
105
+ <text dominant-baseline="middle" font-family="Courier New, monospace" font-size="18" text-anchor="middle" x="60" y="91">01</text>
106
+ <line stroke="#000000" stroke-width="1" x1="80" x2="120" y1="75" y2="75"></line>
107
+ <line stroke="#000000" stroke-width="1" x1="80" x2="120" y1="105" y2="105"></line>
108
+ <line stroke="#000000" stroke-width="1" x1="120" x2="120" y1="75" y2="105"></line>
109
+ <line stroke="#000000" stroke-width="1" x1="80" x2="80" y1="75" y2="105"></line>
110
+ <text dominant-baseline="middle" font-family="Courier New, monospace" font-size="18" font-weight="bold" text-anchor="middle" x="100" y="91">02</text>
111
+ <line stroke="#000000" stroke-width="1" x1="120" x2="200" y1="75" y2="75"></line>
112
+ <line stroke="#000000" stroke-width="1" x1="120" x2="200" y1="105" y2="105"></line>
113
+ <line stroke="#000000" stroke-width="1" x1="200" x2="200" y1="75" y2="105"></line>
114
+ <line stroke="#000000" stroke-width="1" x1="120" x2="120" y1="75" y2="105"></line>
115
+ <text dominant-baseline="middle" font-family="Palatino, Georgia, Times New Roman, serif" font-size="18" font-style="italic" text-anchor="middle" x="160" y="91">len<tspan dominant-baseline="middle" dy="0.5ex" font-size="70%">p</tspan></text>
116
+ <line stroke="#000000" stroke-width="1" x1="200" x2="240" y1="75" y2="75"></line>
117
+ <line stroke="#000000" stroke-width="1" x1="200" x2="240" y1="105" y2="105"></line>
118
+ <line stroke="#000000" stroke-width="1" x1="240" x2="240" y1="75" y2="105"></line>
119
+ <line stroke="#000000" stroke-width="1" x1="200" x2="200" y1="75" y2="105"></line>
120
+ <text dominant-baseline="middle" font-family="Courier New, monospace" font-size="18" text-anchor="middle" x="220" y="91">02</text>
121
+ </svg>
@@ -0,0 +1,26 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg height="500" style="text-decoration: underline;" version="1.0" viewBox="0 0 681 500" width="681" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
+ <rect fill="none" height="500" stroke="red" width="681"></rect>
4
+ <line stroke="red" x1="340" x2="340" y1="0" y2="500"></line>
5
+ <text text-anchor="middle" x="360" y="21">Centered text with "<tspan font-size="40">tspan</tspan>"</text>
6
+ <text text-anchor="middle" x="360" y="41">Centered text with "<tspan dx="20">offset tspan</tspan>"</text>
7
+ <text lengthAdjust="spacingAndGlyphs" textLength="340" y="61">Text with "<tspan dx="20">tspan</tspan>"</text>
8
+ <text textLength="340" y="81">Text with "<tspan dx="20">tspan</tspan>"</text>
9
+ <g transform="translate(100,0)">
10
+ <text transform="translate(100,0) rotate(1)" x="0" y="101">Translated and "<tspan textLength="300">stretched</tspan>"</text>
11
+ </g>
12
+ <text y="121">Text with "<tspan textLength="300">stretched <tspan>(partial)</tspan></tspan>"</text>
13
+ <text y="141">Text with <tspan dx="20">offset</tspan> <tspan dy="20">and</tspan> <tspan dx="20">more offset</tspan></text>
14
+ <text y="181">tspans are <tspan transform="translate(100,0)">not transformed</tspan></text>
15
+ <text textLength="340" y="201">double <tspan textLength="150">text length</tspan></text>
16
+ <text lengthAdjust="spacingAndGlyphs" textLength="340" y="221">double <tspan textLength="150">text length</tspan></text>
17
+ <text lengthAdjust="spacingAndGlyphs" textLength="340" y="241">double <tspan lengthAdjust="spacingAndGlyphs" textLength="150">text length</tspan></text>
18
+ <text x="10 30 50 70 90 110 130 150 170 190" y="261">1234<tspan x="300 320">5678</tspan>90ABC</text>
19
+ <text style="letter-spacing: 30" y="281">Letter spacing</text>
20
+ <text style="letter-spacing: 30" textLength="340" y="301">Text length and letter spacing</text>
21
+ <text textLength="340" y="321">ab</text>
22
+ <text lengthAdjust="spacingAndGlyphs" textLength="120" y="341">Squashing text with "<tspan dx="20">tspan</tspan>"</text>
23
+ <text textLength="120" y="361">Squashing text with "<tspan dx="20">tspan</tspan>"</text>
24
+ <text textLength="340" y="381">Simple text length</text>
25
+ <text lengthAdjust="spacingAndGlyphs" style="letter-spacing: 20" textLength="340" y="401">Text length and letter spacing</text>
26
+ </svg>
@@ -3,11 +3,15 @@
3
3
  <rect x="0" y="560" width="772" height="19" r="0" rx="0" ry="0" fill="#000000" stroke="#000000" transform="matrix(1,0,0,1,0,0.5)" stroke-width="1"></rect>
4
4
  <rect x="0" y="0" width="19" height="579" r="0" rx="0" ry="0" fill="#000000" stroke="#000000" transform="matrix(1,0,0,1,0,0.5)" stroke-width="1"></rect>
5
5
  <rect x="753" y="0" width="19" height="579" r="0" rx="0" ry="0" fill="#000000" stroke="#000000" transform="matrix(1,0,0,1,0,0.5)" stroke-width="1"></rect>
6
- <g style="text-anchor: middle; font-style: normal; font-variant: normal; font-size: 80px; line-height: normal; font-family: 'Open Sans';" transform="translate(186, 151)">
6
+ <g style="text-anchor: middle; font-style: normal; font-variant: normal; font-size: 60px; line-height: normal; font-family: 'Open Sans';" transform="translate(186, 151)">
7
7
  <text y="0" fill="black" style="font-weight: 100;">prawn-svg</text>
8
+ <text x="300" y="0" fill="black" style="font-style: italic; font-weight: 100;">prawn-svg</text>
8
9
  <text y="100" fill="black" style="font-weight: 400;">prawn-svg</text>
9
10
  <text y="200" fill="black" style="font-weight: 600;">prawn-svg</text>
11
+ <text x="300" y="200" fill="black" style="font-weight: 700;">prawn-svg</text>
10
12
  <text y="300" fill="black" style="font-weight: 800;">prawn-svg</text>
13
+ <text x="300" y="300" fill="black" style="font-weight: bold;">prawn-svg</text>
11
14
  <text y="400" fill="black" style="font-style: italic;">prawn-svg</text>
15
+ <text x="300" y="400" fill="black" style="font-style: italic; font-weight: bold;">prawn-svg</text>
12
16
  </g>
13
17
  </svg>
@@ -0,0 +1,37 @@
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="12cm" height="8cm" viewBox="0 0 1200 800" xmlns="http://www.w3.org/2000/svg" xmlns:xlink='http://www.w3.org/1999/xlink' version="1.1">
4
+ <defs>
5
+ <text id="basic-text" x="50" y="50" font-family="Arial" font-size="24" fill="black">Hello World</text>
6
+
7
+ <text id="styled-text" x="0" y="0" font-family="Arial" font-size="20" fill="blue" font-weight="bold">Styled Text</text>
8
+
9
+ <g id="text-group">
10
+ <text x="10" y="30" font-family="Arial" font-size="16" fill="red">Line 1</text>
11
+ <text x="10" y="50" font-family="Arial" font-size="16" fill="green">Line 2</text>
12
+ <text x="10" y="70" font-family="Arial" font-size="16" fill="blue">Line 3</text>
13
+ </g>
14
+ </defs>
15
+
16
+ <!-- Test basic text use -->
17
+ <use xlink:href="#basic-text"/>
18
+ <use xlink:href="#basic-text" x="200" y="50"/>
19
+ <use xlink:href="#basic-text" x="400" y="100"/>
20
+
21
+ <!-- Test styled text with transforms -->
22
+ <use xlink:href="#styled-text" x="100" y="200" transform="scale(1.5)"/>
23
+ <use xlink:href="#styled-text" x="300" y="250" transform="rotate(15)"/>
24
+ <use xlink:href="#styled-text" x="500" y="200" style="opacity: 0.5;"/>
25
+
26
+ <!-- Test text group reuse -->
27
+ <use xlink:href="#text-group" x="50" y="350"/>
28
+ <use xlink:href="#text-group" x="250" y="400" transform="scale(0.8)"/>
29
+ <use xlink:href="#text-group" x="450" y="350" style="fill: purple;"/>
30
+
31
+ <!-- Test with additional styling on use elements -->
32
+ <use xlink:href="#basic-text" x="100" y="600" style="fill: orange; font-size: 32px;"/>
33
+ <use xlink:href="#styled-text" x="400" y="650" style="stroke: black; stroke-width: 1;"/>
34
+
35
+ <!-- Border for reference -->
36
+ <rect x="1" y="1" width="1198" height="798" fill="none" stroke="gray" stroke-width="2"/>
37
+ </svg>
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.37.0
4
+ version: 0.38.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: 2025-03-14 00:00:00.000000000 Z
11
+ date: 2025-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: css_parser
@@ -121,7 +121,7 @@ files:
121
121
  - lib/prawn/svg/elements/circle.rb
122
122
  - lib/prawn/svg/elements/clip_path.rb
123
123
  - lib/prawn/svg/elements/container.rb
124
- - lib/prawn/svg/elements/depth_first_base.rb
124
+ - lib/prawn/svg/elements/direct_render_base.rb
125
125
  - lib/prawn/svg/elements/ellipse.rb
126
126
  - lib/prawn/svg/elements/gradient.rb
127
127
  - lib/prawn/svg/elements/ignored.rb
@@ -135,10 +135,12 @@ files:
135
135
  - lib/prawn/svg/elements/root.rb
136
136
  - lib/prawn/svg/elements/text.rb
137
137
  - lib/prawn/svg/elements/text_component.rb
138
+ - lib/prawn/svg/elements/text_node.rb
138
139
  - lib/prawn/svg/elements/use.rb
139
140
  - lib/prawn/svg/elements/viewport.rb
140
141
  - lib/prawn/svg/extension.rb
141
142
  - lib/prawn/svg/font.rb
143
+ - lib/prawn/svg/font_metrics.rb
142
144
  - lib/prawn/svg/font_registry.rb
143
145
  - lib/prawn/svg/funciri.rb
144
146
  - lib/prawn/svg/gradient_renderer.rb
@@ -160,6 +162,7 @@ files:
160
162
  - lib/prawn/svg/url_loader.rb
161
163
  - lib/prawn/svg/version.rb
162
164
  - prawn-svg.gemspec
165
+ - scripts/compare_samples
163
166
  - spec/integration_spec.rb
164
167
  - spec/prawn/svg/attributes/opacity_spec.rb
165
168
  - spec/prawn/svg/attributes/transform_spec.rb
@@ -203,6 +206,7 @@ files:
203
206
  - spec/sample_output/.keep
204
207
  - spec/sample_svg/arcs01.svg
205
208
  - spec/sample_svg/arrows.svg
209
+ - spec/sample_svg/bytes.svg
206
210
  - spec/sample_svg/cap_styles.svg
207
211
  - spec/sample_svg/circle01.svg
208
212
  - spec/sample_svg/clip_path.svg
@@ -245,6 +249,7 @@ files:
245
249
  - spec/sample_svg/pie_piece.svg
246
250
  - spec/sample_svg/polygon01.svg
247
251
  - spec/sample_svg/polyline01.svg
252
+ - spec/sample_svg/positioning.svg
248
253
  - spec/sample_svg/presentation_attribute_precedence.svg
249
254
  - spec/sample_svg/preserve-space.svg
250
255
  - spec/sample_svg/quad01.svg
@@ -263,6 +268,7 @@ files:
263
268
  - spec/sample_svg/text-decoration.svg
264
269
  - spec/sample_svg/text_entities.svg
265
270
  - spec/sample_svg/text_stroke.svg
271
+ - spec/sample_svg/text_use.svg
266
272
  - spec/sample_svg/transform.svg
267
273
  - spec/sample_svg/tref01.svg
268
274
  - spec/sample_svg/triangle01.svg
@@ -1,52 +0,0 @@
1
- class Prawn::SVG::Elements::DepthFirstBase < Prawn::SVG::Elements::Base
2
- def initialize(document, source, parent_calls, state)
3
- super
4
- @base_calls = @calls = @parent_calls
5
- end
6
-
7
- def process
8
- parse_step
9
- apply_step(calls)
10
- rescue SkipElementQuietly
11
- rescue SkipElementError => e
12
- @document.warnings << e.message
13
- end
14
-
15
- def parse_and_apply
16
- raise 'unsupported'
17
- end
18
-
19
- protected
20
-
21
- def parse_step
22
- extract_attributes_and_properties
23
- parse_standard_attributes
24
- parse
25
- parse_child_elements if container?
26
- end
27
-
28
- def apply_step(calls)
29
- @base_calls = @calls = calls
30
- apply_calls_from_standard_attributes
31
- apply
32
- apply_child_elements if container?
33
- end
34
-
35
- def parse_child_elements
36
- return unless source
37
-
38
- svg_child_elements.each do |elem|
39
- next unless (element_class = Prawn::SVG::Elements::TAG_CLASS_MAPPING[elem.name.to_sym])
40
-
41
- child = element_class.new(@document, elem, @calls, state.dup)
42
- child.parse_step
43
- @children << child
44
- end
45
- end
46
-
47
- def apply_child_elements
48
- @children.each do |child|
49
- child.apply_step(calls)
50
- end
51
- end
52
- end